maven-maven-3.5.2/000077500000000000000000000000001317160430700137355ustar00rootroot00000000000000maven-maven-3.5.2/.gitattributes000066400000000000000000000002441317160430700166300ustar00rootroot00000000000000# Auto detect text files and perform LF normalization * text=auto *.java text diff=java *.html text diff=html *.css text *.js text *.sql text maven-maven-3.5.2/.gitignore000066400000000000000000000002111317160430700157170ustar00rootroot00000000000000target/ .project .classpath .settings/ .svn/ bin/ # Intellij *.ipr *.iml .idea out/ .DS_Store /bootstrap /dependencies.xml .java-version maven-maven-3.5.2/Jenkinsfile000066400000000000000000000201611317160430700161210ustar00rootroot00000000000000/* * 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. */ properties([buildDiscarder(logRotator(artifactNumToKeepStr: '5', numToKeepStr: env.BRANCH_NAME=='master'?'10':'5'))]) def tests def CORE_IT_PROFILES='run-its,embedded' try { node('ubuntu') { dir('build') { stage('Checkout') { checkout scm } def WORK_DIR=pwd() stage('Build / Unit Test') { def MAVEN_BUILD=tool name: 'Maven 3.3.9', type: 'hudson.tasks.Maven$MavenInstallation' echo "Driving build and unit tests using Maven $MAVEN_BUILD" def JAVA7_HOME=tool name: 'JDK 1.7 (latest)', type: 'hudson.model.JDK' echo "Running build and unit tests with Java $JAVA7_HOME" withEnv(["PATH+MAVEN=$MAVEN_BUILD/bin","PATH+JDK=$JAVA7_HOME/bin"]) { sh "mvn clean verify -B -U -e -fae -V -Dmaven.test.failure.ignore=true -Dmaven.repo.local=$WORK_DIR/.repository" } dir ('apache-maven/target') { sh "mv apache-maven-*-bin.zip apache-maven-dist.zip" stash includes: 'apache-maven-dist.zip', name: 'dist' } junit allowEmptyResults: true, testResults:'**/target/*-reports/*.xml' } tests = resolveScm source: [$class: 'GitSCMSource', credentialsId: '', id: '_', remote: 'https://git-wip-us.apache.org/repos/asf/maven-integration-testing.git', traits: [[$class: 'jenkins.plugins.git.traits.BranchDiscoveryTrait'], [$class: 'GitToolSCMSourceTrait', gitTool: 'Default']]], targets: [BRANCH_NAME, 'master'] } } stage 'Integration Test' parallel linuxJava7:{ node('ubuntu') { def MAVEN_NIX_J7=tool name: 'Maven 3 (latest)', type: 'hudson.tasks.Maven$MavenInstallation' echo "Driving integration tests using Maven $MAVEN_NIX_J7" def JAVA_NIX_J7=tool name: 'JDK 1.7 (latest)', type: 'hudson.model.JDK' echo "Running integration tests with Java $JAVA_NIX_J7" dir('test') { def WORK_DIR=pwd() checkout tests sh "rm -rvf $WORK_DIR/apache-maven-dist.zip $WORK_DIR/it-local-repo" unstash 'dist' withEnv(["PATH+MAVEN=$MAVEN_NIX_J7/bin","PATH+JDK=$JAVA_NIX_J7/bin"]) { sh "mvn clean install -P$CORE_IT_PROFILES -B -U -V -Dmaven.test.failure.ignore=true -Dmaven.repo.local=$WORK_DIR/it-local-repo -DmavenDistro=$WORK_DIR/apache-maven-dist.zip" } junit allowEmptyResults: true, testResults:'core-it-support/**/target/*-reports/*.xml,core-it-suite/target/*-reports/*.xml' deleteDir() // clean up after ourselves to reduce disk space } } },linuxJava8: { node('ubuntu') { def MAVEN_NIX_J8=tool name: 'Maven 3 (latest)', type: 'hudson.tasks.Maven$MavenInstallation' echo "Driving integration tests using Maven $MAVEN_NIX_J8" def JAVA_NIX_J8=tool name: 'JDK 1.8 (latest)', type: 'hudson.model.JDK' echo "Running integration tests with Java $JAVA_NIX_J8" dir('test') { def WORK_DIR=pwd() checkout tests sh "rm -rvf $WORK_DIR/apache-maven-dist.zip $WORK_DIR/it-local-repo" unstash 'dist' withEnv(["PATH+MAVEN=$MAVEN_NIX_J8/bin","PATH+JDK=$JAVA_NIX_J8/bin"]) { sh "mvn clean install -P$CORE_IT_PROFILES -B -U -V -Dmaven.test.failure.ignore=true -Dmaven.repo.local=$WORK_DIR/it-local-repo -DmavenDistro=$WORK_DIR/apache-maven-dist.zip" } junit allowEmptyResults: true, testResults:'core-it-support/**/target/*-reports/*.xml,core-it-suite/target/*-reports/*.xml' deleteDir() // clean up after ourselves to reduce disk space } } }, winJava7: { node('Windows') { def MAVEN_WIN_J7=tool name: 'Maven 3 (latest)', type: 'hudson.tasks.Maven$MavenInstallation' dir(MAVEN_WIN_J7) { MAVEN_WIN_J7=pwd() } echo "Driving integration tests using Maven $MAVEN_WIN_J7" def JAVA_WIN_J7=tool name: 'JDK 1.7 (latest)', type: 'hudson.model.JDK' dir(JAVA_WIN_J7) { JAVA_WIN_J7=pwd() } echo "Running integration tests with Java $JAVA_WIN_J7" // need a short path or we hit 256 character limit for paths // using EXECUTOR_NUMBER guarantees that concurrent builds on same agent // will not trample each other dir("/mvn-it-${EXECUTOR_NUMBER}.tmp") { def WORK_DIR=pwd() checkout tests bat "if exist it-local-repo rmdir /s /q it-local-repo" bat "if exist apache-maven-dist.zip del /q apache-maven-dist.zip" withEnv(["Path+MAVEN=$MAVEN_WIN_J7\\bin","Path+JDK=$JAVA_WIN_J7\\bin","JAVA_HOME=$JAVA_WIN_J7"]) { bat "set" unstash 'dist' bat "mvn clean install -P$CORE_IT_PROFILES -B -U -V -Dmaven.test.failure.ignore=true -Dmaven.repo.local=$WORK_DIR/it-local-repo -DmavenDistro=$WORK_DIR/apache-maven-dist.zip" } junit allowEmptyResults: true, testResults:'core-it-support/**/target/*-reports/*.xml,core-it-suite/target/*-reports/*.xml' deleteDir() // clean up after ourselves to reduce disk space } } }, winJava8: { node('Windows') { def MAVEN_WIN_J8=tool name: 'Maven 3 (latest)', type: 'hudson.tasks.Maven$MavenInstallation' dir(MAVEN_WIN_J8) { MAVEN_WIN_J8=pwd() } echo "Driving integration tests using Maven $MAVEN_WIN_J8" def JAVA_WIN_J8=tool name: 'JDK 1.8 (latest)', type: 'hudson.model.JDK' dir(JAVA_WIN_J8) { JAVA_WIN_J8=pwd() } echo "Running integration tests with Java $JAVA_WIN_J8" // need a short path or we hit 256 character limit for paths // using EXECUTOR_NUMBER guarantees that concurrent builds on same agent // will not trample each other dir("/mvn-it-${EXECUTOR_NUMBER}.tmp") { def WORK_DIR=pwd() checkout tests bat "if exist it-local-repo rmdir /s /q it-local-repo" bat "if exist apache-maven-dist.zip del /q apache-maven-dist.zip" withEnv(["Path+MAVEN=$MAVEN_WIN_J8\\bin","Path+JDK=$JAVA_WIN_J8\\bin","JAVA_HOME=$JAVA_WIN_J8"]) { bat "set" unstash 'dist' bat "mvn clean install -P$CORE_IT_PROFILES -B -U -V -Dmaven.test.failure.ignore=true -Dmaven.repo.local=$WORK_DIR/it-local-repo -DmavenDistro=$WORK_DIR/apache-maven-dist.zip" } junit allowEmptyResults: true, testResults:'core-it-support/**/target/*-reports/*.xml,core-it-suite/target/*-reports/*.xml' deleteDir() // clean up after ourselves to reduce disk space } } } } finally { node('ubuntu') { emailext body: "See ${env.BUILD_URL}", recipientProviders: [[$class: 'CulpritsRecipientProvider'], [$class: 'FailingTestSuspectsRecipientProvider'], [$class: 'FirstFailingBuildSuspectsRecipientProvider']], replyTo: 'dev@maven.apache.org', subject: "${env.JOB_NAME} - build ${env.BUILD_DISPLAY_NAME} - ${currentBuild.result}", to: 'notifications@maven.apache.org' } } maven-maven-3.5.2/LICENSE000066400000000000000000000261361317160430700147520ustar00rootroot00000000000000 Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and (b) You must cause any modified files to carry prominent notices stating that You changed the files; and (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. END OF TERMS AND CONDITIONS APPENDIX: How to apply the Apache License to your work. To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives. Copyright [yyyy] [name of copyright owner] 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. maven-maven-3.5.2/NOTICE000066400000000000000000000002461317160430700146430ustar00rootroot00000000000000Apache Maven Copyright 2001-2015 The Apache Software Foundation This product includes software developed at The Apache Software Foundation (http://www.apache.org/). maven-maven-3.5.2/README.md000066400000000000000000000014521317160430700152160ustar00rootroot00000000000000# Maven Maven is available under the [Apache License, Version 2.0](https://www.apache.org/licenses/LICENSE-2.0.txt) - [Maven Issue Tracker](https://issues.apache.org/jira/browse/MNG) - [Maven Wiki](https://cwiki.apache.org/confluence/display/MAVEN/Index) - [Building Maven](https://maven.apache.org/guides/development/guide-building-maven.html) - [Running Core ITs](https://maven.apache.org/core-its/core-it-suite/) ## Bootstrapping Basics If you want to bootstrap Maven, you'll need: - Java 1.7+ - Maven 3.0.5 or later Run Maven, specifying a location into which the completed Maven distro should be installed: ``` mvn -DdistributionTargetDir="$HOME/app/maven/apache-maven-3.5.x-SNAPSHOT" clean package ``` Once the build completes, you should have a new Maven distro ready to roll in that directory! maven-maven-3.5.2/apache-maven/000077500000000000000000000000001317160430700162625ustar00rootroot00000000000000maven-maven-3.5.2/apache-maven/README.txt000066400000000000000000000047601317160430700177670ustar00rootroot00000000000000 Apache Maven What is it? ----------- Maven is a software project management and comprehension tool. Based on the concept of a Project Object Model (POM), Maven can manage a project's build, reporting and documentation from a central piece of information. Documentation ------------- The most up-to-date documentation can be found at https://maven.apache.org/. Release Notes ------------- The full list of changes can be found at https://maven.apache.org/docs/history.html. System Requirements ------------------- JDK: 1.7 or above (this is to execute Maven - it still allows you to build against 1.3 and prior JDK's). Memory: No minimum requirement. Disk: Approximately 10MB is required for the Maven installation itself. In addition to that, additional disk space will be used for your local Maven repository. The size of your local repository will vary depending on usage but expect at least 500MB. Operating System: Windows: Windows 2000 or above. Unix based systems (Linux, Solaris and Mac OS X) and others: No minimum requirement. Installing Maven ---------------- 1) Unpack the archive where you would like to store the binaries, e.g.: Unix-based operating systems (Linux, Solaris and Mac OS X) tar zxvf apache-maven-3.x.y.tar.gz Windows unzip apache-maven-3.x.y.zip 2) A directory called "apache-maven-3.x.y" will be created. 3) Add the bin directory to your PATH, e.g.: Unix-based operating systems (Linux, Solaris and Mac OS X) export PATH=/usr/local/apache-maven-3.x.y/bin:$PATH Windows set PATH="c:\program files\apache-maven-3.x.y\bin";%PATH% 4) Make sure JAVA_HOME is set to the location of your JDK 5) Run "mvn --version" to verify that it is correctly installed. For complete documentation, see https://maven.apache.org/download.html#Installation Licensing --------- Please see the file called LICENSE. Maven URLS ---------- Home Page: https://maven.apache.org/ Downloads: https://maven.apache.org/download.html Release Notes: https://maven.apache.org/docs/history.html Mailing Lists: https://maven.apache.org/mail-lists.html Source Code: https://git-wip-us.apache.org/repos/asf/maven.git Issue Tracking: https://issues.apache.org/jira/browse/MNG Wiki: https://cwiki.apache.org/confluence/display/MAVEN/ Available Plugins: https://maven.apache.org/plugins/index.html maven-maven-3.5.2/apache-maven/pom.xml000066400000000000000000000220341317160430700176000ustar00rootroot00000000000000 4.0.0 org.apache.maven maven 3.5.2 apache-maven pom Apache Maven Distribution The Apache Maven distribution, source and binary, in zip and tar.gz formats. ${distributionId}-${project.version} org.apache.maven maven-embedder org.apache.maven maven-core org.apache.maven maven-compat org.eclipse.sisu org.eclipse.sisu.plexus commons-cli commons-cli org.apache.maven.wagon wagon-http shaded org.apache.httpcomponents httpclient org.apache.httpcomponents httpcore org.apache.maven.wagon wagon-http-shared org.slf4j jcl-over-slf4j ${slf4jVersion} runtime org.apache.maven.wagon wagon-file org.apache.maven.resolver maven-resolver-connector-basic org.apache.maven.resolver maven-resolver-transport-wagon org.apache.maven maven-slf4j-provider org.fusesource.jansi jansi ${distributionFileName} org.apache.maven.plugins maven-remote-resources-plugin 1.5 org.apache.rat apache-rat-plugin src/bin/m2.conf org.apache.maven.plugins maven-dependency-plugin jansi META-INF/native/** unpack-jansi-native unpack-dependencies org.apache.maven.plugins maven-compiler-plugin test-compile testCompile org.apache.maven.plugins maven-surefire-plugin basedir ${basedir} test test org.apache.maven.plugins maven-assembly-plugin create-distro-packages package single src/main/assembly/bin.xml apache.snapshots http://repository.apache.org/snapshots/ true false create-distribution-in-dir distributionTargetDir org.apache.maven.plugins maven-clean-plugin clean clean-target-dir prepare-package true ${distributionTargetDir} maven-assembly-plugin create-distribution-dir package single ./ false false ${distributionTargetDir} src/main/assembly/dir.xml apache-release maven-assembly-plugin make-src-assembly package single src/main/assembly/src.xml gnu maven-maven-3.5.2/apache-maven/src/000077500000000000000000000000001317160430700170515ustar00rootroot00000000000000maven-maven-3.5.2/apache-maven/src/bin/000077500000000000000000000000001317160430700176215ustar00rootroot00000000000000maven-maven-3.5.2/apache-maven/src/bin/.gitattributes000066400000000000000000000001571317160430700225170ustar00rootroot00000000000000mvn eol=lf crlf=input mvnDebug eol=lf crlf=input mvnyjp eol=lf crlf=input maven-maven-3.5.2/apache-maven/src/bin/m2.conf000066400000000000000000000003341317160430700210060ustar00rootroot00000000000000main is org.apache.maven.cli.MavenCli from plexus.core set maven.conf default ${maven.home}/conf [plexus.core] load ${maven.conf}/logging optionally ${maven.home}/lib/ext/*.jar load ${maven.home}/lib/*.jar maven-maven-3.5.2/apache-maven/src/bin/mvn000077500000000000000000000135211317160430700203510ustar00rootroot00000000000000#!/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 Startup Script # # Environment Variable Prerequisites # # JAVA_HOME Must point at your Java Development Kit installation. # MAVEN_OPTS (Optional) Java runtime options used when Maven is executed. # MAVEN_SKIP_RC (Optional) Flag to disable loading of mavenrc files. # ----------------------------------------------------------------------------- if [ -z "$MAVEN_SKIP_RC" ] ; then if [ -f /etc/mavenrc ] ; then . /etc/mavenrc fi if [ -f "$HOME/.mavenrc" ] ; then . "$HOME/.mavenrc" fi fi # OS specific support. $var _must_ be set to either true or false. cygwin=false; mingw=false; case "`uname`" in CYGWIN*) cygwin=true;; MINGW*) mingw=true;; esac ## resolve links - $0 may be a link to Maven's home PRG="$0" # need this for relative symlinks while [ -h "$PRG" ] ; do ls=`ls -ld "$PRG"` link=`expr "$ls" : '.*-> \(.*\)$'` if expr "$link" : '/.*' > /dev/null; then PRG="$link" else PRG="`dirname "$PRG"`/$link" fi done saveddir=`pwd` MAVEN_HOME=`dirname "$PRG"`/.. # make it fully qualified MAVEN_HOME=`cd "$MAVEN_HOME" && pwd` cd "$saveddir" # For Cygwin, ensure paths are in Unix format before anything is touched if $cygwin ; then [ -n "$MAVEN_HOME" ] && MAVEN_HOME=`cygpath --unix "$MAVEN_HOME"` [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"` [ -n "$CLASSPATH" ] && CLASSPATH=`cygpath --path --unix "$CLASSPATH"` fi # For MinGW, ensure paths are in Unix format before anything is touched if $mingw ; then [ -n "$MAVEN_HOME" ] && MAVEN_HOME=`(cd "$MAVEN_HOME"; pwd)` [ -n "$JAVA_HOME" ] && JAVA_HOME=`(cd "$JAVA_HOME"; pwd)` # TODO classpath? fi if [ -z "$JAVA_HOME" ] ; then JAVACMD=`which java` else JAVACMD="$JAVA_HOME/bin/java" fi if [ ! -x "$JAVACMD" ] ; then echo "The JAVA_HOME environment variable is not defined correctly" >&2 echo "This environment variable is needed to run this program" >&2 echo "NB: JAVA_HOME should point to a JDK not a JRE" >&2 exit 1 fi CLASSWORLDS_JAR=`echo "${MAVEN_HOME}"/boot/plexus-classworlds-*.jar` CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher # For Cygwin, switch paths to Windows format before running java if $cygwin ; then [ -n "$MAVEN_HOME" ] && MAVEN_HOME=`cygpath --path --windows "$MAVEN_HOME"` [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"` [ -n "$CLASSPATH" ] && CLASSPATH=`cygpath --path --windows "$CLASSPATH"` [ -n "$CLASSWORLDS_JAR" ] && CLASSWORLDS_JAR=`cygpath --path --windows "$CLASSWORLDS_JAR"` fi # traverses directory structure from process work directory to filesystem root # first directory with .mvn subdirectory is considered project base directory find_maven_basedir() { ( basedir=`find_file_argument_basedir "$@"` wdir="${basedir}" while [ "$wdir" != '/' ] ; do if [ -d "$wdir"/.mvn ] ; then basedir=$wdir break fi wdir=`cd "$wdir/.."; pwd` done echo "${basedir}" ) } find_file_argument_basedir() { ( basedir=`pwd` found_file_switch=0 for arg in "$@"; do if [ ${found_file_switch} -eq 1 ]; then if [ -d "${arg}" ]; then basedir=`cd "${arg}" && pwd -P` elif [ -f "${arg}" ]; then basedir=`dirname "${arg}"` basedir=`cd "${basedir}" && pwd -P` if [ ! -d "${basedir}" ]; then echo "Directory ${basedir} extracted from the -f/--file command-line argument ${arg} does not exist" >&2 exit 1 fi else echo "POM file ${arg} specified with the -f/--file command line argument does not exist" >&2 exit 1 fi break fi if [ "$arg" = "-f" -o "$arg" = "--file" ]; then found_file_switch=1 fi done echo "${basedir}" ) } # concatenates all lines of a file concat_lines() { if [ -f "$1" ]; then echo "`tr -s '\n' ' ' < "$1"`" fi } MAVEN_PROJECTBASEDIR="${MAVEN_BASEDIR:-`find_maven_basedir "$@"`}" MAVEN_OPTS="`concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config"` $MAVEN_OPTS" # For Cygwin, switch project base directory path to Windows format before # executing Maven otherwise this will cause Maven not to consider it. if $cygwin ; then [ -n "$MAVEN_PROJECTBASEDIR" ] && MAVEN_PROJECTBASEDIR=`cygpath --path --windows "$MAVEN_PROJECTBASEDIR"` fi export MAVEN_PROJECTBASEDIR # Provide a "standardized" way to retrieve the CLI args that will # work with both Windows and non-Windows executions. MAVEN_CMD_LINE_ARGS="$MAVEN_CONFIG $@" export MAVEN_CMD_LINE_ARGS # detect cygwin or mingw pseudo-terminal for Jansi # workaround for https://github.com/fusesource/jansi-native/issues/11 if $cygwin || $mingw; then if [ -t 1 ]; then MAVEN_OPTS="-Djansi.passthrough=true $MAVEN_OPTS" fi fi exec "$JAVACMD" \ $MAVEN_OPTS \ $MAVEN_DEBUG_OPTS \ -classpath "${CLASSWORLDS_JAR}" \ "-Dclassworlds.conf=${MAVEN_HOME}/bin/m2.conf" \ "-Dmaven.home=${MAVEN_HOME}" \ "-Dlibrary.jansi.path=${MAVEN_HOME}/lib/jansi-native" \ "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \ ${CLASSWORLDS_LAUNCHER} "$@" maven-maven-3.5.2/apache-maven/src/bin/mvn.cmd000066400000000000000000000140031317160430700211040ustar00rootroot00000000000000@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 Startup Script @REM @REM Environment Variable Prerequisites @REM @REM JAVA_HOME Must point at your Java Development Kit 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 ----------------------------------------------------------------------------- @REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on' @echo off @REM enable echoing my setting MAVEN_BATCH_ECHO to 'on' @if "%MAVEN_BATCH_ECHO%"=="on" echo %MAVEN_BATCH_ECHO% @REM Execute a user defined script before this one if not "%MAVEN_SKIP_RC%"=="" goto skipRcPre @REM check for pre script, once with legacy .bat ending and once with .cmd ending if exist "%USERPROFILE%\mavenrc_pre.bat" call "%USERPROFILE%\mavenrc_pre.bat" if exist "%USERPROFILE%\mavenrc_pre.cmd" call "%USERPROFILE%\mavenrc_pre.cmd" :skipRcPre @setlocal set ERROR_CODE=0 @REM ==== START VALIDATION ==== if not "%JAVA_HOME%"=="" goto OkJHome for %%i in (java.exe) do set "JAVACMD=%%~$PATH:i" goto checkJCmd :OkJHome set "JAVACMD=%JAVA_HOME%\bin\java.exe" :checkJCmd if exist "%JAVACMD%" goto chkMHome echo The JAVA_HOME environment variable is not defined correctly >&2 echo This environment variable is needed to run this program >&2 echo NB: JAVA_HOME should point to a JDK not a JRE >&2 goto error :chkMHome set "MAVEN_HOME=%~dp0.." if not "%MAVEN_HOME%"=="" goto valMHome goto error :valMHome :stripMHome if not "_%MAVEN_HOME:~-1%"=="_\" goto checkMCmd set "MAVEN_HOME=%MAVEN_HOME:~0,-1%" goto stripMHome :checkMCmd if exist "%MAVEN_HOME%\bin\mvn.cmd" goto init goto error @REM ==== END VALIDATION ==== :init set MAVEN_CMD_LINE_ARGS=%* @REM Find the project basedir, i.e., the directory that contains the folder ".mvn". @REM Fallback to current working directory if not found. set "MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR%" if not "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir set "EXEC_DIR=%CD%" set "WDIR=%EXEC_DIR%" @REM Look for the --file switch and start the search for the .mvn directory from the specified @REM POM location, if supplied. set FILE_ARG= :arg_loop if "%~1" == "-f" ( set "FILE_ARG=%~2" shift goto process_file_arg ) if "%~1" == "--file" ( set "FILE_ARG=%~2" shift goto process_file_arg ) @REM If none of the above, skip the argument shift if not "%~1" == "" ( goto arg_loop ) else ( goto findBaseDir ) :process_file_arg if "%FILE_ARG%" == "" ( goto findBaseDir ) if not exist "%FILE_ARG%" ( echo POM file %FILE_ARG% specified the -f/--file command-line argument does not exist >&2 goto error ) if exist "%FILE_ARG%\*" ( set "POM_DIR=%FILE_ARG%" ) else ( call :get_directory_from_file "%FILE_ARG%" ) if not exist "%POM_DIR%" ( echo Directory %POM_DIR% extracted from the -f/--file command-line argument %FILE_ARG% does not exist >&2 goto error ) set "WDIR=%POM_DIR%" goto findBaseDir :get_directory_from_file set "POM_DIR=%~dp1" :stripPomDir if not "_%POM_DIR:~-1%"=="_\" goto pomDirStripped set "POM_DIR=%POM_DIR:~0,-1%" goto stripPomDir :pomDirStripped exit /b :findBaseDir cd /d "%WDIR%" :findBaseDirLoop if exist "%WDIR%\.mvn" goto baseDirFound cd .. IF "%WDIR%"=="%CD%" goto baseDirNotFound set "WDIR=%CD%" goto findBaseDirLoop :baseDirFound set "MAVEN_PROJECTBASEDIR=%WDIR%" cd /d "%EXEC_DIR%" goto endDetectBaseDir :baseDirNotFound if "_%EXEC_DIR:~-1%"=="_\" set "EXEC_DIR=%EXEC_DIR:~0,-1%" set "MAVEN_PROJECTBASEDIR=%EXEC_DIR%" cd "%EXEC_DIR%" :endDetectBaseDir set "jvmConfig=\.mvn\jvm.config" if not exist "%MAVEN_PROJECTBASEDIR%%jvmConfig%" goto endReadAdditionalConfig @setlocal EnableExtensions EnableDelayedExpansion for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a @endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS% :endReadAdditionalConfig for %%i in ("%MAVEN_HOME%"\boot\plexus-classworlds-*) do set CLASSWORLDS_JAR="%%i" set CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher "%JAVACMD%" ^ %JVM_CONFIG_MAVEN_PROPS% ^ %MAVEN_OPTS% ^ %MAVEN_DEBUG_OPTS% ^ -classpath %CLASSWORLDS_JAR% ^ "-Dclassworlds.conf=%MAVEN_HOME%\bin\m2.conf" ^ "-Dmaven.home=%MAVEN_HOME%" ^ "-Dlibrary.jansi.path=%MAVEN_HOME%\lib\jansi-native" ^ "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" ^ %CLASSWORLDS_LAUNCHER% %MAVEN_CMD_LINE_ARGS% if ERRORLEVEL 1 goto error goto end :error set ERROR_CODE=1 :end @endlocal & set ERROR_CODE=%ERROR_CODE% if not "%MAVEN_SKIP_RC%"=="" goto skipRcPost @REM check for post script, once with legacy .bat ending and once with .cmd ending if exist "%USERPROFILE%\mavenrc_post.bat" call "%USERPROFILE%\mavenrc_post.bat" if exist "%USERPROFILE%\mavenrc_post.cmd" call "%USERPROFILE%\mavenrc_post.cmd" :skipRcPost @REM pause the script if MAVEN_BATCH_PAUSE is set to 'on' if "%MAVEN_BATCH_PAUSE%"=="on" pause if "%MAVEN_TERMINATE_CMD%"=="on" exit %ERROR_CODE% cmd /C exit /B %ERROR_CODE% maven-maven-3.5.2/apache-maven/src/bin/mvnDebug000077500000000000000000000027151317160430700213230ustar00rootroot00000000000000#!/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 Must point at your Java Development Kit 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_OPTS="-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000" echo Preparing to execute Maven in debug mode env MAVEN_OPTS="$MAVEN_OPTS" MAVEN_DEBUG_OPTS="$MAVEN_DEBUG_OPTS" "`dirname "$0"`/mvn" "$@" maven-maven-3.5.2/apache-maven/src/bin/mvnDebug.cmd000066400000000000000000000031431317160430700220560ustar00rootroot00000000000000@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 Must point at your Java Development Kit 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 ----------------------------------------------------------------------------- @setlocal @set MAVEN_DEBUG_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 @call "%~dp0"mvn.cmd %* maven-maven-3.5.2/apache-maven/src/bin/mvnyjp000077500000000000000000000027741317160430700211040ustar00rootroot00000000000000#!/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 YourKit Profiler Startup Script # # Environment Variable Prerequisites # # JAVA_HOME Must point at your Java Development Kit installation. # MAVEN_OPTS (Optional) Java runtime options used when Maven is executed. # MAVEN_SKIP_RC (Optional) Flag to disable loading of mavenrc files. # ----------------------------------------------------------------------------- if [ ! -f "$YJPLIB" ]; then echo "Error: Unable to autodetect the YJP library location. Please set YJPLIB variable" >&2 exit 1 fi env MAVEN_OPTS="-agentpath:$YJPLIB=onexit=snapshot,onexit=memory,tracing,onlylocal $MAVEN_OPTS" "`dirname "$0"`/mvn" "$@" maven-maven-3.5.2/apache-maven/src/conf/000077500000000000000000000000001317160430700177765ustar00rootroot00000000000000maven-maven-3.5.2/apache-maven/src/conf/logging/000077500000000000000000000000001317160430700214245ustar00rootroot00000000000000maven-maven-3.5.2/apache-maven/src/conf/logging/simplelogger.properties000066400000000000000000000027571317160430700262460ustar00rootroot00000000000000# 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. org.slf4j.simpleLogger.defaultLogLevel=info org.slf4j.simpleLogger.showDateTime=false org.slf4j.simpleLogger.showThreadName=false org.slf4j.simpleLogger.showLogName=false org.slf4j.simpleLogger.logFile=System.out org.slf4j.simpleLogger.cacheOutputStream=true org.slf4j.simpleLogger.levelInBrackets=true org.slf4j.simpleLogger.log.Sisu=info org.slf4j.simpleLogger.warnLevelString=WARNING # MNG-6181: mvn -X also prints all debug logging from HttpClient # Be aware that the shaded packages are used # org.apache.http -> org.apache.maven.wagon.providers.http.httpclient org.slf4j.simpleLogger.log.org.apache.maven.wagon.providers.http.httpclient=off org.slf4j.simpleLogger.log.org.apache.maven.wagon.providers.http.httpclient.wire=off maven-maven-3.5.2/apache-maven/src/conf/settings.xml000066400000000000000000000237431317160430700223710ustar00rootroot00000000000000 maven-maven-3.5.2/apache-maven/src/conf/toolchains.xml000066400000000000000000000070751317160430700226740ustar00rootroot00000000000000 maven-maven-3.5.2/apache-maven/src/lib/000077500000000000000000000000001317160430700176175ustar00rootroot00000000000000maven-maven-3.5.2/apache-maven/src/lib/ext/000077500000000000000000000000001317160430700204175ustar00rootroot00000000000000maven-maven-3.5.2/apache-maven/src/lib/ext/README.txt000066400000000000000000000002301317160430700221100ustar00rootroot00000000000000Use this directory to contribute 3rd-party extensions to the Maven core. These extensions can either extend or override Maven's default implementation. maven-maven-3.5.2/apache-maven/src/lib/jansi-native/000077500000000000000000000000001317160430700222075ustar00rootroot00000000000000maven-maven-3.5.2/apache-maven/src/lib/jansi-native/README.txt000066400000000000000000000006101317160430700237020ustar00rootroot00000000000000This directory contains Jansi native libraries, extracted from Jansi jar. You can add your own extensions for platforms not natively supported by Jansi: the libraries follow HawtJNI directory and filename conventions. See http://fusesource.github.io/hawtjni/documentation/api/org/fusesource/hawtjni/runtime/Library.html See https://github.com/fusesource/jansi-native for native lib source. maven-maven-3.5.2/apache-maven/src/main/000077500000000000000000000000001317160430700177755ustar00rootroot00000000000000maven-maven-3.5.2/apache-maven/src/main/appended-resources/000077500000000000000000000000001317160430700235655ustar00rootroot00000000000000maven-maven-3.5.2/apache-maven/src/main/appended-resources/META-INF/000077500000000000000000000000001317160430700247255ustar00rootroot00000000000000maven-maven-3.5.2/apache-maven/src/main/appended-resources/META-INF/LICENSE.vm000066400000000000000000000033561317160430700263620ustar00rootroot00000000000000## ## 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 includes a number of components and libraries with separate copyright notices and license terms. Your use of those components are subject to the terms and conditions of the following licenses. #set ( $apacheTxt = "The Apache Software License, Version 2.0" ) #foreach ( $project in $projects ) #foreach ( $license in $project.licenses) #if ( ! ($apacheTxt == $license.name) ) #set ( $artId = $project.artifact.artifactId) #set ( $lf = $locator ) #set ( $url = $license.url ) ## glass fish URL is now invalid, use a fixed one #if ($url == "https://glassfish.dev.java.net/public/CDDLv1.0.html") #set ( $url = 'https://glassfish.java.net/public/CDDLv1.0.html' ) #end #if ($url) #set ( $licFile = 'lib/' + $artId + '.license' ) #set ( $downloaded = $lf.getResourceAsFile($url, "licenses/${licFile}") ) #end $project.name #if ($project.url)($project.url)#end $project.artifact License: $license.name #if ($url) $url ($licFile)#end #end #end #end maven-maven-3.5.2/apache-maven/src/main/assembly/000077500000000000000000000000001317160430700216145ustar00rootroot00000000000000maven-maven-3.5.2/apache-maven/src/main/assembly/bin.xml000066400000000000000000000024051317160430700231070ustar00rootroot00000000000000 bin zip tar.gz src/main/assembly/component.xml maven-maven-3.5.2/apache-maven/src/main/assembly/component.xml000066400000000000000000000062771317160430700243540ustar00rootroot00000000000000 false boot org.codehaus.plexus:plexus-classworlds false lib org.codehaus.plexus:plexus-classworlds README* target/maven-shared-archive-resources/META-INF ./ LICENSE NOTICE target/licenses/lib lib ** target/dependency/META-INF/native lib/jansi-native ** 0755 src/bin bin *.cmd *.conf dos src/bin bin mvn mvnDebug mvnyjp unix 0755 src/conf conf src/lib lib maven-maven-3.5.2/apache-maven/src/main/assembly/dir.xml000066400000000000000000000024361317160430700231210ustar00rootroot00000000000000 dir dir false src/main/assembly/component.xml maven-maven-3.5.2/apache-maven/src/main/assembly/src.xml000066400000000000000000000036571317160430700231400ustar00rootroot00000000000000 src zip tar.gz ${project.basedir}/.. / %regex[(?!((?!target/)[^/]+/)*src/).*target.*] **/*.log **/.gitignore **/.gitattributes init-git-svn.sh **/.repository/** ${project.build.directory}/maven-shared-archive-resources/META-INF / DEPENDENCIES maven-maven-3.5.2/apache-maven/src/site/000077500000000000000000000000001317160430700200155ustar00rootroot00000000000000maven-maven-3.5.2/apache-maven/src/site/site.xml000066400000000000000000000021311317160430700215000ustar00rootroot00000000000000 maven-maven-3.5.2/apache-maven/src/test/000077500000000000000000000000001317160430700200305ustar00rootroot00000000000000maven-maven-3.5.2/apache-maven/src/test/java/000077500000000000000000000000001317160430700207515ustar00rootroot00000000000000maven-maven-3.5.2/apache-maven/src/test/java/org/000077500000000000000000000000001317160430700215405ustar00rootroot00000000000000maven-maven-3.5.2/apache-maven/src/test/java/org/apache/000077500000000000000000000000001317160430700227615ustar00rootroot00000000000000maven-maven-3.5.2/apache-maven/src/test/java/org/apache/maven/000077500000000000000000000000001317160430700240675ustar00rootroot00000000000000maven-maven-3.5.2/apache-maven/src/test/java/org/apache/maven/settings/000077500000000000000000000000001317160430700257275ustar00rootroot00000000000000maven-maven-3.5.2/apache-maven/src/test/java/org/apache/maven/settings/GlobalSettingsTest.java000066400000000000000000000033371317160430700323610ustar00rootroot00000000000000package org.apache.maven.settings; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import junit.framework.TestCase; import org.apache.maven.settings.io.xpp3.SettingsXpp3Reader; import java.io.File; import java.io.FileInputStream; import java.io.InputStreamReader; import java.io.Reader; /** * Tests that the global settings.xml shipped with the distribution is in good state. * * @author Benjamin Bentmann */ public class GlobalSettingsTest extends TestCase { public void testValidGlobalSettings() throws Exception { String basedir = System.getProperty( "basedir", System.getProperty( "user.dir" ) ); File globalSettingsFile = new File( basedir, "src/conf/settings.xml" ); assertTrue( globalSettingsFile.getAbsolutePath(), globalSettingsFile.isFile() ); try ( Reader reader = new InputStreamReader( new FileInputStream( globalSettingsFile ), "UTF-8" ) ) { new SettingsXpp3Reader().read( reader ); } } } maven-maven-3.5.2/deploySite.sh000066400000000000000000000015431317160430700164150ustar00rootroot00000000000000#!/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. # mvn -Preporting site site:stage $@ mvn scm-publish:publish-scm $@ maven-maven-3.5.2/doap_Maven.rdf000066400000000000000000000320761317160430700165130ustar00rootroot00000000000000 2001 Apache Maven Maven is a project development management and comprehension tool. Maven is a project development management and comprehension tool. Based on the concept of a project object model: builds, dependency management, documentation creation, site publication, and distribution publication are all controlled from the declarative file. Maven can be extended by plugins to utilise a number of other development tools for reporting or the build process. Java Latest stable release 2017-04-07 3.5.0 http://archive.apache.org/dist/maven/maven-3/3.5.0/binaries/apache-maven-3.5.0-bin.zip http://archive.apache.org/dist/maven/maven-3/3.5.0/binaries/apache-maven-3.5.0-bin.tar.gz http://archive.apache.org/dist/maven/maven-3/3.5.0/source/apache-maven-3.5.0-src.zip http://archive.apache.org/dist/maven/maven-3/3.5.0/source/apache-maven-3.5.0-src.tar.gz Apache Maven 3.3.9 2015-11-14 3.3.9 http://archive.apache.org/dist/maven/maven-3/3.3.9/binaries/apache-maven-3.3.9-bin.zip http://archive.apache.org/dist/maven/maven-3/3.3.9/binaries/apache-maven-3.3.9-bin.tar.gz http://archive.apache.org/dist/maven/maven-3/3.3.9/source/apache-maven-3.3.9-src.zip http://archive.apache.org/dist/maven/maven-3/3.3.9/source/apache-maven-3.3.9-src.tar.gz Apache Maven 3.3.3 2015-04-28 3.3.3 http://archive.apache.org/dist/maven/maven-3/3.3.3/binaries/apache-maven-3.3.3-bin.zip http://archive.apache.org/dist/maven/maven-3/3.3.3/binaries/apache-maven-3.3.3-bin.tar.gz http://archive.apache.org/dist/maven/maven-3/3.3.3/source/apache-maven-3.3.3-src.zip http://archive.apache.org/dist/maven/maven-3/3.3.3/source/apache-maven-3.3.3-src.tar.gz Apache Maven 3.3.1 2015-03-18 3.3.1 http://archive.apache.org/dist/maven/maven-3/3.3.1/binaries/apache-maven-3.3.1-bin.zip http://archive.apache.org/dist/maven/maven-3/3.3.1/binaries/apache-maven-3.3.1-bin.tar.gz http://archive.apache.org/dist/maven/maven-3/3.3.1/source/apache-maven-3.3.1-src.zip http://archive.apache.org/dist/maven/maven-3/3.3.1/source/apache-maven-3.3.1-src.tar.gz Apache Maven 3.2.5 2014-12-20 3.2.5 http://archive.apache.org/dist/maven/maven-3/3.2.5/binaries/apache-maven-3.2.5-bin.zip http://archive.apache.org/dist/maven/maven-3/3.2.5/binaries/apache-maven-3.2.5-bin.tar.gz http://archive.apache.org/dist/maven/maven-3/3.2.5/source/apache-maven-3.2.5-src.zip http://archive.apache.org/dist/maven/maven-3/3.2.5/source/apache-maven-3.2.5-src.tar.gz Apache Maven 3.2.3 2014-08-17 3.2.3 http://archive.apache.org/dist/maven/maven-3/3.2.3/binaries/apache-maven-3.2.3-bin.zip http://archive.apache.org/dist/maven/maven-3/3.2.3/binaries/apache-maven-3.2.3-bin.tar.gz http://archive.apache.org/dist/maven/maven-3/3.2.3/source/apache-maven-3.2.3-src.zip http://archive.apache.org/dist/maven/maven-3/3.2.3/source/apache-maven-3.2.3-src.tar.gz Apache Maven 3.2.2 2014-06-25 3.2.2 http://archive.apache.org/dist/maven/maven-3/3.2.2/binaries/apache-maven-3.2.2-bin.zip http://archive.apache.org/dist/maven/maven-3/3.2.2/binaries/apache-maven-3.2.2-bin.tar.gz http://archive.apache.org/dist/maven/maven-3/3.2.2/source/apache-maven-3.2.2-src.zip http://archive.apache.org/dist/maven/maven-3/3.2.2/source/apache-maven-3.2.2-src.tar.gz Apache Maven 3.2.1 2014-02-21 3.2.1 http://archive.apache.org/dist/maven/maven-3/3.2.1/binaries/apache-maven-3.2.1-bin.zip http://archive.apache.org/dist/maven/maven-3/3.2.1/binaries/apache-maven-3.2.1-bin.tar.gz http://archive.apache.org/dist/maven/maven-3/3.2.1/source/apache-maven-3.2.1-src.zip http://archive.apache.org/dist/maven/maven-3/3.2.1/source/apache-maven-3.2.1-src.tar.gz Apache Maven 3.1.1 2013-10-04 3.1.1 http://archive.apache.org/dist/maven/maven-3/3.1.1/binaries/apache-maven-3.1.1-bin.zip http://archive.apache.org/dist/maven/maven-3/3.1.1/binaries/apache-maven-3.1.1-bin.tar.gz http://archive.apache.org/dist/maven/maven-3/3.1.1/source/apache-maven-3.1.1-src.zip http://archive.apache.org/dist/maven/maven-3/3.1.1/source/apache-maven-3.1.1-src.tar.gz Apache Maven 3.1.0 2013-07-15 3.1.0 http://archive.apache.org/dist/maven/maven-3/3.1.0/binaries/apache-maven-3.1.0-bin.zip http://archive.apache.org/dist/maven/maven-3/3.1.0/binaries/apache-maven-3.1.0-bin.tar.gz http://archive.apache.org/dist/maven/maven-3/3.1.0/source/apache-maven-3.1.0-src.zip http://archive.apache.org/dist/maven/maven-3/3.1.0/source/apache-maven-3.1.0-src.tar.gz Apache Maven 3.0.5 2013-02-23 3.0.5 http://archive.apache.org/dist/maven/maven-3/3.0.5/binaries/apache-maven-3.0.5-bin.zip http://archive.apache.org/dist/maven/maven-3/3.0.5/binaries/apache-maven-3.0.5-bin.tar.gz http://archive.apache.org/dist/maven/maven-3/3.0.5/source/apache-maven-3.0.5-src.zip http://archive.apache.org/dist/maven/maven-3/3.0.5/source/apache-maven-3.0.5-src.tar.gz Apache Maven 3.0.4 2012-01-20 3.0.4 http://archive.apache.org/dist/maven/binaries/apache-maven-3.0.4-bin.zip http://archive.apache.org/dist/maven/binaries/apache-maven-3.0.4-bin.tar.gz http://archive.apache.org/dist/maven/source/apache-maven-3.0.4-src.zip http://archive.apache.org/dist/maven/source/apache-maven-3.0.4-src.tar.gz Apache Maven 3.0.3 2011-03-03 3.0.3 http://archive.apache.org/dist/maven/binaries/apache-maven-3.0.3-bin.zip http://archive.apache.org/dist/maven/binaries/apache-maven-3.0.3-bin.tar.gz http://archive.apache.org/dist/maven/source/apache-maven-3.0.3-src.zip http://archive.apache.org/dist/maven/source/apache-maven-3.0.3-src.tar.gz Apache Maven 3.0.2 2011-01-12 3.0.2 http://archive.apache.org/dist/maven/binaries/apache-maven-3.0.2-bin.zip http://archive.apache.org/dist/maven/binaries/apache-maven-3.0.2-bin.tar.gz http://archive.apache.org/dist/maven/source/apache-maven-3.0.2-src.zip http://archive.apache.org/dist/maven/source/apache-maven-3.0.2-src.tar.gz Apache Maven 3.0.1 2010-11-23 3.0.1 http://archive.apache.org/dist/maven/binaries/apache-maven-3.0.1-bin.zip http://archive.apache.org/dist/maven/binaries/apache-maven-3.0.1-bin.tar.gz http://archive.apache.org/dist/maven/source/apache-maven-3.0.1-src.zip http://archive.apache.org/dist/maven/source/apache-maven-3.0.1-src.tar.gz Apache Maven 3.0 2010-10-04 3.0 http://archive.apache.org/dist/maven/binaries/apache-maven-3.0-bin.zip http://archive.apache.org/dist/maven/binaries/apache-maven-3.0-bin.tar.gz http://archive.apache.org/dist/maven/source/apache-maven-3.0-src.zip http://archive.apache.org/dist/maven/source/apache-maven-3.0-src.tar.gz Apache Maven PMC maven-maven-3.5.2/maven-artifact/000077500000000000000000000000001317160430700166365ustar00rootroot00000000000000maven-maven-3.5.2/maven-artifact/pom.xml000066400000000000000000000041001317160430700201460ustar00rootroot00000000000000 4.0.0 org.apache.maven maven 3.5.2 maven-artifact Maven Artifact org.codehaus.plexus plexus-utils org.apache.commons commons-lang3 org.codehaus.plexus plexus-component-metadata org.apache.maven.plugins maven-jar-plugin org.apache.maven.artifact.versioning.ComparableVersion maven-maven-3.5.2/maven-artifact/src/000077500000000000000000000000001317160430700174255ustar00rootroot00000000000000maven-maven-3.5.2/maven-artifact/src/main/000077500000000000000000000000001317160430700203515ustar00rootroot00000000000000maven-maven-3.5.2/maven-artifact/src/main/java/000077500000000000000000000000001317160430700212725ustar00rootroot00000000000000maven-maven-3.5.2/maven-artifact/src/main/java/org/000077500000000000000000000000001317160430700220615ustar00rootroot00000000000000maven-maven-3.5.2/maven-artifact/src/main/java/org/apache/000077500000000000000000000000001317160430700233025ustar00rootroot00000000000000maven-maven-3.5.2/maven-artifact/src/main/java/org/apache/maven/000077500000000000000000000000001317160430700244105ustar00rootroot00000000000000maven-maven-3.5.2/maven-artifact/src/main/java/org/apache/maven/artifact/000077500000000000000000000000001317160430700262055ustar00rootroot00000000000000maven-maven-3.5.2/maven-artifact/src/main/java/org/apache/maven/artifact/Artifact.java000066400000000000000000000101701317160430700306040ustar00rootroot00000000000000package org.apache.maven.artifact; /* * 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.File; import java.util.Collection; import java.util.List; import java.util.regex.Pattern; import org.apache.maven.artifact.handler.ArtifactHandler; import org.apache.maven.artifact.metadata.ArtifactMetadata; import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.resolver.filter.ArtifactFilter; import org.apache.maven.artifact.versioning.ArtifactVersion; import org.apache.maven.artifact.versioning.OverConstrainedVersionException; import org.apache.maven.artifact.versioning.VersionRange; /** * Maven Artifact interface. Notice that it mixes artifact definition concepts (groupId, artifactId, version) * with dependency information (version range, scope). */ public interface Artifact extends Comparable { String RELEASE_VERSION = "RELEASE"; String LATEST_VERSION = "LATEST"; String SNAPSHOT_VERSION = "SNAPSHOT"; Pattern VERSION_FILE_PATTERN = Pattern.compile( "^(.*)-([0-9]{8}.[0-9]{6})-([0-9]+)$" ); // TODO into artifactScope handler String SCOPE_COMPILE = "compile"; String SCOPE_COMPILE_PLUS_RUNTIME = "compile+runtime"; String SCOPE_TEST = "test"; String SCOPE_RUNTIME = "runtime"; String SCOPE_RUNTIME_PLUS_SYSTEM = "runtime+system"; String SCOPE_PROVIDED = "provided"; String SCOPE_SYSTEM = "system"; String SCOPE_IMPORT = "import"; // Used to import dependencyManagement dependencies String getGroupId(); String getArtifactId(); String getVersion(); void setVersion( String version ); String getScope(); String getType(); String getClassifier(); boolean hasClassifier(); File getFile(); void setFile( File destination ); String getBaseVersion(); void setBaseVersion( String baseVersion ); String getId(); String getDependencyConflictId(); void addMetadata( ArtifactMetadata metadata ); Collection getMetadataList(); void setRepository( ArtifactRepository remoteRepository ); ArtifactRepository getRepository(); void updateVersion( String version, ArtifactRepository localRepository ); String getDownloadUrl(); void setDownloadUrl( String downloadUrl ); ArtifactFilter getDependencyFilter(); void setDependencyFilter( ArtifactFilter artifactFilter ); ArtifactHandler getArtifactHandler(); List getDependencyTrail(); void setDependencyTrail( List dependencyTrail ); void setScope( String scope ); VersionRange getVersionRange(); void setVersionRange( VersionRange newRange ); void selectVersion( String version ); void setGroupId( String groupId ); void setArtifactId( String artifactId ); boolean isSnapshot(); void setResolved( boolean resolved ); boolean isResolved(); void setResolvedVersion( String version ); void setArtifactHandler( ArtifactHandler handler ); boolean isRelease(); void setRelease( boolean release ); List getAvailableVersions(); void setAvailableVersions( List versions ); boolean isOptional(); void setOptional( boolean optional ); ArtifactVersion getSelectedVersion() throws OverConstrainedVersionException; boolean isSelectedVersionKnown() throws OverConstrainedVersionException; } maven-maven-3.5.2/maven-artifact/src/main/java/org/apache/maven/artifact/ArtifactUtils.java000066400000000000000000000146351317160430700316370ustar00rootroot00000000000000package org.apache.maven.artifact; /* * 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.util.ArrayList; import java.util.Collection; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import java.util.regex.Matcher; import org.apache.commons.lang3.Validate; import org.apache.maven.artifact.versioning.VersionRange; public final class ArtifactUtils { public static boolean isSnapshot( String version ) { if ( version != null ) { if ( version.regionMatches( true, version.length() - Artifact.SNAPSHOT_VERSION.length(), Artifact.SNAPSHOT_VERSION, 0, Artifact.SNAPSHOT_VERSION.length() ) ) { return true; } else if ( Artifact.VERSION_FILE_PATTERN.matcher( version ).matches() ) { return true; } } return false; } public static String toSnapshotVersion( String version ) { Validate.notBlank( version, "version can neither be null, empty nor blank" ); Matcher m = Artifact.VERSION_FILE_PATTERN.matcher( version ); if ( m.matches() ) { return m.group( 1 ) + "-" + Artifact.SNAPSHOT_VERSION; } else { return version; } } public static String versionlessKey( Artifact artifact ) { return versionlessKey( artifact.getGroupId(), artifact.getArtifactId() ); } public static String versionlessKey( String groupId, String artifactId ) { Validate.notBlank( groupId, "groupId can neither be null, empty nor blank" ); Validate.notBlank( artifactId, "artifactId can neither be null, empty nor blank" ); return groupId + ":" + artifactId; } public static String key( Artifact artifact ) { return key( artifact.getGroupId(), artifact.getArtifactId(), artifact.getVersion() ); } public static String key( String groupId, String artifactId, String version ) { Validate.notBlank( groupId, "groupId can neither be null, empty nor blank" ); Validate.notBlank( artifactId, "artifactId can neither be null, empty nor blank" ); Validate.notBlank( version, "version can neither be null, empty nor blank" ); return groupId + ":" + artifactId + ":" + version; } public static Map artifactMapByVersionlessId( Collection artifacts ) { Map artifactMap = new LinkedHashMap<>(); if ( artifacts != null ) { for ( Artifact artifact : artifacts ) { artifactMap.put( versionlessKey( artifact ), artifact ); } } return artifactMap; } public static Artifact copyArtifactSafe( Artifact artifact ) { return ( artifact != null ) ? copyArtifact( artifact ) : null; } public static Artifact copyArtifact( Artifact artifact ) { VersionRange range = artifact.getVersionRange(); // For some reason with the introduction of MNG-1577 we have the case in Yoko where a depMan section has // something like the following: // // // // // // org.apache.yoko // yoko-core // ${version} // // ... // // And the range is not set so we'll check here and set it. jvz. if ( range == null ) { range = VersionRange.createFromVersion( artifact.getVersion() ); } DefaultArtifact clone = new DefaultArtifact( artifact.getGroupId(), artifact.getArtifactId(), range.cloneOf(), artifact.getScope(), artifact.getType(), artifact.getClassifier(), artifact.getArtifactHandler(), artifact.isOptional() ); clone.setRelease( artifact.isRelease() ); clone.setResolvedVersion( artifact.getVersion() ); clone.setResolved( artifact.isResolved() ); clone.setFile( artifact.getFile() ); clone.setAvailableVersions( copyList( artifact.getAvailableVersions() ) ); if ( artifact.getVersion() != null ) { clone.setBaseVersion( artifact.getBaseVersion() ); } clone.setDependencyFilter( artifact.getDependencyFilter() ); clone.setDependencyTrail( copyList( artifact.getDependencyTrail() ) ); clone.setDownloadUrl( artifact.getDownloadUrl() ); clone.setRepository( artifact.getRepository() ); return clone; } /** Returns to collection */ public static > T copyArtifacts( Collection from, T to ) { for ( Artifact artifact : from ) { to.add( ArtifactUtils.copyArtifact( artifact ) ); } return to; } public static > T copyArtifacts( Map from, T to ) { if ( from != null ) { for ( Map.Entry entry : from.entrySet() ) { to.put( entry.getKey(), ArtifactUtils.copyArtifact( entry.getValue() ) ); } } return to; } private static List copyList( List original ) { List copy = null; if ( original != null ) { copy = new ArrayList<>(); if ( !original.isEmpty() ) { copy.addAll( original ); } } return copy; } } maven-maven-3.5.2/maven-artifact/src/main/java/org/apache/maven/artifact/DefaultArtifact.java000066400000000000000000000353621317160430700321230ustar00rootroot00000000000000package org.apache.maven.artifact; /* * 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.File; import java.util.Collection; import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.regex.Matcher; import org.apache.maven.artifact.handler.ArtifactHandler; import org.apache.maven.artifact.metadata.ArtifactMetadata; import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.resolver.filter.ArtifactFilter; import org.apache.maven.artifact.versioning.ArtifactVersion; import org.apache.maven.artifact.versioning.DefaultArtifactVersion; import org.apache.maven.artifact.versioning.OverConstrainedVersionException; import org.apache.maven.artifact.versioning.VersionRange; import org.codehaus.plexus.util.StringUtils; /** * @author Jason van Zyl */ public class DefaultArtifact implements Artifact { private String groupId; private String artifactId; private String baseVersion; private final String type; private final String classifier; private volatile String scope; private volatile File file; private ArtifactRepository repository; private String downloadUrl; private ArtifactFilter dependencyFilter; private ArtifactHandler artifactHandler; private List dependencyTrail; private volatile String version; private VersionRange versionRange; private volatile boolean resolved; private boolean release; private List availableVersions; private Map metadataMap; private boolean optional; public DefaultArtifact( String groupId, String artifactId, String version, String scope, String type, String classifier, ArtifactHandler artifactHandler ) { this( groupId, artifactId, VersionRange.createFromVersion( version ), scope, type, classifier, artifactHandler, false ); } public DefaultArtifact( String groupId, String artifactId, VersionRange versionRange, String scope, String type, String classifier, ArtifactHandler artifactHandler ) { this( groupId, artifactId, versionRange, scope, type, classifier, artifactHandler, false ); } public DefaultArtifact( String groupId, String artifactId, VersionRange versionRange, String scope, String type, String classifier, ArtifactHandler artifactHandler, boolean optional ) { this.groupId = groupId; this.artifactId = artifactId; this.versionRange = versionRange; selectVersionFromNewRangeIfAvailable(); this.artifactHandler = artifactHandler; this.scope = scope; this.type = type; if ( classifier == null ) { classifier = artifactHandler.getClassifier(); } this.classifier = classifier; this.optional = optional; validateIdentity(); } private void validateIdentity() { if ( empty( groupId ) ) { throw new InvalidArtifactRTException( groupId, artifactId, getVersion(), type, "The groupId cannot be empty." ); } if ( artifactId == null ) { throw new InvalidArtifactRTException( groupId, artifactId, getVersion(), type, "The artifactId cannot be empty." ); } if ( type == null ) { throw new InvalidArtifactRTException( groupId, artifactId, getVersion(), type, "The type cannot be empty." ); } if ( ( version == null ) && ( versionRange == null ) ) { throw new InvalidArtifactRTException( groupId, artifactId, getVersion(), type, "The version cannot be empty." ); } } private boolean empty( String value ) { return ( value == null ) || ( value.trim().length() < 1 ); } public String getClassifier() { return classifier; } public boolean hasClassifier() { return StringUtils.isNotEmpty( classifier ); } public String getScope() { return scope; } public String getGroupId() { return groupId; } public String getArtifactId() { return artifactId; } public String getVersion() { return version; } public void setVersion( String version ) { this.version = version; setBaseVersionInternal( version ); versionRange = null; } public String getType() { return type; } public void setFile( File file ) { this.file = file; } public File getFile() { return file; } public ArtifactRepository getRepository() { return repository; } public void setRepository( ArtifactRepository repository ) { this.repository = repository; } // ---------------------------------------------------------------------- // // ---------------------------------------------------------------------- public String getId() { return getDependencyConflictId() + ":" + getBaseVersion(); } public String getDependencyConflictId() { StringBuilder sb = new StringBuilder( 128 ); sb.append( getGroupId() ); sb.append( ':' ); appendArtifactTypeClassifierString( sb ); return sb.toString(); } private void appendArtifactTypeClassifierString( StringBuilder sb ) { sb.append( getArtifactId() ); sb.append( ':' ); sb.append( getType() ); if ( hasClassifier() ) { sb.append( ':' ); sb.append( getClassifier() ); } } public void addMetadata( ArtifactMetadata metadata ) { if ( metadataMap == null ) { metadataMap = new HashMap<>(); } ArtifactMetadata m = metadataMap.get( metadata.getKey() ); if ( m != null ) { m.merge( metadata ); } else { metadataMap.put( metadata.getKey(), metadata ); } } public Collection getMetadataList() { if ( metadataMap == null ) { return Collections.emptyList(); } return metadataMap.values(); } // ---------------------------------------------------------------------- // Object overrides // ---------------------------------------------------------------------- public String toString() { StringBuilder sb = new StringBuilder(); if ( getGroupId() != null ) { sb.append( getGroupId() ); sb.append( ':' ); } appendArtifactTypeClassifierString( sb ); sb.append( ':' ); if ( getBaseVersionInternal() != null ) { sb.append( getBaseVersionInternal() ); } else { sb.append( versionRange.toString() ); } if ( scope != null ) { sb.append( ':' ); sb.append( scope ); } return sb.toString(); } public int hashCode() { int result = 17; result = 37 * result + groupId.hashCode(); result = 37 * result + artifactId.hashCode(); result = 37 * result + type.hashCode(); if ( version != null ) { result = 37 * result + version.hashCode(); } result = 37 * result + ( classifier != null ? classifier.hashCode() : 0 ); return result; } public boolean equals( Object o ) { if ( o == this ) { return true; } if ( !( o instanceof Artifact ) ) { return false; } Artifact a = (Artifact) o; if ( !a.getGroupId().equals( groupId ) ) { return false; } else if ( !a.getArtifactId().equals( artifactId ) ) { return false; } else if ( !a.getVersion().equals( version ) ) { return false; } else if ( !a.getType().equals( type ) ) { return false; } else if ( a.getClassifier() == null ? classifier != null : !a.getClassifier().equals( classifier ) ) { return false; } // We don't consider the version range in the comparison, just the resolved version return true; } public String getBaseVersion() { if ( baseVersion == null && version != null ) { setBaseVersionInternal( version ); } return baseVersion; } protected String getBaseVersionInternal() { if ( ( baseVersion == null ) && ( version != null ) ) { setBaseVersionInternal( version ); } return baseVersion; } public void setBaseVersion( String baseVersion ) { setBaseVersionInternal( baseVersion ); } protected void setBaseVersionInternal( String baseVersion ) { Matcher m = VERSION_FILE_PATTERN.matcher( baseVersion ); if ( m.matches() ) { this.baseVersion = m.group( 1 ) + "-" + SNAPSHOT_VERSION; } else { this.baseVersion = baseVersion; } } public int compareTo( Artifact a ) { int result = groupId.compareTo( a.getGroupId() ); if ( result == 0 ) { result = artifactId.compareTo( a.getArtifactId() ); if ( result == 0 ) { result = type.compareTo( a.getType() ); if ( result == 0 ) { if ( classifier == null ) { if ( a.getClassifier() != null ) { result = 1; } } else { if ( a.getClassifier() != null ) { result = classifier.compareTo( a.getClassifier() ); } else { result = -1; } } if ( result == 0 ) { // We don't consider the version range in the comparison, just the resolved version result = new DefaultArtifactVersion( version ).compareTo( new DefaultArtifactVersion( a.getVersion() ) ); } } } } return result; } public void updateVersion( String version, ArtifactRepository localRepository ) { setResolvedVersion( version ); setFile( new File( localRepository.getBasedir(), localRepository.pathOf( this ) ) ); } public String getDownloadUrl() { return downloadUrl; } public void setDownloadUrl( String downloadUrl ) { this.downloadUrl = downloadUrl; } public ArtifactFilter getDependencyFilter() { return dependencyFilter; } public void setDependencyFilter( ArtifactFilter artifactFilter ) { dependencyFilter = artifactFilter; } public ArtifactHandler getArtifactHandler() { return artifactHandler; } public List getDependencyTrail() { return dependencyTrail; } public void setDependencyTrail( List dependencyTrail ) { this.dependencyTrail = dependencyTrail; } public void setScope( String scope ) { this.scope = scope; } public VersionRange getVersionRange() { return versionRange; } public void setVersionRange( VersionRange versionRange ) { this.versionRange = versionRange; selectVersionFromNewRangeIfAvailable(); } private void selectVersionFromNewRangeIfAvailable() { if ( ( versionRange != null ) && ( versionRange.getRecommendedVersion() != null ) ) { selectVersion( versionRange.getRecommendedVersion().toString() ); } else { version = null; baseVersion = null; } } public void selectVersion( String version ) { this.version = version; setBaseVersionInternal( version ); } public void setGroupId( String groupId ) { this.groupId = groupId; } public void setArtifactId( String artifactId ) { this.artifactId = artifactId; } public boolean isSnapshot() { return getBaseVersion() != null && ( getBaseVersion().endsWith( SNAPSHOT_VERSION ) || getBaseVersion().equals( LATEST_VERSION ) ); } public void setResolved( boolean resolved ) { this.resolved = resolved; } public boolean isResolved() { return resolved; } public void setResolvedVersion( String version ) { this.version = version; // retain baseVersion } public void setArtifactHandler( ArtifactHandler artifactHandler ) { this.artifactHandler = artifactHandler; } public void setRelease( boolean release ) { this.release = release; } public boolean isRelease() { return release; } public List getAvailableVersions() { return availableVersions; } public void setAvailableVersions( List availableVersions ) { this.availableVersions = availableVersions; } public boolean isOptional() { return optional; } public ArtifactVersion getSelectedVersion() throws OverConstrainedVersionException { return versionRange.getSelectedVersion( this ); } public boolean isSelectedVersionKnown() throws OverConstrainedVersionException { return versionRange.isSelectedVersionKnown( this ); } public void setOptional( boolean optional ) { this.optional = optional; } } InvalidArtifactRTException.java000066400000000000000000000054001317160430700341610ustar00rootroot00000000000000maven-maven-3.5.2/maven-artifact/src/main/java/org/apache/maven/artifactpackage org.apache.maven.artifact; /* * 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. */ /** * Exception thrown when the identity of an artifact can not be established, * eg. one of groupId, artifactId, version or type is null. */ public class InvalidArtifactRTException extends RuntimeException { private final String groupId; private final String artifactId; private final String version; private final String type; private final String baseMessage; public InvalidArtifactRTException( String groupId, String artifactId, String version, String type, String message ) { this.groupId = groupId; this.artifactId = artifactId; this.version = version; this.type = type; this.baseMessage = message; } public InvalidArtifactRTException( String groupId, String artifactId, String version, String type, String message, Throwable cause ) { super( cause ); this.groupId = groupId; this.artifactId = artifactId; this.version = version; this.type = type; this.baseMessage = message; } public String getMessage() { return "For artifact {" + getArtifactKey() + "}: " + getBaseMessage(); } public String getBaseMessage() { return baseMessage; } public String getArtifactId() { return artifactId; } public String getGroupId() { return groupId; } public String getType() { return type; } public String getVersion() { return version; } public String getArtifactKey() { return groupId + ":" + artifactId + ":" + version + ":" + type; } } maven-maven-3.5.2/maven-artifact/src/main/java/org/apache/maven/artifact/handler/000077500000000000000000000000001317160430700276225ustar00rootroot00000000000000ArtifactHandler.java000066400000000000000000000023101317160430700334350ustar00rootroot00000000000000maven-maven-3.5.2/maven-artifact/src/main/java/org/apache/maven/artifact/handlerpackage org.apache.maven.artifact.handler; /* * 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 Jason van Zyl */ public interface ArtifactHandler { String ROLE = ArtifactHandler.class.getName(); String getExtension(); String getDirectory(); String getClassifier(); String getPackaging(); boolean isIncludesDependencies(); String getLanguage(); boolean isAddedToClasspath(); } maven-maven-3.5.2/maven-artifact/src/main/java/org/apache/maven/artifact/metadata/000077500000000000000000000000001317160430700277655ustar00rootroot00000000000000ArtifactMetadata.java000066400000000000000000000017751317160430700337610ustar00rootroot00000000000000maven-maven-3.5.2/maven-artifact/src/main/java/org/apache/maven/artifact/metadatapackage org.apache.maven.artifact.metadata; /* * 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. */ @Deprecated public interface ArtifactMetadata extends org.apache.maven.repository.legacy.metadata.ArtifactMetadata { void merge( ArtifactMetadata metadata ); } maven-maven-3.5.2/maven-artifact/src/main/java/org/apache/maven/artifact/repository/000077500000000000000000000000001317160430700304245ustar00rootroot00000000000000ArtifactRepository.java000066400000000000000000000073021317160430700350470ustar00rootroot00000000000000maven-maven-3.5.2/maven-artifact/src/main/java/org/apache/maven/artifact/repositorypackage org.apache.maven.artifact.repository; /* * 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.util.List; import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.metadata.ArtifactMetadata; import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout; import org.apache.maven.repository.Proxy; /** * Abstraction of an artifact repository. Artifact repositories can be remote, local, or even build reactor or * IDE workspace. */ public interface ArtifactRepository { String pathOf( Artifact artifact ); String pathOfRemoteRepositoryMetadata( ArtifactMetadata artifactMetadata ); String pathOfLocalRepositoryMetadata( ArtifactMetadata metadata, ArtifactRepository repository ); String getUrl(); void setUrl( String url ); String getBasedir(); String getProtocol(); String getId(); void setId( String id ); ArtifactRepositoryPolicy getSnapshots(); void setSnapshotUpdatePolicy( ArtifactRepositoryPolicy policy ); ArtifactRepositoryPolicy getReleases(); void setReleaseUpdatePolicy( ArtifactRepositoryPolicy policy ); ArtifactRepositoryLayout getLayout(); void setLayout( ArtifactRepositoryLayout layout ); String getKey(); @Deprecated boolean isUniqueVersion(); @Deprecated boolean isBlacklisted(); @Deprecated void setBlacklisted( boolean blackListed ); // // New interface methods for the repository system. // /** * * @param artifact * @since 3.0-alpha-3 */ Artifact find( Artifact artifact ); /** * Finds the versions of the specified artifact that are available in this repository. * * @param artifact The artifact whose available versions should be determined, must not be {@code null}. * @return The available versions of the artifact or an empty list if none, never {@code null}. * @since 3.0-alpha-3 */ List findVersions( Artifact artifact ); /** * Indicates whether this repository is backed by actual projects. For instance, the build reactor or IDE workspace * are examples of such repositories. * * @return {@code true} if the repository is backed by actual projects, {@code false} otherwise. * @since 3.0-beta-1 */ boolean isProjectAware(); /** * @since 3.0-alpha-3 */ void setAuthentication( Authentication authentication ); /** * @since 3.0-alpha-3 */ Authentication getAuthentication(); /** * @since 3.0-alpha-3 */ void setProxy( Proxy proxy ); /** * @since 3.0-alpha-3 */ Proxy getProxy(); /** * @since 3.0.3 * @return the repositories mirrored by the actual one */ List getMirroredRepositories(); /** * @since 3.0.3 * @param mirroredRepositories the repositories that the actual one mirrors */ void setMirroredRepositories( List mirroredRepositories ); } ArtifactRepositoryPolicy.java000066400000000000000000000141511317160430700362270ustar00rootroot00000000000000maven-maven-3.5.2/maven-artifact/src/main/java/org/apache/maven/artifact/repositorypackage org.apache.maven.artifact.repository; /* * 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.util.Calendar; import java.util.Date; /** * Describes a set of policies for a repository to use under certain conditions. * * @author Brett Porter */ public class ArtifactRepositoryPolicy { public static final String UPDATE_POLICY_NEVER = "never"; public static final String UPDATE_POLICY_ALWAYS = "always"; public static final String UPDATE_POLICY_DAILY = "daily"; public static final String UPDATE_POLICY_INTERVAL = "interval"; public static final String CHECKSUM_POLICY_FAIL = "fail"; public static final String CHECKSUM_POLICY_WARN = "warn"; public static final String CHECKSUM_POLICY_IGNORE = "ignore"; private boolean enabled; private String updatePolicy; private String checksumPolicy; public ArtifactRepositoryPolicy() { this( true, null, null ); } public ArtifactRepositoryPolicy( ArtifactRepositoryPolicy policy ) { this( policy.isEnabled(), policy.getUpdatePolicy(), policy.getChecksumPolicy() ); } public ArtifactRepositoryPolicy( boolean enabled, String updatePolicy, String checksumPolicy ) { this.enabled = enabled; if ( updatePolicy == null ) { updatePolicy = UPDATE_POLICY_DAILY; } this.updatePolicy = updatePolicy; if ( checksumPolicy == null ) { checksumPolicy = CHECKSUM_POLICY_WARN; } this.checksumPolicy = checksumPolicy; } public void setEnabled( boolean enabled ) { this.enabled = enabled; } public void setUpdatePolicy( String updatePolicy ) { if ( updatePolicy != null ) { this.updatePolicy = updatePolicy; } } public void setChecksumPolicy( String checksumPolicy ) { if ( checksumPolicy != null ) { this.checksumPolicy = checksumPolicy; } } public boolean isEnabled() { return enabled; } public String getUpdatePolicy() { return updatePolicy; } public String getChecksumPolicy() { return checksumPolicy; } public boolean checkOutOfDate( Date lastModified ) { boolean checkForUpdates = false; if ( UPDATE_POLICY_ALWAYS.equals( updatePolicy ) ) { checkForUpdates = true; } else if ( UPDATE_POLICY_DAILY.equals( updatePolicy ) ) { // Get local midnight boundary Calendar cal = Calendar.getInstance(); cal.set( Calendar.HOUR_OF_DAY, 0 ); cal.set( Calendar.MINUTE, 0 ); cal.set( Calendar.SECOND, 0 ); cal.set( Calendar.MILLISECOND, 0 ); if ( cal.getTime().after( lastModified ) ) { checkForUpdates = true; } } else if ( updatePolicy.startsWith( UPDATE_POLICY_INTERVAL ) ) { String s = updatePolicy.substring( UPDATE_POLICY_INTERVAL.length() + 1 ); int minutes = Integer.valueOf( s ); Calendar cal = Calendar.getInstance(); cal.add( Calendar.MINUTE, -minutes ); if ( cal.getTime().after( lastModified ) ) { checkForUpdates = true; } } // else assume "never" return checkForUpdates; } @Override public String toString() { StringBuilder buffer = new StringBuilder( 64 ); buffer.append( "{enabled=" ); buffer.append( enabled ); buffer.append( ", checksums=" ); buffer.append( checksumPolicy ); buffer.append( ", updates=" ); buffer.append( updatePolicy ); buffer.append( '}' ); return buffer.toString(); } public void merge( ArtifactRepositoryPolicy policy ) { if ( policy != null && policy.isEnabled() ) { setEnabled( true ); if ( ordinalOfCksumPolicy( policy.getChecksumPolicy() ) < ordinalOfCksumPolicy( getChecksumPolicy() ) ) { setChecksumPolicy( policy.getChecksumPolicy() ); } if ( ordinalOfUpdatePolicy( policy.getUpdatePolicy() ) < ordinalOfUpdatePolicy( getUpdatePolicy() ) ) { setUpdatePolicy( policy.getUpdatePolicy() ); } } } private int ordinalOfCksumPolicy( String policy ) { if ( ArtifactRepositoryPolicy.CHECKSUM_POLICY_FAIL.equals( policy ) ) { return 2; } else if ( ArtifactRepositoryPolicy.CHECKSUM_POLICY_IGNORE.equals( policy ) ) { return 0; } else { return 1; } } private int ordinalOfUpdatePolicy( String policy ) { if ( ArtifactRepositoryPolicy.UPDATE_POLICY_DAILY.equals( policy ) ) { return 1440; } else if ( ArtifactRepositoryPolicy.UPDATE_POLICY_ALWAYS.equals( policy ) ) { return 0; } else if ( policy != null && policy.startsWith( ArtifactRepositoryPolicy.UPDATE_POLICY_INTERVAL ) ) { String s = policy.substring( UPDATE_POLICY_INTERVAL.length() + 1 ); return Integer.valueOf( s ); } else { return Integer.MAX_VALUE; } } } Authentication.java000066400000000000000000000061551317160430700341760ustar00rootroot00000000000000maven-maven-3.5.2/maven-artifact/src/main/java/org/apache/maven/artifact/repositorypackage org.apache.maven.artifact.repository; /* * 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. */ public class Authentication { private String privateKey; private String passphrase; public Authentication( String userName, String password ) { this.username = userName; this.password = password; } /** * Username used to login to the host */ private String username; /** * Password associated with the login */ private String password; /** * Get the user's password which is used when connecting to the repository. * * @return password of user */ public String getPassword() { return password; } /** * Set the user's password which is used when connecting to the repository. * * @param password password of the user */ public void setPassword( String password ) { this.password = password; } /** * Get the username used to access the repository. * * @return username at repository */ public String getUsername() { return username; } /** * Set username used to access the repository. * * @param userName the username used to access repository */ public void setUsername( final String userName ) { this.username = userName; } /** * Get the passphrase of the private key file. The passphrase is used only when host/protocol supports * authentication via exchange of private/public keys and private key was used for authentication. * * @return passphrase of the private key file */ public String getPassphrase() { return passphrase; } /** * Set the passphrase of the private key file. * * @param passphrase passphrase of the private key file */ public void setPassphrase( final String passphrase ) { this.passphrase = passphrase; } /** * Get the absolute path to the private key file. * * @return absolute path to private key */ public String getPrivateKey() { return privateKey; } /** * Set the absolute path to private key file. * * @param privateKey path to private key in local file system */ public void setPrivateKey( final String privateKey ) { this.privateKey = privateKey; } } maven-maven-3.5.2/maven-artifact/src/main/java/org/apache/maven/artifact/repository/layout/000077500000000000000000000000001317160430700317415ustar00rootroot00000000000000ArtifactRepositoryLayout.java000066400000000000000000000025651317160430700375700ustar00rootroot00000000000000maven-maven-3.5.2/maven-artifact/src/main/java/org/apache/maven/artifact/repository/layoutpackage org.apache.maven.artifact.repository.layout; /* * 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 org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.metadata.ArtifactMetadata; import org.apache.maven.artifact.repository.ArtifactRepository; /** @author jdcasey */ public interface ArtifactRepositoryLayout { String ROLE = ArtifactRepositoryLayout.class.getName(); String getId(); String pathOf( Artifact artifact ); String pathOfLocalRepositoryMetadata( ArtifactMetadata metadata, ArtifactRepository repository ); String pathOfRemoteRepositoryMetadata( ArtifactMetadata metadata ); } ArtifactRepositoryLayout2.java000066400000000000000000000024001317160430700376360ustar00rootroot00000000000000maven-maven-3.5.2/maven-artifact/src/main/java/org/apache/maven/artifact/repository/layoutpackage org.apache.maven.artifact.repository.layout; /* * 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 org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.repository.ArtifactRepositoryPolicy; public interface ArtifactRepositoryLayout2 extends ArtifactRepositoryLayout { ArtifactRepository newMavenArtifactRepository( String id, String url, ArtifactRepositoryPolicy snapshots, ArtifactRepositoryPolicy releases ); } maven-maven-3.5.2/maven-artifact/src/main/java/org/apache/maven/artifact/repository/metadata/000077500000000000000000000000001317160430700322045ustar00rootroot00000000000000RepositoryMetadataStoreException.java000066400000000000000000000024731317160430700415120ustar00rootroot00000000000000maven-maven-3.5.2/maven-artifact/src/main/java/org/apache/maven/artifact/repository/metadatapackage org.apache.maven.artifact.repository.metadata; /* * 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. */ /** * Problem storing the repository metadata in the local repository. * * @author Brett Porter */ public class RepositoryMetadataStoreException extends Exception { public RepositoryMetadataStoreException( String message ) { super( message ); } public RepositoryMetadataStoreException( String message, Exception e ) { super( message, e ); } } maven-maven-3.5.2/maven-artifact/src/main/java/org/apache/maven/artifact/resolver/000077500000000000000000000000001317160430700300465ustar00rootroot00000000000000AbstractArtifactResolutionException.java000066400000000000000000000276561317160430700400360ustar00rootroot00000000000000maven-maven-3.5.2/maven-artifact/src/main/java/org/apache/maven/artifact/resolverpackage org.apache.maven.artifact.resolver; /* * 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.util.Iterator; import java.util.List; import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.repository.ArtifactRepositoryPolicy; /** * Base class for artifact resolution exceptions. * * @author Brett Porter */ public class AbstractArtifactResolutionException extends Exception { private String groupId; private String artifactId; private String version; private String type; private String classifier; private Artifact artifact; private List remoteRepositories; private final String originalMessage; private final String path; static final String LS = System.getProperty( "line.separator" ); @SuppressWarnings( "checkstyle:parameternumber" ) protected AbstractArtifactResolutionException( String message, String groupId, String artifactId, String version, String type, String classifier, List remoteRepositories, List path ) { this( message, groupId, artifactId, version, type, classifier, remoteRepositories, path, null ); } @SuppressWarnings( "checkstyle:parameternumber" ) protected AbstractArtifactResolutionException( String message, String groupId, String artifactId, String version, String type, String classifier, List remoteRepositories, List path, Throwable t ) { super( constructMessageBase( message, groupId, artifactId, version, type, remoteRepositories, path ), t ); this.originalMessage = message; this.groupId = groupId; this.artifactId = artifactId; this.type = type; this.classifier = classifier; this.version = version; this.remoteRepositories = remoteRepositories; this.path = constructArtifactPath( path, "" ); } protected AbstractArtifactResolutionException( String message, Artifact artifact ) { this( message, artifact, null ); } protected AbstractArtifactResolutionException( String message, Artifact artifact, List remoteRepositories ) { this( message, artifact, remoteRepositories, null ); } protected AbstractArtifactResolutionException( String message, Artifact artifact, List remoteRepositories, Throwable t ) { this( message, artifact.getGroupId(), artifact.getArtifactId(), artifact.getVersion(), artifact.getType(), artifact.getClassifier(), remoteRepositories, artifact.getDependencyTrail(), t ); this.artifact = artifact; } public Artifact getArtifact() { return artifact; } public String getGroupId() { return groupId; } public String getArtifactId() { return artifactId; } public String getVersion() { return version; } public String getType() { return type; } /** @return the classifier */ public String getClassifier() { return this.classifier; } /** @return the path */ public String getPath() { return this.path; } public List getRemoteRepositories() { return remoteRepositories; } public String getOriginalMessage() { return originalMessage; } protected static String constructArtifactPath( List path, String indentation ) { StringBuilder sb = new StringBuilder(); if ( path != null ) { sb.append( LS ); sb.append( indentation ); sb.append( "Path to dependency: " ); sb.append( LS ); int num = 1; for ( Iterator i = path.iterator(); i.hasNext(); num++ ) { sb.append( indentation ); sb.append( '\t' ); sb.append( num ); sb.append( ") " ); sb.append( i.next() ); sb.append( LS ); } } return sb.toString(); } private static String constructMessageBase( String message, String groupId, String artifactId, String version, String type, List remoteRepositories, List path ) { StringBuilder sb = new StringBuilder(); sb.append( message ); if ( message == null || !message.contains( "from the specified remote repositories:" ) ) { sb.append( LS ); sb.append( " " ).append( groupId ).append( ':' ).append( artifactId ).append( ':' ).append( type ).append( ':' ).append( version ); sb.append( LS ); if ( remoteRepositories != null ) { sb.append( LS ); sb.append( "from the specified remote repositories:" ); sb.append( LS ).append( " " ); if ( remoteRepositories.isEmpty() ) { sb.append( "(none)" ); } for ( Iterator i = remoteRepositories.iterator(); i.hasNext(); ) { ArtifactRepository remoteRepository = i.next(); sb.append( remoteRepository.getId() ); sb.append( " (" ); sb.append( remoteRepository.getUrl() ); ArtifactRepositoryPolicy releases = remoteRepository.getReleases(); if ( releases != null ) { sb.append( ", releases=" ).append( releases.isEnabled() ); } ArtifactRepositoryPolicy snapshots = remoteRepository.getSnapshots(); if ( snapshots != null ) { sb.append( ", snapshots=" ).append( snapshots.isEnabled() ); } sb.append( ')' ); if ( i.hasNext() ) { sb.append( ',' ).append( LS ).append( " " ); } } } sb.append( constructArtifactPath( path, "" ) ); sb.append( LS ); } return sb.toString(); } @SuppressWarnings( "checkstyle:parameternumber" ) protected static String constructMissingArtifactMessage( String message, String indentation, String groupId, String artifactId, String version, String type, String classifier, String downloadUrl, List path ) { StringBuilder sb = new StringBuilder( message ); if ( !"pom".equals( type ) ) { if ( downloadUrl != null ) { sb.append( LS ); sb.append( LS ); sb.append( indentation ); sb.append( "Try downloading the file manually from: " ); sb.append( LS ); sb.append( indentation ); sb.append( " " ); sb.append( downloadUrl ); } else { sb.append( LS ); sb.append( LS ); sb.append( indentation ); sb.append( "Try downloading the file manually from the project website." ); } sb.append( LS ); sb.append( LS ); sb.append( indentation ); sb.append( "Then, install it using the command: " ); sb.append( LS ); sb.append( indentation ); sb.append( " mvn install:install-file -DgroupId=" ); sb.append( groupId ); sb.append( " -DartifactId=" ); sb.append( artifactId ); sb.append( " -Dversion=" ); sb.append( version ); //insert classifier only if it was used in the artifact if ( classifier != null && !classifier.equals( "" ) ) { sb.append( " -Dclassifier=" ); sb.append( classifier ); } sb.append( " -Dpackaging=" ); sb.append( type ); sb.append( " -Dfile=/path/to/file" ); sb.append( LS ); // If people want to deploy it sb.append( LS ); sb.append( indentation ); sb.append( "Alternatively, if you host your own repository you can deploy the file there: " ); sb.append( LS ); sb.append( indentation ); sb.append( " mvn deploy:deploy-file -DgroupId=" ); sb.append( groupId ); sb.append( " -DartifactId=" ); sb.append( artifactId ); sb.append( " -Dversion=" ); sb.append( version ); //insert classifier only if it was used in the artifact if ( classifier != null && !classifier.equals( "" ) ) { sb.append( " -Dclassifier=" ); sb.append( classifier ); } sb.append( " -Dpackaging=" ); sb.append( type ); sb.append( " -Dfile=/path/to/file" ); sb.append( " -Durl=[url] -DrepositoryId=[id]" ); sb.append( LS ); } sb.append( constructArtifactPath( path, indentation ) ); sb.append( LS ); return sb.toString(); } public String getArtifactPath() { return path; } } ArtifactNotFoundException.java000066400000000000000000000070011317160430700357210ustar00rootroot00000000000000maven-maven-3.5.2/maven-artifact/src/main/java/org/apache/maven/artifact/resolverpackage org.apache.maven.artifact.resolver; /* * 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.util.List; import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.repository.ArtifactRepository; /** * @author Jason van Zyl */ public class ArtifactNotFoundException extends AbstractArtifactResolutionException { private String downloadUrl; protected ArtifactNotFoundException( String message, Artifact artifact, List remoteRepositories ) { super( message, artifact, remoteRepositories ); } public ArtifactNotFoundException( String message, Artifact artifact ) { this( message, artifact.getGroupId(), artifact.getArtifactId(), artifact.getVersion(), artifact.getType(), artifact.getClassifier(), null, artifact.getDownloadUrl(), artifact.getDependencyTrail() ); } protected ArtifactNotFoundException( String message, Artifact artifact, List remoteRepositories, Throwable cause ) { this( message, artifact.getGroupId(), artifact.getArtifactId(), artifact.getVersion(), artifact.getType(), artifact.getClassifier(), remoteRepositories, artifact.getDownloadUrl(), artifact.getDependencyTrail(), cause ); } @SuppressWarnings( "checkstyle:parameternumber" ) public ArtifactNotFoundException( String message, String groupId, String artifactId, String version, String type, String classifier, List remoteRepositories, String downloadUrl, List path, Throwable cause ) { super( constructMissingArtifactMessage( message, "", groupId, artifactId, version, type, classifier, downloadUrl, path ), groupId, artifactId, version, type, classifier, remoteRepositories, null, cause ); this.downloadUrl = downloadUrl; } @SuppressWarnings( "checkstyle:parameternumber" ) private ArtifactNotFoundException( String message, String groupId, String artifactId, String version, String type, String classifier, List remoteRepositories, String downloadUrl, List path ) { super( constructMissingArtifactMessage( message, "", groupId, artifactId, version, type, classifier, downloadUrl, path ), groupId, artifactId, version, type, classifier, remoteRepositories, null ); this.downloadUrl = downloadUrl; } public String getDownloadUrl() { return downloadUrl; } } ArtifactResolutionException.java000066400000000000000000000050451317160430700363360ustar00rootroot00000000000000maven-maven-3.5.2/maven-artifact/src/main/java/org/apache/maven/artifact/resolverpackage org.apache.maven.artifact.resolver; /* * 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.util.List; import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.repository.ArtifactRepository; /** * @author Jason van Zyl */ public class ArtifactResolutionException extends AbstractArtifactResolutionException { @SuppressWarnings( "checkstyle:parameternumber" ) public ArtifactResolutionException( String message, String groupId, String artifactId, String version, String type, String classifier, List remoteRepositories, List path, Throwable t ) { super( message, groupId, artifactId, version, type, classifier, remoteRepositories, path, t ); } public ArtifactResolutionException( String message, String groupId, String artifactId, String version, String type, String classifier, Throwable t ) { super( message, groupId, artifactId, version, type, classifier, null, null, t ); } public ArtifactResolutionException( String message, Artifact artifact ) { super( message, artifact ); } public ArtifactResolutionException( String message, Artifact artifact, List remoteRepositories ) { super( message, artifact, remoteRepositories ); } public ArtifactResolutionException( String message, Artifact artifact, Throwable cause ) { super( message, artifact, null, cause ); } public ArtifactResolutionException( String message, Artifact artifact, List remoteRepositories, Throwable cause ) { super( message, artifact, remoteRepositories, cause ); } } CyclicDependencyException.java000066400000000000000000000025651317160430700357260ustar00rootroot00000000000000maven-maven-3.5.2/maven-artifact/src/main/java/org/apache/maven/artifact/resolverpackage org.apache.maven.artifact.resolver; /* * 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 org.apache.maven.artifact.Artifact; /** * Indicates a cycle in the dependency graph. * * @author Brett Porter */ public class CyclicDependencyException extends ArtifactResolutionException { private Artifact artifact; public CyclicDependencyException( String message, Artifact artifact ) { super( message, artifact ); this.artifact = artifact; } public Artifact getArtifact() { return artifact; } } MultipleArtifactsNotFoundException.java000066400000000000000000000102431317160430700376220ustar00rootroot00000000000000maven-maven-3.5.2/maven-artifact/src/main/java/org/apache/maven/artifact/resolverpackage org.apache.maven.artifact.resolver; /* * 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.util.ArrayList; import java.util.List; import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.repository.ArtifactRepository; /** * Exception caused when one or more artifacts can not be resolved because they are not found in the * local or remote repositories. */ public class MultipleArtifactsNotFoundException extends ArtifactResolutionException { private final List resolvedArtifacts; private final List missingArtifacts; /** @deprecated use {@link #MultipleArtifactsNotFoundException(Artifact, List, List, List)} */ @Deprecated public MultipleArtifactsNotFoundException( Artifact originatingArtifact, List missingArtifacts, List remoteRepositories ) { this( originatingArtifact, new ArrayList(), missingArtifacts, remoteRepositories ); } /** * Create an instance of the exception with allrequired information. * * @param originatingArtifact the artifact that was being resolved * @param resolvedArtifacts artifacts that could be resolved * @param missingArtifacts artifacts that could not be resolved * @param remoteRepositories remote repositories where the missing artifacts were not found */ public MultipleArtifactsNotFoundException( Artifact originatingArtifact, List resolvedArtifacts, List missingArtifacts, List remoteRepositories ) { super( constructMessage( missingArtifacts ), originatingArtifact, remoteRepositories ); this.resolvedArtifacts = resolvedArtifacts; this.missingArtifacts = missingArtifacts; } /** * artifacts that could be resolved * * @return {@link List} of {@link Artifact} */ public List getResolvedArtifacts() { return resolvedArtifacts; } /** * artifacts that could NOT be resolved * * @return {@link List} of {@link Artifact} */ public List getMissingArtifacts() { return missingArtifacts; } private static String constructMessage( List artifacts ) { StringBuilder buffer = new StringBuilder( 256 ); buffer.append( "Missing:\n" ); buffer.append( "----------\n" ); int counter = 0; for ( Artifact artifact : artifacts ) { String message = ( ++counter ) + ") " + artifact.getId(); buffer.append( constructMissingArtifactMessage( message, " ", artifact.getGroupId(), artifact.getArtifactId(), artifact.getVersion(), artifact.getType(), artifact.getClassifier(), artifact.getDownloadUrl(), artifact.getDependencyTrail() ) ); } buffer.append( "----------\n" ); int size = artifacts.size(); buffer.append( size ).append( " required artifact" ); if ( size > 1 ) { buffer.append( "s are" ); } else { buffer.append( " is" ); } buffer.append( " missing.\n\nfor artifact: " ); return buffer.toString(); } } maven-maven-3.5.2/maven-artifact/src/main/java/org/apache/maven/artifact/resolver/filter/000077500000000000000000000000001317160430700313335ustar00rootroot00000000000000ArtifactFilter.java000066400000000000000000000020341317160430700350210ustar00rootroot00000000000000maven-maven-3.5.2/maven-artifact/src/main/java/org/apache/maven/artifact/resolver/filterpackage org.apache.maven.artifact.resolver.filter; /* * 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 org.apache.maven.artifact.Artifact; /** * @author Jason van Zyl */ public interface ArtifactFilter { boolean include( Artifact artifact ); } maven-maven-3.5.2/maven-artifact/src/main/java/org/apache/maven/artifact/versioning/000077500000000000000000000000001317160430700303705ustar00rootroot00000000000000ArtifactVersion.java000066400000000000000000000024371317160430700342650ustar00rootroot00000000000000maven-maven-3.5.2/maven-artifact/src/main/java/org/apache/maven/artifact/versioningpackage org.apache.maven.artifact.versioning; /* * 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. */ /** * Describes an artifact version in terms of its components, converts it to/from a string and * compares two versions. * * @author Brett Porter */ public interface ArtifactVersion extends Comparable { int getMajorVersion(); int getMinorVersion(); int getIncrementalVersion(); int getBuildNumber(); String getQualifier(); void parseVersion( String version ); } ComparableVersion.java000066400000000000000000000365651317160430700346060ustar00rootroot00000000000000maven-maven-3.5.2/maven-artifact/src/main/java/org/apache/maven/artifact/versioningpackage org.apache.maven.artifact.versioning; /* * 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.math.BigInteger; import java.util.ArrayList; import java.util.Arrays; import java.util.Iterator; import java.util.List; import java.util.Locale; import java.util.Properties; import java.util.Stack; /** *

* Generic implementation of version comparison. *

* * Features: *
    *
  • mixing of '-' (hyphen) and '.' (dot) separators,
  • *
  • transition between characters and digits also constitutes a separator: * 1.0alpha1 => [1, 0, alpha, 1]
  • *
  • unlimited number of version components,
  • *
  • version components in the text can be digits or strings,
  • *
  • strings are checked for well-known qualifiers and the qualifier ordering is used for version ordering. * Well-known qualifiers (case insensitive) are:
      *
    • alpha or a
    • *
    • beta or b
    • *
    • milestone or m
    • *
    • rc or cr
    • *
    • snapshot
    • *
    • (the empty string) or ga or final
    • *
    • sp
    • *
    * Unknown qualifiers are considered after known qualifiers, with lexical order (always case insensitive), *
  • *
  • a hyphen usually precedes a qualifier, and is always less important than something preceded with a dot.
  • *
* * @see "Versioning" on Maven Wiki * @author Kenney Westerhof * @author Hervé Boutemy */ public class ComparableVersion implements Comparable { private String value; private String canonical; private ListItem items; private interface Item { int INTEGER_ITEM = 0; int STRING_ITEM = 1; int LIST_ITEM = 2; int compareTo( Item item ); int getType(); boolean isNull(); } /** * Represents a numeric item in the version item list. */ private static class IntegerItem implements Item { private static final BigInteger BIG_INTEGER_ZERO = new BigInteger( "0" ); private final BigInteger value; public static final IntegerItem ZERO = new IntegerItem(); private IntegerItem() { this.value = BIG_INTEGER_ZERO; } public IntegerItem( String str ) { this.value = new BigInteger( str ); } public int getType() { return INTEGER_ITEM; } public boolean isNull() { return BIG_INTEGER_ZERO.equals( value ); } public int compareTo( Item item ) { if ( item == null ) { return BIG_INTEGER_ZERO.equals( value ) ? 0 : 1; // 1.0 == 1, 1.1 > 1 } switch ( item.getType() ) { case INTEGER_ITEM: return value.compareTo( ( (IntegerItem) item ).value ); case STRING_ITEM: return 1; // 1.1 > 1-sp case LIST_ITEM: return 1; // 1.1 > 1-1 default: throw new RuntimeException( "invalid item: " + item.getClass() ); } } public String toString() { return value.toString(); } } /** * Represents a string in the version item list, usually a qualifier. */ private static class StringItem implements Item { private static final String[] QUALIFIERS = { "alpha", "beta", "milestone", "rc", "snapshot", "", "sp" }; @SuppressWarnings( "checkstyle:constantname" ) private static final List _QUALIFIERS = Arrays.asList( QUALIFIERS ); private static final Properties ALIASES = new Properties(); static { ALIASES.put( "ga", "" ); ALIASES.put( "final", "" ); ALIASES.put( "cr", "rc" ); } /** * A comparable value for the empty-string qualifier. This one is used to determine if a given qualifier makes * the version older than one without a qualifier, or more recent. */ private static final String RELEASE_VERSION_INDEX = String.valueOf( _QUALIFIERS.indexOf( "" ) ); private String value; public StringItem( String value, boolean followedByDigit ) { if ( followedByDigit && value.length() == 1 ) { // a1 = alpha-1, b1 = beta-1, m1 = milestone-1 switch ( value.charAt( 0 ) ) { case 'a': value = "alpha"; break; case 'b': value = "beta"; break; case 'm': value = "milestone"; break; default: } } this.value = ALIASES.getProperty( value , value ); } public int getType() { return STRING_ITEM; } public boolean isNull() { return ( comparableQualifier( value ).compareTo( RELEASE_VERSION_INDEX ) == 0 ); } /** * Returns a comparable value for a qualifier. * * This method takes into account the ordering of known qualifiers then unknown qualifiers with lexical * ordering. * * just returning an Integer with the index here is faster, but requires a lot of if/then/else to check for -1 * or QUALIFIERS.size and then resort to lexical ordering. Most comparisons are decided by the first character, * so this is still fast. If more characters are needed then it requires a lexical sort anyway. * * @param qualifier * @return an equivalent value that can be used with lexical comparison */ public static String comparableQualifier( String qualifier ) { int i = _QUALIFIERS.indexOf( qualifier ); return i == -1 ? ( _QUALIFIERS.size() + "-" + qualifier ) : String.valueOf( i ); } public int compareTo( Item item ) { if ( item == null ) { // 1-rc < 1, 1-ga > 1 return comparableQualifier( value ).compareTo( RELEASE_VERSION_INDEX ); } switch ( item.getType() ) { case INTEGER_ITEM: return -1; // 1.any < 1.1 ? case STRING_ITEM: return comparableQualifier( value ).compareTo( comparableQualifier( ( (StringItem) item ).value ) ); case LIST_ITEM: return -1; // 1.any < 1-1 default: throw new RuntimeException( "invalid item: " + item.getClass() ); } } public String toString() { return value; } } /** * Represents a version list item. This class is used both for the global item list and for sub-lists (which start * with '-(number)' in the version specification). */ private static class ListItem extends ArrayList implements Item { public int getType() { return LIST_ITEM; } public boolean isNull() { return ( size() == 0 ); } void normalize() { for ( int i = size() - 1; i >= 0; i-- ) { Item lastItem = get( i ); if ( lastItem.isNull() ) { // remove null trailing items: 0, "", empty list remove( i ); } else if ( !( lastItem instanceof ListItem ) ) { break; } } } public int compareTo( Item item ) { if ( item == null ) { if ( size() == 0 ) { return 0; // 1-0 = 1- (normalize) = 1 } Item first = get( 0 ); return first.compareTo( null ); } switch ( item.getType() ) { case INTEGER_ITEM: return -1; // 1-1 < 1.0.x case STRING_ITEM: return 1; // 1-1 > 1-sp case LIST_ITEM: Iterator left = iterator(); Iterator right = ( (ListItem) item ).iterator(); while ( left.hasNext() || right.hasNext() ) { Item l = left.hasNext() ? left.next() : null; Item r = right.hasNext() ? right.next() : null; // if this is shorter, then invert the compare and mul with -1 int result = l == null ? ( r == null ? 0 : -1 * r.compareTo( l ) ) : l.compareTo( r ); if ( result != 0 ) { return result; } } return 0; default: throw new RuntimeException( "invalid item: " + item.getClass() ); } } public String toString() { StringBuilder buffer = new StringBuilder(); for ( Item item : this ) { if ( buffer.length() > 0 ) { buffer.append( ( item instanceof ListItem ) ? '-' : '.' ); } buffer.append( item ); } return buffer.toString(); } } public ComparableVersion( String version ) { parseVersion( version ); } public final void parseVersion( String version ) { this.value = version; items = new ListItem(); version = version.toLowerCase( Locale.ENGLISH ); ListItem list = items; Stack stack = new Stack<>(); stack.push( list ); boolean isDigit = false; int startIndex = 0; for ( int i = 0; i < version.length(); i++ ) { char c = version.charAt( i ); if ( c == '.' ) { if ( i == startIndex ) { list.add( IntegerItem.ZERO ); } else { list.add( parseItem( isDigit, version.substring( startIndex, i ) ) ); } startIndex = i + 1; } else if ( c == '-' ) { if ( i == startIndex ) { list.add( IntegerItem.ZERO ); } else { list.add( parseItem( isDigit, version.substring( startIndex, i ) ) ); } startIndex = i + 1; list.add( list = new ListItem() ); stack.push( list ); } else if ( Character.isDigit( c ) ) { if ( !isDigit && i > startIndex ) { list.add( new StringItem( version.substring( startIndex, i ), true ) ); startIndex = i; list.add( list = new ListItem() ); stack.push( list ); } isDigit = true; } else { if ( isDigit && i > startIndex ) { list.add( parseItem( true, version.substring( startIndex, i ) ) ); startIndex = i; list.add( list = new ListItem() ); stack.push( list ); } isDigit = false; } } if ( version.length() > startIndex ) { list.add( parseItem( isDigit, version.substring( startIndex ) ) ); } while ( !stack.isEmpty() ) { list = (ListItem) stack.pop(); list.normalize(); } canonical = items.toString(); } private static Item parseItem( boolean isDigit, String buf ) { return isDigit ? new IntegerItem( buf ) : new StringItem( buf, false ); } public int compareTo( ComparableVersion o ) { return items.compareTo( o.items ); } public String toString() { return value; } public String getCanonical() { return canonical; } public boolean equals( Object o ) { return ( o instanceof ComparableVersion ) && canonical.equals( ( (ComparableVersion) o ).canonical ); } public int hashCode() { return canonical.hashCode(); } // CHECKSTYLE_OFF: LineLength /** * Main to test version parsing and comparison. *

* To check how "1.2.7" compares to "1.2-SNAPSHOT", for example, you can issue *

java -jar ${maven.repo.local}/org/apache/maven/maven-artifact/${maven.version}/maven-artifact-${maven.version}.jar "1.2.7" "1.2-SNAPSHOT"
* command to command line. Result of given command will be something like this: *
     * Display parameters as parsed by Maven (in canonical form) and comparison result:
     * 1. 1.2.7 == 1.2.7
     *    1.2.7 > 1.2-SNAPSHOT
     * 2. 1.2-SNAPSHOT == 1.2-snapshot
     * 
* * @param args the version strings to parse and compare. You can pass arbitrary number of version strings and always * two adjacent will be compared */ // CHECKSTYLE_ON: LineLength public static void main( String... args ) { System.out.println( "Display parameters as parsed by Maven (in canonical form) and comparison result:" ); if ( args.length == 0 ) { return; } ComparableVersion prev = null; int i = 1; for ( String version : args ) { ComparableVersion c = new ComparableVersion( version ); if ( prev != null ) { int compare = prev.compareTo( c ); System.out.println( " " + prev.toString() + ' ' + ( ( compare == 0 ) ? "==" : ( ( compare < 0 ) ? "<" : ">" ) ) + ' ' + version ); } System.out.println( String.valueOf( i++ ) + ". " + version + " == " + c.getCanonical() ); prev = c; } } } DefaultArtifactVersion.java000066400000000000000000000136561317160430700355770ustar00rootroot00000000000000maven-maven-3.5.2/maven-artifact/src/main/java/org/apache/maven/artifact/versioningpackage org.apache.maven.artifact.versioning; /* * 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.util.StringTokenizer; import java.util.regex.Pattern; import java.util.NoSuchElementException; /** * Default implementation of artifact versioning. * * @author Brett Porter */ public class DefaultArtifactVersion implements ArtifactVersion { private Integer majorVersion; private Integer minorVersion; private Integer incrementalVersion; private Integer buildNumber; private String qualifier; private ComparableVersion comparable; public DefaultArtifactVersion( String version ) { parseVersion( version ); } @Override public int hashCode() { return 11 + comparable.hashCode(); } @Override public boolean equals( Object other ) { if ( this == other ) { return true; } if ( !( other instanceof ArtifactVersion ) ) { return false; } return compareTo( (ArtifactVersion) other ) == 0; } public int compareTo( ArtifactVersion otherVersion ) { if ( otherVersion instanceof DefaultArtifactVersion ) { return this.comparable.compareTo( ( (DefaultArtifactVersion) otherVersion ).comparable ); } else { return compareTo( new DefaultArtifactVersion( otherVersion.toString() ) ); } } public int getMajorVersion() { return majorVersion != null ? majorVersion : 0; } public int getMinorVersion() { return minorVersion != null ? minorVersion : 0; } public int getIncrementalVersion() { return incrementalVersion != null ? incrementalVersion : 0; } public int getBuildNumber() { return buildNumber != null ? buildNumber : 0; } public String getQualifier() { return qualifier; } public final void parseVersion( String version ) { comparable = new ComparableVersion( version ); int index = version.indexOf( '-' ); String part1; String part2 = null; if ( index < 0 ) { part1 = version; } else { part1 = version.substring( 0, index ); part2 = version.substring( index + 1 ); } if ( part2 != null ) { try { if ( ( part2.length() == 1 ) || !part2.startsWith( "0" ) ) { buildNumber = Integer.valueOf( part2 ); } else { qualifier = part2; } } catch ( NumberFormatException e ) { qualifier = part2; } } if ( ( !part1.contains( "." ) ) && !part1.startsWith( "0" ) ) { try { majorVersion = Integer.valueOf( part1 ); } catch ( NumberFormatException e ) { // qualifier is the whole version, including "-" qualifier = version; buildNumber = null; } } else { boolean fallback = false; StringTokenizer tok = new StringTokenizer( part1, "." ); try { majorVersion = getNextIntegerToken( tok ); if ( tok.hasMoreTokens() ) { minorVersion = getNextIntegerToken( tok ); } if ( tok.hasMoreTokens() ) { incrementalVersion = getNextIntegerToken( tok ); } if ( tok.hasMoreTokens() ) { qualifier = tok.nextToken(); fallback = Pattern.compile( "\\d+" ).matcher( qualifier ).matches(); } // string tokenizer won't detect these and ignores them if ( part1.contains( ".." ) || part1.startsWith( "." ) || part1.endsWith( "." ) ) { fallback = true; } } catch ( NumberFormatException e ) { fallback = true; } if ( fallback ) { // qualifier is the whole version, including "-" qualifier = version; majorVersion = null; minorVersion = null; incrementalVersion = null; buildNumber = null; } } } private static Integer getNextIntegerToken( StringTokenizer tok ) { try { String s = tok.nextToken(); if ( ( s.length() > 1 ) && s.startsWith( "0" ) ) { throw new NumberFormatException( "Number part has a leading 0: '" + s + "'" ); } return Integer.valueOf( s ); } catch ( NoSuchElementException e ) { throw new NumberFormatException( "Number is invalid" ); } } @Override public String toString() { return comparable.toString(); } } InvalidVersionSpecificationException.java000066400000000000000000000021711317160430700404710ustar00rootroot00000000000000maven-maven-3.5.2/maven-artifact/src/main/java/org/apache/maven/artifact/versioningpackage org.apache.maven.artifact.versioning; /* * 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. */ /** * Occurs when a version is invalid. * * @author Brett Porter */ public class InvalidVersionSpecificationException extends Exception { public InvalidVersionSpecificationException( String message ) { super( message ); } } OverConstrainedVersionException.java000066400000000000000000000033001317160430700375020ustar00rootroot00000000000000maven-maven-3.5.2/maven-artifact/src/main/java/org/apache/maven/artifact/versioningpackage org.apache.maven.artifact.versioning; /* * 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.util.List; import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.resolver.ArtifactResolutionException; /** * Occurs when ranges exclude each other and no valid value remains. * * @author Brett Porter */ public class OverConstrainedVersionException extends ArtifactResolutionException { public OverConstrainedVersionException( String msg, Artifact artifact ) { super( msg, artifact ); } public OverConstrainedVersionException( String msg, Artifact artifact, List remoteRepositories ) { super( msg, artifact, remoteRepositories ); } } maven-maven-3.5.2/maven-artifact/src/main/java/org/apache/maven/artifact/versioning/Restriction.java000066400000000000000000000112731317160430700335440ustar00rootroot00000000000000package org.apache.maven.artifact.versioning; /* * 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. */ /** * Describes a restriction in versioning. * * @author Brett Porter */ public class Restriction { private final ArtifactVersion lowerBound; private final boolean lowerBoundInclusive; private final ArtifactVersion upperBound; private final boolean upperBoundInclusive; public static final Restriction EVERYTHING = new Restriction( null, false, null, false ); public Restriction( ArtifactVersion lowerBound, boolean lowerBoundInclusive, ArtifactVersion upperBound, boolean upperBoundInclusive ) { this.lowerBound = lowerBound; this.lowerBoundInclusive = lowerBoundInclusive; this.upperBound = upperBound; this.upperBoundInclusive = upperBoundInclusive; } public ArtifactVersion getLowerBound() { return lowerBound; } public boolean isLowerBoundInclusive() { return lowerBoundInclusive; } public ArtifactVersion getUpperBound() { return upperBound; } public boolean isUpperBoundInclusive() { return upperBoundInclusive; } public boolean containsVersion( ArtifactVersion version ) { if ( lowerBound != null ) { int comparison = lowerBound.compareTo( version ); if ( ( comparison == 0 ) && !lowerBoundInclusive ) { return false; } if ( comparison > 0 ) { return false; } } if ( upperBound != null ) { int comparison = upperBound.compareTo( version ); if ( ( comparison == 0 ) && !upperBoundInclusive ) { return false; } if ( comparison < 0 ) { return false; } } return true; } @Override public int hashCode() { int result = 13; if ( lowerBound == null ) { result += 1; } else { result += lowerBound.hashCode(); } result *= lowerBoundInclusive ? 1 : 2; if ( upperBound == null ) { result -= 3; } else { result -= upperBound.hashCode(); } result *= upperBoundInclusive ? 2 : 3; return result; } @Override public boolean equals( Object other ) { if ( this == other ) { return true; } if ( !( other instanceof Restriction ) ) { return false; } Restriction restriction = (Restriction) other; if ( lowerBound != null ) { if ( !lowerBound.equals( restriction.lowerBound ) ) { return false; } } else if ( restriction.lowerBound != null ) { return false; } if ( lowerBoundInclusive != restriction.lowerBoundInclusive ) { return false; } if ( upperBound != null ) { if ( !upperBound.equals( restriction.upperBound ) ) { return false; } } else if ( restriction.upperBound != null ) { return false; } return upperBoundInclusive == restriction.upperBoundInclusive; } public String toString() { StringBuilder buf = new StringBuilder(); buf.append( isLowerBoundInclusive() ? '[' : '(' ); if ( getLowerBound() != null ) { buf.append( getLowerBound().toString() ); } buf.append( ',' ); if ( getUpperBound() != null ) { buf.append( getUpperBound().toString() ); } buf.append( isUpperBoundInclusive() ? ']' : ')' ); return buf.toString(); } } VersionRange.java000066400000000000000000000476701317160430700335740ustar00rootroot00000000000000maven-maven-3.5.2/maven-artifact/src/main/java/org/apache/maven/artifact/versioningpackage org.apache.maven.artifact.versioning; /* * 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.util.ArrayList; import java.util.Collections; import java.util.Iterator; import java.util.List; import org.apache.maven.artifact.Artifact; /** * Construct a version range from a specification. * * @author Brett Porter */ public class VersionRange { private final ArtifactVersion recommendedVersion; private final List restrictions; private VersionRange( ArtifactVersion recommendedVersion, List restrictions ) { this.recommendedVersion = recommendedVersion; this.restrictions = restrictions; } public ArtifactVersion getRecommendedVersion() { return recommendedVersion; } public List getRestrictions() { return restrictions; } public VersionRange cloneOf() { List copiedRestrictions = null; if ( restrictions != null ) { copiedRestrictions = new ArrayList<>(); if ( !restrictions.isEmpty() ) { copiedRestrictions.addAll( restrictions ); } } return new VersionRange( recommendedVersion, copiedRestrictions ); } /** *

* Create a version range from a string representation *

* Some spec examples are: *
    *
  • 1.0 Version 1.0
  • *
  • [1.0,2.0) Versions 1.0 (included) to 2.0 (not included)
  • *
  • [1.0,2.0] Versions 1.0 to 2.0 (both included)
  • *
  • [1.5,) Versions 1.5 and higher
  • *
  • (,1.0],[1.2,) Versions up to 1.0 (included) and 1.2 or higher
  • *
* * @param spec string representation of a version or version range * @return a new {@link VersionRange} object that represents the spec * @throws InvalidVersionSpecificationException * */ public static VersionRange createFromVersionSpec( String spec ) throws InvalidVersionSpecificationException { if ( spec == null ) { return null; } List restrictions = new ArrayList<>(); String process = spec; ArtifactVersion version = null; ArtifactVersion upperBound = null; ArtifactVersion lowerBound = null; while ( process.startsWith( "[" ) || process.startsWith( "(" ) ) { int index1 = process.indexOf( ')' ); int index2 = process.indexOf( ']' ); int index = index2; if ( index2 < 0 || index1 < index2 ) { if ( index1 >= 0 ) { index = index1; } } if ( index < 0 ) { throw new InvalidVersionSpecificationException( "Unbounded range: " + spec ); } Restriction restriction = parseRestriction( process.substring( 0, index + 1 ) ); if ( lowerBound == null ) { lowerBound = restriction.getLowerBound(); } if ( upperBound != null ) { if ( restriction.getLowerBound() == null || restriction.getLowerBound().compareTo( upperBound ) < 0 ) { throw new InvalidVersionSpecificationException( "Ranges overlap: " + spec ); } } restrictions.add( restriction ); upperBound = restriction.getUpperBound(); process = process.substring( index + 1 ).trim(); if ( process.length() > 0 && process.startsWith( "," ) ) { process = process.substring( 1 ).trim(); } } if ( process.length() > 0 ) { if ( restrictions.size() > 0 ) { throw new InvalidVersionSpecificationException( "Only fully-qualified sets allowed in multiple set scenario: " + spec ); } else { version = new DefaultArtifactVersion( process ); restrictions.add( Restriction.EVERYTHING ); } } return new VersionRange( version, restrictions ); } private static Restriction parseRestriction( String spec ) throws InvalidVersionSpecificationException { boolean lowerBoundInclusive = spec.startsWith( "[" ); boolean upperBoundInclusive = spec.endsWith( "]" ); String process = spec.substring( 1, spec.length() - 1 ).trim(); Restriction restriction; int index = process.indexOf( ',' ); if ( index < 0 ) { if ( !lowerBoundInclusive || !upperBoundInclusive ) { throw new InvalidVersionSpecificationException( "Single version must be surrounded by []: " + spec ); } ArtifactVersion version = new DefaultArtifactVersion( process ); restriction = new Restriction( version, lowerBoundInclusive, version, upperBoundInclusive ); } else { String lowerBound = process.substring( 0, index ).trim(); String upperBound = process.substring( index + 1 ).trim(); if ( lowerBound.equals( upperBound ) ) { throw new InvalidVersionSpecificationException( "Range cannot have identical boundaries: " + spec ); } ArtifactVersion lowerVersion = null; if ( lowerBound.length() > 0 ) { lowerVersion = new DefaultArtifactVersion( lowerBound ); } ArtifactVersion upperVersion = null; if ( upperBound.length() > 0 ) { upperVersion = new DefaultArtifactVersion( upperBound ); } if ( upperVersion != null && lowerVersion != null && upperVersion.compareTo( lowerVersion ) < 0 ) { throw new InvalidVersionSpecificationException( "Range defies version ordering: " + spec ); } restriction = new Restriction( lowerVersion, lowerBoundInclusive, upperVersion, upperBoundInclusive ); } return restriction; } public static VersionRange createFromVersion( String version ) { List restrictions = Collections.emptyList(); return new VersionRange( new DefaultArtifactVersion( version ), restrictions ); } /** * Creates and returns a new VersionRange that is a restriction of this * version range and the specified version range. *

* Note: Precedence is given to the recommended version from this version range over the * recommended version from the specified version range. *

* * @param restriction the VersionRange that will be used to restrict this version * range. * @return the VersionRange that is a restriction of this version range and the * specified version range. *

* The restrictions of the returned version range will be an intersection of the restrictions * of this version range and the specified version range if both version ranges have * restrictions. Otherwise, the restrictions on the returned range will be empty. *

*

* The recommended version of the returned version range will be the recommended version of * this version range, provided that ranges falls within the intersected restrictions. If * the restrictions are empty, this version range's recommended version is used if it is not * null. If it is null, the specified version range's recommended * version is used (provided it is non-null). If no recommended version can be * obtained, the returned version range's recommended version is set to null. *

* @throws NullPointerException if the specified VersionRange is * null. */ public VersionRange restrict( VersionRange restriction ) { List r1 = this.restrictions; List r2 = restriction.restrictions; List restrictions; if ( r1.isEmpty() || r2.isEmpty() ) { restrictions = Collections.emptyList(); } else { restrictions = intersection( r1, r2 ); } ArtifactVersion version = null; if ( restrictions.size() > 0 ) { for ( Restriction r : restrictions ) { if ( recommendedVersion != null && r.containsVersion( recommendedVersion ) ) { // if we find the original, use that version = recommendedVersion; break; } else if ( version == null && restriction.getRecommendedVersion() != null && r.containsVersion( restriction.getRecommendedVersion() ) ) { // use this if we can, but prefer the original if possible version = restriction.getRecommendedVersion(); } } } // Either the original or the specified version ranges have no restrictions else if ( recommendedVersion != null ) { // Use the original recommended version since it exists version = recommendedVersion; } else if ( restriction.recommendedVersion != null ) { // Use the recommended version from the specified VersionRange since there is no // original recommended version version = restriction.recommendedVersion; } /* TODO should throw this immediately, but need artifact else { throw new OverConstrainedVersionException( "Restricting incompatible version ranges" ); } */ return new VersionRange( version, restrictions ); } private List intersection( List r1, List r2 ) { List restrictions = new ArrayList<>( r1.size() + r2.size() ); Iterator i1 = r1.iterator(); Iterator i2 = r2.iterator(); Restriction res1 = i1.next(); Restriction res2 = i2.next(); boolean done = false; while ( !done ) { if ( res1.getLowerBound() == null || res2.getUpperBound() == null || res1.getLowerBound().compareTo( res2.getUpperBound() ) <= 0 ) { if ( res1.getUpperBound() == null || res2.getLowerBound() == null || res1.getUpperBound().compareTo( res2.getLowerBound() ) >= 0 ) { ArtifactVersion lower; ArtifactVersion upper; boolean lowerInclusive; boolean upperInclusive; // overlaps if ( res1.getLowerBound() == null ) { lower = res2.getLowerBound(); lowerInclusive = res2.isLowerBoundInclusive(); } else if ( res2.getLowerBound() == null ) { lower = res1.getLowerBound(); lowerInclusive = res1.isLowerBoundInclusive(); } else { int comparison = res1.getLowerBound().compareTo( res2.getLowerBound() ); if ( comparison < 0 ) { lower = res2.getLowerBound(); lowerInclusive = res2.isLowerBoundInclusive(); } else if ( comparison == 0 ) { lower = res1.getLowerBound(); lowerInclusive = res1.isLowerBoundInclusive() && res2.isLowerBoundInclusive(); } else { lower = res1.getLowerBound(); lowerInclusive = res1.isLowerBoundInclusive(); } } if ( res1.getUpperBound() == null ) { upper = res2.getUpperBound(); upperInclusive = res2.isUpperBoundInclusive(); } else if ( res2.getUpperBound() == null ) { upper = res1.getUpperBound(); upperInclusive = res1.isUpperBoundInclusive(); } else { int comparison = res1.getUpperBound().compareTo( res2.getUpperBound() ); if ( comparison < 0 ) { upper = res1.getUpperBound(); upperInclusive = res1.isUpperBoundInclusive(); } else if ( comparison == 0 ) { upper = res1.getUpperBound(); upperInclusive = res1.isUpperBoundInclusive() && res2.isUpperBoundInclusive(); } else { upper = res2.getUpperBound(); upperInclusive = res2.isUpperBoundInclusive(); } } // don't add if they are equal and one is not inclusive if ( lower == null || upper == null || lower.compareTo( upper ) != 0 ) { restrictions.add( new Restriction( lower, lowerInclusive, upper, upperInclusive ) ); } else if ( lowerInclusive && upperInclusive ) { restrictions.add( new Restriction( lower, lowerInclusive, upper, upperInclusive ) ); } //noinspection ObjectEquality if ( upper == res2.getUpperBound() ) { // advance res2 if ( i2.hasNext() ) { res2 = i2.next(); } else { done = true; } } else { // advance res1 if ( i1.hasNext() ) { res1 = i1.next(); } else { done = true; } } } else { // move on to next in r1 if ( i1.hasNext() ) { res1 = i1.next(); } else { done = true; } } } else { // move on to next in r2 if ( i2.hasNext() ) { res2 = i2.next(); } else { done = true; } } } return restrictions; } public ArtifactVersion getSelectedVersion( Artifact artifact ) throws OverConstrainedVersionException { ArtifactVersion version; if ( recommendedVersion != null ) { version = recommendedVersion; } else { if ( restrictions.size() == 0 ) { throw new OverConstrainedVersionException( "The artifact has no valid ranges", artifact ); } version = null; } return version; } public boolean isSelectedVersionKnown( Artifact artifact ) throws OverConstrainedVersionException { boolean value = false; if ( recommendedVersion != null ) { value = true; } else { if ( restrictions.size() == 0 ) { throw new OverConstrainedVersionException( "The artifact has no valid ranges", artifact ); } } return value; } public String toString() { if ( recommendedVersion != null ) { return recommendedVersion.toString(); } else { StringBuilder buf = new StringBuilder(); for ( Iterator i = restrictions.iterator(); i.hasNext(); ) { Restriction r = i.next(); buf.append( r.toString() ); if ( i.hasNext() ) { buf.append( ',' ); } } return buf.toString(); } } public ArtifactVersion matchVersion( List versions ) { // TODO could be more efficient by sorting the list and then moving along the restrictions in order? ArtifactVersion matched = null; for ( ArtifactVersion version : versions ) { if ( containsVersion( version ) ) { // valid - check if it is greater than the currently matched version if ( matched == null || version.compareTo( matched ) > 0 ) { matched = version; } } } return matched; } public boolean containsVersion( ArtifactVersion version ) { for ( Restriction restriction : restrictions ) { if ( restriction.containsVersion( version ) ) { return true; } } return false; } public boolean hasRestrictions() { return !restrictions.isEmpty() && recommendedVersion == null; } public boolean equals( Object obj ) { if ( this == obj ) { return true; } if ( !( obj instanceof VersionRange ) ) { return false; } VersionRange other = (VersionRange) obj; boolean equals = recommendedVersion == other.recommendedVersion || ( ( recommendedVersion != null ) && recommendedVersion.equals( other.recommendedVersion ) ); equals &= restrictions == other.restrictions || ( ( restrictions != null ) && restrictions.equals( other.restrictions ) ); return equals; } public int hashCode() { int hash = 7; hash = 31 * hash + ( recommendedVersion == null ? 0 : recommendedVersion.hashCode() ); hash = 31 * hash + ( restrictions == null ? 0 : restrictions.hashCode() ); return hash; } } maven-maven-3.5.2/maven-artifact/src/main/java/org/apache/maven/repository/000077500000000000000000000000001317160430700266275ustar00rootroot00000000000000maven-maven-3.5.2/maven-artifact/src/main/java/org/apache/maven/repository/Proxy.java000066400000000000000000000100261317160430700306120ustar00rootroot00000000000000package org.apache.maven.repository; /* * 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. */ public class Proxy { public static final String PROXY_SOCKS5 = "SOCKS_5"; public static final String PROXY_SOCKS4 = "SOCKS4"; public static final String PROXY_HTTP = "HTTP"; /** * Proxy server host */ private String host; /** * Username used to access the proxy server */ private String userName; /** * Password associated with the proxy server */ private String password; /** * Proxy server port */ private int port; /** * Type of the proxy */ private String protocol; /** * The non-proxy hosts. Follows Java system property format: *.foo.com|localhost. */ private String nonProxyHosts; /** * For NTLM proxies, specifies the NTLM host. */ private String ntlmHost; /** * For NTLM proxies, specifies the NTLM domain. */ private String ntlmDomain; /** * Return proxy server host name. * * @return proxy server host name */ public String getHost() { return host; } /** * Set proxy host name. * * @param host proxy server host name */ public void setHost( String host ) { this.host = host; } /** * Get user's password used to login to proxy server. * * @return user's password at proxy host */ public String getPassword() { return password; } /** * Set the user's password for the proxy server. * * @param password password to use to login to a proxy server */ public void setPassword( String password ) { this.password = password; } /** * Get the proxy port. * * @return proxy server port */ public int getPort() { return port; } /** * Set the proxy port. * * @param port proxy server port */ public void setPort( int port ) { this.port = port; } /** * Get the proxy username. * * @return username for the proxy server */ public String getUserName() { return userName; } /** * Set the proxy username. * * @param userName username for the proxy server */ public void setUserName( String userName ) { this.userName = userName; } /** * Get the protocol of the proxy server. * * @return the protocol of the proxy server */ public String getProtocol() { return protocol; } /** * @param protocol the protocol of the proxy server like SOCKSv4 */ public void setProtocol( String protocol ) { this.protocol = protocol; } public String getNonProxyHosts() { return nonProxyHosts; } public void setNonProxyHosts( String nonProxyHosts ) { this.nonProxyHosts = nonProxyHosts; } public String getNtlmHost() { return ntlmHost; } public void setNtlmHost( String ntlmHost ) { this.ntlmHost = ntlmHost; } public void setNtlmDomain( String ntlmDomain ) { this.ntlmDomain = ntlmDomain; } public String getNtlmDomain() { return ntlmDomain; } } maven-maven-3.5.2/maven-artifact/src/main/java/org/apache/maven/repository/legacy/000077500000000000000000000000001317160430700300735ustar00rootroot00000000000000maven-maven-3.5.2/maven-artifact/src/main/java/org/apache/maven/repository/legacy/metadata/000077500000000000000000000000001317160430700316535ustar00rootroot00000000000000ArtifactMetadata.java000066400000000000000000000053211317160430700356360ustar00rootroot00000000000000maven-maven-3.5.2/maven-artifact/src/main/java/org/apache/maven/repository/legacy/metadatapackage org.apache.maven.repository.legacy.metadata; /* * 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 org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.repository.metadata.RepositoryMetadataStoreException; /** * Contains metadata about an artifact, and methods to retrieve/store it from an artifact repository. * * @author Brett Porter * TODO merge with artifactmetadatasource * TODO retrieval exception not appropriate for store */ public interface ArtifactMetadata { /** Whether this metadata should be stored alongside the artifact. */ boolean storedInArtifactVersionDirectory(); /** Whether this metadata should be stored alongside the group. */ boolean storedInGroupDirectory(); String getGroupId(); String getArtifactId(); String getBaseVersion(); Object getKey(); /** * Get the filename of this metadata on the local repository. * * @param repository the remote repository it came from * @return the filename */ String getLocalFilename( ArtifactRepository repository ); /** * Get the filename of this metadata on the remote repository. * * @return the filename */ String getRemoteFilename(); /** * Merge a new metadata set into this piece of metadata. * * @param metadata the new metadata * TODO this should only be needed on the repository metadata */ void merge( ArtifactMetadata metadata ); /** * Store the metadata in the local repository. * * @param localRepository the local repository * @param remoteRepository the remote repository it came from * TODO this should only be needed on the repository metadata */ void storeInLocalRepository( ArtifactRepository localRepository, ArtifactRepository remoteRepository ) throws RepositoryMetadataStoreException; String extendedToString(); } maven-maven-3.5.2/maven-artifact/src/site/000077500000000000000000000000001317160430700203715ustar00rootroot00000000000000maven-maven-3.5.2/maven-artifact/src/site/apt/000077500000000000000000000000001317160430700211555ustar00rootroot00000000000000maven-maven-3.5.2/maven-artifact/src/site/apt/index.apt000066400000000000000000000033661317160430700230020ustar00rootroot00000000000000~~ 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 ----- 2014-11-30 ----- Maven Artifact Maven Artifact classes, providing <<>> interface ({{{./apidocs/org/apache/maven/artifact/Artifact.html}javadoc}}), with its <<>> implementation ({{{./xref/org/apache/maven/artifact/DefaultArtifact.html}source}}). The jar file is executable and provides a little tool to display how Maven parses and compares versions: +----+ $ java -jar maven-artifact-*.jar 3.2.4-alpha-1 3.2.4-SNAPSHOT 3.2.4.0 Display parameters as parsed by Maven (in canonical form) and comparison result: 1. 3.2.4-alpha-1 == 3.2.4.alpha.1 3.2.4-alpha-1 < 3.2.4-SNAPSHOT 2. 3.2.4-SNAPSHOT == 3.2.4.snapshot 3.2.4-SNAPSHOT < 3.2.4.0 3. 3.2.4.0 == 3.2.4 +----+ * Useful entry points * artifact version comparison {{{./apidocs/org/apache/maven/artifact/versioning/ComparableVersion.html}javadoc}}, * {{{./apidocs/org/apache/maven/artifact/versioning/VersionRange.html}version range}}. maven-maven-3.5.2/maven-artifact/src/site/site.xml000066400000000000000000000025231317160430700220610ustar00rootroot00000000000000 maven-maven-3.5.2/maven-artifact/src/test/000077500000000000000000000000001317160430700204045ustar00rootroot00000000000000maven-maven-3.5.2/maven-artifact/src/test/java/000077500000000000000000000000001317160430700213255ustar00rootroot00000000000000maven-maven-3.5.2/maven-artifact/src/test/java/org/000077500000000000000000000000001317160430700221145ustar00rootroot00000000000000maven-maven-3.5.2/maven-artifact/src/test/java/org/apache/000077500000000000000000000000001317160430700233355ustar00rootroot00000000000000maven-maven-3.5.2/maven-artifact/src/test/java/org/apache/maven/000077500000000000000000000000001317160430700244435ustar00rootroot00000000000000maven-maven-3.5.2/maven-artifact/src/test/java/org/apache/maven/artifact/000077500000000000000000000000001317160430700262405ustar00rootroot00000000000000maven-maven-3.5.2/maven-artifact/src/test/java/org/apache/maven/artifact/versioning/000077500000000000000000000000001317160430700304235ustar00rootroot00000000000000ComparableVersionTest.java000066400000000000000000000211121317160430700354570ustar00rootroot00000000000000maven-maven-3.5.2/maven-artifact/src/test/java/org/apache/maven/artifact/versioningpackage org.apache.maven.artifact.versioning; /* * 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.util.Locale; import junit.framework.TestCase; /** * Test ComparableVersion. * * @author Hervé Boutemy */ @SuppressWarnings( "unchecked" ) public class ComparableVersionTest extends TestCase { private Comparable newComparable( String version ) { ComparableVersion ret = new ComparableVersion( version ); String canonical = ret.getCanonical(); String parsedCanonical = new ComparableVersion( canonical ).getCanonical(); System.out.println( "canonical( " + version + " ) = " + canonical ); assertEquals( "canonical( " + version + " ) = " + canonical + " -> canonical: " + parsedCanonical, canonical, parsedCanonical ); return ret; } private static final String[] VERSIONS_QUALIFIER = { "1-alpha2snapshot", "1-alpha2", "1-alpha-123", "1-beta-2", "1-beta123", "1-m2", "1-m11", "1-rc", "1-cr2", "1-rc123", "1-SNAPSHOT", "1", "1-sp", "1-sp2", "1-sp123", "1-abc", "1-def", "1-pom-1", "1-1-snapshot", "1-1", "1-2", "1-123" }; private static final String[] VERSIONS_NUMBER = { "2.0", "2-1", "2.0.a", "2.0.0.a", "2.0.2", "2.0.123", "2.1.0", "2.1-a", "2.1b", "2.1-c", "2.1-1", "2.1.0.1", "2.2", "2.123", "11.a2", "11.a11", "11.b2", "11.b11", "11.m2", "11.m11", "11", "11.a", "11b", "11c", "11m" }; private void checkVersionsOrder( String[] versions ) { Comparable[] c = new Comparable[versions.length]; for ( int i = 0; i < versions.length; i++ ) { c[i] = newComparable( versions[i] ); } for ( int i = 1; i < versions.length; i++ ) { Comparable low = c[i - 1]; for ( int j = i; j < versions.length; j++ ) { Comparable high = c[j]; assertTrue( "expected " + low + " < " + high, low.compareTo( high ) < 0 ); assertTrue( "expected " + high + " > " + low, high.compareTo( low ) > 0 ); } } } private void checkVersionsEqual( String v1, String v2 ) { Comparable c1 = newComparable( v1 ); Comparable c2 = newComparable( v2 ); assertTrue( "expected " + v1 + " == " + v2, c1.compareTo( c2 ) == 0 ); assertTrue( "expected " + v2 + " == " + v1, c2.compareTo( c1 ) == 0 ); assertTrue( "expected same hashcode for " + v1 + " and " + v2, c1.hashCode() == c2.hashCode() ); assertTrue( "expected " + v1 + ".equals( " + v2 + " )", c1.equals( c2 ) ); assertTrue( "expected " + v2 + ".equals( " + v1 + " )", c2.equals( c1 ) ); } private void checkVersionsOrder( String v1, String v2 ) { Comparable c1 = newComparable( v1 ); Comparable c2 = newComparable( v2 ); assertTrue( "expected " + v1 + " < " + v2, c1.compareTo( c2 ) < 0 ); assertTrue( "expected " + v2 + " > " + v1, c2.compareTo( c1 ) > 0 ); } public void testVersionsQualifier() { checkVersionsOrder( VERSIONS_QUALIFIER ); } public void testVersionsNumber() { checkVersionsOrder( VERSIONS_NUMBER ); } public void testVersionsEqual() { newComparable( "1.0-alpha" ); checkVersionsEqual( "1", "1" ); checkVersionsEqual( "1", "1.0" ); checkVersionsEqual( "1", "1.0.0" ); checkVersionsEqual( "1.0", "1.0.0" ); checkVersionsEqual( "1", "1-0" ); checkVersionsEqual( "1", "1.0-0" ); checkVersionsEqual( "1.0", "1.0-0" ); // no separator between number and character checkVersionsEqual( "1a", "1-a" ); checkVersionsEqual( "1a", "1.0-a" ); checkVersionsEqual( "1a", "1.0.0-a" ); checkVersionsEqual( "1.0a", "1-a" ); checkVersionsEqual( "1.0.0a", "1-a" ); checkVersionsEqual( "1x", "1-x" ); checkVersionsEqual( "1x", "1.0-x" ); checkVersionsEqual( "1x", "1.0.0-x" ); checkVersionsEqual( "1.0x", "1-x" ); checkVersionsEqual( "1.0.0x", "1-x" ); // aliases checkVersionsEqual( "1ga", "1" ); checkVersionsEqual( "1final", "1" ); checkVersionsEqual( "1cr", "1rc" ); // special "aliases" a, b and m for alpha, beta and milestone checkVersionsEqual( "1a1", "1-alpha-1" ); checkVersionsEqual( "1b2", "1-beta-2" ); checkVersionsEqual( "1m3", "1-milestone-3" ); // case insensitive checkVersionsEqual( "1X", "1x" ); checkVersionsEqual( "1A", "1a" ); checkVersionsEqual( "1B", "1b" ); checkVersionsEqual( "1M", "1m" ); checkVersionsEqual( "1Ga", "1" ); checkVersionsEqual( "1GA", "1" ); checkVersionsEqual( "1Final", "1" ); checkVersionsEqual( "1FinaL", "1" ); checkVersionsEqual( "1FINAL", "1" ); checkVersionsEqual( "1Cr", "1Rc" ); checkVersionsEqual( "1cR", "1rC" ); checkVersionsEqual( "1m3", "1Milestone3" ); checkVersionsEqual( "1m3", "1MileStone3" ); checkVersionsEqual( "1m3", "1MILESTONE3" ); } public void testVersionComparing() { checkVersionsOrder( "1", "2" ); checkVersionsOrder( "1.5", "2" ); checkVersionsOrder( "1", "2.5" ); checkVersionsOrder( "1.0", "1.1" ); checkVersionsOrder( "1.1", "1.2" ); checkVersionsOrder( "1.0.0", "1.1" ); checkVersionsOrder( "1.0.1", "1.1" ); checkVersionsOrder( "1.1", "1.2.0" ); checkVersionsOrder( "1.0-alpha-1", "1.0" ); checkVersionsOrder( "1.0-alpha-1", "1.0-alpha-2" ); checkVersionsOrder( "1.0-alpha-1", "1.0-beta-1" ); checkVersionsOrder( "1.0-beta-1", "1.0-SNAPSHOT" ); checkVersionsOrder( "1.0-SNAPSHOT", "1.0" ); checkVersionsOrder( "1.0-alpha-1-SNAPSHOT", "1.0-alpha-1" ); checkVersionsOrder( "1.0", "1.0-1" ); checkVersionsOrder( "1.0-1", "1.0-2" ); checkVersionsOrder( "1.0.0", "1.0-1" ); checkVersionsOrder( "2.0-1", "2.0.1" ); checkVersionsOrder( "2.0.1-klm", "2.0.1-lmn" ); checkVersionsOrder( "2.0.1", "2.0.1-xyz" ); checkVersionsOrder( "2.0.1", "2.0.1-123" ); checkVersionsOrder( "2.0.1-xyz", "2.0.1-123" ); } /** * Test MNG-5568 edge case * which was showing transitive inconsistency: since A > B and B > C then we should have A > C * otherwise sorting a list of ComparableVersions() will in some cases throw runtime exception; * see Netbeans issues 240845 and * 226100 */ public void testMng5568() { String a = "6.1.0"; String b = "6.1.0rc3"; String c = "6.1H.5-beta"; // this is the unusual version string, with 'H' in the middle checkVersionsOrder( b, a ); // classical checkVersionsOrder( b, c ); // now b < c, but before MNG-5568, we had b > c checkVersionsOrder( a, c ); } public void testLocaleIndependent() { Locale orig = Locale.getDefault(); Locale[] locales = { Locale.ENGLISH, new Locale( "tr" ), Locale.getDefault() }; try { for ( Locale locale : locales ) { Locale.setDefault( locale ); checkVersionsEqual( "1-abcdefghijklmnopqrstuvwxyz", "1-ABCDEFGHIJKLMNOPQRSTUVWXYZ" ); } } finally { Locale.setDefault( orig ); } } public void testReuse() { ComparableVersion c1 = new ComparableVersion( "1" ); c1.parseVersion( "2" ); Comparable c2 = newComparable( "2" ); assertEquals( "reused instance should be equivalent to new instance", c1, c2 ); } } DefaultArtifactVersionTest.java000066400000000000000000000240621317160430700364630ustar00rootroot00000000000000maven-maven-3.5.2/maven-artifact/src/test/java/org/apache/maven/artifact/versioningpackage org.apache.maven.artifact.versioning; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import junit.framework.TestCase; /** * Test DefaultArtifactVersion. * * @author Brett Porter */ public class DefaultArtifactVersionTest extends TestCase { private ArtifactVersion newArtifactVersion( String version ) { return new DefaultArtifactVersion( version ); } private void checkVersionParsing( String version, int major, int minor, int incremental, int buildnumber, String qualifier ) { ArtifactVersion artifactVersion = newArtifactVersion( version ); String parsed = "'" + version + "' parsed as ('" + artifactVersion.getMajorVersion() + "', '" + artifactVersion.getMinorVersion() + "', '" + artifactVersion.getIncrementalVersion() + "', '" + artifactVersion.getBuildNumber() + "', '" + artifactVersion.getQualifier() + "'), "; assertEquals( parsed + "check major version", major, artifactVersion.getMajorVersion() ); assertEquals( parsed + "check minor version", minor, artifactVersion.getMinorVersion() ); assertEquals( parsed + "check incremental version", incremental, artifactVersion.getIncrementalVersion() ); assertEquals( parsed + "check build number", buildnumber, artifactVersion.getBuildNumber() ); assertEquals( parsed + "check qualifier", qualifier, artifactVersion.getQualifier() ); assertEquals( "check " + version + " string value", version, artifactVersion.toString() ); } public void testVersionParsing() { checkVersionParsing( "1", 1, 0, 0, 0, null ); checkVersionParsing( "1.2", 1, 2, 0, 0, null ); checkVersionParsing( "1.2.3", 1, 2, 3, 0, null ); checkVersionParsing( "1.2.3-1", 1, 2, 3, 1, null ); checkVersionParsing( "1.2.3-alpha-1", 1, 2, 3, 0, "alpha-1" ); checkVersionParsing( "1.2-alpha-1", 1, 2, 0, 0, "alpha-1" ); checkVersionParsing( "1.2-alpha-1-20050205.060708-1", 1, 2, 0, 0, "alpha-1-20050205.060708-1" ); checkVersionParsing( "RELEASE", 0, 0, 0, 0, "RELEASE" ); checkVersionParsing( "2.0-1", 2, 0, 0, 1, null ); // 0 at the beginning of a number has a special handling checkVersionParsing( "02", 0, 0, 0, 0, "02" ); checkVersionParsing( "0.09", 0, 0, 0, 0, "0.09" ); checkVersionParsing( "0.2.09", 0, 0, 0, 0, "0.2.09" ); checkVersionParsing( "2.0-01", 2, 0, 0, 0, "01" ); // version schemes not really supported: fully transformed as qualifier checkVersionParsing( "1.0.1b", 0, 0, 0, 0, "1.0.1b" ); checkVersionParsing( "1.0M2", 0, 0, 0, 0, "1.0M2" ); checkVersionParsing( "1.0RC2", 0, 0, 0, 0, "1.0RC2" ); checkVersionParsing( "1.1.2.beta1", 1, 1, 2, 0, "beta1" ); checkVersionParsing( "1.7.3.beta1", 1, 7, 3, 0, "beta1" ); checkVersionParsing( "1.7.3.0", 0, 0, 0, 0, "1.7.3.0" ); checkVersionParsing( "1.7.3.0-1", 0, 0, 0, 0, "1.7.3.0-1" ); checkVersionParsing( "PATCH-1193602", 0, 0, 0, 0, "PATCH-1193602" ); checkVersionParsing( "5.0.0alpha-2006020117", 0, 0, 0, 0, "5.0.0alpha-2006020117" ); checkVersionParsing( "1.0.0.-SNAPSHOT", 0, 0, 0, 0, "1.0.0.-SNAPSHOT" ); checkVersionParsing( "1..0-SNAPSHOT", 0, 0, 0, 0, "1..0-SNAPSHOT" ); checkVersionParsing( "1.0.-SNAPSHOT", 0, 0, 0, 0, "1.0.-SNAPSHOT" ); checkVersionParsing( ".1.0-SNAPSHOT", 0, 0, 0, 0, ".1.0-SNAPSHOT" ); checkVersionParsing( "1.2.3.200705301630", 0, 0, 0, 0, "1.2.3.200705301630" ); checkVersionParsing( "1.2.3-200705301630", 1, 2, 3, 0, "200705301630" ); } public void testVersionComparing() { assertVersionEqual( "1", "1" ); assertVersionOlder( "1", "2" ); assertVersionOlder( "1.5", "2" ); assertVersionOlder( "1", "2.5" ); assertVersionEqual( "1", "1.0" ); assertVersionEqual( "1", "1.0.0" ); assertVersionOlder( "1.0", "1.1" ); assertVersionOlder( "1.1", "1.2" ); assertVersionOlder( "1.0.0", "1.1" ); assertVersionOlder( "1.1", "1.2.0" ); assertVersionOlder( "1.1.2.alpha1", "1.1.2" ); assertVersionOlder( "1.1.2.alpha1", "1.1.2.beta1" ); assertVersionOlder( "1.1.2.beta1", "1.2" ); assertVersionOlder( "1.0-alpha-1", "1.0" ); assertVersionOlder( "1.0-alpha-1", "1.0-alpha-2" ); assertVersionOlder( "1.0-alpha-2", "1.0-alpha-15" ); assertVersionOlder( "1.0-alpha-1", "1.0-beta-1" ); assertVersionOlder( "1.0-beta-1", "1.0-SNAPSHOT" ); assertVersionOlder( "1.0-SNAPSHOT", "1.0" ); assertVersionOlder( "1.0-alpha-1-SNAPSHOT", "1.0-alpha-1" ); assertVersionOlder( "1.0", "1.0-1" ); assertVersionOlder( "1.0-1", "1.0-2" ); assertVersionEqual( "2.0-0", "2.0" ); assertVersionOlder( "2.0", "2.0-1" ); assertVersionOlder( "2.0.0", "2.0-1" ); assertVersionOlder( "2.0-1", "2.0.1" ); assertVersionOlder( "2.0.1-klm", "2.0.1-lmn" ); assertVersionOlder( "2.0.1", "2.0.1-xyz" ); assertVersionOlder( "2.0.1-xyz-1", "2.0.1-1-xyz" ); assertVersionOlder( "2.0.1", "2.0.1-123" ); assertVersionOlder( "2.0.1-xyz", "2.0.1-123" ); assertVersionOlder( "1.2.3-10000000000", "1.2.3-10000000001" ); assertVersionOlder( "1.2.3-1", "1.2.3-10000000001" ); assertVersionOlder( "2.3.0-v200706262000", "2.3.0-v200706262130" ); // org.eclipse:emf:2.3.0-v200706262000 // org.eclipse.wst.common_core.feature_2.0.0.v200706041905-7C78EK9E_EkMNfNOd2d8qq assertVersionOlder( "2.0.0.v200706041905-7C78EK9E_EkMNfNOd2d8qq", "2.0.0.v200706041906-7C78EK9E_EkMNfNOd2d8qq" ); } public void testVersionSnapshotComparing() { assertVersionEqual( "1-SNAPSHOT", "1-SNAPSHOT" ); assertVersionOlder( "1-SNAPSHOT", "2-SNAPSHOT" ); assertVersionOlder( "1.5-SNAPSHOT", "2-SNAPSHOT" ); assertVersionOlder( "1-SNAPSHOT", "2.5-SNAPSHOT" ); assertVersionEqual( "1-SNAPSHOT", "1.0-SNAPSHOT" ); assertVersionEqual( "1-SNAPSHOT", "1.0.0-SNAPSHOT" ); assertVersionOlder( "1.0-SNAPSHOT", "1.1-SNAPSHOT" ); assertVersionOlder( "1.1-SNAPSHOT", "1.2-SNAPSHOT" ); assertVersionOlder( "1.0.0-SNAPSHOT", "1.1-SNAPSHOT" ); assertVersionOlder( "1.1-SNAPSHOT", "1.2.0-SNAPSHOT" ); // assertVersionOlder( "1.0-alpha-1-SNAPSHOT", "1.0-SNAPSHOT" ); assertVersionOlder( "1.0-alpha-1-SNAPSHOT", "1.0-alpha-2-SNAPSHOT" ); assertVersionOlder( "1.0-alpha-1-SNAPSHOT", "1.0-beta-1-SNAPSHOT" ); assertVersionOlder( "1.0-beta-1-SNAPSHOT", "1.0-SNAPSHOT-SNAPSHOT" ); assertVersionOlder( "1.0-SNAPSHOT-SNAPSHOT", "1.0-SNAPSHOT" ); assertVersionOlder( "1.0-alpha-1-SNAPSHOT-SNAPSHOT", "1.0-alpha-1-SNAPSHOT" ); assertVersionOlder( "1.0-SNAPSHOT", "1.0-1-SNAPSHOT" ); assertVersionOlder( "1.0-1-SNAPSHOT", "1.0-2-SNAPSHOT" ); // assertVersionEqual( "2.0-0-SNAPSHOT", "2.0-SNAPSHOT" ); assertVersionOlder( "2.0-SNAPSHOT", "2.0-1-SNAPSHOT" ); assertVersionOlder( "2.0.0-SNAPSHOT", "2.0-1-SNAPSHOT" ); assertVersionOlder( "2.0-1-SNAPSHOT", "2.0.1-SNAPSHOT" ); assertVersionOlder( "2.0.1-klm-SNAPSHOT", "2.0.1-lmn-SNAPSHOT" ); // assertVersionOlder( "2.0.1-xyz-SNAPSHOT", "2.0.1-SNAPSHOT" ); assertVersionOlder( "2.0.1-SNAPSHOT", "2.0.1-123-SNAPSHOT" ); assertVersionOlder( "2.0.1-xyz-SNAPSHOT", "2.0.1-123-SNAPSHOT" ); } public void testSnapshotVsReleases() { assertVersionOlder( "1.0-RC1", "1.0-SNAPSHOT" ); assertVersionOlder( "1.0-rc1", "1.0-SNAPSHOT" ); assertVersionOlder( "1.0-rc-1", "1.0-SNAPSHOT" ); } public void testHashCode() { ArtifactVersion v1 = newArtifactVersion( "1" ); ArtifactVersion v2 = newArtifactVersion( "1.0" ); assertEquals( true, v1.equals( v2 ) ); assertEquals( v1.hashCode(), v2.hashCode() ); } public void testEqualsNullSafe() { assertFalse( newArtifactVersion( "1" ).equals( null ) ); } public void testEqualsTypeSafe() { assertFalse( newArtifactVersion( "1" ).equals( "non-an-artifact-version-instance" ) ); } public void testNonNumericVersionRepresentationReturnsANumberFormatException() { try { new DefaultArtifactVersion( "..." ); } catch ( Exception e ) { assertTrue( "We expect a NumberFormatException to be thrown.", e instanceof NumberFormatException ); } } private void assertVersionOlder( String left, String right ) { assertTrue( left + " should be older than " + right, newArtifactVersion( left ).compareTo( newArtifactVersion( right ) ) < 0 ); assertTrue( right + " should be newer than " + left, newArtifactVersion( right ).compareTo( newArtifactVersion( left ) ) > 0 ); } private void assertVersionEqual( String left, String right ) { assertTrue( left + " should be equal to " + right, newArtifactVersion( left ).compareTo( newArtifactVersion( right ) ) == 0 ); assertTrue( right + " should be equal to " + left, newArtifactVersion( right ).compareTo( newArtifactVersion( left ) ) == 0 ); } } VersionRangeTest.java000066400000000000000000001276031317160430700344620ustar00rootroot00000000000000maven-maven-3.5.2/maven-artifact/src/test/java/org/apache/maven/artifact/versioningpackage org.apache.maven.artifact.versioning; /* * 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.util.List; import junit.framework.TestCase; import org.apache.maven.artifact.Artifact; /** * Tests version range construction. * * @author Brett Porter */ public class VersionRangeTest extends TestCase { private static final String CHECK_NUM_RESTRICTIONS = "check number of restrictions"; private static final String CHECK_UPPER_BOUND = "check upper bound"; private static final String CHECK_UPPER_BOUND_INCLUSIVE = "check upper bound is inclusive"; private static final String CHECK_LOWER_BOUND = "check lower bound"; private static final String CHECK_LOWER_BOUND_INCLUSIVE = "check lower bound is inclusive"; private static final String CHECK_VERSION_RECOMMENDATION = "check version recommended"; private static final String CHECK_SELECTED_VERSION_KNOWN = "check selected version known"; private static final String CHECK_SELECTED_VERSION = "check selected version"; public void testRange() throws InvalidVersionSpecificationException, OverConstrainedVersionException { Artifact artifact = null; VersionRange range = VersionRange.createFromVersionSpec( "(,1.0]" ); List restrictions = range.getRestrictions(); assertEquals( CHECK_NUM_RESTRICTIONS, 1, restrictions.size() ); Restriction restriction = restrictions.get( 0 ); assertNull( CHECK_LOWER_BOUND, restriction.getLowerBound() ); assertFalse( CHECK_LOWER_BOUND_INCLUSIVE, restriction.isLowerBoundInclusive() ); assertEquals( CHECK_UPPER_BOUND, "1.0", restriction.getUpperBound().toString() ); assertTrue( CHECK_UPPER_BOUND_INCLUSIVE, restriction.isUpperBoundInclusive() ); assertNull( CHECK_VERSION_RECOMMENDATION, range.getRecommendedVersion() ); assertFalse( CHECK_SELECTED_VERSION_KNOWN, range.isSelectedVersionKnown( artifact ) ); assertNull( CHECK_SELECTED_VERSION, range.getSelectedVersion( artifact ) ); range = VersionRange.createFromVersionSpec( "1.0" ); assertEquals( CHECK_VERSION_RECOMMENDATION, "1.0", range.getRecommendedVersion().toString() ); restrictions = range.getRestrictions(); assertEquals( CHECK_NUM_RESTRICTIONS, 1, restrictions.size() ); restriction = restrictions.get( 0 ); assertNull( CHECK_LOWER_BOUND, restriction.getLowerBound() ); assertFalse( CHECK_LOWER_BOUND_INCLUSIVE, restriction.isLowerBoundInclusive() ); assertNull( CHECK_UPPER_BOUND, restriction.getUpperBound() ); assertFalse( CHECK_UPPER_BOUND_INCLUSIVE, restriction.isUpperBoundInclusive() ); assertTrue( CHECK_SELECTED_VERSION_KNOWN, range.isSelectedVersionKnown( artifact ) ); assertEquals( CHECK_SELECTED_VERSION, "1.0", range.getSelectedVersion( artifact ).toString() ); range = VersionRange.createFromVersionSpec( "[1.0]" ); restrictions = range.getRestrictions(); assertEquals( CHECK_NUM_RESTRICTIONS, 1, restrictions.size() ); restriction = restrictions.get( 0 ); assertEquals( CHECK_LOWER_BOUND, "1.0", restriction.getLowerBound().toString() ); assertTrue( CHECK_LOWER_BOUND_INCLUSIVE, restriction.isLowerBoundInclusive() ); assertEquals( CHECK_UPPER_BOUND, "1.0", restriction.getUpperBound().toString() ); assertTrue( CHECK_UPPER_BOUND_INCLUSIVE, restriction.isUpperBoundInclusive() ); assertNull( CHECK_VERSION_RECOMMENDATION, range.getRecommendedVersion() ); assertFalse( CHECK_SELECTED_VERSION_KNOWN, range.isSelectedVersionKnown( artifact ) ); assertNull( CHECK_SELECTED_VERSION, range.getSelectedVersion( artifact ) ); range = VersionRange.createFromVersionSpec( "[1.2,1.3]" ); restrictions = range.getRestrictions(); assertEquals( CHECK_NUM_RESTRICTIONS, 1, restrictions.size() ); restriction = restrictions.get( 0 ); assertEquals( CHECK_LOWER_BOUND, "1.2", restriction.getLowerBound().toString() ); assertTrue( CHECK_LOWER_BOUND_INCLUSIVE, restriction.isLowerBoundInclusive() ); assertEquals( CHECK_UPPER_BOUND, "1.3", restriction.getUpperBound().toString() ); assertTrue( CHECK_UPPER_BOUND_INCLUSIVE, restriction.isUpperBoundInclusive() ); assertNull( CHECK_VERSION_RECOMMENDATION, range.getRecommendedVersion() ); assertFalse( CHECK_SELECTED_VERSION_KNOWN, range.isSelectedVersionKnown( artifact ) ); assertNull( CHECK_SELECTED_VERSION, range.getSelectedVersion( artifact ) ); range = VersionRange.createFromVersionSpec( "[1.0,2.0)" ); restrictions = range.getRestrictions(); assertEquals( CHECK_NUM_RESTRICTIONS, 1, restrictions.size() ); restriction = restrictions.get( 0 ); assertEquals( CHECK_LOWER_BOUND, "1.0", restriction.getLowerBound().toString() ); assertTrue( CHECK_LOWER_BOUND_INCLUSIVE, restriction.isLowerBoundInclusive() ); assertEquals( CHECK_UPPER_BOUND, "2.0", restriction.getUpperBound().toString() ); assertFalse( CHECK_UPPER_BOUND_INCLUSIVE, restriction.isUpperBoundInclusive() ); assertNull( CHECK_VERSION_RECOMMENDATION, range.getRecommendedVersion() ); assertFalse( CHECK_SELECTED_VERSION_KNOWN, range.isSelectedVersionKnown( artifact ) ); assertNull( CHECK_SELECTED_VERSION, range.getSelectedVersion( artifact ) ); range = VersionRange.createFromVersionSpec( "[1.5,)" ); restrictions = range.getRestrictions(); assertEquals( CHECK_NUM_RESTRICTIONS, 1, restrictions.size() ); restriction = restrictions.get( 0 ); assertEquals( CHECK_LOWER_BOUND, "1.5", restriction.getLowerBound().toString() ); assertTrue( CHECK_LOWER_BOUND_INCLUSIVE, restriction.isLowerBoundInclusive() ); assertNull( CHECK_UPPER_BOUND, restriction.getUpperBound() ); assertFalse( CHECK_UPPER_BOUND_INCLUSIVE, restriction.isUpperBoundInclusive() ); assertNull( CHECK_VERSION_RECOMMENDATION, range.getRecommendedVersion() ); assertFalse( CHECK_SELECTED_VERSION_KNOWN, range.isSelectedVersionKnown( artifact ) ); assertNull( CHECK_SELECTED_VERSION, range.getSelectedVersion( artifact ) ); range = VersionRange.createFromVersionSpec( "(,1.0],[1.2,)" ); restrictions = range.getRestrictions(); assertEquals( CHECK_NUM_RESTRICTIONS, 2, restrictions.size() ); restriction = restrictions.get( 0 ); assertNull( CHECK_LOWER_BOUND, restriction.getLowerBound() ); assertFalse( CHECK_LOWER_BOUND_INCLUSIVE, restriction.isLowerBoundInclusive() ); assertEquals( CHECK_UPPER_BOUND, "1.0", restriction.getUpperBound().toString() ); assertTrue( CHECK_UPPER_BOUND_INCLUSIVE, restriction.isUpperBoundInclusive() ); assertNull( CHECK_VERSION_RECOMMENDATION, range.getRecommendedVersion() ); restriction = restrictions.get( 1 ); assertEquals( CHECK_LOWER_BOUND, "1.2", restriction.getLowerBound().toString() ); assertTrue( CHECK_LOWER_BOUND_INCLUSIVE, restriction.isLowerBoundInclusive() ); assertNull( CHECK_UPPER_BOUND, restriction.getUpperBound() ); assertFalse( CHECK_UPPER_BOUND_INCLUSIVE, restriction.isUpperBoundInclusive() ); assertNull( CHECK_VERSION_RECOMMENDATION, range.getRecommendedVersion() ); assertFalse( CHECK_SELECTED_VERSION_KNOWN, range.isSelectedVersionKnown( artifact ) ); assertNull( CHECK_SELECTED_VERSION, range.getSelectedVersion( artifact ) ); range = VersionRange.createFromVersionSpec( "[1.0,)" ); assertFalse( range.containsVersion( new DefaultArtifactVersion( "1.0-SNAPSHOT" ) ) ); range = VersionRange.createFromVersionSpec( "[1.0,1.1-SNAPSHOT]" ); assertTrue( range.containsVersion( new DefaultArtifactVersion( "1.1-SNAPSHOT" ) ) ); range = VersionRange.createFromVersionSpec( "[5.0.9.0,5.0.10.0)" ); assertTrue( range.containsVersion( new DefaultArtifactVersion( "5.0.9.0" ) ) ); } public void testInvalidRanges() { checkInvalidRange( "(1.0)" ); checkInvalidRange( "[1.0)" ); checkInvalidRange( "(1.0]" ); checkInvalidRange( "(1.0,1.0]" ); checkInvalidRange( "[1.0,1.0)" ); checkInvalidRange( "(1.0,1.0)" ); checkInvalidRange( "[1.1,1.0]" ); checkInvalidRange( "[1.0,1.2),1.3" ); // overlap checkInvalidRange( "[1.0,1.2),(1.1,1.3]" ); // overlap checkInvalidRange( "[1.1,1.3),(1.0,1.2]" ); // ordering checkInvalidRange( "(1.1,1.2],[1.0,1.1)" ); } public void testIntersections() throws InvalidVersionSpecificationException { VersionRange range1 = VersionRange.createFromVersionSpec( "1.0" ); VersionRange range2 = VersionRange.createFromVersionSpec( "1.1" ); VersionRange mergedRange = range1.restrict( range2 ); // TODO current policy is to retain the original version - is this correct, do we need strategies or is that handled elsewhere? // assertEquals( CHECK_VERSION_RECOMMENDATION, "1.1", mergedRange.getRecommendedVersion().toString() ); assertEquals( CHECK_VERSION_RECOMMENDATION, "1.0", mergedRange.getRecommendedVersion().toString() ); List restrictions = mergedRange.getRestrictions(); assertEquals( CHECK_NUM_RESTRICTIONS, 1, restrictions.size() ); Restriction restriction = restrictions.get( 0 ); assertNull( CHECK_LOWER_BOUND, restriction.getLowerBound() ); assertFalse( CHECK_LOWER_BOUND_INCLUSIVE, restriction.isLowerBoundInclusive() ); assertNull( CHECK_UPPER_BOUND, restriction.getUpperBound() ); assertFalse( CHECK_UPPER_BOUND_INCLUSIVE, restriction.isUpperBoundInclusive() ); mergedRange = range2.restrict( range1 ); assertEquals( CHECK_VERSION_RECOMMENDATION, "1.1", mergedRange.getRecommendedVersion().toString() ); restrictions = mergedRange.getRestrictions(); assertEquals( CHECK_NUM_RESTRICTIONS, 1, restrictions.size() ); restriction = restrictions.get( 0 ); assertNull( CHECK_LOWER_BOUND, restriction.getLowerBound() ); assertFalse( CHECK_LOWER_BOUND_INCLUSIVE, restriction.isLowerBoundInclusive() ); assertNull( CHECK_UPPER_BOUND, restriction.getUpperBound() ); assertFalse( CHECK_UPPER_BOUND_INCLUSIVE, restriction.isUpperBoundInclusive() ); // TODO test reversed restrictions on all below range1 = VersionRange.createFromVersionSpec( "[1.0,)" ); range2 = VersionRange.createFromVersionSpec( "1.1" ); mergedRange = range1.restrict( range2 ); assertEquals( CHECK_VERSION_RECOMMENDATION, "1.1", mergedRange.getRecommendedVersion().toString() ); restrictions = mergedRange.getRestrictions(); assertEquals( CHECK_NUM_RESTRICTIONS, 1, restrictions.size() ); restriction = restrictions.get( 0 ); assertEquals( CHECK_LOWER_BOUND, "1.0", restriction.getLowerBound().toString() ); assertTrue( CHECK_LOWER_BOUND_INCLUSIVE, restriction.isLowerBoundInclusive() ); assertNull( CHECK_UPPER_BOUND, restriction.getUpperBound() ); assertFalse( CHECK_UPPER_BOUND_INCLUSIVE, restriction.isUpperBoundInclusive() ); range1 = VersionRange.createFromVersionSpec( "[1.1,)" ); range2 = VersionRange.createFromVersionSpec( "1.1" ); mergedRange = range1.restrict( range2 ); assertEquals( CHECK_VERSION_RECOMMENDATION, "1.1", mergedRange.getRecommendedVersion().toString() ); restrictions = mergedRange.getRestrictions(); assertEquals( CHECK_NUM_RESTRICTIONS, 1, restrictions.size() ); restriction = restrictions.get( 0 ); assertEquals( CHECK_LOWER_BOUND, "1.1", restriction.getLowerBound().toString() ); assertTrue( CHECK_LOWER_BOUND_INCLUSIVE, restriction.isLowerBoundInclusive() ); assertNull( CHECK_UPPER_BOUND, restriction.getUpperBound() ); assertFalse( CHECK_UPPER_BOUND_INCLUSIVE, restriction.isUpperBoundInclusive() ); range1 = VersionRange.createFromVersionSpec( "[1.1]" ); range2 = VersionRange.createFromVersionSpec( "1.1" ); mergedRange = range1.restrict( range2 ); assertEquals( CHECK_VERSION_RECOMMENDATION, "1.1", mergedRange.getRecommendedVersion().toString() ); restrictions = mergedRange.getRestrictions(); assertEquals( CHECK_NUM_RESTRICTIONS, 1, restrictions.size() ); restriction = restrictions.get( 0 ); assertEquals( CHECK_LOWER_BOUND, "1.1", restriction.getLowerBound().toString() ); assertTrue( CHECK_LOWER_BOUND_INCLUSIVE, restriction.isLowerBoundInclusive() ); assertEquals( CHECK_UPPER_BOUND, "1.1", restriction.getLowerBound().toString() ); assertTrue( CHECK_UPPER_BOUND_INCLUSIVE, restriction.isUpperBoundInclusive() ); range1 = VersionRange.createFromVersionSpec( "(1.1,)" ); range2 = VersionRange.createFromVersionSpec( "1.1" ); mergedRange = range1.restrict( range2 ); assertNull( CHECK_VERSION_RECOMMENDATION, mergedRange.getRecommendedVersion() ); restrictions = mergedRange.getRestrictions(); assertEquals( CHECK_NUM_RESTRICTIONS, 1, restrictions.size() ); restriction = restrictions.get( 0 ); assertEquals( CHECK_LOWER_BOUND, "1.1", restriction.getLowerBound().toString() ); assertFalse( CHECK_LOWER_BOUND_INCLUSIVE, restriction.isLowerBoundInclusive() ); assertNull( CHECK_UPPER_BOUND, restriction.getUpperBound() ); assertFalse( CHECK_UPPER_BOUND_INCLUSIVE, restriction.isUpperBoundInclusive() ); range1 = VersionRange.createFromVersionSpec( "[1.2,)" ); range2 = VersionRange.createFromVersionSpec( "1.1" ); mergedRange = range1.restrict( range2 ); assertNull( CHECK_VERSION_RECOMMENDATION, mergedRange.getRecommendedVersion() ); restrictions = mergedRange.getRestrictions(); assertEquals( CHECK_NUM_RESTRICTIONS, 1, restrictions.size() ); restriction = restrictions.get( 0 ); assertEquals( CHECK_LOWER_BOUND, "1.2", restriction.getLowerBound().toString() ); assertTrue( CHECK_LOWER_BOUND_INCLUSIVE, restriction.isLowerBoundInclusive() ); assertNull( CHECK_UPPER_BOUND, restriction.getUpperBound() ); assertFalse( CHECK_UPPER_BOUND_INCLUSIVE, restriction.isUpperBoundInclusive() ); range1 = VersionRange.createFromVersionSpec( "(,1.2]" ); range2 = VersionRange.createFromVersionSpec( "1.1" ); mergedRange = range1.restrict( range2 ); assertEquals( CHECK_VERSION_RECOMMENDATION, "1.1", mergedRange.getRecommendedVersion().toString() ); restrictions = mergedRange.getRestrictions(); assertEquals( CHECK_NUM_RESTRICTIONS, 1, restrictions.size() ); restriction = restrictions.get( 0 ); assertNull( CHECK_LOWER_BOUND, restriction.getLowerBound() ); assertFalse( CHECK_LOWER_BOUND_INCLUSIVE, restriction.isLowerBoundInclusive() ); assertEquals( CHECK_UPPER_BOUND, "1.2", restriction.getUpperBound().toString() ); assertTrue( CHECK_UPPER_BOUND_INCLUSIVE, restriction.isUpperBoundInclusive() ); range1 = VersionRange.createFromVersionSpec( "(,1.1]" ); range2 = VersionRange.createFromVersionSpec( "1.1" ); mergedRange = range1.restrict( range2 ); assertEquals( CHECK_VERSION_RECOMMENDATION, "1.1", mergedRange.getRecommendedVersion().toString() ); restrictions = mergedRange.getRestrictions(); assertEquals( CHECK_NUM_RESTRICTIONS, 1, restrictions.size() ); restriction = restrictions.get( 0 ); assertNull( CHECK_LOWER_BOUND, restriction.getLowerBound() ); assertFalse( CHECK_LOWER_BOUND_INCLUSIVE, restriction.isLowerBoundInclusive() ); assertEquals( CHECK_UPPER_BOUND, "1.1", restriction.getUpperBound().toString() ); assertTrue( CHECK_UPPER_BOUND_INCLUSIVE, restriction.isUpperBoundInclusive() ); range1 = VersionRange.createFromVersionSpec( "(,1.1)" ); range2 = VersionRange.createFromVersionSpec( "1.1" ); mergedRange = range1.restrict( range2 ); assertNull( CHECK_VERSION_RECOMMENDATION, mergedRange.getRecommendedVersion() ); restrictions = mergedRange.getRestrictions(); assertEquals( CHECK_NUM_RESTRICTIONS, 1, restrictions.size() ); restriction = restrictions.get( 0 ); assertNull( CHECK_LOWER_BOUND, restriction.getLowerBound() ); assertFalse( CHECK_LOWER_BOUND_INCLUSIVE, restriction.isLowerBoundInclusive() ); assertEquals( CHECK_UPPER_BOUND, "1.1", restriction.getUpperBound().toString() ); assertFalse( CHECK_UPPER_BOUND_INCLUSIVE, restriction.isUpperBoundInclusive() ); range1 = VersionRange.createFromVersionSpec( "(,1.0]" ); range2 = VersionRange.createFromVersionSpec( "1.1" ); mergedRange = range1.restrict( range2 ); assertNull( CHECK_VERSION_RECOMMENDATION, mergedRange.getRecommendedVersion() ); restrictions = mergedRange.getRestrictions(); assertEquals( CHECK_NUM_RESTRICTIONS, 1, restrictions.size() ); restriction = restrictions.get( 0 ); assertNull( CHECK_LOWER_BOUND, restriction.getLowerBound() ); assertFalse( CHECK_LOWER_BOUND_INCLUSIVE, restriction.isLowerBoundInclusive() ); assertEquals( CHECK_UPPER_BOUND, "1.0", restriction.getUpperBound().toString() ); assertTrue( CHECK_UPPER_BOUND_INCLUSIVE, restriction.isUpperBoundInclusive() ); range1 = VersionRange.createFromVersionSpec( "(,1.0], [1.1,)" ); range2 = VersionRange.createFromVersionSpec( "1.2" ); mergedRange = range1.restrict( range2 ); assertEquals( CHECK_VERSION_RECOMMENDATION, "1.2", mergedRange.getRecommendedVersion().toString() ); restrictions = mergedRange.getRestrictions(); assertEquals( CHECK_NUM_RESTRICTIONS, 2, restrictions.size() ); restriction = restrictions.get( 0 ); assertNull( CHECK_LOWER_BOUND, restriction.getLowerBound() ); assertFalse( CHECK_LOWER_BOUND_INCLUSIVE, restriction.isLowerBoundInclusive() ); assertEquals( CHECK_UPPER_BOUND, "1.0", restriction.getUpperBound().toString() ); assertTrue( CHECK_UPPER_BOUND_INCLUSIVE, restriction.isUpperBoundInclusive() ); restriction = restrictions.get( 1 ); assertEquals( CHECK_LOWER_BOUND, "1.1", restriction.getLowerBound().toString() ); assertTrue( CHECK_LOWER_BOUND_INCLUSIVE, restriction.isLowerBoundInclusive() ); assertNull( CHECK_UPPER_BOUND, restriction.getUpperBound() ); assertFalse( CHECK_UPPER_BOUND_INCLUSIVE, restriction.isUpperBoundInclusive() ); range1 = VersionRange.createFromVersionSpec( "(,1.0], [1.1,)" ); range2 = VersionRange.createFromVersionSpec( "1.0.5" ); mergedRange = range1.restrict( range2 ); assertNull( CHECK_VERSION_RECOMMENDATION, mergedRange.getRecommendedVersion() ); restrictions = mergedRange.getRestrictions(); assertEquals( CHECK_NUM_RESTRICTIONS, 2, restrictions.size() ); restriction = restrictions.get( 0 ); assertNull( CHECK_LOWER_BOUND, restriction.getLowerBound() ); assertFalse( CHECK_LOWER_BOUND_INCLUSIVE, restriction.isLowerBoundInclusive() ); assertEquals( CHECK_UPPER_BOUND, "1.0", restriction.getUpperBound().toString() ); assertTrue( CHECK_UPPER_BOUND_INCLUSIVE, restriction.isUpperBoundInclusive() ); restriction = restrictions.get( 1 ); assertEquals( CHECK_LOWER_BOUND, "1.1", restriction.getLowerBound().toString() ); assertTrue( CHECK_LOWER_BOUND_INCLUSIVE, restriction.isLowerBoundInclusive() ); assertNull( CHECK_UPPER_BOUND, restriction.getUpperBound() ); assertFalse( CHECK_UPPER_BOUND_INCLUSIVE, restriction.isUpperBoundInclusive() ); range1 = VersionRange.createFromVersionSpec( "(,1.1), (1.1,)" ); range2 = VersionRange.createFromVersionSpec( "1.1" ); mergedRange = range1.restrict( range2 ); assertNull( CHECK_VERSION_RECOMMENDATION, mergedRange.getRecommendedVersion() ); restrictions = mergedRange.getRestrictions(); assertEquals( CHECK_NUM_RESTRICTIONS, 2, restrictions.size() ); restriction = restrictions.get( 0 ); assertNull( CHECK_LOWER_BOUND, restriction.getLowerBound() ); assertFalse( CHECK_LOWER_BOUND_INCLUSIVE, restriction.isLowerBoundInclusive() ); assertEquals( CHECK_UPPER_BOUND, "1.1", restriction.getUpperBound().toString() ); assertFalse( CHECK_UPPER_BOUND_INCLUSIVE, restriction.isUpperBoundInclusive() ); restriction = restrictions.get( 1 ); assertEquals( CHECK_LOWER_BOUND, "1.1", restriction.getLowerBound().toString() ); assertFalse( CHECK_LOWER_BOUND_INCLUSIVE, restriction.isLowerBoundInclusive() ); assertNull( CHECK_UPPER_BOUND, restriction.getUpperBound() ); assertFalse( CHECK_UPPER_BOUND_INCLUSIVE, restriction.isUpperBoundInclusive() ); range1 = VersionRange.createFromVersionSpec( "[1.1,1.3]" ); range2 = VersionRange.createFromVersionSpec( "(1.1,)" ); mergedRange = range1.restrict( range2 ); assertNull( CHECK_VERSION_RECOMMENDATION, mergedRange.getRecommendedVersion() ); restrictions = mergedRange.getRestrictions(); assertEquals( CHECK_NUM_RESTRICTIONS, 1, restrictions.size() ); restriction = restrictions.get( 0 ); assertEquals( CHECK_LOWER_BOUND, "1.1", restriction.getLowerBound().toString() ); assertFalse( CHECK_LOWER_BOUND_INCLUSIVE, restriction.isLowerBoundInclusive() ); assertEquals( CHECK_UPPER_BOUND, "1.3", restriction.getUpperBound().toString() ); assertTrue( CHECK_UPPER_BOUND_INCLUSIVE, restriction.isUpperBoundInclusive() ); range1 = VersionRange.createFromVersionSpec( "(,1.3)" ); range2 = VersionRange.createFromVersionSpec( "[1.2,1.3]" ); mergedRange = range1.restrict( range2 ); assertNull( CHECK_VERSION_RECOMMENDATION, mergedRange.getRecommendedVersion() ); restrictions = mergedRange.getRestrictions(); assertEquals( CHECK_NUM_RESTRICTIONS, 1, restrictions.size() ); restriction = restrictions.get( 0 ); assertEquals( CHECK_LOWER_BOUND, "1.2", restriction.getLowerBound().toString() ); assertTrue( CHECK_LOWER_BOUND_INCLUSIVE, restriction.isLowerBoundInclusive() ); assertEquals( CHECK_UPPER_BOUND, "1.3", restriction.getUpperBound().toString() ); assertFalse( CHECK_UPPER_BOUND_INCLUSIVE, restriction.isUpperBoundInclusive() ); range1 = VersionRange.createFromVersionSpec( "[1.1,1.3]" ); range2 = VersionRange.createFromVersionSpec( "[1.2,)" ); mergedRange = range1.restrict( range2 ); assertNull( CHECK_VERSION_RECOMMENDATION, mergedRange.getRecommendedVersion() ); restrictions = mergedRange.getRestrictions(); assertEquals( CHECK_NUM_RESTRICTIONS, 1, restrictions.size() ); restriction = restrictions.get( 0 ); assertEquals( CHECK_LOWER_BOUND, "1.2", restriction.getLowerBound().toString() ); assertTrue( CHECK_LOWER_BOUND_INCLUSIVE, restriction.isLowerBoundInclusive() ); assertEquals( CHECK_UPPER_BOUND, "1.3", restriction.getUpperBound().toString() ); assertTrue( CHECK_UPPER_BOUND_INCLUSIVE, restriction.isUpperBoundInclusive() ); range1 = VersionRange.createFromVersionSpec( "(,1.3]" ); range2 = VersionRange.createFromVersionSpec( "[1.2,1.4]" ); mergedRange = range1.restrict( range2 ); assertNull( CHECK_VERSION_RECOMMENDATION, mergedRange.getRecommendedVersion() ); restrictions = mergedRange.getRestrictions(); assertEquals( CHECK_NUM_RESTRICTIONS, 1, restrictions.size() ); restriction = restrictions.get( 0 ); assertEquals( CHECK_LOWER_BOUND, "1.2", restriction.getLowerBound().toString() ); assertTrue( CHECK_LOWER_BOUND_INCLUSIVE, restriction.isLowerBoundInclusive() ); assertEquals( CHECK_UPPER_BOUND, "1.3", restriction.getUpperBound().toString() ); assertTrue( CHECK_UPPER_BOUND_INCLUSIVE, restriction.isUpperBoundInclusive() ); range1 = VersionRange.createFromVersionSpec( "(1.2,1.3]" ); range2 = VersionRange.createFromVersionSpec( "[1.1,1.4]" ); mergedRange = range1.restrict( range2 ); assertNull( CHECK_VERSION_RECOMMENDATION, mergedRange.getRecommendedVersion() ); restrictions = mergedRange.getRestrictions(); assertEquals( CHECK_NUM_RESTRICTIONS, 1, restrictions.size() ); restriction = restrictions.get( 0 ); assertEquals( CHECK_LOWER_BOUND, "1.2", restriction.getLowerBound().toString() ); assertFalse( CHECK_LOWER_BOUND_INCLUSIVE, restriction.isLowerBoundInclusive() ); assertEquals( CHECK_UPPER_BOUND, "1.3", restriction.getUpperBound().toString() ); assertTrue( CHECK_UPPER_BOUND_INCLUSIVE, restriction.isUpperBoundInclusive() ); range1 = VersionRange.createFromVersionSpec( "(1.2,1.3)" ); range2 = VersionRange.createFromVersionSpec( "[1.1,1.4]" ); mergedRange = range1.restrict( range2 ); assertNull( CHECK_VERSION_RECOMMENDATION, mergedRange.getRecommendedVersion() ); restrictions = mergedRange.getRestrictions(); assertEquals( CHECK_NUM_RESTRICTIONS, 1, restrictions.size() ); restriction = restrictions.get( 0 ); assertEquals( CHECK_LOWER_BOUND, "1.2", restriction.getLowerBound().toString() ); assertFalse( CHECK_LOWER_BOUND_INCLUSIVE, restriction.isLowerBoundInclusive() ); assertEquals( CHECK_UPPER_BOUND, "1.3", restriction.getUpperBound().toString() ); assertFalse( CHECK_UPPER_BOUND_INCLUSIVE, restriction.isUpperBoundInclusive() ); range1 = VersionRange.createFromVersionSpec( "[1.2,1.3)" ); range2 = VersionRange.createFromVersionSpec( "[1.1,1.4]" ); mergedRange = range1.restrict( range2 ); assertNull( CHECK_VERSION_RECOMMENDATION, mergedRange.getRecommendedVersion() ); restrictions = mergedRange.getRestrictions(); assertEquals( CHECK_NUM_RESTRICTIONS, 1, restrictions.size() ); restriction = restrictions.get( 0 ); assertEquals( CHECK_LOWER_BOUND, "1.2", restriction.getLowerBound().toString() ); assertTrue( CHECK_LOWER_BOUND_INCLUSIVE, restriction.isLowerBoundInclusive() ); assertEquals( CHECK_UPPER_BOUND, "1.3", restriction.getUpperBound().toString() ); assertFalse( CHECK_UPPER_BOUND_INCLUSIVE, restriction.isUpperBoundInclusive() ); range1 = VersionRange.createFromVersionSpec( "[1.0,1.1]" ); range2 = VersionRange.createFromVersionSpec( "[1.1,1.4]" ); mergedRange = range1.restrict( range2 ); assertNull( CHECK_VERSION_RECOMMENDATION, mergedRange.getRecommendedVersion() ); restrictions = mergedRange.getRestrictions(); assertEquals( CHECK_NUM_RESTRICTIONS, 1, restrictions.size() ); restriction = restrictions.get( 0 ); assertEquals( CHECK_LOWER_BOUND, "1.1", restriction.getLowerBound().toString() ); assertTrue( CHECK_LOWER_BOUND_INCLUSIVE, restriction.isLowerBoundInclusive() ); assertEquals( CHECK_UPPER_BOUND, "1.1", restriction.getUpperBound().toString() ); assertTrue( CHECK_UPPER_BOUND_INCLUSIVE, restriction.isUpperBoundInclusive() ); range1 = VersionRange.createFromVersionSpec( "[1.0,1.1)" ); range2 = VersionRange.createFromVersionSpec( "[1.1,1.4]" ); mergedRange = range1.restrict( range2 ); assertNull( CHECK_VERSION_RECOMMENDATION, mergedRange.getRecommendedVersion() ); restrictions = mergedRange.getRestrictions(); assertEquals( CHECK_NUM_RESTRICTIONS, 0, restrictions.size() ); range1 = VersionRange.createFromVersionSpec( "[1.0,1.2],[1.3,1.5]" ); range2 = VersionRange.createFromVersionSpec( "[1.1]" ); mergedRange = range1.restrict( range2 ); assertNull( CHECK_VERSION_RECOMMENDATION, mergedRange.getRecommendedVersion() ); restrictions = mergedRange.getRestrictions(); assertEquals( CHECK_NUM_RESTRICTIONS, 1, restrictions.size() ); restriction = restrictions.get( 0 ); assertEquals( CHECK_LOWER_BOUND, "1.1", restriction.getLowerBound().toString() ); assertTrue( CHECK_LOWER_BOUND_INCLUSIVE, restriction.isLowerBoundInclusive() ); assertEquals( CHECK_UPPER_BOUND, "1.1", restriction.getUpperBound().toString() ); assertTrue( CHECK_UPPER_BOUND_INCLUSIVE, restriction.isUpperBoundInclusive() ); range1 = VersionRange.createFromVersionSpec( "[1.0,1.2],[1.3,1.5]" ); range2 = VersionRange.createFromVersionSpec( "[1.4]" ); mergedRange = range1.restrict( range2 ); assertNull( CHECK_VERSION_RECOMMENDATION, mergedRange.getRecommendedVersion() ); restrictions = mergedRange.getRestrictions(); assertEquals( CHECK_NUM_RESTRICTIONS, 1, restrictions.size() ); restriction = restrictions.get( 0 ); assertEquals( CHECK_LOWER_BOUND, "1.4", restriction.getLowerBound().toString() ); assertTrue( CHECK_LOWER_BOUND_INCLUSIVE, restriction.isLowerBoundInclusive() ); assertEquals( CHECK_UPPER_BOUND, "1.4", restriction.getUpperBound().toString() ); assertTrue( CHECK_UPPER_BOUND_INCLUSIVE, restriction.isUpperBoundInclusive() ); range1 = VersionRange.createFromVersionSpec( "[1.0,1.2],[1.3,1.5]" ); range2 = VersionRange.createFromVersionSpec( "[1.1,1.4]" ); mergedRange = range1.restrict( range2 ); assertNull( CHECK_VERSION_RECOMMENDATION, mergedRange.getRecommendedVersion() ); restrictions = mergedRange.getRestrictions(); assertEquals( CHECK_NUM_RESTRICTIONS, 2, restrictions.size() ); restriction = restrictions.get( 0 ); assertEquals( CHECK_LOWER_BOUND, "1.1", restriction.getLowerBound().toString() ); assertTrue( CHECK_LOWER_BOUND_INCLUSIVE, restriction.isLowerBoundInclusive() ); assertEquals( CHECK_UPPER_BOUND, "1.2", restriction.getUpperBound().toString() ); assertTrue( CHECK_UPPER_BOUND_INCLUSIVE, restriction.isUpperBoundInclusive() ); restriction = restrictions.get( 1 ); assertEquals( CHECK_LOWER_BOUND, "1.3", restriction.getLowerBound().toString() ); assertTrue( CHECK_LOWER_BOUND_INCLUSIVE, restriction.isLowerBoundInclusive() ); assertEquals( CHECK_UPPER_BOUND, "1.4", restriction.getUpperBound().toString() ); assertTrue( CHECK_UPPER_BOUND_INCLUSIVE, restriction.isUpperBoundInclusive() ); range1 = VersionRange.createFromVersionSpec( "[1.0,1.2),(1.3,1.5]" ); range2 = VersionRange.createFromVersionSpec( "[1.1,1.4]" ); mergedRange = range1.restrict( range2 ); assertNull( CHECK_VERSION_RECOMMENDATION, mergedRange.getRecommendedVersion() ); restrictions = mergedRange.getRestrictions(); assertEquals( CHECK_NUM_RESTRICTIONS, 2, restrictions.size() ); restriction = restrictions.get( 0 ); assertEquals( CHECK_LOWER_BOUND, "1.1", restriction.getLowerBound().toString() ); assertTrue( CHECK_LOWER_BOUND_INCLUSIVE, restriction.isLowerBoundInclusive() ); assertEquals( CHECK_UPPER_BOUND, "1.2", restriction.getUpperBound().toString() ); assertFalse( CHECK_UPPER_BOUND_INCLUSIVE, restriction.isUpperBoundInclusive() ); restriction = restrictions.get( 1 ); assertEquals( CHECK_LOWER_BOUND, "1.3", restriction.getLowerBound().toString() ); assertFalse( CHECK_LOWER_BOUND_INCLUSIVE, restriction.isLowerBoundInclusive() ); assertEquals( CHECK_UPPER_BOUND, "1.4", restriction.getUpperBound().toString() ); assertTrue( CHECK_UPPER_BOUND_INCLUSIVE, restriction.isUpperBoundInclusive() ); range1 = VersionRange.createFromVersionSpec( "[1.0,1.2],[1.3,1.5]" ); range2 = VersionRange.createFromVersionSpec( "(1.1,1.4)" ); mergedRange = range1.restrict( range2 ); assertNull( CHECK_VERSION_RECOMMENDATION, mergedRange.getRecommendedVersion() ); restrictions = mergedRange.getRestrictions(); assertEquals( CHECK_NUM_RESTRICTIONS, 2, restrictions.size() ); restriction = restrictions.get( 0 ); assertEquals( CHECK_LOWER_BOUND, "1.1", restriction.getLowerBound().toString() ); assertFalse( CHECK_LOWER_BOUND_INCLUSIVE, restriction.isLowerBoundInclusive() ); assertEquals( CHECK_UPPER_BOUND, "1.2", restriction.getUpperBound().toString() ); assertTrue( CHECK_UPPER_BOUND_INCLUSIVE, restriction.isUpperBoundInclusive() ); restriction = restrictions.get( 1 ); assertEquals( CHECK_LOWER_BOUND, "1.3", restriction.getLowerBound().toString() ); assertTrue( CHECK_LOWER_BOUND_INCLUSIVE, restriction.isLowerBoundInclusive() ); assertEquals( CHECK_UPPER_BOUND, "1.4", restriction.getUpperBound().toString() ); assertFalse( CHECK_UPPER_BOUND_INCLUSIVE, restriction.isUpperBoundInclusive() ); range1 = VersionRange.createFromVersionSpec( "[1.0,1.2),(1.3,1.5]" ); range2 = VersionRange.createFromVersionSpec( "(1.1,1.4)" ); mergedRange = range1.restrict( range2 ); assertNull( CHECK_VERSION_RECOMMENDATION, mergedRange.getRecommendedVersion() ); restrictions = mergedRange.getRestrictions(); assertEquals( CHECK_NUM_RESTRICTIONS, 2, restrictions.size() ); restriction = restrictions.get( 0 ); assertEquals( CHECK_LOWER_BOUND, "1.1", restriction.getLowerBound().toString() ); assertFalse( CHECK_LOWER_BOUND_INCLUSIVE, restriction.isLowerBoundInclusive() ); assertEquals( CHECK_UPPER_BOUND, "1.2", restriction.getUpperBound().toString() ); assertFalse( CHECK_UPPER_BOUND_INCLUSIVE, restriction.isUpperBoundInclusive() ); restriction = restrictions.get( 1 ); assertEquals( CHECK_LOWER_BOUND, "1.3", restriction.getLowerBound().toString() ); assertFalse( CHECK_LOWER_BOUND_INCLUSIVE, restriction.isLowerBoundInclusive() ); assertEquals( CHECK_UPPER_BOUND, "1.4", restriction.getUpperBound().toString() ); assertFalse( CHECK_UPPER_BOUND_INCLUSIVE, restriction.isUpperBoundInclusive() ); range1 = VersionRange.createFromVersionSpec( "(,1.1),(1.4,)" ); range2 = VersionRange.createFromVersionSpec( "[1.1,1.4]" ); mergedRange = range1.restrict( range2 ); assertNull( CHECK_VERSION_RECOMMENDATION, mergedRange.getRecommendedVersion() ); restrictions = mergedRange.getRestrictions(); assertEquals( CHECK_NUM_RESTRICTIONS, 0, restrictions.size() ); range1 = VersionRange.createFromVersionSpec( "(,1.1],[1.4,)" ); range2 = VersionRange.createFromVersionSpec( "(1.1,1.4)" ); mergedRange = range1.restrict( range2 ); assertNull( CHECK_VERSION_RECOMMENDATION, mergedRange.getRecommendedVersion() ); restrictions = mergedRange.getRestrictions(); assertEquals( CHECK_NUM_RESTRICTIONS, 0, restrictions.size() ); range1 = VersionRange.createFromVersionSpec( "[,1.1],[1.4,]" ); range2 = VersionRange.createFromVersionSpec( "[1.2,1.3]" ); mergedRange = range1.restrict( range2 ); assertNull( CHECK_VERSION_RECOMMENDATION, mergedRange.getRecommendedVersion() ); restrictions = mergedRange.getRestrictions(); assertEquals( CHECK_NUM_RESTRICTIONS, 0, restrictions.size() ); range1 = VersionRange.createFromVersionSpec( "[1.0,1.2],[1.3,1.5]" ); range2 = VersionRange.createFromVersionSpec( "[1.1,1.4],[1.6,]" ); mergedRange = range1.restrict( range2 ); assertNull( CHECK_VERSION_RECOMMENDATION, mergedRange.getRecommendedVersion() ); restrictions = mergedRange.getRestrictions(); assertEquals( CHECK_NUM_RESTRICTIONS, 2, restrictions.size() ); restriction = restrictions.get( 0 ); assertEquals( CHECK_LOWER_BOUND, "1.1", restriction.getLowerBound().toString() ); assertTrue( CHECK_LOWER_BOUND_INCLUSIVE, restriction.isLowerBoundInclusive() ); assertEquals( CHECK_UPPER_BOUND, "1.2", restriction.getUpperBound().toString() ); assertTrue( CHECK_UPPER_BOUND_INCLUSIVE, restriction.isUpperBoundInclusive() ); restriction = restrictions.get( 1 ); assertEquals( CHECK_LOWER_BOUND, "1.3", restriction.getLowerBound().toString() ); assertTrue( CHECK_LOWER_BOUND_INCLUSIVE, restriction.isLowerBoundInclusive() ); assertEquals( CHECK_UPPER_BOUND, "1.4", restriction.getUpperBound().toString() ); assertTrue( CHECK_UPPER_BOUND_INCLUSIVE, restriction.isUpperBoundInclusive() ); range1 = VersionRange.createFromVersionSpec( "[1.0,1.2],[1.3,1.5]" ); range2 = VersionRange.createFromVersionSpec( "[1.1,1.4],[1.5,]" ); mergedRange = range1.restrict( range2 ); assertNull( CHECK_VERSION_RECOMMENDATION, mergedRange.getRecommendedVersion() ); restrictions = mergedRange.getRestrictions(); assertEquals( CHECK_NUM_RESTRICTIONS, 3, restrictions.size() ); restriction = restrictions.get( 0 ); assertEquals( CHECK_LOWER_BOUND, "1.1", restriction.getLowerBound().toString() ); assertTrue( CHECK_LOWER_BOUND_INCLUSIVE, restriction.isLowerBoundInclusive() ); assertEquals( CHECK_UPPER_BOUND, "1.2", restriction.getUpperBound().toString() ); assertTrue( CHECK_UPPER_BOUND_INCLUSIVE, restriction.isUpperBoundInclusive() ); restriction = restrictions.get( 1 ); assertEquals( CHECK_LOWER_BOUND, "1.3", restriction.getLowerBound().toString() ); assertTrue( CHECK_LOWER_BOUND_INCLUSIVE, restriction.isLowerBoundInclusive() ); assertEquals( CHECK_UPPER_BOUND, "1.4", restriction.getUpperBound().toString() ); assertTrue( CHECK_UPPER_BOUND_INCLUSIVE, restriction.isUpperBoundInclusive() ); restriction = restrictions.get( 2 ); assertEquals( CHECK_LOWER_BOUND, "1.5", restriction.getLowerBound().toString() ); assertTrue( CHECK_LOWER_BOUND_INCLUSIVE, restriction.isLowerBoundInclusive() ); assertEquals( CHECK_UPPER_BOUND, "1.5", restriction.getUpperBound().toString() ); assertTrue( CHECK_UPPER_BOUND_INCLUSIVE, restriction.isUpperBoundInclusive() ); range1 = VersionRange.createFromVersionSpec( "[1.0,1.2],[1.3,1.7]" ); range2 = VersionRange.createFromVersionSpec( "[1.1,1.4],[1.5,1.6]" ); mergedRange = range1.restrict( range2 ); assertNull( CHECK_VERSION_RECOMMENDATION, mergedRange.getRecommendedVersion() ); restrictions = mergedRange.getRestrictions(); assertEquals( CHECK_NUM_RESTRICTIONS, 3, restrictions.size() ); restriction = restrictions.get( 0 ); assertEquals( CHECK_LOWER_BOUND, "1.1", restriction.getLowerBound().toString() ); assertTrue( CHECK_LOWER_BOUND_INCLUSIVE, restriction.isLowerBoundInclusive() ); assertEquals( CHECK_UPPER_BOUND, "1.2", restriction.getUpperBound().toString() ); assertTrue( CHECK_UPPER_BOUND_INCLUSIVE, restriction.isUpperBoundInclusive() ); restriction = restrictions.get( 1 ); assertEquals( CHECK_LOWER_BOUND, "1.3", restriction.getLowerBound().toString() ); assertTrue( CHECK_LOWER_BOUND_INCLUSIVE, restriction.isLowerBoundInclusive() ); assertEquals( CHECK_UPPER_BOUND, "1.4", restriction.getUpperBound().toString() ); assertTrue( CHECK_UPPER_BOUND_INCLUSIVE, restriction.isUpperBoundInclusive() ); restriction = restrictions.get( 2 ); assertEquals( CHECK_LOWER_BOUND, "1.5", restriction.getLowerBound().toString() ); assertTrue( CHECK_LOWER_BOUND_INCLUSIVE, restriction.isLowerBoundInclusive() ); assertEquals( CHECK_UPPER_BOUND, "1.6", restriction.getUpperBound().toString() ); assertTrue( CHECK_UPPER_BOUND_INCLUSIVE, restriction.isUpperBoundInclusive() ); // test restricting empty sets range1 = VersionRange.createFromVersionSpec( "[,1.1],[1.4,]" ); range2 = VersionRange.createFromVersionSpec( "[1.2,1.3]" ); range1 = range1.restrict( range2 ); mergedRange = range1.restrict( range2 ); assertNull( CHECK_VERSION_RECOMMENDATION, mergedRange.getRecommendedVersion() ); restrictions = mergedRange.getRestrictions(); assertEquals( CHECK_NUM_RESTRICTIONS, 0, restrictions.size() ); range1 = VersionRange.createFromVersionSpec( "[,1.1],[1.4,]" ); range2 = VersionRange.createFromVersionSpec( "[1.2,1.3]" ); range2 = range1.restrict( range2 ); mergedRange = range1.restrict( range2 ); assertNull( CHECK_VERSION_RECOMMENDATION, mergedRange.getRecommendedVersion() ); restrictions = mergedRange.getRestrictions(); assertEquals( CHECK_NUM_RESTRICTIONS, 0, restrictions.size() ); } public void testReleaseRangeBoundsContainsSnapshots() throws InvalidVersionSpecificationException { VersionRange range = VersionRange.createFromVersionSpec( "[1.0,1.2]" ); assertTrue( range.containsVersion( new DefaultArtifactVersion( "1.1-SNAPSHOT" ) ) ); assertTrue( range.containsVersion( new DefaultArtifactVersion( "1.2-SNAPSHOT" ) ) ); assertFalse( range.containsVersion( new DefaultArtifactVersion( "1.0-SNAPSHOT" ) ) ); } public void testSnapshotRangeBoundsCanContainSnapshots() throws InvalidVersionSpecificationException { VersionRange range = VersionRange.createFromVersionSpec( "[1.0,1.2-SNAPSHOT]" ); assertTrue( range.containsVersion( new DefaultArtifactVersion( "1.1-SNAPSHOT" ) ) ); assertTrue( range.containsVersion( new DefaultArtifactVersion( "1.2-SNAPSHOT" ) ) ); range = VersionRange.createFromVersionSpec( "[1.0-SNAPSHOT,1.2]" ); assertTrue( range.containsVersion( new DefaultArtifactVersion( "1.0-SNAPSHOT" ) ) ); assertTrue( range.containsVersion( new DefaultArtifactVersion( "1.1-SNAPSHOT" ) ) ); } public void testSnapshotSoftVersionCanContainSnapshot() throws InvalidVersionSpecificationException { VersionRange range = VersionRange.createFromVersionSpec( "1.0-SNAPSHOT" ); assertTrue( range.containsVersion( new DefaultArtifactVersion( "1.0-SNAPSHOT" ) ) ); } private void checkInvalidRange( String version ) { try { VersionRange.createFromVersionSpec( version ); fail( "Version " + version + " should have failed to construct" ); } catch ( InvalidVersionSpecificationException expected ) { // expected } } public void testContains() throws InvalidVersionSpecificationException { ArtifactVersion actualVersion = new DefaultArtifactVersion( "2.0.5" ); assertTrue( enforceVersion( "2.0.5", actualVersion ) ); assertTrue( enforceVersion( "2.0.4", actualVersion ) ); assertTrue( enforceVersion( "[2.0.5]", actualVersion ) ); assertFalse( enforceVersion( "[2.0.6,)", actualVersion ) ); assertFalse( enforceVersion( "[2.0.6]", actualVersion ) ); assertTrue( enforceVersion( "[2.0,2.1]", actualVersion ) ); assertFalse( enforceVersion( "[2.0,2.0.3]", actualVersion ) ); assertTrue( enforceVersion( "[2.0,2.0.5]", actualVersion ) ); assertFalse( enforceVersion( "[2.0,2.0.5)", actualVersion ) ); } public boolean enforceVersion( String requiredVersionRange, ArtifactVersion actualVersion ) throws InvalidVersionSpecificationException { VersionRange vr = null; vr = VersionRange.createFromVersionSpec( requiredVersionRange ); return vr.containsVersion( actualVersion ); } public void testOrder0() { // assertTrue( new DefaultArtifactVersion( "1.0-alpha10" ).compareTo( new DefaultArtifactVersion( "1.0-alpha1" ) ) > 0 ); } } maven-maven-3.5.2/maven-builder-support/000077500000000000000000000000001317160430700202015ustar00rootroot00000000000000maven-maven-3.5.2/maven-builder-support/pom.xml000066400000000000000000000027671317160430700215320ustar00rootroot00000000000000 4.0.0 org.apache.maven maven 3.5.2 maven-builder-support Maven Builder Support Support for descriptor builders (model, setting, toolchains) org.apache.commons commons-lang3 maven-maven-3.5.2/maven-builder-support/src/000077500000000000000000000000001317160430700207705ustar00rootroot00000000000000maven-maven-3.5.2/maven-builder-support/src/main/000077500000000000000000000000001317160430700217145ustar00rootroot00000000000000maven-maven-3.5.2/maven-builder-support/src/main/java/000077500000000000000000000000001317160430700226355ustar00rootroot00000000000000maven-maven-3.5.2/maven-builder-support/src/main/java/org/000077500000000000000000000000001317160430700234245ustar00rootroot00000000000000maven-maven-3.5.2/maven-builder-support/src/main/java/org/apache/000077500000000000000000000000001317160430700246455ustar00rootroot00000000000000maven-maven-3.5.2/maven-builder-support/src/main/java/org/apache/maven/000077500000000000000000000000001317160430700257535ustar00rootroot00000000000000maven-maven-3.5.2/maven-builder-support/src/main/java/org/apache/maven/building/000077500000000000000000000000001317160430700275505ustar00rootroot00000000000000maven-maven-3.5.2/maven-builder-support/src/main/java/org/apache/maven/building/DefaultProblem.java000066400000000000000000000106401317160430700333210ustar00rootroot00000000000000package org.apache.maven.building; /* * 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. */ /** * Describes a problem that was encountered during settings building. A problem can either be an exception that was * thrown or a simple string message. In addition, a problem carries a hint about its source, e.g. the settings file * that exhibits the problem. * * @author Benjamin Bentmann * @author Robert Scholte */ class DefaultProblem implements Problem { private final String source; private final int lineNumber; private final int columnNumber; private final String message; private final Exception exception; private final Severity severity; /** * Creates a new problem with the specified message and exception. * Either {@code message} or {@code exception} is required * * @param message The message describing the problem, may be {@code null}. * @param severity The severity level of the problem, may be {@code null} to default to * {@link SettingsProblem.Severity#ERROR}. * @param source A hint about the source of the problem like a file path, may be {@code null}. * @param lineNumber The one-based index of the line containing the problem or {@code -1} if unknown. * @param columnNumber The one-based index of the column containing the problem or {@code -1} if unknown. * @param exception The exception that caused this problem, may be {@code null}. */ public DefaultProblem( String message, Severity severity, String source, int lineNumber, int columnNumber, Exception exception ) { this.message = message; this.severity = ( severity != null ) ? severity : Severity.ERROR; this.source = ( source != null ) ? source : ""; this.lineNumber = lineNumber; this.columnNumber = columnNumber; this.exception = exception; } public String getSource() { return source; } public int getLineNumber() { return lineNumber; } public int getColumnNumber() { return columnNumber; } public String getLocation() { StringBuilder buffer = new StringBuilder( 256 ); if ( getSource().length() > 0 ) { if ( buffer.length() > 0 ) { buffer.append( ", " ); } buffer.append( getSource() ); } if ( getLineNumber() > 0 ) { if ( buffer.length() > 0 ) { buffer.append( ", " ); } buffer.append( "line " ).append( getLineNumber() ); } if ( getColumnNumber() > 0 ) { if ( buffer.length() > 0 ) { buffer.append( ", " ); } buffer.append( "column " ).append( getColumnNumber() ); } return buffer.toString(); } public Exception getException() { return exception; } public String getMessage() { String msg; if ( message != null && message.length() > 0 ) { msg = message; } else { msg = exception.getMessage(); if ( msg == null ) { msg = ""; } } return msg; } public Severity getSeverity() { return severity; } @Override public String toString() { StringBuilder buffer = new StringBuilder( 128 ); buffer.append( '[' ).append( getSeverity() ).append( "] " ); buffer.append( getMessage() ); buffer.append( " @ " ).append( getLocation() ); return buffer.toString(); } } DefaultProblemCollector.java000066400000000000000000000033551317160430700351160ustar00rootroot00000000000000maven-maven-3.5.2/maven-builder-support/src/main/java/org/apache/maven/buildingpackage org.apache.maven.building; /* * 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.util.ArrayList; import java.util.List; /** * Collects problems that are encountered during settings building. * * @author Benjamin Bentmann * @author Robert Scholte */ class DefaultProblemCollector implements ProblemCollector { private List problems; private String source; public DefaultProblemCollector( List problems ) { this.problems = ( problems != null ) ? problems : new ArrayList(); } @Override public List getProblems() { return problems; } @Override public void setSource( String source ) { this.source = source; } @Override public void add( Problem.Severity severity, String message, int line, int column, Exception cause ) { Problem problem = new DefaultProblem( message, severity, source, line, column, cause ); problems.add( problem ); } } maven-maven-3.5.2/maven-builder-support/src/main/java/org/apache/maven/building/FileSource.java000066400000000000000000000036051317160430700324570ustar00rootroot00000000000000package org.apache.maven.building; /* * 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.File; import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; import org.apache.commons.lang3.Validate; /** * Wraps an ordinary {@link File} as a source. * * @author Benjamin Bentmann */ public class FileSource implements Source { private final File file; /** * Creates a new source backed by the specified file. * * @param file The file, must not be {@code null}. */ public FileSource( File file ) { this.file = Validate.notNull( file, "file cannot be null" ).getAbsoluteFile(); } @Override public InputStream getInputStream() throws IOException { return new FileInputStream( file ); } @Override public String getLocation() { return file.getPath(); } /** * Gets the file of this source. * * @return The underlying file, never {@code null}. */ public File getFile() { return file; } @Override public String toString() { return getLocation(); } } maven-maven-3.5.2/maven-builder-support/src/main/java/org/apache/maven/building/Problem.java000066400000000000000000000066311317160430700320210ustar00rootroot00000000000000package org.apache.maven.building; /* * 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. */ /** * Describes a problem that was encountered during settings building. A problem can either be an exception that was * thrown or a simple string message. In addition, a problem carries a hint about its source, e.g. the settings file * that exhibits the problem. * * @author Benjamin Bentmann * @author Robert Scholte */ public interface Problem { /** * The different severity levels for a problem, in decreasing order. */ enum Severity { FATAL, // ERROR, // WARNING // } /** * Gets the hint about the source of the problem. While the syntax of this hint is unspecified and depends on the * creator of the problem, the general expectation is that the hint provides sufficient information to the user to * track the problem back to its origin. A concrete example for such a source hint can be the file path or URL from * which the settings were read. * * @return The hint about the source of the problem or an empty string if unknown, never {@code null}. */ String getSource(); /** * Gets the one-based index of the line containing the problem. The line number should refer to some text file that * is given by {@link #getSource()}. * * @return The one-based index of the line containing the problem or a non-positive value if unknown. */ int getLineNumber(); /** * Gets the one-based index of the column containing the problem. The column number should refer to some text file * that is given by {@link #getSource()}. * * @return The one-based index of the column containing the problem or non-positive value if unknown. */ int getColumnNumber(); /** * Gets the location of the problem. The location is a user-friendly combination of the values from * {@link #getSource()}, {@link #getLineNumber()} and {@link #getColumnNumber()}. The exact syntax of the returned * value is undefined. * * @return The location of the problem, never {@code null}. */ String getLocation(); /** * Gets the exception that caused this problem (if any). * * @return The exception that caused this problem or {@code null} if not applicable. */ Exception getException(); /** * Gets the message that describes this problem. * * @return The message describing this problem, never {@code null}. */ String getMessage(); /** * Gets the severity level of this problem. * * @return The severity level of this problem, never {@code null}. */ Severity getSeverity(); } ProblemCollector.java000066400000000000000000000040121317160430700336000ustar00rootroot00000000000000maven-maven-3.5.2/maven-builder-support/src/main/java/org/apache/maven/buildingpackage org.apache.maven.building; /* * 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.util.List; /** * Collects problems that are encountered during settings building. * * @author Benjamin Bentmann * @author Robert Scholte */ public interface ProblemCollector { /** * Adds the specified problem. * Either message or exception is required * * @param severity The severity of the problem, must not be {@code null}. * @param message The detail message of the problem, may be {@code null}. * @param line The one-based index of the line containing the problem or {@code -1} if unknown. * @param column The one-based index of the column containing the problem or {@code -1} if unknown. * @param cause The cause of the problem, may be {@code null}. */ void add( Problem.Severity severity, String message, int line, int column, Exception cause ); /** * The next messages will be bound to this source. When calling this method again, previous messages keep * their source, but the next messages will use the new source. * * @param source */ void setSource( String source ); /** * * @return the collected Problems, never {@code null} */ List getProblems(); } ProblemCollectorFactory.java000066400000000000000000000024631317160430700351400ustar00rootroot00000000000000maven-maven-3.5.2/maven-builder-support/src/main/java/org/apache/maven/buildingpackage org.apache.maven.building; /* * 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.util.List; /** * * @author Robert Scholte * @since 3.3.0 */ public class ProblemCollectorFactory { /** * The default implementation is not visible, create it with this factory * * @param problems starting set of problems, may be {@code null} * @return a new instance of a ProblemCollector */ public static ProblemCollector newInstance( List problems ) { return new DefaultProblemCollector( problems ); } } maven-maven-3.5.2/maven-builder-support/src/main/java/org/apache/maven/building/Source.java000066400000000000000000000032471317160430700316610ustar00rootroot00000000000000package org.apache.maven.building; /* * 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; /** * Provides access to the contents of a source independently of the backing store (e.g. file system, database, memory). * * @author Benjamin Bentmann */ public interface Source { /** * Gets a byte stream to the source contents. Closing the returned stream is the responsibility of the caller. * * @return A byte stream to the source contents, never {@code null}. */ InputStream getInputStream() throws IOException; /** * Provides a user-friendly hint about the location of the source. This could be a local file path, a URI or just an * empty string. The intention is to assist users during error reporting. * * @return A user-friendly hint about the location of the source, never {@code null}. */ String getLocation(); } maven-maven-3.5.2/maven-builder-support/src/main/java/org/apache/maven/building/StringSource.java000066400000000000000000000045341317160430700330500ustar00rootroot00000000000000package org.apache.maven.building; /* * 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.ByteArrayInputStream; import java.io.IOException; import java.io.InputStream; /** * Wraps an ordinary {@link CharSequence} as a source. * * @author Benjamin Bentmann */ public class StringSource implements Source { private String content; private String location; /** * Creates a new source backed by the specified string. * * @param content The String representation, may be empty or {@code null}. */ public StringSource( CharSequence content ) { this( content, null ); } /** * Creates a new source backed by the specified string. * * @param content The String representation, may be empty or {@code null}. * @param location The location to report for this use, may be {@code null}. */ public StringSource( CharSequence content, String location ) { this.content = ( content != null ) ? content.toString() : ""; this.location = ( location != null ) ? location : "(memory)"; } @Override public InputStream getInputStream() throws IOException { return new ByteArrayInputStream( content.getBytes( "UTF-8" ) ); } @Override public String getLocation() { return location; } /** * Gets the content of this source. * * @return The underlying character stream, never {@code null}. */ public String getContent() { return content; } @Override public String toString() { return getLocation(); } } maven-maven-3.5.2/maven-builder-support/src/main/java/org/apache/maven/building/UrlSource.java000066400000000000000000000034631317160430700323440ustar00rootroot00000000000000package org.apache.maven.building; /* * 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.URL; import org.apache.commons.lang3.Validate; /** * Wraps an ordinary {@link URL} as a source. * * @author Benjamin Bentmann */ public class UrlSource implements Source { private URL url; /** * Creates a new source backed by the specified URL. * * @param url The file, must not be {@code null}. */ public UrlSource( URL url ) { this.url = Validate.notNull( url, "url cannot be null" ); } @Override public InputStream getInputStream() throws IOException { return url.openStream(); } @Override public String getLocation() { return url.toString(); } /** * Gets the URL of this source. * * @return The underlying URL, never {@code null}. */ public URL getUrl() { return url; } @Override public String toString() { return getLocation(); } } maven-maven-3.5.2/maven-builder-support/src/site/000077500000000000000000000000001317160430700217345ustar00rootroot00000000000000maven-maven-3.5.2/maven-builder-support/src/site/site.xml000066400000000000000000000025231317160430700234240ustar00rootroot00000000000000 maven-maven-3.5.2/maven-builder-support/src/test/000077500000000000000000000000001317160430700217475ustar00rootroot00000000000000maven-maven-3.5.2/maven-builder-support/src/test/java/000077500000000000000000000000001317160430700226705ustar00rootroot00000000000000maven-maven-3.5.2/maven-builder-support/src/test/java/org/000077500000000000000000000000001317160430700234575ustar00rootroot00000000000000maven-maven-3.5.2/maven-builder-support/src/test/java/org/apache/000077500000000000000000000000001317160430700247005ustar00rootroot00000000000000maven-maven-3.5.2/maven-builder-support/src/test/java/org/apache/maven/000077500000000000000000000000001317160430700260065ustar00rootroot00000000000000maven-maven-3.5.2/maven-builder-support/src/test/java/org/apache/maven/building/000077500000000000000000000000001317160430700276035ustar00rootroot00000000000000DefaultProblemCollectorTest.java000066400000000000000000000053321317160430700360060ustar00rootroot00000000000000maven-maven-3.5.2/maven-builder-support/src/test/java/org/apache/maven/buildingpackage org.apache.maven.building; /* * 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.Assert.*; import org.apache.maven.building.Problem.Severity; import org.junit.Test; public class DefaultProblemCollectorTest { @Test public void testGetProblems() { DefaultProblemCollector collector = new DefaultProblemCollector( null ); assertNotNull( collector.getProblems() ); assertEquals( 0, collector.getProblems().size() ); collector.add( null, "MESSAGE1", -1, -1, null ); Exception e2 = new Exception(); collector.add( Severity.WARNING, null, 42, 127, e2 ); assertEquals( 2, collector.getProblems().size() ); Problem p1 = collector.getProblems().get(0); assertEquals( Severity.ERROR, p1.getSeverity() ); assertEquals( "MESSAGE1",p1.getMessage() ); assertEquals( -1, p1.getLineNumber() ); assertEquals( -1, p1.getColumnNumber() ); assertEquals( null, p1.getException() ); Problem p2 = collector.getProblems().get(1); assertEquals( Severity.WARNING, p2.getSeverity() ); assertEquals( "",p2.getMessage() ); assertEquals( 42, p2.getLineNumber() ); assertEquals( 127, p2.getColumnNumber() ); assertEquals( e2, p2.getException() ); } @Test public void testSetSource() { DefaultProblemCollector collector = new DefaultProblemCollector( null ); collector.add( null, "PROBLEM1", -1, -1, null ); collector.setSource( "SOURCE_PROBLEM2" ); collector.add( null, "PROBLEM2", -1, -1, null ); collector.setSource( "SOURCE_PROBLEM3" ); collector.add( null, "PROBLEM3", -1, -1, null ); assertEquals( "", collector.getProblems().get( 0 ).getSource() ); assertEquals( "SOURCE_PROBLEM2", collector.getProblems().get( 1 ).getSource() ); assertEquals( "SOURCE_PROBLEM3", collector.getProblems().get( 2 ).getSource() ); } } DefaultProblemTest.java000066400000000000000000000121501317160430700341330ustar00rootroot00000000000000maven-maven-3.5.2/maven-builder-support/src/test/java/org/apache/maven/buildingpackage org.apache.maven.building; /* * 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.Assert.assertEquals; import static org.junit.Assert.assertSame; import org.apache.maven.building.Problem.Severity; import org.junit.Test; public class DefaultProblemTest { @Test public void testGetSeverity() { DefaultProblem problem = new DefaultProblem( null, null, null, -1, -1, null ); assertEquals( Severity.ERROR, problem.getSeverity() ); problem = new DefaultProblem( null, Severity.FATAL, null, -1, -1, null ); assertEquals( Severity.FATAL, problem.getSeverity() ); problem = new DefaultProblem( null, Severity.ERROR, null, -1, -1, null ); assertEquals( Severity.ERROR, problem.getSeverity() ); problem = new DefaultProblem( null, Severity.WARNING, null, -1, -1, null ); assertEquals( Severity.WARNING, problem.getSeverity() ); } @Test public void testGetLineNumber() { DefaultProblem problem = new DefaultProblem( null, null, null, -1, -1, null ); assertEquals( -1, problem.getLineNumber() ); problem = new DefaultProblem( null, null, null, 42, -1, null ); assertEquals( 42, problem.getLineNumber() ); problem = new DefaultProblem( null, null, null, Integer.MAX_VALUE, -1, null ); assertEquals( Integer.MAX_VALUE, problem.getLineNumber() ); // this case is not specified, might also return -1 problem = new DefaultProblem( null, null, null, Integer.MIN_VALUE, -1, null ); assertEquals( Integer.MIN_VALUE, problem.getLineNumber() ); } @Test public void testGetColumnNumber() { DefaultProblem problem = new DefaultProblem( null, null, null, -1, -1, null ); assertEquals( -1, problem.getColumnNumber() ); problem = new DefaultProblem( null, null, null, -1, 42, null ); assertEquals( 42, problem.getColumnNumber() ); problem = new DefaultProblem( null, null, null, -1, Integer.MAX_VALUE, null ); assertEquals( Integer.MAX_VALUE, problem.getColumnNumber() ); // this case is not specified, might also return -1 problem = new DefaultProblem( null, null, null, -1, Integer.MIN_VALUE, null ); assertEquals( Integer.MIN_VALUE, problem.getColumnNumber() ); } @Test public void testGetException() { DefaultProblem problem = new DefaultProblem( null, null, null, -1, -1, null ); assertEquals( null, problem.getException() ); Exception e = new Exception(); problem = new DefaultProblem( null, null, null, -1, -1, e ); assertSame( e, problem.getException() ); } @Test public void testGetSource() { DefaultProblem problem = new DefaultProblem( null, null, null, -1, -1, null ); assertEquals( "", problem.getSource() ); problem = new DefaultProblem( null, null, "", -1, -1, null ); assertEquals( "", problem.getSource() ); problem = new DefaultProblem( null, null, "SOURCE", -1, -1, null ); assertEquals( "SOURCE", problem.getSource() ); } @Test public void testGetLocation() { DefaultProblem problem = new DefaultProblem( null, null, null, -1, -1, null ); assertEquals( "", problem.getLocation() ); problem = new DefaultProblem( null, null, "SOURCE", -1, -1, null ); assertEquals( "SOURCE", problem.getLocation() ); problem = new DefaultProblem( null, null, null, 42, -1, null ); assertEquals( "line 42", problem.getLocation() ); problem = new DefaultProblem( null, null, null, -1, 127, null ); assertEquals( "column 127", problem.getLocation() ); problem = new DefaultProblem( null, null, "SOURCE", 42, 127, null ); assertEquals( "SOURCE, line 42, column 127", problem.getLocation() ); } @Test public void testGetMessage() { DefaultProblem problem = new DefaultProblem( "MESSAGE", null, null, -1, -1, null ); assertEquals( "MESSAGE", problem.getMessage() ); problem = new DefaultProblem( null, null, null, -1, -1, new Exception() ); assertEquals( "", problem.getMessage() ); problem = new DefaultProblem( null, null, null, -1, -1, new Exception( "EXCEPTION MESSAGE" ) ); assertEquals( "EXCEPTION MESSAGE", problem.getMessage() ); } } maven-maven-3.5.2/maven-builder-support/src/test/java/org/apache/maven/building/FileSourceTest.java000066400000000000000000000043521317160430700333520ustar00rootroot00000000000000package org.apache.maven.building; /* * 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 org.junit.Test; import java.io.File; import java.io.InputStream; import java.util.Scanner; import static org.junit.Assert.assertEquals; import static org.junit.Assert.fail; public class FileSourceTest { @Test public void testFileSource() { try { new FileSource( null ); fail( "Should fail, since you must specify a file" ); } catch ( NullPointerException e ) { assertEquals( "file cannot be null", e.getMessage() ); } } @Test public void testGetInputStream() throws Exception { File txtFile = new File( "target/test-classes/source.txt" ); FileSource source = new FileSource( txtFile ); try ( InputStream is = source.getInputStream(); Scanner scanner = new Scanner( is ) ) { assertEquals( "Hello World!", scanner.nextLine() ); } } @Test public void testGetLocation() { File txtFile = new File( "target/test-classes/source.txt" ); FileSource source = new FileSource( txtFile ); assertEquals( txtFile.getAbsolutePath(), source.getLocation() ); } @Test public void testGetFile() { File txtFile = new File( "target/test-classes/source.txt" ); FileSource source = new FileSource( txtFile ); assertEquals( txtFile.getAbsoluteFile(), source.getFile() ); } } ProblemCollectorFactoryTest.java000066400000000000000000000030361317160430700360300ustar00rootroot00000000000000maven-maven-3.5.2/maven-builder-support/src/test/java/org/apache/maven/buildingpackage org.apache.maven.building; /* * 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.Assert.assertEquals; import static org.junit.Assert.assertNotSame; import java.util.Collections; import org.junit.Test; public class ProblemCollectorFactoryTest { @Test public void testNewInstance() { ProblemCollector collector1 = ProblemCollectorFactory.newInstance( null ); Problem problem = new DefaultProblem( "MESSAGE1", null, null, -1, -1, null ); ProblemCollector collector2 = ProblemCollectorFactory.newInstance( Collections.singletonList( problem ) ); assertNotSame( collector1, collector2 ); assertEquals( 0, collector1.getProblems().size() ); assertEquals( 1, collector2.getProblems().size() ); } } StringSourceTest.java000066400000000000000000000036251317160430700336640ustar00rootroot00000000000000maven-maven-3.5.2/maven-builder-support/src/test/java/org/apache/maven/buildingpackage org.apache.maven.building; /* * 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 org.junit.Test; import java.io.InputStream; import java.util.Scanner; import static org.junit.Assert.assertEquals; public class StringSourceTest { @Test public void testGetInputStream() throws Exception { StringSource source = new StringSource( "Hello World!" ); try ( InputStream is = source.getInputStream(); Scanner scanner = new Scanner( is ) ) { assertEquals( "Hello World!", scanner.nextLine() ); } } @Test public void testGetLocation() { StringSource source = new StringSource( "Hello World!" ); assertEquals( "(memory)", source.getLocation() ); source = new StringSource( "Hello World!", "LOCATION" ); assertEquals( "LOCATION", source.getLocation() ); } @Test public void testGetContent() { StringSource source = new StringSource( null ); assertEquals( "", source.getContent() ); source = new StringSource( "Hello World!", "LOCATION" ); assertEquals( "Hello World!", source.getContent() ); } } maven-maven-3.5.2/maven-builder-support/src/test/java/org/apache/maven/building/UrlSourceTest.java000066400000000000000000000040641317160430700332350ustar00rootroot00000000000000package org.apache.maven.building; /* * 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 org.junit.Test; import java.io.File; import java.io.InputStream; import java.net.URL; import java.util.Scanner; import static org.junit.Assert.assertEquals; import static org.junit.Assert.fail; public class UrlSourceTest { @Test public void testUrlSource() { try { new UrlSource( null ); fail( "Should fail, since you must specify a url" ); } catch ( NullPointerException e ) { assertEquals( "url cannot be null", e.getMessage() ); } } @Test public void testGetInputStream() throws Exception { URL txtFile = new File( "target/test-classes/source.txt" ).toURI().toURL(); UrlSource source = new UrlSource( txtFile ); try ( InputStream is = source.getInputStream(); Scanner scanner = new Scanner( is ) ) { assertEquals( "Hello World!", scanner.nextLine() ); } } @Test public void testGetLocation() throws Exception { URL txtFile = new File( "target/test-classes/source.txt" ).toURI().toURL(); UrlSource source = new UrlSource( txtFile ); assertEquals( txtFile.toExternalForm(), source.getLocation() ); } } maven-maven-3.5.2/maven-builder-support/src/test/resources/000077500000000000000000000000001317160430700237615ustar00rootroot00000000000000maven-maven-3.5.2/maven-builder-support/src/test/resources/source.txt000066400000000000000000000000141317160430700260150ustar00rootroot00000000000000Hello World!maven-maven-3.5.2/maven-compat/000077500000000000000000000000001317160430700163245ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/pom.xml000066400000000000000000000110671317160430700176460ustar00rootroot00000000000000 4.0.0 org.apache.maven maven 3.5.2 maven-compat Maven Compat Maven2 classes maintained as compatibility layer. false org.apache.maven maven-model org.apache.maven maven-model-builder org.apache.maven maven-settings org.apache.maven maven-settings-builder org.apache.maven maven-artifact org.apache.maven maven-core org.apache.maven maven-resolver-provider org.apache.maven maven-repository-metadata org.apache.maven.resolver maven-resolver-api org.apache.maven.resolver maven-resolver-util org.apache.maven.resolver maven-resolver-impl org.codehaus.plexus plexus-utils org.codehaus.plexus plexus-interpolation org.eclipse.sisu org.eclipse.sisu.plexus org.codehaus.plexus plexus-component-annotations org.apache.maven.wagon wagon-provider-api org.apache.maven.wagon wagon-file test org.apache.maven.resolver maven-resolver-connector-basic test org.apache.maven.resolver maven-resolver-transport-wagon test org.codehaus.plexus plexus-component-metadata org.codehaus.modello modello-maven-plugin 1.0.0 src/main/mdo/profiles.mdo src/main/mdo/paramdoc.mdo maven-maven-3.5.2/maven-compat/src/000077500000000000000000000000001317160430700171135ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/main/000077500000000000000000000000001317160430700200375ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/main/java/000077500000000000000000000000001317160430700207605ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/main/java/org/000077500000000000000000000000001317160430700215475ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/main/java/org/apache/000077500000000000000000000000001317160430700227705ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/main/java/org/apache/maven/000077500000000000000000000000001317160430700240765ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/main/java/org/apache/maven/artifact/000077500000000000000000000000001317160430700256735ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/main/java/org/apache/maven/artifact/ArtifactScopeEnum.java000066400000000000000000000067371317160430700321270ustar00rootroot00000000000000package org.apache.maven.artifact; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ /** * Type safe reincarnation of Artifact scope. Also supplies the {@code DEFAULT_SCOPE} as well * as convenience method to deal with scope relationships. * * @author Oleg Gusakov * */ public enum ArtifactScopeEnum { compile( 1 ), test( 2 ), runtime( 3 ), provided( 4 ), system( 5 ), runtime_plus_system( 6 ); public static final ArtifactScopeEnum DEFAULT_SCOPE = compile; private int id; // Constructor ArtifactScopeEnum( int id ) { this.id = id; } int getId() { return id; } /** * Helper method to simplify null processing */ public static final ArtifactScopeEnum checkScope( ArtifactScopeEnum scope ) { return scope == null ? DEFAULT_SCOPE : scope; } /** * * @return unsafe String representation of this scope. */ public String getScope() { if ( id == 1 ) { return Artifact.SCOPE_COMPILE; } else if ( id == 2 ) { return Artifact.SCOPE_TEST; } else if ( id == 3 ) { return Artifact.SCOPE_RUNTIME; } else if ( id == 4 ) { return Artifact.SCOPE_PROVIDED; } else if ( id == 5 ) { return Artifact.SCOPE_SYSTEM; } else { return Artifact.SCOPE_RUNTIME_PLUS_SYSTEM; } } private static final ArtifactScopeEnum [][][] COMPLIANCY_SETS = { { { compile }, { compile, provided, system } } , { { test }, { compile, test, provided, system } } , { { runtime }, { compile, runtime, system } } , { { provided }, { compile, test, provided } } }; /** * scope relationship function. Used by the graph conflict resolution policies * * @param scope * @return true is supplied scope is an inclusive sub-scope of current one. */ public boolean encloses( ArtifactScopeEnum scope ) { final ArtifactScopeEnum s = checkScope( scope ); // system scope is historic only - and simple if ( id == system.id ) { return scope.id == system.id; } for ( ArtifactScopeEnum[][] set : COMPLIANCY_SETS ) { if ( id == set[0][0].id ) { for ( ArtifactScopeEnum ase : set[1] ) { if ( s.id == ase.id ) { return true; } } break; } } return false; } } maven-maven-3.5.2/maven-compat/src/main/java/org/apache/maven/artifact/ArtifactStatus.java000066400000000000000000000061601317160430700315020ustar00rootroot00000000000000package org.apache.maven.artifact; /* * 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.util.HashMap; import java.util.Map; /** * Type safe enumeration for the artifact status field. * * @author Brett Porter */ public final class ArtifactStatus implements Comparable { /** * No trust - no information about status. */ public static final ArtifactStatus NONE = new ArtifactStatus( "none", 0 ); /** * No trust - information was generated with defaults. */ public static final ArtifactStatus GENERATED = new ArtifactStatus( "generated", 1 ); /** * Low trust - was converted from the Maven 1.x repository. */ public static final ArtifactStatus CONVERTED = new ArtifactStatus( "converted", 2 ); /** * Moderate trust - it was deployed directly from a partner. */ public static final ArtifactStatus PARTNER = new ArtifactStatus( "partner", 3 ); /** * Moderate trust - it was deployed directly by a user. */ public static final ArtifactStatus DEPLOYED = new ArtifactStatus( "deployed", 4 ); /** * Trusted, as it has had its data verified by hand. */ public static final ArtifactStatus VERIFIED = new ArtifactStatus( "verified", 5 ); private final int rank; private final String key; private static Map map; private ArtifactStatus( String key, int rank ) { this.rank = rank; this.key = key; if ( map == null ) { map = new HashMap<>(); } map.put( key, this ); } public static ArtifactStatus valueOf( String status ) { ArtifactStatus retVal = null; if ( status != null ) { retVal = map.get( status ); } return retVal != null ? retVal : NONE; } public boolean equals( Object o ) { if ( this == o ) { return true; } if ( o == null || getClass() != o.getClass() ) { return false; } final ArtifactStatus that = (ArtifactStatus) o; return rank == that.rank; } public int hashCode() { return rank; } public String toString() { return key; } public int compareTo( ArtifactStatus s ) { return rank - s.rank; } } UnknownRepositoryLayoutException.java000066400000000000000000000035271317160430700353020ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/main/java/org/apache/maven/artifactpackage org.apache.maven.artifact; /* * 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 org.codehaus.plexus.component.repository.exception.ComponentLookupException; /** * Exception which is meant to occur when a layout specified for a particular * repository doesn't have a corresponding {@link org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout} * component in the current container. * * @author jdcasey */ public class UnknownRepositoryLayoutException extends InvalidRepositoryException { private final String layoutId; public UnknownRepositoryLayoutException( String repositoryId, String layoutId ) { super( "Cannot find ArtifactRepositoryLayout instance for: " + layoutId, repositoryId ); this.layoutId = layoutId; } public UnknownRepositoryLayoutException( String repositoryId, String layoutId, ComponentLookupException e ) { super( "Cannot find ArtifactRepositoryLayout instance for: " + layoutId, repositoryId, e ); this.layoutId = layoutId; } public String getLayoutId() { return layoutId; } } maven-maven-3.5.2/maven-compat/src/main/java/org/apache/maven/artifact/deployer/000077500000000000000000000000001317160430700275165ustar00rootroot00000000000000ArtifactDeployer.java000066400000000000000000000047561317160430700335570ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/main/java/org/apache/maven/artifact/deployerpackage org.apache.maven.artifact.deployer; /* * 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.File; import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.repository.ArtifactRepository; public interface ArtifactDeployer { String ROLE = ArtifactDeployer.class.getName(); /** * Deploy an artifact from a particular directory. The artifact handler is used to determine the * filename of the source file. * * @param basedir the directory where the artifact is stored * @param finalName the name of the artifact without extension * @param artifact the artifact definition * @param deploymentRepository the repository to deploy to * @param localRepository the local repository to install into * @throws ArtifactDeploymentException if an error occurred deploying the artifact * @deprecated to be removed before 2.0 after the install/deploy plugins use the alternate * method */ @Deprecated void deploy( String basedir, String finalName, Artifact artifact, ArtifactRepository deploymentRepository, ArtifactRepository localRepository ) throws ArtifactDeploymentException; /** * Deploy an artifact from a particular file. * * @param source the file to deploy * @param artifact the artifact definition * @param deploymentRepository the repository to deploy to * @param localRepository the local repository to install into * @throws ArtifactDeploymentException if an error occurred deploying the artifact */ void deploy( File source, Artifact artifact, ArtifactRepository deploymentRepository, ArtifactRepository localRepository ) throws ArtifactDeploymentException; } ArtifactDeploymentException.java000066400000000000000000000024271317160430700357640ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/main/java/org/apache/maven/artifact/deployerpackage org.apache.maven.artifact.deployer; /* * 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 Jason van Zyl */ public class ArtifactDeploymentException extends Exception { public ArtifactDeploymentException( String message ) { super( message ); } public ArtifactDeploymentException( Throwable cause ) { super( cause ); } public ArtifactDeploymentException( String message, Throwable cause ) { super( message, cause ); } } DefaultArtifactDeployer.java000066400000000000000000000153141317160430700350540ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/main/java/org/apache/maven/artifact/deployerpackage org.apache.maven.artifact.deployer; /* * 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.File; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; import org.apache.maven.RepositoryUtils; import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.metadata.ArtifactMetadata; import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.repository.DefaultArtifactRepository; import org.apache.maven.artifact.repository.LegacyLocalRepositoryManager; import org.apache.maven.artifact.repository.metadata.ArtifactRepositoryMetadata; import org.apache.maven.artifact.repository.metadata.MetadataBridge; import org.apache.maven.artifact.repository.metadata.SnapshotArtifactRepositoryMetadata; import org.apache.maven.plugin.LegacySupport; import org.apache.maven.project.artifact.ProjectArtifactMetadata; import org.codehaus.plexus.component.annotations.Component; import org.codehaus.plexus.component.annotations.Requirement; import org.codehaus.plexus.logging.AbstractLogEnabled; import org.eclipse.aether.RepositorySystem; import org.eclipse.aether.RepositorySystemSession; import org.eclipse.aether.RequestTrace; import org.eclipse.aether.deployment.DeployRequest; import org.eclipse.aether.deployment.DeployResult; import org.eclipse.aether.deployment.DeploymentException; import org.eclipse.aether.metadata.MergeableMetadata; import org.eclipse.aether.repository.RemoteRepository; import org.eclipse.aether.util.artifact.SubArtifact; @Component( role = ArtifactDeployer.class, instantiationStrategy = "per-lookup" ) public class DefaultArtifactDeployer extends AbstractLogEnabled implements ArtifactDeployer { @Requirement private RepositorySystem repoSystem; @Requirement private LegacySupport legacySupport; private Map relatedMetadata = new ConcurrentHashMap<>(); /** * @deprecated we want to use the artifact method only, and ensure artifact.file is set * correctly. */ @Deprecated public void deploy( String basedir, String finalName, Artifact artifact, ArtifactRepository deploymentRepository, ArtifactRepository localRepository ) throws ArtifactDeploymentException { String extension = artifact.getArtifactHandler().getExtension(); File source = new File( basedir, finalName + "." + extension ); deploy( source, artifact, deploymentRepository, localRepository ); } public void deploy( File source, Artifact artifact, ArtifactRepository deploymentRepository, ArtifactRepository localRepository ) throws ArtifactDeploymentException { RepositorySystemSession session = LegacyLocalRepositoryManager.overlay( localRepository, legacySupport.getRepositorySession(), repoSystem ); DeployRequest request = new DeployRequest(); request.setTrace( RequestTrace.newChild( null, legacySupport.getSession().getCurrentProject() ) ); org.eclipse.aether.artifact.Artifact mainArtifact = RepositoryUtils.toArtifact( artifact ); mainArtifact = mainArtifact.setFile( source ); request.addArtifact( mainArtifact ); String versionKey = artifact.getGroupId() + ':' + artifact.getArtifactId(); String snapshotKey = null; if ( artifact.isSnapshot() ) { snapshotKey = versionKey + ':' + artifact.getBaseVersion(); request.addMetadata( relatedMetadata.get( snapshotKey ) ); } request.addMetadata( relatedMetadata.get( versionKey ) ); for ( ArtifactMetadata metadata : artifact.getMetadataList() ) { if ( metadata instanceof ProjectArtifactMetadata ) { org.eclipse.aether.artifact.Artifact pomArtifact = new SubArtifact( mainArtifact, "", "pom" ); pomArtifact = pomArtifact.setFile( ( (ProjectArtifactMetadata) metadata ).getFile() ); request.addArtifact( pomArtifact ); } else if ( metadata instanceof SnapshotArtifactRepositoryMetadata || metadata instanceof ArtifactRepositoryMetadata ) { // eaten, handled by repo system } else { request.addMetadata( new MetadataBridge( metadata ) ); } } RemoteRepository remoteRepo = RepositoryUtils.toRepo( deploymentRepository ); /* * NOTE: This provides backward-compat with maven-deploy-plugin:2.4 which bypasses the repository factory when * using an alternative deployment location. */ if ( deploymentRepository instanceof DefaultArtifactRepository && deploymentRepository.getAuthentication() == null ) { RemoteRepository.Builder builder = new RemoteRepository.Builder( remoteRepo ); builder.setAuthentication( session.getAuthenticationSelector().getAuthentication( remoteRepo ) ); builder.setProxy( session.getProxySelector().getProxy( remoteRepo ) ); remoteRepo = builder.build(); } request.setRepository( remoteRepo ); DeployResult result; try { result = repoSystem.deploy( session, request ); } catch ( DeploymentException e ) { throw new ArtifactDeploymentException( e.getMessage(), e ); } for ( Object metadata : result.getMetadata() ) { if ( metadata.getClass().getName().endsWith( ".internal.VersionsMetadata" ) ) { relatedMetadata.put( versionKey, (MergeableMetadata) metadata ); } if ( snapshotKey != null && metadata.getClass().getName().endsWith( ".internal.RemoteSnapshotMetadata" ) ) { relatedMetadata.put( snapshotKey, (MergeableMetadata) metadata ); } } artifact.setResolvedVersion( result.getArtifacts().iterator().next().getVersion() ); } } maven-maven-3.5.2/maven-compat/src/main/java/org/apache/maven/artifact/installer/000077500000000000000000000000001317160430700276705ustar00rootroot00000000000000ArtifactInstallationException.java000066400000000000000000000025071317160430700364560ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/main/java/org/apache/maven/artifact/installerpackage org.apache.maven.artifact.installer; /* * 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 Jason van Zyl */ public class ArtifactInstallationException extends Exception { public ArtifactInstallationException( String message ) { super( message ); } public ArtifactInstallationException( Throwable cause ) { super( cause ); } public ArtifactInstallationException( String message, Throwable cause ) { super( message, cause ); } } ArtifactInstaller.java000066400000000000000000000045161317160430700340750ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/main/java/org/apache/maven/artifact/installerpackage org.apache.maven.artifact.installer; /* * 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.File; import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.repository.ArtifactRepository; /** * @author Michal Maczka */ public interface ArtifactInstaller { String ROLE = ArtifactInstaller.class.getName(); /** * Install an artifact from a particular directory. The artifact handler is used to determine * the filename of the source file. * * @param basedir the directory where the artifact is stored * @param finalName the name of the artifact sans extension * @param artifact the artifact definition * @param localRepository the local repository to install into * @throws ArtifactInstallationException if an error occurred installing the artifact * @deprecated to be removed before 2.0 after the install/deploy plugins use the alternate * method */ @Deprecated void install( String basedir, String finalName, Artifact artifact, ArtifactRepository localRepository ) throws ArtifactInstallationException; /** * Install an artifact from a particular file. * * @param source the file to install * @param artifact the artifact definition * @param localRepository the local repository to install into * @throws ArtifactInstallationException if an error occurred installing the artifact */ void install( File source, Artifact artifact, ArtifactRepository localRepository ) throws ArtifactInstallationException; } DefaultArtifactInstaller.java000066400000000000000000000123451317160430700354010ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/main/java/org/apache/maven/artifact/installerpackage org.apache.maven.artifact.installer; /* * 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.File; import org.apache.maven.RepositoryUtils; import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.metadata.ArtifactMetadata; import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.repository.LegacyLocalRepositoryManager; import org.apache.maven.artifact.repository.metadata.ArtifactRepositoryMetadata; import org.apache.maven.artifact.repository.metadata.MetadataBridge; import org.apache.maven.artifact.repository.metadata.Snapshot; import org.apache.maven.artifact.repository.metadata.SnapshotArtifactRepositoryMetadata; import org.apache.maven.artifact.repository.metadata.Versioning; import org.apache.maven.plugin.LegacySupport; import org.apache.maven.project.artifact.ProjectArtifactMetadata; import org.codehaus.plexus.component.annotations.Component; import org.codehaus.plexus.component.annotations.Requirement; import org.codehaus.plexus.logging.AbstractLogEnabled; import org.eclipse.aether.RepositorySystem; import org.eclipse.aether.RepositorySystemSession; import org.eclipse.aether.RequestTrace; import org.eclipse.aether.installation.InstallRequest; import org.eclipse.aether.installation.InstallationException; import org.eclipse.aether.util.artifact.SubArtifact; /** * @author Jason van Zyl */ @Component( role = ArtifactInstaller.class ) public class DefaultArtifactInstaller extends AbstractLogEnabled implements ArtifactInstaller { @Requirement private RepositorySystem repoSystem; @Requirement private LegacySupport legacySupport; /** @deprecated we want to use the artifact method only, and ensure artifact.file is set correctly. */ @Deprecated public void install( String basedir, String finalName, Artifact artifact, ArtifactRepository localRepository ) throws ArtifactInstallationException { String extension = artifact.getArtifactHandler().getExtension(); File source = new File( basedir, finalName + "." + extension ); install( source, artifact, localRepository ); } public void install( File source, Artifact artifact, ArtifactRepository localRepository ) throws ArtifactInstallationException { RepositorySystemSession session = LegacyLocalRepositoryManager.overlay( localRepository, legacySupport.getRepositorySession(), repoSystem ); InstallRequest request = new InstallRequest(); request.setTrace( RequestTrace.newChild( null, legacySupport.getSession().getCurrentProject() ) ); org.eclipse.aether.artifact.Artifact mainArtifact = RepositoryUtils.toArtifact( artifact ); mainArtifact = mainArtifact.setFile( source ); request.addArtifact( mainArtifact ); for ( ArtifactMetadata metadata : artifact.getMetadataList() ) { if ( metadata instanceof ProjectArtifactMetadata ) { org.eclipse.aether.artifact.Artifact pomArtifact = new SubArtifact( mainArtifact, "", "pom" ); pomArtifact = pomArtifact.setFile( ( (ProjectArtifactMetadata) metadata ).getFile() ); request.addArtifact( pomArtifact ); } else if ( metadata instanceof SnapshotArtifactRepositoryMetadata || metadata instanceof ArtifactRepositoryMetadata ) { // eaten, handled by repo system } else { request.addMetadata( new MetadataBridge( metadata ) ); } } try { repoSystem.install( session, request ); } catch ( InstallationException e ) { throw new ArtifactInstallationException( e.getMessage(), e ); } /* * NOTE: Not used by Maven core, only here to provide backward-compat with plugins like the Install Plugin. */ if ( artifact.isSnapshot() ) { Snapshot snapshot = new Snapshot(); snapshot.setLocalCopy( true ); artifact.addMetadata( new SnapshotArtifactRepositoryMetadata( artifact, snapshot ) ); } Versioning versioning = new Versioning(); versioning.updateTimestamp(); versioning.addVersion( artifact.getBaseVersion() ); if ( artifact.isRelease() ) { versioning.setRelease( artifact.getBaseVersion() ); } artifact.addMetadata( new ArtifactRepositoryMetadata( artifact, versioning ) ); } } maven-maven-3.5.2/maven-compat/src/main/java/org/apache/maven/artifact/manager/000077500000000000000000000000001317160430700273055ustar00rootroot00000000000000DefaultWagonManager.java000066400000000000000000000153361317160430700337540ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/main/java/org/apache/maven/artifact/managerpackage org.apache.maven.artifact.manager; /* * 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.util.List; import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.repository.ArtifactRepositoryFactory; import org.apache.maven.execution.MavenExecutionRequest; import org.apache.maven.execution.MavenSession; import org.apache.maven.plugin.LegacySupport; import org.apache.maven.repository.MirrorSelector; import org.apache.maven.settings.Mirror; import org.apache.maven.settings.Proxy; import org.apache.maven.settings.Server; import org.apache.maven.settings.crypto.DefaultSettingsDecryptionRequest; import org.apache.maven.settings.crypto.SettingsDecrypter; import org.apache.maven.settings.crypto.SettingsDecryptionResult; import org.apache.maven.wagon.ResourceDoesNotExistException; import org.apache.maven.wagon.TransferFailedException; import org.apache.maven.wagon.authentication.AuthenticationInfo; import org.apache.maven.wagon.proxy.ProxyInfo; import org.codehaus.plexus.component.annotations.Component; import org.codehaus.plexus.component.annotations.Requirement; import org.codehaus.plexus.logging.Logger; @Component( role = WagonManager.class ) public class DefaultWagonManager extends org.apache.maven.repository.legacy.DefaultWagonManager implements WagonManager { // NOTE: This must use a different field name than in the super class or IoC has no chance to inject the loggers @Requirement private Logger log; @Requirement private LegacySupport legacySupport; @Requirement private SettingsDecrypter settingsDecrypter; @Requirement private MirrorSelector mirrorSelector; @Requirement private ArtifactRepositoryFactory artifactRepositoryFactory; public AuthenticationInfo getAuthenticationInfo( String id ) { MavenSession session = legacySupport.getSession(); if ( session != null && id != null ) { MavenExecutionRequest request = session.getRequest(); if ( request != null ) { List servers = request.getServers(); if ( servers != null ) { for ( Server server : servers ) { if ( id.equalsIgnoreCase( server.getId() ) ) { SettingsDecryptionResult result = settingsDecrypter.decrypt( new DefaultSettingsDecryptionRequest( server ) ); server = result.getServer(); AuthenticationInfo authInfo = new AuthenticationInfo(); authInfo.setUserName( server.getUsername() ); authInfo.setPassword( server.getPassword() ); authInfo.setPrivateKey( server.getPrivateKey() ); authInfo.setPassphrase( server.getPassphrase() ); return authInfo; } } } } } // empty one to prevent NPE return new AuthenticationInfo(); } public ProxyInfo getProxy( String protocol ) { MavenSession session = legacySupport.getSession(); if ( session != null && protocol != null ) { MavenExecutionRequest request = session.getRequest(); if ( request != null ) { List proxies = request.getProxies(); if ( proxies != null ) { for ( Proxy proxy : proxies ) { if ( proxy.isActive() && protocol.equalsIgnoreCase( proxy.getProtocol() ) ) { SettingsDecryptionResult result = settingsDecrypter.decrypt( new DefaultSettingsDecryptionRequest( proxy ) ); proxy = result.getProxy(); ProxyInfo proxyInfo = new ProxyInfo(); proxyInfo.setHost( proxy.getHost() ); proxyInfo.setType( proxy.getProtocol() ); proxyInfo.setPort( proxy.getPort() ); proxyInfo.setNonProxyHosts( proxy.getNonProxyHosts() ); proxyInfo.setUserName( proxy.getUsername() ); proxyInfo.setPassword( proxy.getPassword() ); return proxyInfo; } } } } } return null; } public void getArtifact( Artifact artifact, ArtifactRepository repository ) throws TransferFailedException, ResourceDoesNotExistException { getArtifact( artifact, repository, null, false ); } public void getArtifact( Artifact artifact, List remoteRepositories ) throws TransferFailedException, ResourceDoesNotExistException { getArtifact( artifact, remoteRepositories, null, false ); } @Deprecated public ArtifactRepository getMirrorRepository( ArtifactRepository repository ) { Mirror mirror = mirrorSelector.getMirror( repository, legacySupport.getSession().getSettings().getMirrors() ); if ( mirror != null ) { String id = mirror.getId(); if ( id == null ) { // TODO this should be illegal in settings.xml id = repository.getId(); } log.debug( "Using mirror: " + mirror.getUrl() + " (id: " + id + ")" ); repository = artifactRepositoryFactory.createArtifactRepository( id, mirror.getUrl(), repository.getLayout(), repository.getSnapshots(), repository.getReleases() ); } return repository; } } WagonConfigurationException.java000066400000000000000000000024261317160430700355570ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/main/java/org/apache/maven/artifact/managerpackage org.apache.maven.artifact.manager; /* * 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 Olivier Lamy */ @Deprecated public class WagonConfigurationException extends org.apache.maven.repository.legacy.WagonConfigurationException { public WagonConfigurationException( String repositoryId, String message, Throwable cause ) { super( repositoryId, message, cause ); } public WagonConfigurationException( String repositoryId, String message ) { super( repositoryId, message ); } } maven-maven-3.5.2/maven-compat/src/main/java/org/apache/maven/artifact/manager/WagonManager.java000066400000000000000000000041471317160430700325240ustar00rootroot00000000000000package org.apache.maven.artifact.manager; /* * 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.util.List; import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.wagon.ResourceDoesNotExistException; import org.apache.maven.wagon.TransferFailedException; import org.apache.maven.wagon.authentication.AuthenticationInfo; import org.apache.maven.wagon.proxy.ProxyInfo; /** * Manages Wagon related operations in Maven. * * @author Michal Maczka */ @Deprecated public interface WagonManager extends org.apache.maven.repository.legacy.WagonManager { /** * this method is only here for backward compat (project-info-reports:dependencies) * the default implementation will return an empty AuthenticationInfo */ AuthenticationInfo getAuthenticationInfo( String id ); ProxyInfo getProxy( String protocol ); void getArtifact( Artifact artifact, ArtifactRepository repository ) throws TransferFailedException, ResourceDoesNotExistException; void getArtifact( Artifact artifact, List remoteRepositories ) throws TransferFailedException, ResourceDoesNotExistException; ArtifactRepository getMirrorRepository( ArtifactRepository repository ); } maven-maven-3.5.2/maven-compat/src/main/java/org/apache/maven/artifact/repository/000077500000000000000000000000001317160430700301125ustar00rootroot00000000000000ArtifactRepositoryFactory.java000066400000000000000000000047761317160430700361010ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/main/java/org/apache/maven/artifact/repositorypackage org.apache.maven.artifact.repository; /* * 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 org.apache.maven.artifact.UnknownRepositoryLayoutException; import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout; /** * @author jdcasey */ public interface ArtifactRepositoryFactory { String ROLE = ArtifactRepositoryFactory.class.getName(); String DEFAULT_LAYOUT_ID = "default"; String LOCAL_REPOSITORY_ID = "local"; @Deprecated ArtifactRepositoryLayout getLayout( String layoutId ) throws UnknownRepositoryLayoutException; @Deprecated ArtifactRepository createDeploymentArtifactRepository( String id, String url, String layoutId, boolean uniqueVersion ) throws UnknownRepositoryLayoutException; ArtifactRepository createDeploymentArtifactRepository( String id, String url, ArtifactRepositoryLayout layout, boolean uniqueVersion ); ArtifactRepository createArtifactRepository( String id, String url, String layoutId, ArtifactRepositoryPolicy snapshots, ArtifactRepositoryPolicy releases ) throws UnknownRepositoryLayoutException; ArtifactRepository createArtifactRepository( String id, String url, ArtifactRepositoryLayout repositoryLayout, ArtifactRepositoryPolicy snapshots, ArtifactRepositoryPolicy releases ); void setGlobalUpdatePolicy( String snapshotPolicy ); void setGlobalChecksumPolicy( String checksumPolicy ); } DefaultArtifactRepository.java000066400000000000000000000165731317160430700360540ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/main/java/org/apache/maven/artifact/repositorypackage org.apache.maven.artifact.repository; /* * 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.File; import java.util.Collections; import java.util.List; import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.metadata.ArtifactMetadata; import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout; import org.apache.maven.repository.Proxy; import org.apache.maven.wagon.repository.Repository; /** * This class is an abstraction of the location from/to resources can be * transfered. * * @author Michal Maczka */ @Deprecated public class DefaultArtifactRepository extends Repository implements ArtifactRepository { private ArtifactRepositoryLayout layout; private ArtifactRepositoryPolicy snapshots; private ArtifactRepositoryPolicy releases; private boolean blacklisted; private Authentication authentication; private Proxy proxy; private List mirroredRepositories = Collections.emptyList(); /** * Create a local repository or a test repository. * * @param id the unique identifier of the repository * @param url the URL of the repository * @param layout the layout of the repository */ public DefaultArtifactRepository( String id, String url, ArtifactRepositoryLayout layout ) { this( id, url, layout, null, null ); } /** * Create a remote deployment repository. * * @param id the unique identifier of the repository * @param url the URL of the repository * @param layout the layout of the repository * @param uniqueVersion whether to assign each snapshot a unique version */ public DefaultArtifactRepository( String id, String url, ArtifactRepositoryLayout layout, boolean uniqueVersion ) { super( id, url ); this.layout = layout; } /** * Create a remote download repository. * * @param id the unique identifier of the repository * @param url the URL of the repository * @param layout the layout of the repository * @param snapshots the policies to use for snapshots * @param releases the policies to use for releases */ public DefaultArtifactRepository( String id, String url, ArtifactRepositoryLayout layout, ArtifactRepositoryPolicy snapshots, ArtifactRepositoryPolicy releases ) { super( id, url ); this.layout = layout; if ( snapshots == null ) { snapshots = new ArtifactRepositoryPolicy( true, ArtifactRepositoryPolicy.UPDATE_POLICY_ALWAYS, ArtifactRepositoryPolicy.CHECKSUM_POLICY_IGNORE ); } this.snapshots = snapshots; if ( releases == null ) { releases = new ArtifactRepositoryPolicy( true, ArtifactRepositoryPolicy.UPDATE_POLICY_ALWAYS, ArtifactRepositoryPolicy.CHECKSUM_POLICY_IGNORE ); } this.releases = releases; } public String pathOf( Artifact artifact ) { return layout.pathOf( artifact ); } public String pathOfRemoteRepositoryMetadata( ArtifactMetadata artifactMetadata ) { return layout.pathOfRemoteRepositoryMetadata( artifactMetadata ); } public String pathOfLocalRepositoryMetadata( ArtifactMetadata metadata, ArtifactRepository repository ) { return layout.pathOfLocalRepositoryMetadata( metadata, repository ); } public void setLayout( ArtifactRepositoryLayout layout ) { this.layout = layout; } public ArtifactRepositoryLayout getLayout() { return layout; } public void setSnapshotUpdatePolicy( ArtifactRepositoryPolicy snapshots ) { this.snapshots = snapshots; } public ArtifactRepositoryPolicy getSnapshots() { return snapshots; } public void setReleaseUpdatePolicy( ArtifactRepositoryPolicy releases ) { this.releases = releases; } public ArtifactRepositoryPolicy getReleases() { return releases; } public String getKey() { return getId(); } public boolean isBlacklisted() { return blacklisted; } public void setBlacklisted( boolean blacklisted ) { this.blacklisted = blacklisted; } public String toString() { StringBuilder sb = new StringBuilder( 256 ); sb.append( " id: " ).append( getId() ).append( '\n' ); sb.append( " url: " ).append( getUrl() ).append( '\n' ); sb.append( " layout: " ).append( layout != null ? layout : "none" ).append( '\n' ); if ( snapshots != null ) { sb.append( "snapshots: [enabled => " ).append( snapshots.isEnabled() ); sb.append( ", update => " ).append( snapshots.getUpdatePolicy() ).append( "]\n" ); } if ( releases != null ) { sb.append( " releases: [enabled => " ).append( releases.isEnabled() ); sb.append( ", update => " ).append( releases.getUpdatePolicy() ).append( "]\n" ); } return sb.toString(); } public Artifact find( Artifact artifact ) { File artifactFile = new File( getBasedir(), pathOf( artifact ) ); // We need to set the file here or the resolver will fail with an NPE, not fully equipped to deal // with multiple local repository implementations yet. artifact.setFile( artifactFile ); if ( artifactFile.exists() ) { artifact.setResolved( true ); } return artifact; } public List findVersions( Artifact artifact ) { return Collections.emptyList(); } public boolean isProjectAware() { return false; } public Authentication getAuthentication() { return authentication; } public void setAuthentication( Authentication authentication ) { this.authentication = authentication; } public Proxy getProxy() { return proxy; } public void setProxy( Proxy proxy ) { this.proxy = proxy; } public boolean isUniqueVersion() { return true; } public List getMirroredRepositories() { return mirroredRepositories; } public void setMirroredRepositories( List mirroredRepositories ) { if ( mirroredRepositories != null ) { this.mirroredRepositories = mirroredRepositories; } else { this.mirroredRepositories = Collections.emptyList(); } } } DefaultArtifactRepositoryFactory.java000066400000000000000000000114421317160430700373720ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/main/java/org/apache/maven/artifact/repositorypackage org.apache.maven.artifact.repository; /* * 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.util.Arrays; import java.util.List; import org.apache.maven.artifact.UnknownRepositoryLayoutException; import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout; import org.apache.maven.plugin.LegacySupport; import org.apache.maven.repository.RepositorySystem; import org.codehaus.plexus.component.annotations.Component; import org.codehaus.plexus.component.annotations.Requirement; import org.eclipse.aether.RepositorySystemSession; /** * @author jdcasey */ @Component( role = ArtifactRepositoryFactory.class ) public class DefaultArtifactRepositoryFactory implements ArtifactRepositoryFactory { @Requirement private org.apache.maven.repository.legacy.repository.ArtifactRepositoryFactory factory; @Requirement private LegacySupport legacySupport; @Requirement private RepositorySystem repositorySystem; public ArtifactRepositoryLayout getLayout( String layoutId ) throws UnknownRepositoryLayoutException { return factory.getLayout( layoutId ); } public ArtifactRepository createDeploymentArtifactRepository( String id, String url, String layoutId, boolean uniqueVersion ) throws UnknownRepositoryLayoutException { return injectSession( factory.createDeploymentArtifactRepository( id, url, layoutId, uniqueVersion ), false ); } public ArtifactRepository createDeploymentArtifactRepository( String id, String url, ArtifactRepositoryLayout repositoryLayout, boolean uniqueVersion ) { return injectSession( factory.createDeploymentArtifactRepository( id, url, repositoryLayout, uniqueVersion ), false ); } public ArtifactRepository createArtifactRepository( String id, String url, String layoutId, ArtifactRepositoryPolicy snapshots, ArtifactRepositoryPolicy releases ) throws UnknownRepositoryLayoutException { return injectSession( factory.createArtifactRepository( id, url, layoutId, snapshots, releases ), true ); } public ArtifactRepository createArtifactRepository( String id, String url, ArtifactRepositoryLayout repositoryLayout, ArtifactRepositoryPolicy snapshots, ArtifactRepositoryPolicy releases ) { return injectSession( factory.createArtifactRepository( id, url, repositoryLayout, snapshots, releases ), true ); } public void setGlobalUpdatePolicy( String updatePolicy ) { factory.setGlobalUpdatePolicy( updatePolicy ); } public void setGlobalChecksumPolicy( String checksumPolicy ) { factory.setGlobalChecksumPolicy( checksumPolicy ); } private ArtifactRepository injectSession( ArtifactRepository repository, boolean mirrors ) { RepositorySystemSession session = legacySupport.getRepositorySession(); if ( session != null && repository != null && !isLocalRepository( repository ) ) { List repositories = Arrays.asList( repository ); if ( mirrors ) { repositorySystem.injectMirror( session, repositories ); } repositorySystem.injectProxy( session, repositories ); repositorySystem.injectAuthentication( session, repositories ); } return repository; } private boolean isLocalRepository( ArtifactRepository repository ) { // unfortunately, the API doesn't allow to tell a remote repo and the local repo apart... return "local".equals( repository.getId() ); } } maven-maven-3.5.2/maven-compat/src/main/java/org/apache/maven/artifact/repository/layout/000077500000000000000000000000001317160430700314275ustar00rootroot00000000000000FlatRepositoryLayout.java000066400000000000000000000053541317160430700364060ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/main/java/org/apache/maven/artifact/repository/layoutpackage org.apache.maven.artifact.repository.layout; /* * 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 org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.handler.ArtifactHandler; import org.apache.maven.artifact.metadata.ArtifactMetadata; import org.apache.maven.artifact.repository.ArtifactRepository; import org.codehaus.plexus.component.annotations.Component; @Component( role = ArtifactRepositoryLayout.class, hint = "flat" ) public class FlatRepositoryLayout implements ArtifactRepositoryLayout { private static final char ARTIFACT_SEPARATOR = '-'; private static final char GROUP_SEPARATOR = '.'; public String getId() { return "flat"; } public String pathOf( Artifact artifact ) { ArtifactHandler artifactHandler = artifact.getArtifactHandler(); StringBuilder path = new StringBuilder( 128 ); path.append( artifact.getArtifactId() ).append( ARTIFACT_SEPARATOR ).append( artifact.getVersion() ); if ( artifact.hasClassifier() ) { path.append( ARTIFACT_SEPARATOR ).append( artifact.getClassifier() ); } if ( artifactHandler.getExtension() != null && artifactHandler.getExtension().length() > 0 ) { path.append( GROUP_SEPARATOR ).append( artifactHandler.getExtension() ); } return path.toString(); } public String pathOfLocalRepositoryMetadata( ArtifactMetadata metadata, ArtifactRepository repository ) { return pathOfRepositoryMetadata( metadata.getLocalFilename( repository ) ); } private String pathOfRepositoryMetadata( String filename ) { StringBuilder path = new StringBuilder( 128 ); path.append( filename ); return path.toString(); } public String pathOfRemoteRepositoryMetadata( ArtifactMetadata metadata ) { return pathOfRepositoryMetadata( metadata.getRemoteFilename() ); } @Override public String toString() { return getId(); } } maven-maven-3.5.2/maven-compat/src/main/java/org/apache/maven/artifact/repository/metadata/000077500000000000000000000000001317160430700316725ustar00rootroot00000000000000DefaultRepositoryMetadataManager.java000066400000000000000000000512621317160430700411040ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/main/java/org/apache/maven/artifact/repository/metadatapackage org.apache.maven.artifact.repository.metadata; /* * 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 org.apache.maven.artifact.metadata.ArtifactMetadata; import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.repository.ArtifactRepositoryPolicy; import org.apache.maven.artifact.repository.DefaultRepositoryRequest; import org.apache.maven.artifact.repository.RepositoryRequest; import org.apache.maven.artifact.repository.metadata.io.xpp3.MetadataXpp3Reader; import org.apache.maven.artifact.repository.metadata.io.xpp3.MetadataXpp3Writer; import org.apache.maven.repository.legacy.UpdateCheckManager; import org.apache.maven.repository.legacy.WagonManager; import org.apache.maven.wagon.ResourceDoesNotExistException; import org.apache.maven.wagon.TransferFailedException; import org.codehaus.plexus.component.annotations.Component; import org.codehaus.plexus.component.annotations.Requirement; import org.codehaus.plexus.logging.AbstractLogEnabled; import org.codehaus.plexus.util.ReaderFactory; import org.codehaus.plexus.util.WriterFactory; import org.codehaus.plexus.util.xml.pull.XmlPullParserException; import java.io.File; import java.io.FileNotFoundException; import java.io.IOException; import java.io.Reader; import java.io.Writer; import java.util.Date; import java.util.HashMap; import java.util.List; import java.util.Map; /** * @author Jason van Zyl */ @Component( role = RepositoryMetadataManager.class ) public class DefaultRepositoryMetadataManager extends AbstractLogEnabled implements RepositoryMetadataManager { @Requirement private WagonManager wagonManager; @Requirement private UpdateCheckManager updateCheckManager; public void resolve( RepositoryMetadata metadata, List remoteRepositories, ArtifactRepository localRepository ) throws RepositoryMetadataResolutionException { RepositoryRequest request = new DefaultRepositoryRequest(); request.setLocalRepository( localRepository ); request.setRemoteRepositories( remoteRepositories ); resolve( metadata, request ); } public void resolve( RepositoryMetadata metadata, RepositoryRequest request ) throws RepositoryMetadataResolutionException { ArtifactRepository localRepo = request.getLocalRepository(); List remoteRepositories = request.getRemoteRepositories(); if ( !request.isOffline() ) { Date localCopyLastModified = null; if ( metadata.getBaseVersion() != null ) { localCopyLastModified = getLocalCopyLastModified( localRepo, metadata ); } for ( ArtifactRepository repository : remoteRepositories ) { ArtifactRepositoryPolicy policy = metadata.getPolicy( repository ); File file = new File( localRepo.getBasedir(), localRepo.pathOfLocalRepositoryMetadata( metadata, repository ) ); boolean update; if ( !policy.isEnabled() ) { update = false; if ( getLogger().isDebugEnabled() ) { getLogger().debug( "Skipping update check for " + metadata.getKey() + " (" + file + ") from disabled repository " + repository.getId() + " (" + repository.getUrl() + ")" ); } } else if ( request.isForceUpdate() ) { update = true; } else if ( localCopyLastModified != null && !policy.checkOutOfDate( localCopyLastModified ) ) { update = false; if ( getLogger().isDebugEnabled() ) { getLogger().debug( "Skipping update check for " + metadata.getKey() + " (" + file + ") from repository " + repository.getId() + " (" + repository.getUrl() + ") in favor of local copy" ); } } else { update = updateCheckManager.isUpdateRequired( metadata, repository, file ); } if ( update ) { getLogger().info( metadata.getKey() + ": checking for updates from " + repository.getId() ); try { wagonManager.getArtifactMetadata( metadata, repository, file, policy.getChecksumPolicy() ); } catch ( ResourceDoesNotExistException e ) { getLogger().debug( metadata + " could not be found on repository: " + repository.getId() ); // delete the local copy so the old details aren't used. if ( file.exists() ) { if ( !file.delete() ) { // sleep for 10ms just in case this is windows holding a file lock try { Thread.sleep( 10 ); } catch ( InterruptedException ie ) { // ignore } file.delete(); // if this fails, forget about it } } } catch ( TransferFailedException e ) { getLogger().warn( metadata + " could not be retrieved from repository: " + repository.getId() + " due to an error: " + e.getMessage() ); getLogger().debug( "Exception", e ); } finally { updateCheckManager.touch( metadata, repository, file ); } } // TODO should this be inside the above check? // touch file so that this is not checked again until interval has passed if ( file.exists() ) { file.setLastModified( System.currentTimeMillis() ); } } } try { mergeMetadata( metadata, remoteRepositories, localRepo ); } catch ( RepositoryMetadataStoreException e ) { throw new RepositoryMetadataResolutionException( "Unable to store local copy of metadata: " + e.getMessage(), e ); } } private Date getLocalCopyLastModified( ArtifactRepository localRepository, RepositoryMetadata metadata ) { String metadataPath = localRepository.pathOfLocalRepositoryMetadata( metadata, localRepository ); File metadataFile = new File( localRepository.getBasedir(), metadataPath ); return metadataFile.isFile() ? new Date( metadataFile.lastModified() ) : null; } private void mergeMetadata( RepositoryMetadata metadata, List remoteRepositories, ArtifactRepository localRepository ) throws RepositoryMetadataStoreException { // TODO currently this is first wins, but really we should take the latest by comparing either the // snapshot timestamp, or some other timestamp later encoded into the metadata. // TODO this needs to be repeated here so the merging doesn't interfere with the written metadata // - we'd be much better having a pristine input, and an ongoing metadata for merging instead Map previousMetadata = new HashMap<>(); ArtifactRepository selected = null; for ( ArtifactRepository repository : remoteRepositories ) { ArtifactRepositoryPolicy policy = metadata.getPolicy( repository ); if ( policy.isEnabled() && loadMetadata( metadata, repository, localRepository, previousMetadata ) ) { metadata.setRepository( repository ); selected = repository; } } if ( loadMetadata( metadata, localRepository, localRepository, previousMetadata ) ) { metadata.setRepository( null ); selected = localRepository; } updateSnapshotMetadata( metadata, previousMetadata, selected, localRepository ); } private void updateSnapshotMetadata( RepositoryMetadata metadata, Map previousMetadata, ArtifactRepository selected, ArtifactRepository localRepository ) throws RepositoryMetadataStoreException { // TODO this could be a lot nicer... should really be in the snapshot transformation? if ( metadata.isSnapshot() ) { Metadata prevMetadata = metadata.getMetadata(); for ( ArtifactRepository repository : previousMetadata.keySet() ) { Metadata m = previousMetadata.get( repository ); if ( repository.equals( selected ) ) { if ( m.getVersioning() == null ) { m.setVersioning( new Versioning() ); } if ( m.getVersioning().getSnapshot() == null ) { m.getVersioning().setSnapshot( new Snapshot() ); } } else { if ( ( m.getVersioning() != null ) && ( m.getVersioning().getSnapshot() != null ) && m.getVersioning().getSnapshot().isLocalCopy() ) { m.getVersioning().getSnapshot().setLocalCopy( false ); metadata.setMetadata( m ); metadata.storeInLocalRepository( localRepository, repository ); } } } metadata.setMetadata( prevMetadata ); } } private boolean loadMetadata( RepositoryMetadata repoMetadata, ArtifactRepository remoteRepository, ArtifactRepository localRepository, Map previousMetadata ) { boolean setRepository = false; File metadataFile = new File( localRepository.getBasedir(), localRepository.pathOfLocalRepositoryMetadata( repoMetadata, remoteRepository ) ); if ( metadataFile.exists() ) { Metadata metadata; try { metadata = readMetadata( metadataFile ); } catch ( RepositoryMetadataReadException e ) { if ( getLogger().isDebugEnabled() ) { getLogger().warn( e.getMessage(), e ); } else { getLogger().warn( e.getMessage() ); } return setRepository; } if ( repoMetadata.isSnapshot() && ( previousMetadata != null ) ) { previousMetadata.put( remoteRepository, metadata ); } if ( repoMetadata.getMetadata() != null ) { setRepository = repoMetadata.getMetadata().merge( metadata ); } else { repoMetadata.setMetadata( metadata ); setRepository = true; } } return setRepository; } /** * TODO share with DefaultPluginMappingManager. */ protected Metadata readMetadata( File mappingFile ) throws RepositoryMetadataReadException { Metadata result; try ( Reader reader = ReaderFactory.newXmlReader( mappingFile ) ) { MetadataXpp3Reader mappingReader = new MetadataXpp3Reader(); result = mappingReader.read( reader, false ); } catch ( FileNotFoundException e ) { throw new RepositoryMetadataReadException( "Cannot read metadata from '" + mappingFile + "'", e ); } catch ( IOException | XmlPullParserException e ) { throw new RepositoryMetadataReadException( "Cannot read metadata from '" + mappingFile + "': " + e.getMessage(), e ); } return result; } /** * Ensures the last updated timestamp of the specified metadata does not refer to the future and fixes the local * metadata if necessary to allow proper merging/updating of metadata during deployment. */ private void fixTimestamp( File metadataFile, Metadata metadata, Metadata reference ) { boolean changed = false; if ( metadata != null && reference != null ) { Versioning versioning = metadata.getVersioning(); Versioning versioningRef = reference.getVersioning(); if ( versioning != null && versioningRef != null ) { String lastUpdated = versioning.getLastUpdated(); String now = versioningRef.getLastUpdated(); if ( lastUpdated != null && now != null && now.compareTo( lastUpdated ) < 0 ) { getLogger().warn( "The last updated timestamp in " + metadataFile + " refers to the future (now = " + now + ", lastUpdated = " + lastUpdated + "). Please verify that the clocks of all" + " deploying machines are reasonably synchronized." ); versioning.setLastUpdated( now ); changed = true; } } } if ( changed ) { getLogger().debug( "Repairing metadata in " + metadataFile ); try ( Writer writer = WriterFactory.newXmlWriter( metadataFile ) ) { new MetadataXpp3Writer().write( writer, metadata ); } catch ( IOException e ) { String msg = "Could not write fixed metadata to " + metadataFile + ": " + e.getMessage(); if ( getLogger().isDebugEnabled() ) { getLogger().warn( msg, e ); } else { getLogger().warn( msg ); } } } } public void resolveAlways( RepositoryMetadata metadata, ArtifactRepository localRepository, ArtifactRepository remoteRepository ) throws RepositoryMetadataResolutionException { File file; try { file = getArtifactMetadataFromDeploymentRepository( metadata, localRepository, remoteRepository ); } catch ( TransferFailedException e ) { throw new RepositoryMetadataResolutionException( metadata + " could not be retrieved from repository: " + remoteRepository.getId() + " due to an error: " + e.getMessage(), e ); } try { if ( file.exists() ) { Metadata prevMetadata = readMetadata( file ); metadata.setMetadata( prevMetadata ); } } catch ( RepositoryMetadataReadException e ) { throw new RepositoryMetadataResolutionException( e.getMessage(), e ); } } private File getArtifactMetadataFromDeploymentRepository( ArtifactMetadata metadata, ArtifactRepository localRepo, ArtifactRepository remoteRepository ) throws TransferFailedException { File file = new File( localRepo.getBasedir(), localRepo.pathOfLocalRepositoryMetadata( metadata, remoteRepository ) ); try { wagonManager.getArtifactMetadataFromDeploymentRepository( metadata, remoteRepository, file, ArtifactRepositoryPolicy.CHECKSUM_POLICY_WARN ); } catch ( ResourceDoesNotExistException e ) { getLogger().info( metadata + " could not be found on repository: " + remoteRepository.getId() + ", so will be created" ); // delete the local copy so the old details aren't used. if ( file.exists() ) { if ( !file.delete() ) { // sleep for 10ms just in case this is windows holding a file lock try { Thread.sleep( 10 ); } catch ( InterruptedException ie ) { // ignore } file.delete(); // if this fails, forget about it } } } finally { if ( metadata instanceof RepositoryMetadata ) { updateCheckManager.touch( (RepositoryMetadata) metadata, remoteRepository, file ); } } return file; } public void deploy( ArtifactMetadata metadata, ArtifactRepository localRepository, ArtifactRepository deploymentRepository ) throws RepositoryMetadataDeploymentException { File file; if ( metadata instanceof RepositoryMetadata ) { getLogger().info( "Retrieving previous metadata from " + deploymentRepository.getId() ); try { file = getArtifactMetadataFromDeploymentRepository( metadata, localRepository, deploymentRepository ); } catch ( TransferFailedException e ) { throw new RepositoryMetadataDeploymentException( metadata + " could not be retrieved from repository: " + deploymentRepository.getId() + " due to an error: " + e.getMessage(), e ); } if ( file.isFile() ) { try { fixTimestamp( file, readMetadata( file ), ( (RepositoryMetadata) metadata ).getMetadata() ); } catch ( RepositoryMetadataReadException e ) { // will be reported via storeInlocalRepository } } } else { // It's a POM - we don't need to retrieve it first file = new File( localRepository.getBasedir(), localRepository.pathOfLocalRepositoryMetadata( metadata, deploymentRepository ) ); } try { metadata.storeInLocalRepository( localRepository, deploymentRepository ); } catch ( RepositoryMetadataStoreException e ) { throw new RepositoryMetadataDeploymentException( "Error installing metadata: " + e.getMessage(), e ); } try { wagonManager.putArtifactMetadata( file, metadata, deploymentRepository ); } catch ( TransferFailedException e ) { throw new RepositoryMetadataDeploymentException( "Error while deploying metadata: " + e.getMessage(), e ); } } public void install( ArtifactMetadata metadata, ArtifactRepository localRepository ) throws RepositoryMetadataInstallationException { try { metadata.storeInLocalRepository( localRepository, localRepository ); } catch ( RepositoryMetadataStoreException e ) { throw new RepositoryMetadataInstallationException( "Error installing metadata: " + e.getMessage(), e ); } } } GroupRepositoryMetadata.java000066400000000000000000000056761317160430700373310ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/main/java/org/apache/maven/artifact/repository/metadatapackage org.apache.maven.artifact.repository.metadata; /* * 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 org.apache.maven.artifact.repository.ArtifactRepository; import java.util.Iterator; import java.util.List; /** * Metadata for the group directory of the repository. * * @author Brett Porter */ public class GroupRepositoryMetadata extends AbstractRepositoryMetadata { private final String groupId; public GroupRepositoryMetadata( String groupId ) { super( new Metadata() ); this.groupId = groupId; } public boolean storedInGroupDirectory() { return true; } public boolean storedInArtifactVersionDirectory() { return false; } public String getGroupId() { return groupId; } public String getArtifactId() { return null; } public String getBaseVersion() { return null; } public void addPluginMapping( String goalPrefix, String artifactId ) { addPluginMapping( goalPrefix, artifactId, artifactId ); } public void addPluginMapping( String goalPrefix, String artifactId, String name ) { List plugins = getMetadata().getPlugins(); boolean found = false; for ( Iterator i = plugins.iterator(); i.hasNext() && !found; ) { Plugin plugin = i.next(); if ( plugin.getPrefix().equals( goalPrefix ) ) { found = true; } } if ( !found ) { Plugin plugin = new Plugin(); plugin.setPrefix( goalPrefix ); plugin.setArtifactId( artifactId ); plugin.setName( name ); getMetadata().addPlugin( plugin ); } } public Object getKey() { return groupId; } public boolean isSnapshot() { return false; } public ArtifactRepository getRepository() { return null; } public void setRepository( ArtifactRepository remoteRepository ) { // intentionally blank } } MetadataBridge.java000066400000000000000000000110401317160430700353070ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/main/java/org/apache/maven/artifact/repository/metadatapackage org.apache.maven.artifact.repository.metadata; /* * 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.File; import java.util.Collections; import java.util.Map; import org.apache.maven.artifact.metadata.ArtifactMetadata; import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.repository.DefaultArtifactRepository; import org.codehaus.plexus.util.FileUtils; import org.eclipse.aether.RepositoryException; import org.eclipse.aether.metadata.AbstractMetadata; import org.eclipse.aether.metadata.MergeableMetadata; import org.eclipse.aether.metadata.Metadata; /** * Warning: This is an internal utility class that is only public for technical reasons, it is not part * of the public API. In particular, this class can be changed or deleted without prior notice. * * @author Benjamin Bentmann */ public final class MetadataBridge extends AbstractMetadata implements MergeableMetadata { private ArtifactMetadata metadata; private boolean merged; public MetadataBridge( ArtifactMetadata metadata ) { this.metadata = metadata; } public void merge( File current, File result ) throws RepositoryException { try { if ( current.exists() ) { FileUtils.copyFile( current, result ); } ArtifactRepository localRepo = new MetadataRepository( result ); metadata.storeInLocalRepository( localRepo, localRepo ); merged = true; } catch ( Exception e ) { throw new RepositoryException( e.getMessage(), e ); } } public boolean isMerged() { return merged; } public String getGroupId() { return emptify( metadata.getGroupId() ); } public String getArtifactId() { return metadata.storedInGroupDirectory() ? "" : emptify( metadata.getArtifactId() ); } public String getVersion() { return metadata.storedInArtifactVersionDirectory() ? emptify( metadata.getBaseVersion() ) : ""; } public String getType() { return metadata.getRemoteFilename(); } private String emptify( String string ) { return ( string != null ) ? string : ""; } public File getFile() { return null; } public MetadataBridge setFile( File file ) { return this; } public Nature getNature() { if ( metadata instanceof RepositoryMetadata ) { switch ( ( (RepositoryMetadata) metadata ).getNature() ) { case RepositoryMetadata.RELEASE_OR_SNAPSHOT: return Nature.RELEASE_OR_SNAPSHOT; case RepositoryMetadata.SNAPSHOT: return Nature.SNAPSHOT; default: return Nature.RELEASE; } } else { return Nature.RELEASE; } } public Map getProperties() { return Collections.emptyMap(); } @Override public Metadata setProperties( Map properties ) { return this; } @SuppressWarnings( "deprecation" ) static class MetadataRepository extends DefaultArtifactRepository { private File metadataFile; public MetadataRepository( File metadataFile ) { super( "local", "", null ); this.metadataFile = metadataFile; } @Override public String getBasedir() { return metadataFile.getParent(); } @Override public String pathOfLocalRepositoryMetadata( ArtifactMetadata metadata, ArtifactRepository repository ) { return metadataFile.getName(); } } } MetadataUtils.java000066400000000000000000000021701317160430700352170ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/main/java/org/apache/maven/artifact/repository/metadatapackage org.apache.maven.artifact.repository.metadata; /* * 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. */ /** * Assists in handling repository metadata. * * @author Benjamin Bentmann */ class MetadataUtils { public static Metadata cloneMetadata( Metadata src ) { if ( src == null ) { return null; } return src.clone(); } } RepositoryMetadataReadException.java000066400000000000000000000024671317160430700407620ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/main/java/org/apache/maven/artifact/repository/metadatapackage org.apache.maven.artifact.repository.metadata; /* * 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. */ /** * Problem storing the repository metadata in the local repository. * * @author Brett Porter */ public class RepositoryMetadataReadException extends Exception { public RepositoryMetadataReadException( String message ) { super( message ); } public RepositoryMetadataReadException( String message, Exception e ) { super( message, e ); } } SnapshotArtifactRepositoryMetadata.java000066400000000000000000000052401317160430700414750ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/main/java/org/apache/maven/artifact/repository/metadatapackage org.apache.maven.artifact.repository.metadata; /* * 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 org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.repository.ArtifactRepository; /** * Metadata for the artifact version directory of the repository. * * @author Brett Porter * TODO split instantiation (versioning, plugin mappings) from definition */ public class SnapshotArtifactRepositoryMetadata extends AbstractRepositoryMetadata { private Artifact artifact; public SnapshotArtifactRepositoryMetadata( Artifact artifact ) { super( createMetadata( artifact, null ) ); this.artifact = artifact; } public SnapshotArtifactRepositoryMetadata( Artifact artifact, Snapshot snapshot ) { super( createMetadata( artifact, createVersioning( snapshot ) ) ); this.artifact = artifact; } public boolean storedInGroupDirectory() { return false; } public boolean storedInArtifactVersionDirectory() { return true; } public String getGroupId() { return artifact.getGroupId(); } public String getArtifactId() { return artifact.getArtifactId(); } public String getBaseVersion() { return artifact.getBaseVersion(); } public Object getKey() { return "snapshot " + artifact.getGroupId() + ":" + artifact.getArtifactId() + ":" + artifact.getBaseVersion(); } public boolean isSnapshot() { return artifact.isSnapshot(); } public int getNature() { return isSnapshot() ? SNAPSHOT : RELEASE; } public ArtifactRepository getRepository() { return artifact.getRepository(); } public void setRepository( ArtifactRepository remoteRepository ) { artifact.setRepository( remoteRepository ); } } maven-maven-3.5.2/maven-compat/src/main/java/org/apache/maven/artifact/resolver/000077500000000000000000000000001317160430700275345ustar00rootroot00000000000000ArtifactCollector.java000066400000000000000000000032561317160430700337320ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/main/java/org/apache/maven/artifact/resolverpackage org.apache.maven.artifact.resolver; /* * 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.util.List; import java.util.Set; import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.metadata.ArtifactMetadataSource; import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.resolver.filter.ArtifactFilter; @Deprecated public interface ArtifactCollector extends org.apache.maven.repository.legacy.resolver.LegacyArtifactCollector { @Deprecated ArtifactResolutionResult collect( Set artifacts, Artifact originatingArtifact, ArtifactRepository localRepository, List remoteRepositories, ArtifactMetadataSource source, ArtifactFilter filter, List listeners ) throws ArtifactResolutionException; } ArtifactResolver.java000066400000000000000000000114271317160430700336040ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/main/java/org/apache/maven/artifact/resolverpackage org.apache.maven.artifact.resolver; /* * 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.util.List; import java.util.Map; import java.util.Set; import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.metadata.ArtifactMetadataSource; import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.resolver.filter.ArtifactFilter; import org.apache.maven.wagon.events.TransferListener; /** * @author Jason van Zyl */ // Just hide the one method we want behind the RepositorySystem interface. public interface ArtifactResolver { ArtifactResolutionResult resolve( ArtifactResolutionRequest request ); // The rest is deprecated // USED BY MAVEN ASSEMBLY PLUGIN 2.2-beta-2 @Deprecated String ROLE = ArtifactResolver.class.getName(); // USED BY SUREFIRE, DEPENDENCY PLUGIN @Deprecated ArtifactResolutionResult resolveTransitively( Set artifacts, Artifact originatingArtifact, ArtifactRepository localRepository, List remoteRepositories, ArtifactMetadataSource source, ArtifactFilter filter ) throws ArtifactResolutionException, ArtifactNotFoundException; // USED BY MAVEN ASSEMBLY PLUGIN @Deprecated ArtifactResolutionResult resolveTransitively( Set artifacts, Artifact originatingArtifact, Map managedVersions, ArtifactRepository localRepository, List remoteRepositories, ArtifactMetadataSource source ) throws ArtifactResolutionException, ArtifactNotFoundException; // USED BY MAVEN ASSEMBLY PLUGIN @Deprecated ArtifactResolutionResult resolveTransitively( Set artifacts, Artifact originatingArtifact, Map managedVersions, ArtifactRepository localRepository, List remoteRepositories, ArtifactMetadataSource source, ArtifactFilter filter ) throws ArtifactResolutionException, ArtifactNotFoundException; // USED BY INVOKER PLUGIN @Deprecated ArtifactResolutionResult resolveTransitively( Set artifacts, Artifact originatingArtifact, List remoteRepositories, ArtifactRepository localRepository, ArtifactMetadataSource source ) throws ArtifactResolutionException, ArtifactNotFoundException; @Deprecated ArtifactResolutionResult resolveTransitively( Set artifacts, Artifact originatingArtifact, Map managedVersions, ArtifactRepository localRepository, List remoteRepositories, ArtifactMetadataSource source, ArtifactFilter filter, List listeners ) throws ArtifactResolutionException, ArtifactNotFoundException; @Deprecated ArtifactResolutionResult resolveTransitively( Set artifacts, Artifact originatingArtifact, List remoteRepositories, ArtifactRepository localRepository, ArtifactMetadataSource source, List listeners ) throws ArtifactResolutionException, ArtifactNotFoundException; // USED BY REMOTE RESOURCES PLUGIN, DEPENDENCY PLUGIN, SHADE PLUGIN @Deprecated void resolve( Artifact artifact, List remoteRepositories, ArtifactRepository localRepository ) throws ArtifactResolutionException, ArtifactNotFoundException; // USED BY REMOTE RESOURCES PLUGIN @Deprecated void resolve( Artifact artifact, List remoteRepositories, ArtifactRepository localRepository, TransferListener downloadMonitor ) throws ArtifactResolutionException, ArtifactNotFoundException; // USED BY DEPENDENCY PLUGIN, ARCHETYPE DOWNLOADER @Deprecated void resolveAlways( Artifact artifact, List remoteRepositories, ArtifactRepository localRepository ) throws ArtifactResolutionException, ArtifactNotFoundException; } DebugResolutionListener.java000066400000000000000000000135551317160430700351510ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/main/java/org/apache/maven/artifact/resolverpackage org.apache.maven.artifact.resolver; /* * 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.util.HashSet; import java.util.Set; import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.versioning.VersionRange; import org.codehaus.plexus.logging.Logger; /** * Send resolution events to the debug log. * * @author Brett Porter */ public class DebugResolutionListener implements ResolutionListener, ResolutionListenerForDepMgmt { private Logger logger; private String indent = ""; private static Set ignoredArtifacts = new HashSet<>(); public DebugResolutionListener( Logger logger ) { this.logger = logger; } public void testArtifact( Artifact node ) { } public void startProcessChildren( Artifact artifact ) { indent += " "; } public void endProcessChildren( Artifact artifact ) { indent = indent.substring( 2 ); } public void includeArtifact( Artifact artifact ) { logger.debug( indent + artifact + " (selected for " + artifact.getScope() + ")" ); } public void omitForNearer( Artifact omitted, Artifact kept ) { String omittedVersion = omitted.getVersion(); String keptVersion = kept.getVersion(); if ( omittedVersion != null ? !omittedVersion.equals( keptVersion ) : keptVersion != null ) { logger.debug( indent + omitted + " (removed - nearer found: " + keptVersion + ")" ); } } public void omitForCycle( Artifact omitted ) { logger.debug( indent + omitted + " (removed - causes a cycle in the graph)" ); } public void updateScopeCurrentPom( Artifact artifact, String ignoredScope ) { logger.debug( indent + artifact + " (not setting artifactScope to: " + ignoredScope + "; local artifactScope " + artifact.getScope() + " wins)" ); // TODO better way than static? this might hide messages in a reactor if ( !ignoredArtifacts.contains( artifact ) ) { logger.warn( "\n\tArtifact " + artifact + " retains local artifactScope '" + artifact.getScope() + "' overriding broader artifactScope '" + ignoredScope + "'\n" + "\tgiven by a dependency. If this is not intended, modify or remove the local artifactScope.\n" ); ignoredArtifacts.add( artifact ); } } public void updateScope( Artifact artifact, String scope ) { logger.debug( indent + artifact + " (setting artifactScope to: " + scope + ")" ); } public void selectVersionFromRange( Artifact artifact ) { logger.debug( indent + artifact + " (setting version to: " + artifact.getVersion() + " from range: " + artifact.getVersionRange() + ")" ); } public void restrictRange( Artifact artifact, Artifact replacement, VersionRange newRange ) { logger.debug( indent + artifact + " (range restricted from: " + artifact.getVersionRange() + " and: " + replacement.getVersionRange() + " to: " + newRange + " )" ); } /** * The logic used here used to be a copy of the logic used in the DefaultArtifactCollector, and this method was * called right before the actual version/artifactScope changes were done. However, a different set of conditionals * (and more information) is needed to be able to determine when and if the version and/or artifactScope changes. * See the two added methods, manageArtifactVersion and manageArtifactScope. */ public void manageArtifact( Artifact artifact, Artifact replacement ) { String msg = indent + artifact; msg += " ("; if ( replacement.getVersion() != null ) { msg += "applying version: " + replacement.getVersion() + ";"; } if ( replacement.getScope() != null ) { msg += "applying artifactScope: " + replacement.getScope(); } msg += ")"; logger.debug( msg ); } public void manageArtifactVersion( Artifact artifact, Artifact replacement ) { // only show msg if a change is actually taking place if ( !replacement.getVersion().equals( artifact.getVersion() ) ) { String msg = indent + artifact + " (applying version: " + replacement.getVersion() + ")"; logger.debug( msg ); } } public void manageArtifactScope( Artifact artifact, Artifact replacement ) { // only show msg if a change is actually taking place if ( !replacement.getScope().equals( artifact.getScope() ) ) { String msg = indent + artifact + " (applying artifactScope: " + replacement.getScope() + ")"; logger.debug( msg ); } } public void manageArtifactSystemPath( Artifact artifact, Artifact replacement ) { // only show msg if a change is actually taking place if ( !replacement.getScope().equals( artifact.getScope() ) ) { String msg = indent + artifact + " (applying system path: " + replacement.getFile() + ")"; logger.debug( msg ); } } } DefaultArtifactCollector.java000066400000000000000000000021551317160430700352340ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/main/java/org/apache/maven/artifact/resolverpackage org.apache.maven.artifact.resolver; /* * 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 org.codehaus.plexus.component.annotations.Component; @Deprecated @Component( role = ArtifactCollector.class ) public class DefaultArtifactCollector extends org.apache.maven.repository.legacy.resolver.DefaultLegacyArtifactCollector implements ArtifactCollector { } DefaultArtifactResolver.java000066400000000000000000000673071317160430700351210ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/main/java/org/apache/maven/artifact/resolverpackage org.apache.maven.artifact.resolver; /* * 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.File; import java.util.ArrayList; import java.util.Collections; import java.util.LinkedHashMap; import java.util.LinkedHashSet; import java.util.List; import java.util.Map; import java.util.Set; import java.util.concurrent.CountDownLatch; import java.util.concurrent.Executor; import java.util.concurrent.ExecutorService; import java.util.concurrent.LinkedBlockingQueue; import java.util.concurrent.ThreadFactory; import java.util.concurrent.ThreadPoolExecutor; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicInteger; import java.util.regex.Matcher; import org.apache.maven.RepositoryUtils; import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.factory.ArtifactFactory; import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException; import org.apache.maven.artifact.metadata.ArtifactMetadataSource; import org.apache.maven.artifact.metadata.ResolutionGroup; import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.repository.LegacyLocalRepositoryManager; import org.apache.maven.artifact.repository.RepositoryRequest; import org.apache.maven.artifact.repository.metadata.Snapshot; import org.apache.maven.artifact.repository.metadata.SnapshotArtifactRepositoryMetadata; import org.apache.maven.artifact.resolver.filter.ArtifactFilter; import org.apache.maven.execution.MavenSession; import org.apache.maven.plugin.LegacySupport; import org.apache.maven.repository.legacy.metadata.DefaultMetadataResolutionRequest; import org.apache.maven.repository.legacy.metadata.MetadataResolutionRequest; import org.apache.maven.repository.legacy.resolver.conflict.ConflictResolver; import org.apache.maven.wagon.events.TransferListener; import org.codehaus.plexus.PlexusContainer; import org.codehaus.plexus.component.annotations.Component; import org.codehaus.plexus.component.annotations.Requirement; import org.codehaus.plexus.component.repository.exception.ComponentLookupException; import org.codehaus.plexus.logging.Logger; import org.codehaus.plexus.personality.plexus.lifecycle.phase.Disposable; import org.eclipse.aether.RepositorySystem; import org.eclipse.aether.RepositorySystemSession; import org.eclipse.aether.repository.LocalRepositoryManager; import org.eclipse.aether.resolution.ArtifactRequest; import org.eclipse.aether.resolution.ArtifactResult; /** * @author Jason van Zyl */ @Component( role = ArtifactResolver.class ) public class DefaultArtifactResolver implements ArtifactResolver, Disposable { @Requirement private Logger logger; @Requirement protected ArtifactFactory artifactFactory; @Requirement private ArtifactCollector artifactCollector; @Requirement private ResolutionErrorHandler resolutionErrorHandler; @Requirement private ArtifactMetadataSource source; @Requirement private PlexusContainer container; @Requirement private LegacySupport legacySupport; @Requirement private RepositorySystem repoSystem; private final Executor executor; public DefaultArtifactResolver() { int threads = Integer.getInteger( "maven.artifact.threads", 5 ); if ( threads <= 1 ) { executor = new Executor() { public void execute( Runnable command ) { command.run(); } }; } else { executor = new ThreadPoolExecutor( threads, threads, 3, TimeUnit.SECONDS, new LinkedBlockingQueue(), new DaemonThreadCreator() ); } } private RepositorySystemSession getSession( ArtifactRepository localRepository ) { return LegacyLocalRepositoryManager.overlay( localRepository, legacySupport.getRepositorySession(), repoSystem ); } private void injectSession1( RepositoryRequest request, MavenSession session ) { if ( session != null ) { request.setOffline( session.isOffline() ); request.setForceUpdate( session.getRequest().isUpdateSnapshots() ); } } private void injectSession2( ArtifactResolutionRequest request, MavenSession session ) { injectSession1( request, session ); if ( session != null ) { request.setServers( session.getRequest().getServers() ); request.setMirrors( session.getRequest().getMirrors() ); request.setProxies( session.getRequest().getProxies() ); } } public void resolve( Artifact artifact, List remoteRepositories, ArtifactRepository localRepository, TransferListener resolutionListener ) throws ArtifactResolutionException, ArtifactNotFoundException { resolve( artifact, remoteRepositories, getSession( localRepository ) ); } public void resolveAlways( Artifact artifact, List remoteRepositories, ArtifactRepository localRepository ) throws ArtifactResolutionException, ArtifactNotFoundException { resolve( artifact, remoteRepositories, getSession( localRepository ) ); } private void resolve( Artifact artifact, List remoteRepositories, RepositorySystemSession session ) throws ArtifactResolutionException, ArtifactNotFoundException { if ( artifact == null ) { return; } if ( Artifact.SCOPE_SYSTEM.equals( artifact.getScope() ) ) { File systemFile = artifact.getFile(); if ( systemFile == null ) { throw new ArtifactNotFoundException( "System artifact: " + artifact + " has no file attached", artifact ); } if ( !systemFile.exists() ) { throw new ArtifactNotFoundException( "System artifact: " + artifact + " not found in path: " + systemFile, artifact ); } if ( !systemFile.isFile() ) { throw new ArtifactNotFoundException( "System artifact: " + artifact + " is not a file: " + systemFile, artifact ); } artifact.setResolved( true ); return; } if ( !artifact.isResolved() ) { ArtifactResult result; try { ArtifactRequest artifactRequest = new ArtifactRequest(); artifactRequest.setArtifact( RepositoryUtils.toArtifact( artifact ) ); artifactRequest.setRepositories( RepositoryUtils.toRepos( remoteRepositories ) ); // Maven 2.x quirk: an artifact always points at the local repo, regardless whether resolved or not LocalRepositoryManager lrm = session.getLocalRepositoryManager(); String path = lrm.getPathForLocalArtifact( artifactRequest.getArtifact() ); artifact.setFile( new File( lrm.getRepository().getBasedir(), path ) ); result = repoSystem.resolveArtifact( session, artifactRequest ); } catch ( org.eclipse.aether.resolution.ArtifactResolutionException e ) { if ( e.getCause() instanceof org.eclipse.aether.transfer.ArtifactNotFoundException ) { throw new ArtifactNotFoundException( e.getMessage(), artifact, remoteRepositories, e ); } else { throw new ArtifactResolutionException( e.getMessage(), artifact, remoteRepositories, e ); } } artifact.selectVersion( result.getArtifact().getVersion() ); artifact.setFile( result.getArtifact().getFile() ); artifact.setResolved( true ); if ( artifact.isSnapshot() ) { Matcher matcher = Artifact.VERSION_FILE_PATTERN.matcher( artifact.getVersion() ); if ( matcher.matches() ) { Snapshot snapshot = new Snapshot(); snapshot.setTimestamp( matcher.group( 2 ) ); try { snapshot.setBuildNumber( Integer.parseInt( matcher.group( 3 ) ) ); artifact.addMetadata( new SnapshotArtifactRepositoryMetadata( artifact, snapshot ) ); } catch ( NumberFormatException e ) { logger.warn( "Invalid artifact version " + artifact.getVersion() + ": " + e.getMessage() ); } } } } } public ArtifactResolutionResult resolveTransitively( Set artifacts, Artifact originatingArtifact, ArtifactRepository localRepository, List remoteRepositories, ArtifactMetadataSource source, ArtifactFilter filter ) throws ArtifactResolutionException, ArtifactNotFoundException { return resolveTransitively( artifacts, originatingArtifact, Collections.emptyMap(), localRepository, remoteRepositories, source, filter ); } public ArtifactResolutionResult resolveTransitively( Set artifacts, Artifact originatingArtifact, Map managedVersions, ArtifactRepository localRepository, List remoteRepositories, ArtifactMetadataSource source ) throws ArtifactResolutionException, ArtifactNotFoundException { return resolveTransitively( artifacts, originatingArtifact, managedVersions, localRepository, remoteRepositories, source, null ); } public ArtifactResolutionResult resolveTransitively( Set artifacts, Artifact originatingArtifact, Map managedVersions, ArtifactRepository localRepository, List remoteRepositories, ArtifactMetadataSource source, ArtifactFilter filter ) throws ArtifactResolutionException, ArtifactNotFoundException { return resolveTransitively( artifacts, originatingArtifact, managedVersions, localRepository, remoteRepositories, source, filter, null ); } public ArtifactResolutionResult resolveTransitively( Set artifacts, Artifact originatingArtifact, List remoteRepositories, ArtifactRepository localRepository, ArtifactMetadataSource source ) throws ArtifactResolutionException, ArtifactNotFoundException { return resolveTransitively( artifacts, originatingArtifact, localRepository, remoteRepositories, source, null ); } public ArtifactResolutionResult resolveTransitively( Set artifacts, Artifact originatingArtifact, List remoteRepositories, ArtifactRepository localRepository, ArtifactMetadataSource source, List listeners ) throws ArtifactResolutionException, ArtifactNotFoundException { return resolveTransitively( artifacts, originatingArtifact, Collections.emptyMap(), localRepository, remoteRepositories, source, null, listeners ); } public ArtifactResolutionResult resolveTransitively( Set artifacts, Artifact originatingArtifact, Map managedVersions, ArtifactRepository localRepository, List remoteRepositories, ArtifactMetadataSource source, ArtifactFilter filter, List listeners ) throws ArtifactResolutionException, ArtifactNotFoundException { return resolveTransitively( artifacts, originatingArtifact, managedVersions, localRepository, remoteRepositories, source, filter, listeners, null ); } public ArtifactResolutionResult resolveTransitively( Set artifacts, Artifact originatingArtifact, Map managedVersions, ArtifactRepository localRepository, List remoteRepositories, ArtifactMetadataSource source, ArtifactFilter filter, List listeners, List conflictResolvers ) throws ArtifactResolutionException, ArtifactNotFoundException { ArtifactResolutionRequest request = new ArtifactResolutionRequest(). setArtifact( originatingArtifact ). setResolveRoot( false ). // This is required by the surefire plugin setArtifactDependencies( artifacts ). setManagedVersionMap( managedVersions ). setLocalRepository( localRepository ). setRemoteRepositories( remoteRepositories ). setCollectionFilter( filter ). setListeners( listeners ); injectSession2( request, legacySupport.getSession() ); return resolveWithExceptions( request ); } public ArtifactResolutionResult resolveWithExceptions( ArtifactResolutionRequest request ) throws ArtifactResolutionException, ArtifactNotFoundException { ArtifactResolutionResult result = resolve( request ); // We have collected all the problems so let's mimic the way the old code worked and just blow up right here. // That's right lets just let it rip right here and send a big incomprehensible blob of text at unsuspecting // users. Bad dog! resolutionErrorHandler.throwErrors( request, result ); return result; } // ------------------------------------------------------------------------ // // ------------------------------------------------------------------------ public ArtifactResolutionResult resolve( ArtifactResolutionRequest request ) { Artifact rootArtifact = request.getArtifact(); Set artifacts = request.getArtifactDependencies(); Map managedVersions = request.getManagedVersionMap(); List listeners = request.getListeners(); ArtifactFilter collectionFilter = request.getCollectionFilter(); ArtifactFilter resolutionFilter = request.getResolutionFilter(); RepositorySystemSession session = getSession( request.getLocalRepository() ); // TODO: hack because metadata isn't generated in m2e correctly and i want to run the maven i have in the // workspace if ( source == null ) { try { source = container.lookup( ArtifactMetadataSource.class ); } catch ( ComponentLookupException e ) { // won't happen } } if ( listeners == null ) { listeners = new ArrayList<>(); if ( logger.isDebugEnabled() ) { listeners.add( new DebugResolutionListener( logger ) ); } listeners.add( new WarningResolutionListener( logger ) ); } ArtifactResolutionResult result = new ArtifactResolutionResult(); // The root artifact may, or may not be resolved so we need to check before we attempt to resolve. // This is often an artifact like a POM that is taken from disk and we already have hold of the // file reference. But this may be a Maven Plugin that we need to resolve from a remote repository // as well as its dependencies. if ( request.isResolveRoot() /* && rootArtifact.getFile() == null */ ) { try { resolve( rootArtifact, request.getRemoteRepositories(), session ); } catch ( ArtifactResolutionException e ) { result.addErrorArtifactException( e ); return result; } catch ( ArtifactNotFoundException e ) { result.addMissingArtifact( request.getArtifact() ); return result; } } ArtifactResolutionRequest collectionRequest = request; if ( request.isResolveTransitively() ) { MetadataResolutionRequest metadataRequest = new DefaultMetadataResolutionRequest( request ); metadataRequest.setArtifact( rootArtifact ); metadataRequest.setResolveManagedVersions( managedVersions == null ); try { ResolutionGroup resolutionGroup = source.retrieve( metadataRequest ); if ( managedVersions == null ) { managedVersions = resolutionGroup.getManagedVersions(); } Set directArtifacts = resolutionGroup.getArtifacts(); if ( artifacts == null || artifacts.isEmpty() ) { artifacts = directArtifacts; } else { List allArtifacts = new ArrayList<>(); allArtifacts.addAll( artifacts ); allArtifacts.addAll( directArtifacts ); Map mergedArtifacts = new LinkedHashMap<>(); for ( Artifact artifact : allArtifacts ) { String conflictId = artifact.getDependencyConflictId(); if ( !mergedArtifacts.containsKey( conflictId ) ) { mergedArtifacts.put( conflictId, artifact ); } } artifacts = new LinkedHashSet<>( mergedArtifacts.values() ); } collectionRequest = new ArtifactResolutionRequest( request ); collectionRequest.setServers( request.getServers() ); collectionRequest.setMirrors( request.getMirrors() ); collectionRequest.setProxies( request.getProxies() ); collectionRequest.setRemoteRepositories( resolutionGroup.getResolutionRepositories() ); } catch ( ArtifactMetadataRetrievalException e ) { ArtifactResolutionException are = new ArtifactResolutionException( "Unable to get dependency information for " + rootArtifact.getId() + ": " + e.getMessage(), rootArtifact, metadataRequest.getRemoteRepositories(), e ); result.addMetadataResolutionException( are ); return result; } } if ( artifacts == null || artifacts.isEmpty() ) { if ( request.isResolveRoot() ) { result.addArtifact( rootArtifact ); } return result; } // After the collection we will have the artifact object in the result but they will not be resolved yet. result = artifactCollector.collect( artifacts, rootArtifact, managedVersions, collectionRequest, source, collectionFilter, listeners, null ); // We have metadata retrieval problems, or there are cycles that have been detected // so we give this back to the calling code and let them deal with this information // appropriately. if ( result.hasMetadataResolutionExceptions() || result.hasVersionRangeViolations() || result.hasCircularDependencyExceptions() ) { logger.info( "Failure detected." ); return result; } if ( result.getArtifactResolutionNodes() != null ) { ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); CountDownLatch latch = new CountDownLatch( result.getArtifactResolutionNodes().size() ); for ( ResolutionNode node : result.getArtifactResolutionNodes() ) { Artifact artifact = node.getArtifact(); if ( resolutionFilter == null || resolutionFilter.include( artifact ) ) { executor.execute( new ResolveTask( classLoader, latch, artifact, session, node.getRemoteRepositories(), result ) ); } else { latch.countDown(); } } try { latch.await(); } catch ( InterruptedException e ) { result.addErrorArtifactException( new ArtifactResolutionException( "Resolution interrupted", rootArtifact, e ) ); } } // We want to send the root artifact back in the result but we need to do this after the other dependencies // have been resolved. if ( request.isResolveRoot() ) { // Add the root artifact (as the first artifact to retain logical order of class path!) Set allArtifacts = new LinkedHashSet<>(); allArtifacts.add( rootArtifact ); allArtifacts.addAll( result.getArtifacts() ); result.setArtifacts( allArtifacts ); } return result; } public void resolve( Artifact artifact, List remoteRepositories, ArtifactRepository localRepository ) throws ArtifactResolutionException, ArtifactNotFoundException { resolve( artifact, remoteRepositories, localRepository, null ); } /** * ThreadCreator for creating daemon threads with fixed ThreadGroup-name. */ static final class DaemonThreadCreator implements ThreadFactory { static final String THREADGROUP_NAME = "org.apache.maven.artifact.resolver.DefaultArtifactResolver"; static final ThreadGroup GROUP = new ThreadGroup( THREADGROUP_NAME ); static final AtomicInteger THREAD_NUMBER = new AtomicInteger( 1 ); public Thread newThread( Runnable r ) { Thread newThread = new Thread( GROUP, r, "resolver-" + THREAD_NUMBER.getAndIncrement() ); newThread.setDaemon( true ); newThread.setContextClassLoader( null ); return newThread; } } private class ResolveTask implements Runnable { private final ClassLoader classLoader; private final CountDownLatch latch; private final Artifact artifact; private final RepositorySystemSession session; private final List remoteRepositories; private final ArtifactResolutionResult result; public ResolveTask( ClassLoader classLoader, CountDownLatch latch, Artifact artifact, RepositorySystemSession session, List remoteRepositories, ArtifactResolutionResult result ) { this.classLoader = classLoader; this.latch = latch; this.artifact = artifact; this.session = session; this.remoteRepositories = remoteRepositories; this.result = result; } public void run() { ClassLoader old = Thread.currentThread().getContextClassLoader(); try { Thread.currentThread().setContextClassLoader( classLoader ); resolve( artifact, remoteRepositories, session ); } catch ( ArtifactNotFoundException anfe ) { // These are cases where the artifact just isn't present in any of the remote repositories // because it wasn't deployed, or it was deployed in the wrong place. synchronized ( result ) { result.addMissingArtifact( artifact ); } } catch ( ArtifactResolutionException e ) { // This is really a wagon TransferFailedException so something went wrong after we successfully // retrieved the metadata. synchronized ( result ) { result.addErrorArtifactException( e ); } } finally { latch.countDown(); Thread.currentThread().setContextClassLoader( old ); } } } @Override public void dispose() { if ( executor instanceof ExecutorService ) { ( (ExecutorService) executor ).shutdownNow(); } } } ResolutionListenerForDepMgmt.java000066400000000000000000000031011317160430700361110ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/main/java/org/apache/maven/artifact/resolverpackage org.apache.maven.artifact.resolver; /* * 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 org.apache.maven.artifact.Artifact; /** * Do not use! *

* Should only be implemented by DebugResolutionListener. Remove this * when the ResolutionListener interface deprecation of the manageArtifact * method (and the [yet to be done] addition of these methods to that * interface) has had a chance to propagate to all interested plugins. */ @Deprecated public interface ResolutionListenerForDepMgmt { void manageArtifactVersion( Artifact artifact, Artifact replacement ); void manageArtifactScope( Artifact artifact, Artifact replacement ); void manageArtifactSystemPath( Artifact artifact, Artifact replacement ); } UnresolvedArtifacts.java000066400000000000000000000037511317160430700343150ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/main/java/org/apache/maven/artifact/resolverpackage org.apache.maven.artifact.resolver; /* * 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.util.List; import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.repository.ArtifactRepository; /** * A simple recording of the Artifacts that could not be resolved for a given resolution request, along with * the remote repositories where attempts were made to resolve the artifacts. * * @author Jason van Zyl */ public class UnresolvedArtifacts { private Artifact originatingArtifact; private List artifacts; private List remoteRepositories; public UnresolvedArtifacts( Artifact originatingArtifact, List artifacts, List remoteRepositories ) { this.originatingArtifact = originatingArtifact; this.artifacts = artifacts; this.remoteRepositories = remoteRepositories; } public Artifact getOriginatingArtifact() { return originatingArtifact; } public List getArtifacts() { return artifacts; } public List getRemoteRepositories() { return remoteRepositories; } } WarningResolutionListener.java000066400000000000000000000044631317160430700355260ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/main/java/org/apache/maven/artifact/resolverpackage org.apache.maven.artifact.resolver; /* * 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 org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.versioning.VersionRange; import org.codehaus.plexus.logging.Logger; /** * Send resolution warning events to the warning log. * * @author Brett Porter */ public class WarningResolutionListener implements ResolutionListener { private Logger logger; public WarningResolutionListener( Logger logger ) { this.logger = logger; } public void testArtifact( Artifact node ) { } public void startProcessChildren( Artifact artifact ) { } public void endProcessChildren( Artifact artifact ) { } public void includeArtifact( Artifact artifact ) { } public void omitForNearer( Artifact omitted, Artifact kept ) { } public void omitForCycle( Artifact omitted ) { } public void updateScopeCurrentPom( Artifact artifact, String scope ) { } public void updateScope( Artifact artifact, String scope ) { } public void manageArtifact( Artifact artifact, Artifact replacement ) { } public void selectVersionFromRange( Artifact artifact ) { } public void restrictRange( Artifact artifact, Artifact replacement, VersionRange newRange ) { } } maven-maven-3.5.2/maven-compat/src/main/java/org/apache/maven/artifact/resolver/filter/000077500000000000000000000000001317160430700310215ustar00rootroot00000000000000InversionArtifactFilter.java000066400000000000000000000033241317160430700364070ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/main/java/org/apache/maven/artifact/resolver/filterpackage org.apache.maven.artifact.resolver.filter; /* * 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 org.apache.maven.artifact.Artifact; public class InversionArtifactFilter implements ArtifactFilter { private final ArtifactFilter toInvert; public InversionArtifactFilter( ArtifactFilter toInvert ) { this.toInvert = toInvert; } public boolean include( Artifact artifact ) { return !toInvert.include( artifact ); } @Override public int hashCode() { int hash = 17; hash = hash * 31 + toInvert.hashCode(); return hash; } @Override public boolean equals( Object obj ) { if ( this == obj ) { return true; } if ( !( obj instanceof InversionArtifactFilter ) ) { return false; } InversionArtifactFilter other = (InversionArtifactFilter) obj; return toInvert.equals( other.toInvert ); } } OrArtifactFilter.java000066400000000000000000000043741317160430700350210ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/main/java/org/apache/maven/artifact/resolver/filterpackage org.apache.maven.artifact.resolver.filter; /* * 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.util.Collection; import java.util.LinkedHashSet; import java.util.Set; import org.apache.maven.artifact.Artifact; /** * Apply multiple filters, accepting an artifact if at least one of the filters accepts it. * * @author Benjamin Bentmann */ public class OrArtifactFilter implements ArtifactFilter { private Set filters; public OrArtifactFilter() { this.filters = new LinkedHashSet<>(); } public OrArtifactFilter( Collection filters ) { this.filters = new LinkedHashSet<>( filters ); } public boolean include( Artifact artifact ) { for ( ArtifactFilter filter : filters ) { if ( filter.include( artifact ) ) { return true; } } return false; } public void add( ArtifactFilter artifactFilter ) { filters.add( artifactFilter ); } @Override public int hashCode() { int hash = 17; hash = hash * 31 + filters.hashCode(); return hash; } @Override public boolean equals( Object obj ) { if ( this == obj ) { return true; } if ( !( obj instanceof OrArtifactFilter ) ) { return false; } OrArtifactFilter other = (OrArtifactFilter) obj; return filters.equals( other.filters ); } } TypeArtifactFilter.java000066400000000000000000000033131317160430700353520ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/main/java/org/apache/maven/artifact/resolver/filterpackage org.apache.maven.artifact.resolver.filter; /* * 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 org.apache.maven.artifact.Artifact; /** Artifact Filter which filters on artifact type */ public class TypeArtifactFilter implements ArtifactFilter { private String type = "jar"; public TypeArtifactFilter( String type ) { this.type = type; } public boolean include( Artifact artifact ) { return type.equals( artifact.getType() ); } @Override public int hashCode() { int hash = 17; hash = hash * 31 + type.hashCode(); return hash; } @Override public boolean equals( Object obj ) { if ( this == obj ) { return true; } if ( !( obj instanceof TypeArtifactFilter ) ) { return false; } TypeArtifactFilter other = (TypeArtifactFilter) obj; return type.equals( other.type ); } } maven-maven-3.5.2/maven-compat/src/main/java/org/apache/maven/artifact/versioning/000077500000000000000000000000001317160430700300565ustar00rootroot00000000000000ManagedVersionMap.java000066400000000000000000000032571317160430700342110ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/main/java/org/apache/maven/artifact/versioningpackage org.apache.maven.artifact.versioning; /* * 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.util.HashMap; import java.util.Iterator; import java.util.Map; import org.apache.maven.artifact.Artifact; @Deprecated public class ManagedVersionMap extends HashMap { public ManagedVersionMap( Map map ) { super(); if ( map != null ) { putAll( map ); } } public String toString() { StringBuilder buffer = new StringBuilder( "ManagedVersionMap (" + size() + " entries)\n" ); Iterator iter = keySet().iterator(); while ( iter.hasNext() ) { String key = iter.next(); buffer.append( key ).append( '=' ).append( get( key ) ); if ( iter.hasNext() ) { buffer.append( '\n' ); } } return buffer.toString(); } } maven-maven-3.5.2/maven-compat/src/main/java/org/apache/maven/execution/000077500000000000000000000000001317160430700261015ustar00rootroot00000000000000DefaultRuntimeInformation.java000066400000000000000000000042231317160430700340240ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/main/java/org/apache/maven/executionpackage org.apache.maven.execution; /* * 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 org.apache.maven.artifact.versioning.ArtifactVersion; import org.apache.maven.artifact.versioning.DefaultArtifactVersion; import org.codehaus.plexus.component.annotations.Component; import org.codehaus.plexus.component.annotations.Requirement; import org.codehaus.plexus.personality.plexus.lifecycle.phase.Initializable; import org.codehaus.plexus.personality.plexus.lifecycle.phase.InitializationException; import org.codehaus.plexus.util.StringUtils; /** * Describes runtime information about the application. * * @author Brett Porter */ @Deprecated @Component( role = RuntimeInformation.class ) public class DefaultRuntimeInformation implements RuntimeInformation, Initializable { @Requirement private org.apache.maven.rtinfo.RuntimeInformation rtInfo; private ArtifactVersion applicationVersion; public ArtifactVersion getApplicationVersion() { return applicationVersion; } public void initialize() throws InitializationException { String mavenVersion = rtInfo.getMavenVersion(); if ( StringUtils.isEmpty( mavenVersion ) ) { throw new InitializationException( "Unable to read Maven version from maven-core" ); } applicationVersion = new DefaultArtifactVersion( mavenVersion ); } } maven-maven-3.5.2/maven-compat/src/main/java/org/apache/maven/execution/RuntimeInformation.java000066400000000000000000000022741317160430700326020ustar00rootroot00000000000000package org.apache.maven.execution; /* * 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 org.apache.maven.artifact.versioning.ArtifactVersion; /** * Describes runtime information about the application. * * @deprecated Use {@link org.apache.maven.rtinfo.RuntimeInformation} instead. * @author Brett Porter */ @Deprecated public interface RuntimeInformation { ArtifactVersion getApplicationVersion(); } maven-maven-3.5.2/maven-compat/src/main/java/org/apache/maven/profiles/000077500000000000000000000000001317160430700257215ustar00rootroot00000000000000DefaultMavenProfilesBuilder.java000066400000000000000000000061401317160430700340740ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/main/java/org/apache/maven/profilespackage org.apache.maven.profiles; /* * 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 org.apache.maven.profiles.io.xpp3.ProfilesXpp3Reader; import org.codehaus.plexus.component.annotations.Component; import org.codehaus.plexus.interpolation.EnvarBasedValueSource; import org.codehaus.plexus.interpolation.RegexBasedInterpolator; import org.codehaus.plexus.logging.AbstractLogEnabled; import org.codehaus.plexus.util.IOUtil; import org.codehaus.plexus.util.ReaderFactory; import org.codehaus.plexus.util.xml.pull.XmlPullParserException; import java.io.File; import java.io.IOException; import java.io.Reader; import java.io.StringReader; import java.io.StringWriter; @Deprecated @Component( role = MavenProfilesBuilder.class ) public class DefaultMavenProfilesBuilder extends AbstractLogEnabled implements MavenProfilesBuilder { private static final String PROFILES_XML_FILE = "profiles.xml"; public ProfilesRoot buildProfiles( File basedir ) throws IOException, XmlPullParserException { File profilesXml = new File( basedir, PROFILES_XML_FILE ); ProfilesRoot profilesRoot = null; if ( profilesXml.exists() ) { ProfilesXpp3Reader reader = new ProfilesXpp3Reader(); try ( Reader profileReader = ReaderFactory.newXmlReader( profilesXml ); StringWriter sWriter = new StringWriter() ) { IOUtil.copy( profileReader, sWriter ); String rawInput = sWriter.toString(); try { RegexBasedInterpolator interpolator = new RegexBasedInterpolator(); interpolator.addValueSource( new EnvarBasedValueSource() ); rawInput = interpolator.interpolate( rawInput, "settings" ); } catch ( Exception e ) { getLogger().warn( "Failed to initialize environment variable resolver. Skipping environment " + "substitution in " + PROFILES_XML_FILE + "." ); getLogger().debug( "Failed to initialize envar resolver. Skipping resolution.", e ); } StringReader sReader = new StringReader( rawInput ); profilesRoot = reader.read( sReader ); } } return profilesRoot; } } maven-maven-3.5.2/maven-compat/src/main/java/org/apache/maven/profiles/DefaultProfileManager.java000066400000000000000000000164051317160430700327720ustar00rootroot00000000000000package org.apache.maven.profiles; /* * 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 org.apache.maven.model.Activation; import org.apache.maven.model.Profile; import org.apache.maven.model.building.ModelProblem; import org.apache.maven.model.building.ModelProblemCollector; import org.apache.maven.model.profile.DefaultProfileActivationContext; import org.apache.maven.model.profile.ProfileSelector; import org.apache.maven.profiles.activation.ProfileActivationException; import org.codehaus.plexus.MutablePlexusContainer; import org.codehaus.plexus.PlexusContainer; import org.codehaus.plexus.component.annotations.Requirement; import org.codehaus.plexus.component.repository.exception.ComponentLookupException; import org.codehaus.plexus.logging.Logger; import java.util.ArrayList; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import java.util.Properties; import org.apache.maven.model.building.ModelProblemCollectorRequest; @Deprecated public class DefaultProfileManager implements ProfileManager { @Requirement private Logger logger; @Requirement private ProfileSelector profileSelector; private List activatedIds = new ArrayList<>(); private List deactivatedIds = new ArrayList<>(); private List defaultIds = new ArrayList<>(); private Map profilesById = new LinkedHashMap<>(); private Properties requestProperties; /** * @deprecated without passing in the system properties, the SystemPropertiesProfileActivator will not work * correctly in embedded environments. */ public DefaultProfileManager( PlexusContainer container ) { this( container, null ); } /** * the properties passed to the profile manager are the props that * are passed to maven, possibly containing profile activator properties * */ public DefaultProfileManager( PlexusContainer container, Properties props ) { try { this.profileSelector = container.lookup( ProfileSelector.class ); this.logger = ( (MutablePlexusContainer) container ).getLogger(); } catch ( ComponentLookupException e ) { throw new IllegalStateException( e ); } this.requestProperties = props; } public Properties getRequestProperties() { return requestProperties; } public Map getProfilesById() { return profilesById; } /* (non-Javadoc) * @see org.apache.maven.profiles.ProfileManager#addProfile(org.apache.maven.model.Profile) */ public void addProfile( Profile profile ) { String profileId = profile.getId(); Profile existing = profilesById.get( profileId ); if ( existing != null ) { logger.warn( "Overriding profile: \'" + profileId + "\' (source: " + existing.getSource() + ") with new instance from source: " + profile.getSource() ); } profilesById.put( profile.getId(), profile ); Activation activation = profile.getActivation(); if ( activation != null && activation.isActiveByDefault() ) { activateAsDefault( profileId ); } } /* (non-Javadoc) * @see org.apache.maven.profiles.ProfileManager#explicitlyActivate(java.lang.String) */ public void explicitlyActivate( String profileId ) { if ( !activatedIds.contains( profileId ) ) { logger.debug( "Profile with id: \'" + profileId + "\' has been explicitly activated." ); activatedIds.add( profileId ); } } /* (non-Javadoc) * @see org.apache.maven.profiles.ProfileManager#explicitlyActivate(java.util.List) */ public void explicitlyActivate( List profileIds ) { for ( String profileId1 : profileIds ) { explicitlyActivate( profileId1 ); } } /* (non-Javadoc) * @see org.apache.maven.profiles.ProfileManager#explicitlyDeactivate(java.lang.String) */ public void explicitlyDeactivate( String profileId ) { if ( !deactivatedIds.contains( profileId ) ) { logger.debug( "Profile with id: \'" + profileId + "\' has been explicitly deactivated." ); deactivatedIds.add( profileId ); } } /* (non-Javadoc) * @see org.apache.maven.profiles.ProfileManager#explicitlyDeactivate(java.util.List) */ public void explicitlyDeactivate( List profileIds ) { for ( String profileId1 : profileIds ) { explicitlyDeactivate( profileId1 ); } } /* (non-Javadoc) * @see org.apache.maven.profiles.ProfileManager#getActiveProfiles() */ public List getActiveProfiles() throws ProfileActivationException { DefaultProfileActivationContext context = new DefaultProfileActivationContext(); context.setActiveProfileIds( activatedIds ); context.setInactiveProfileIds( deactivatedIds ); context.setSystemProperties( System.getProperties() ); context.setUserProperties( requestProperties ); final List errors = new ArrayList<>(); List profiles = profileSelector.getActiveProfiles( profilesById.values(), context, new ModelProblemCollector() { public void add( ModelProblemCollectorRequest req ) { if ( !ModelProblem.Severity.WARNING.equals( req.getSeverity() ) ) { errors.add( new ProfileActivationException( req.getMessage(), req.getException() ) ); } } } ); if ( !errors.isEmpty() ) { throw errors.get( 0 ); } return profiles; } /* (non-Javadoc) * @see org.apache.maven.profiles.ProfileManager#addProfiles(java.util.List) */ public void addProfiles( List profiles ) { for ( Profile profile1 : profiles ) { addProfile( profile1 ); } } public void activateAsDefault( String profileId ) { if ( !defaultIds.contains( profileId ) ) { defaultIds.add( profileId ); } } public List getExplicitlyActivatedIds() { return activatedIds; } public List getExplicitlyDeactivatedIds() { return deactivatedIds; } public List getIdsActivatedByDefault() { return defaultIds; } } maven-maven-3.5.2/maven-compat/src/main/java/org/apache/maven/profiles/MavenProfilesBuilder.java000066400000000000000000000022551317160430700326510ustar00rootroot00000000000000package org.apache.maven.profiles; /* * 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 org.codehaus.plexus.util.xml.pull.XmlPullParserException; import java.io.File; import java.io.IOException; /** * @author jdcasey */ @Deprecated public interface MavenProfilesBuilder { String ROLE = MavenProfilesBuilder.class.getName(); ProfilesRoot buildProfiles( File basedir ) throws IOException, XmlPullParserException; } maven-maven-3.5.2/maven-compat/src/main/java/org/apache/maven/profiles/ProfileManager.java000066400000000000000000000031771317160430700314670ustar00rootroot00000000000000package org.apache.maven.profiles; /* * 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 org.apache.maven.model.Profile; import org.apache.maven.profiles.activation.ProfileActivationException; import java.util.List; import java.util.Map; import java.util.Properties; @Deprecated public interface ProfileManager { void addProfile( Profile profile ); void explicitlyActivate( String profileId ); void explicitlyActivate( List profileIds ); void explicitlyDeactivate( String profileId ); void explicitlyDeactivate( List profileIds ); List getActiveProfiles() throws ProfileActivationException; void addProfiles( List profiles ); Map getProfilesById(); List getExplicitlyActivatedIds(); List getExplicitlyDeactivatedIds(); List getIdsActivatedByDefault(); Properties getRequestProperties(); } maven-maven-3.5.2/maven-compat/src/main/java/org/apache/maven/profiles/ProfilesConversionUtils.java000066400000000000000000000117251317160430700334440ustar00rootroot00000000000000package org.apache.maven.profiles; /* * 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 org.apache.maven.model.Activation; import org.apache.maven.model.ActivationFile; import org.apache.maven.model.ActivationProperty; import org.apache.maven.model.Profile; import org.apache.maven.model.Repository; import java.util.List; @Deprecated public class ProfilesConversionUtils { private ProfilesConversionUtils() { } public static Profile convertFromProfileXmlProfile( org.apache.maven.profiles.Profile profileXmlProfile ) { Profile profile = new Profile(); profile.setId( profileXmlProfile.getId() ); profile.setSource( "profiles.xml" ); org.apache.maven.profiles.Activation profileActivation = profileXmlProfile.getActivation(); if ( profileActivation != null ) { Activation activation = new Activation(); activation.setActiveByDefault( profileActivation.isActiveByDefault() ); activation.setJdk( profileActivation.getJdk() ); org.apache.maven.profiles.ActivationProperty profileProp = profileActivation.getProperty(); if ( profileProp != null ) { ActivationProperty prop = new ActivationProperty(); prop.setName( profileProp.getName() ); prop.setValue( profileProp.getValue() ); activation.setProperty( prop ); } ActivationOS profileOs = profileActivation.getOs(); if ( profileOs != null ) { org.apache.maven.model.ActivationOS os = new org.apache.maven.model.ActivationOS(); os.setArch( profileOs.getArch() ); os.setFamily( profileOs.getFamily() ); os.setName( profileOs.getName() ); os.setVersion( profileOs.getVersion() ); activation.setOs( os ); } org.apache.maven.profiles.ActivationFile profileFile = profileActivation.getFile(); if ( profileFile != null ) { ActivationFile file = new ActivationFile(); file.setExists( profileFile.getExists() ); file.setMissing( profileFile.getMissing() ); activation.setFile( file ); } profile.setActivation( activation ); } profile.setProperties( profileXmlProfile.getProperties() ); List repos = profileXmlProfile.getRepositories(); if ( repos != null ) { for ( Object repo : repos ) { profile.addRepository( convertFromProfileXmlRepository( (org.apache.maven.profiles.Repository) repo ) ); } } List pluginRepos = profileXmlProfile.getPluginRepositories(); if ( pluginRepos != null ) { for ( Object pluginRepo : pluginRepos ) { profile.addPluginRepository( convertFromProfileXmlRepository( (org.apache.maven.profiles.Repository) pluginRepo ) ); } } return profile; } private static Repository convertFromProfileXmlRepository( org.apache.maven.profiles.Repository profileXmlRepo ) { Repository repo = new Repository(); repo.setId( profileXmlRepo.getId() ); repo.setLayout( profileXmlRepo.getLayout() ); repo.setName( profileXmlRepo.getName() ); repo.setUrl( profileXmlRepo.getUrl() ); if ( profileXmlRepo.getSnapshots() != null ) { repo.setSnapshots( convertRepositoryPolicy( profileXmlRepo.getSnapshots() ) ); } if ( profileXmlRepo.getReleases() != null ) { repo.setReleases( convertRepositoryPolicy( profileXmlRepo.getReleases() ) ); } return repo; } private static org.apache.maven.model.RepositoryPolicy convertRepositoryPolicy( RepositoryPolicy profileXmlRepo ) { org.apache.maven.model.RepositoryPolicy policy = new org.apache.maven.model.RepositoryPolicy(); policy.setEnabled( profileXmlRepo.isEnabled() ); policy.setUpdatePolicy( profileXmlRepo.getUpdatePolicy() ); policy.setChecksumPolicy( profileXmlRepo.getChecksumPolicy() ); return policy; } } maven-maven-3.5.2/maven-compat/src/main/java/org/apache/maven/profiles/activation/000077500000000000000000000000001317160430700300625ustar00rootroot00000000000000DetectedProfileActivator.java000066400000000000000000000022371317160430700355710ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/main/java/org/apache/maven/profiles/activationpackage org.apache.maven.profiles.activation; /* * 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 org.apache.maven.model.Profile; @Deprecated public abstract class DetectedProfileActivator implements ProfileActivator { public boolean canDetermineActivation( Profile profile ) { return canDetectActivation( profile ); } protected abstract boolean canDetectActivation( Profile profile ); } FileProfileActivator.java000066400000000000000000000075051317160430700347320ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/main/java/org/apache/maven/profiles/activationpackage org.apache.maven.profiles.activation; /* * 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 org.apache.maven.model.Activation; import org.apache.maven.model.ActivationFile; import org.apache.maven.model.Profile; import org.codehaus.plexus.interpolation.EnvarBasedValueSource; import org.codehaus.plexus.interpolation.InterpolationException; import org.codehaus.plexus.interpolation.MapBasedValueSource; import org.codehaus.plexus.interpolation.RegexBasedInterpolator; import org.codehaus.plexus.logging.LogEnabled; import org.codehaus.plexus.logging.Logger; import org.codehaus.plexus.util.FileUtils; import org.codehaus.plexus.util.StringUtils; @Deprecated public class FileProfileActivator extends DetectedProfileActivator implements LogEnabled { private Logger logger; protected boolean canDetectActivation( Profile profile ) { return profile.getActivation() != null && profile.getActivation().getFile() != null; } public boolean isActive( Profile profile ) { Activation activation = profile.getActivation(); ActivationFile actFile = activation.getFile(); if ( actFile != null ) { // check if the file exists, if it does then the profile will be active String fileString = actFile.getExists(); RegexBasedInterpolator interpolator = new RegexBasedInterpolator(); try { interpolator.addValueSource( new EnvarBasedValueSource() ); } catch ( IOException e ) { // ignored } interpolator.addValueSource( new MapBasedValueSource( System.getProperties() ) ); try { if ( StringUtils.isNotEmpty( fileString ) ) { fileString = StringUtils.replace( interpolator.interpolate( fileString, "" ), "\\", "/" ); return FileUtils.fileExists( fileString ); } // check if the file is missing, if it is then the profile will be active fileString = actFile.getMissing(); if ( StringUtils.isNotEmpty( fileString ) ) { fileString = StringUtils.replace( interpolator.interpolate( fileString, "" ), "\\", "/" ); return !FileUtils.fileExists( fileString ); } } catch ( InterpolationException e ) { if ( logger.isDebugEnabled() ) { logger.debug( "Failed to interpolate missing file location for profile activator: " + fileString, e ); } else { logger.warn( "Failed to interpolate missing file location for profile activator: " + fileString + ". Run in debug mode (-X) for more information." ); } } } return false; } public void enableLogging( Logger logger ) { this.logger = logger; } } JdkPrefixProfileActivator.java000066400000000000000000000062011317160430700357310ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/main/java/org/apache/maven/profiles/activationpackage org.apache.maven.profiles.activation; /* * 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 org.apache.maven.artifact.versioning.DefaultArtifactVersion; import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException; import org.apache.maven.artifact.versioning.VersionRange; import org.apache.maven.model.Activation; import org.apache.maven.model.Profile; import org.codehaus.plexus.util.StringUtils; @Deprecated public class JdkPrefixProfileActivator extends DetectedProfileActivator { private static final String JDK_VERSION = System.getProperty( "java.version" ); public boolean isActive( Profile profile ) throws ProfileActivationException { Activation activation = profile.getActivation(); String jdk = activation.getJdk(); // null case is covered by canDetermineActivation(), so we can do a straight startsWith() here. if ( jdk.startsWith( "[" ) || jdk.startsWith( "(" ) ) { try { return matchJdkVersionRange( jdk ); } catch ( InvalidVersionSpecificationException e ) { throw new ProfileActivationException( "Invalid JDK version in profile '" + profile.getId() + "': " + e.getMessage() ); } } boolean reverse = false; if ( jdk.startsWith( "!" ) ) { reverse = true; jdk = jdk.substring( 1 ); } if ( getJdkVersion().startsWith( jdk ) ) { return !reverse; } else { return reverse; } } private boolean matchJdkVersionRange( String jdk ) throws InvalidVersionSpecificationException { VersionRange jdkVersionRange = VersionRange.createFromVersionSpec( convertJdkToMavenVersion( jdk ) ); DefaultArtifactVersion jdkVersion = new DefaultArtifactVersion( convertJdkToMavenVersion( getJdkVersion() ) ); return jdkVersionRange.containsVersion( jdkVersion ); } private String convertJdkToMavenVersion( String jdk ) { return jdk.replaceAll( "_", "-" ); } protected String getJdkVersion() { return JDK_VERSION; } protected boolean canDetectActivation( Profile profile ) { return profile.getActivation() != null && StringUtils.isNotEmpty( profile.getActivation().getJdk() ); } } OperatingSystemProfileActivator.java000066400000000000000000000076341317160430700372130ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/main/java/org/apache/maven/profiles/activationpackage org.apache.maven.profiles.activation; /* * 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 org.apache.maven.model.Activation; import org.apache.maven.model.ActivationOS; import org.apache.maven.model.Profile; import org.codehaus.plexus.util.Os; @Deprecated public class OperatingSystemProfileActivator implements ProfileActivator { public boolean canDetermineActivation( Profile profile ) { Activation activation = profile.getActivation(); return activation != null && activation.getOs() != null; } public boolean isActive( Profile profile ) { Activation activation = profile.getActivation(); ActivationOS os = activation.getOs(); boolean result = ensureAtLeastOneNonNull( os ); if ( result && os.getFamily() != null ) { result = determineFamilyMatch( os.getFamily() ); } if ( result && os.getName() != null ) { result = determineNameMatch( os.getName() ); } if ( result && os.getArch() != null ) { result = determineArchMatch( os.getArch() ); } if ( result && os.getVersion() != null ) { result = determineVersionMatch( os.getVersion() ); } return result; } private boolean ensureAtLeastOneNonNull( ActivationOS os ) { return os.getArch() != null || os.getFamily() != null || os.getName() != null || os.getVersion() != null; } private boolean determineVersionMatch( String version ) { String test = version; boolean reverse = false; if ( test.startsWith( "!" ) ) { reverse = true; test = test.substring( 1 ); } boolean result = Os.isVersion( test ); if ( reverse ) { return !result; } else { return result; } } private boolean determineArchMatch( String arch ) { String test = arch; boolean reverse = false; if ( test.startsWith( "!" ) ) { reverse = true; test = test.substring( 1 ); } boolean result = Os.isArch( test ); if ( reverse ) { return !result; } else { return result; } } private boolean determineNameMatch( String name ) { String test = name; boolean reverse = false; if ( test.startsWith( "!" ) ) { reverse = true; test = test.substring( 1 ); } boolean result = Os.isName( test ); if ( reverse ) { return !result; } else { return result; } } private boolean determineFamilyMatch( String family ) { String test = family; boolean reverse = false; if ( test.startsWith( "!" ) ) { reverse = true; test = test.substring( 1 ); } boolean result = Os.isFamily( test ); if ( reverse ) { return !result; } else { return result; } } } ProfileActivationException.java000066400000000000000000000023031317160430700361450ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/main/java/org/apache/maven/profiles/activationpackage org.apache.maven.profiles.activation; /* * 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. */ @Deprecated public class ProfileActivationException extends Exception { private static final long serialVersionUID = -90820222109103638L; public ProfileActivationException( String message, Throwable cause ) { super( message, cause ); } public ProfileActivationException( String message ) { super( message ); } } ProfileActivator.java000066400000000000000000000021631317160430700341250ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/main/java/org/apache/maven/profiles/activationpackage org.apache.maven.profiles.activation; /* * 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 org.apache.maven.model.Profile; @Deprecated public interface ProfileActivator { String ROLE = ProfileActivator.class.getName(); boolean canDetermineActivation( Profile profile ); boolean isActive( Profile profile ) throws ProfileActivationException; } SystemPropertyProfileActivator.java000066400000000000000000000067701317160430700371070ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/main/java/org/apache/maven/profiles/activationpackage org.apache.maven.profiles.activation; /* * 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.util.Properties; import org.apache.maven.model.Activation; import org.apache.maven.model.ActivationProperty; import org.apache.maven.model.Profile; import org.codehaus.plexus.context.Context; import org.codehaus.plexus.context.ContextException; import org.codehaus.plexus.personality.plexus.lifecycle.phase.Contextualizable; import org.codehaus.plexus.util.StringUtils; @Deprecated public class SystemPropertyProfileActivator extends DetectedProfileActivator implements Contextualizable { private Properties properties; public void contextualize( Context context ) throws ContextException { properties = (Properties) context.get( "SystemProperties" ); } protected boolean canDetectActivation( Profile profile ) { return profile.getActivation() != null && profile.getActivation().getProperty() != null; } public boolean isActive( Profile profile ) throws ProfileActivationException { Activation activation = profile.getActivation(); ActivationProperty property = activation.getProperty(); if ( property != null ) { String name = property.getName(); boolean reverseName = false; if ( name == null ) { throw new ProfileActivationException( "The property name is required to activate the profile '" + profile.getId() + "'" ); } if ( name.startsWith( "!" ) ) { reverseName = true; name = name.substring( 1 ); } String sysValue = properties.getProperty( name ); String propValue = property.getValue(); if ( StringUtils.isNotEmpty( propValue ) ) { boolean reverseValue = false; if ( propValue.startsWith( "!" ) ) { reverseValue = true; propValue = propValue.substring( 1 ); } // we have a value, so it has to match the system value... boolean result = propValue.equals( sysValue ); if ( reverseValue ) { return !result; } else { return result; } } else { boolean result = StringUtils.isNotEmpty( sysValue ); if ( reverseName ) { return !result; } else { return result; } } } return false; } } maven-maven-3.5.2/maven-compat/src/main/java/org/apache/maven/project/000077500000000000000000000000001317160430700255445ustar00rootroot00000000000000DefaultMavenProjectBuilder.java000066400000000000000000000315201317160430700335420ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/main/java/org/apache/maven/projectpackage org.apache.maven.project; /* * 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.File; import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.Properties; import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.InvalidRepositoryException; import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.resolver.ArtifactNotFoundException; import org.apache.maven.artifact.resolver.ArtifactResolutionException; import org.apache.maven.execution.MavenExecutionRequest; import org.apache.maven.execution.MavenSession; import org.apache.maven.model.Repository; import org.apache.maven.model.building.ModelBuildingException; import org.apache.maven.model.building.ModelBuildingRequest; import org.apache.maven.model.building.ModelSource; import org.apache.maven.model.building.UrlModelSource; import org.apache.maven.plugin.LegacySupport; import org.apache.maven.profiles.ProfileManager; import org.apache.maven.properties.internal.EnvironmentUtils; import org.apache.maven.repository.RepositorySystem; import org.apache.maven.wagon.events.TransferListener; import org.codehaus.plexus.component.annotations.Component; import org.codehaus.plexus.component.annotations.Requirement; /** */ @Component( role = MavenProjectBuilder.class ) @Deprecated public class DefaultMavenProjectBuilder implements MavenProjectBuilder { @Requirement private ProjectBuilder projectBuilder; @Requirement private RepositorySystem repositorySystem; @Requirement private LegacySupport legacySupport; // ---------------------------------------------------------------------- // MavenProjectBuilder Implementation // ---------------------------------------------------------------------- private ProjectBuildingRequest toRequest( ProjectBuilderConfiguration configuration ) { DefaultProjectBuildingRequest request = new DefaultProjectBuildingRequest(); request.setValidationLevel( ModelBuildingRequest.VALIDATION_LEVEL_MAVEN_2_0 ); request.setResolveDependencies( false ); request.setLocalRepository( configuration.getLocalRepository() ); request.setBuildStartTime( configuration.getBuildStartTime() ); request.setUserProperties( configuration.getUserProperties() ); request.setSystemProperties( configuration.getExecutionProperties() ); ProfileManager profileManager = configuration.getGlobalProfileManager(); if ( profileManager != null ) { request.setActiveProfileIds( profileManager.getExplicitlyActivatedIds() ); request.setInactiveProfileIds( profileManager.getExplicitlyDeactivatedIds() ); } else { /* * MNG-4900: Hack to workaround deficiency of legacy API which makes it impossible for plugins to access the * global profile manager which is required to build a POM like a CLI invocation does. Failure to consider * the activated profiles can cause repo declarations to be lost which in turn will result in artifact * resolution failures, in particular when using the enhanced local repo which guards access to local files * based on the configured remote repos. */ MavenSession session = legacySupport.getSession(); if ( session != null ) { MavenExecutionRequest req = session.getRequest(); if ( req != null ) { request.setActiveProfileIds( req.getActiveProfiles() ); request.setInactiveProfileIds( req.getInactiveProfiles() ); } } } return request; } private ProjectBuildingRequest injectSession( ProjectBuildingRequest request ) { MavenSession session = legacySupport.getSession(); if ( session != null ) { request.setRepositorySession( session.getRepositorySession() ); request.setSystemProperties( session.getSystemProperties() ); if ( request.getUserProperties().isEmpty() ) { request.setUserProperties( session.getUserProperties() ); } MavenExecutionRequest req = session.getRequest(); if ( req != null ) { request.setRemoteRepositories( req.getRemoteRepositories() ); } } else { Properties props = new Properties(); EnvironmentUtils.addEnvVars( props ); props.putAll( System.getProperties() ); request.setSystemProperties( props ); } return request; } @SuppressWarnings( "unchecked" ) private List normalizeToArtifactRepositories( List repositories, ProjectBuildingRequest request ) throws ProjectBuildingException { /* * This provides backward-compat with 2.x that allowed plugins like the maven-remote-resources-plugin:1.0 to * populate the builder configuration with model repositories instead of artifact repositories. */ if ( repositories != null ) { boolean normalized = false; List repos = new ArrayList<>( repositories.size() ); for ( Object repository : repositories ) { if ( repository instanceof Repository ) { try { ArtifactRepository repo = repositorySystem.buildArtifactRepository( (Repository) repository ); repositorySystem.injectMirror( request.getRepositorySession(), Arrays.asList( repo ) ); repositorySystem.injectProxy( request.getRepositorySession(), Arrays.asList( repo ) ); repositorySystem.injectAuthentication( request.getRepositorySession(), Arrays.asList( repo ) ); repos.add( repo ); } catch ( InvalidRepositoryException e ) { throw new ProjectBuildingException( "", "Invalid remote repository " + repository, e ); } normalized = true; } else { repos.add( (ArtifactRepository) repository ); } } if ( normalized ) { return repos; } } return (List) repositories; } private ProjectBuildingException transformError( ProjectBuildingException e ) { if ( e.getCause() instanceof ModelBuildingException ) { return new InvalidProjectModelException( e.getProjectId(), e.getMessage(), e.getPomFile() ); } return e; } public MavenProject build( File pom, ProjectBuilderConfiguration configuration ) throws ProjectBuildingException { ProjectBuildingRequest request = injectSession( toRequest( configuration ) ); try { return projectBuilder.build( pom, request ).getProject(); } catch ( ProjectBuildingException e ) { throw transformError( e ); } } // This is used by the SITE plugin. public MavenProject build( File pom, ArtifactRepository localRepository, ProfileManager profileManager ) throws ProjectBuildingException { ProjectBuilderConfiguration configuration = new DefaultProjectBuilderConfiguration(); configuration.setLocalRepository( localRepository ); configuration.setGlobalProfileManager( profileManager ); return build( pom, configuration ); } public MavenProject buildFromRepository( Artifact artifact, List remoteRepositories, ProjectBuilderConfiguration configuration, boolean allowStubModel ) throws ProjectBuildingException { ProjectBuildingRequest request = injectSession( toRequest( configuration ) ); request.setRemoteRepositories( normalizeToArtifactRepositories( remoteRepositories, request ) ); request.setProcessPlugins( false ); request.setValidationLevel( ModelBuildingRequest.VALIDATION_LEVEL_MINIMAL ); try { return projectBuilder.build( artifact, allowStubModel, request ).getProject(); } catch ( ProjectBuildingException e ) { throw transformError( e ); } } public MavenProject buildFromRepository( Artifact artifact, List remoteRepositories, ArtifactRepository localRepository, boolean allowStubModel ) throws ProjectBuildingException { ProjectBuilderConfiguration configuration = new DefaultProjectBuilderConfiguration(); configuration.setLocalRepository( localRepository ); return buildFromRepository( artifact, remoteRepositories, configuration, allowStubModel ); } public MavenProject buildFromRepository( Artifact artifact, List remoteRepositories, ArtifactRepository localRepository ) throws ProjectBuildingException { return buildFromRepository( artifact, remoteRepositories, localRepository, true ); } /** * This is used for pom-less execution like running archetype:generate. I am taking out the profile handling and the * interpolation of the base directory until we spec this out properly. */ public MavenProject buildStandaloneSuperProject( ProjectBuilderConfiguration configuration ) throws ProjectBuildingException { ProjectBuildingRequest request = injectSession( toRequest( configuration ) ); request.setProcessPlugins( false ); request.setValidationLevel( ModelBuildingRequest.VALIDATION_LEVEL_MINIMAL ); ModelSource modelSource = new UrlModelSource( getClass().getResource( "standalone.xml" ) ); MavenProject project = projectBuilder.build( modelSource, request ).getProject(); project.setExecutionRoot( true ); return project; } public MavenProject buildStandaloneSuperProject( ArtifactRepository localRepository ) throws ProjectBuildingException { return buildStandaloneSuperProject( localRepository, null ); } public MavenProject buildStandaloneSuperProject( ArtifactRepository localRepository, ProfileManager profileManager ) throws ProjectBuildingException { ProjectBuilderConfiguration configuration = new DefaultProjectBuilderConfiguration(); configuration.setLocalRepository( localRepository ); configuration.setGlobalProfileManager( profileManager ); return buildStandaloneSuperProject( configuration ); } public MavenProject buildWithDependencies( File pom, ArtifactRepository localRepository, ProfileManager profileManager, TransferListener transferListener ) throws ProjectBuildingException, ArtifactResolutionException, ArtifactNotFoundException { ProjectBuilderConfiguration configuration = new DefaultProjectBuilderConfiguration(); configuration.setLocalRepository( localRepository ); configuration.setGlobalProfileManager( profileManager ); ProjectBuildingRequest request = injectSession( toRequest( configuration ) ); request.setResolveDependencies( true ); try { return projectBuilder.build( pom, request ).getProject(); } catch ( ProjectBuildingException e ) { throw transformError( e ); } } public MavenProject buildWithDependencies( File pom, ArtifactRepository localRepository, ProfileManager profileManager ) throws ProjectBuildingException, ArtifactResolutionException, ArtifactNotFoundException { return buildWithDependencies( pom, localRepository, profileManager, null ); } } DefaultProjectBuilderConfiguration.java000066400000000000000000000054701317160430700353100ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/main/java/org/apache/maven/projectpackage org.apache.maven.project; /* * 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.util.Date; import java.util.Properties; import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.profiles.ProfileManager; @Deprecated public class DefaultProjectBuilderConfiguration implements ProjectBuilderConfiguration { private ProfileManager globalProfileManager; private ArtifactRepository localRepository; private Properties userProperties; private Properties executionProperties = System.getProperties(); private Date buildStartTime; public DefaultProjectBuilderConfiguration() { } public ProjectBuilderConfiguration setGlobalProfileManager( ProfileManager globalProfileManager ) { this.globalProfileManager = globalProfileManager; return this; } public ProfileManager getGlobalProfileManager() { return globalProfileManager; } public ProjectBuilderConfiguration setLocalRepository( ArtifactRepository localRepository ) { this.localRepository = localRepository; return this; } public ArtifactRepository getLocalRepository() { return localRepository; } public ProjectBuilderConfiguration setUserProperties( Properties userProperties ) { this.userProperties = userProperties; return this; } public Properties getUserProperties() { if ( userProperties == null ) { userProperties = new Properties(); } return userProperties; } public Properties getExecutionProperties() { return executionProperties; } public ProjectBuilderConfiguration setExecutionProperties( Properties executionProperties ) { this.executionProperties = executionProperties; return this; } public Date getBuildStartTime() { return buildStartTime; } public ProjectBuilderConfiguration setBuildStartTime( Date buildStartTime ) { this.buildStartTime = buildStartTime; return this; } } InvalidProjectModelException.java000066400000000000000000000046401317160430700341110ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/main/java/org/apache/maven/projectpackage org.apache.maven.project; /* * 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.File; import org.apache.maven.project.validation.ModelValidationResult; @Deprecated public class InvalidProjectModelException extends ProjectBuildingException { private ModelValidationResult validationResult; public InvalidProjectModelException( String projectId, String message, File pomLocation ) { super( projectId, message, pomLocation ); } /** * @param projectId * @param pomLocation absolute path of the pom file * @param message * @param validationResult * @deprecated use {@link File} constructor for pomLocation */ public InvalidProjectModelException( String projectId, String pomLocation, String message, ModelValidationResult validationResult ) { this( projectId, message, new File( pomLocation ), validationResult ); } public InvalidProjectModelException( String projectId, String message, File pomFile, ModelValidationResult validationResult ) { super( projectId, message, pomFile ); this.validationResult = validationResult; } /** * @param projectId * @param pomLocation absolute path of the pom file * @param message * @deprecated use {@link File} constructor for pomLocation */ public InvalidProjectModelException( String projectId, String pomLocation, String message ) { this( projectId, message, new File( pomLocation ) ); } public final ModelValidationResult getValidationResult() { return validationResult; } } maven-maven-3.5.2/maven-compat/src/main/java/org/apache/maven/project/MavenProjectBuilder.java000066400000000000000000000067471317160430700323310ustar00rootroot00000000000000package org.apache.maven.project; /* * 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.File; import java.util.List; import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.resolver.ArtifactNotFoundException; import org.apache.maven.artifact.resolver.ArtifactResolutionException; import org.apache.maven.profiles.ProfileManager; import org.apache.maven.wagon.events.TransferListener; /** * @deprecated use {@link ProjectBuilder} instead */ @Deprecated public interface MavenProjectBuilder { MavenProject build( File pom, ProjectBuilderConfiguration configuration ) throws ProjectBuildingException; //TODO maven-site-plugin -- not used by the plugin directly, but used by Doxia Integration Tool & MPIR // see DOXIASITETOOLS-167 & MPIR-349 MavenProject build( File pom, ArtifactRepository localRepository, ProfileManager profileManager ) throws ProjectBuildingException; //TODO remote-resources-plugin MavenProject buildFromRepository( Artifact artifact, List remoteRepositories, ArtifactRepository localRepository ) throws ProjectBuildingException; //TODO remote-resources-plugin MavenProject buildFromRepository( Artifact artifact, List remoteRepositories, ArtifactRepository localRepository, boolean allowStubModel ) throws ProjectBuildingException; // TODO this is only to provide a project for plugins that don't need a project to execute but need some // of the values from a MavenProject. Ideally this should be something internal and nothing outside Maven // would ever need this so it should not be exposed in a public API MavenProject buildStandaloneSuperProject( ProjectBuilderConfiguration configuration ) throws ProjectBuildingException; MavenProject buildStandaloneSuperProject( ArtifactRepository localRepository ) throws ProjectBuildingException; MavenProject buildStandaloneSuperProject( ArtifactRepository localRepository, ProfileManager profileManager ) throws ProjectBuildingException; MavenProject buildWithDependencies( File pom, ArtifactRepository localRepository, ProfileManager globalProfileManager, TransferListener transferListener ) throws ProjectBuildingException, ArtifactResolutionException, ArtifactNotFoundException; MavenProject buildWithDependencies( File pom, ArtifactRepository localRepository, ProfileManager globalProfileManager ) throws ProjectBuildingException, ArtifactResolutionException, ArtifactNotFoundException; } MissingRepositoryElementException.java000066400000000000000000000023401317160430700352310ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/main/java/org/apache/maven/projectpackage org.apache.maven.project; /* * 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 org.apache.maven.artifact.InvalidRepositoryException; public class MissingRepositoryElementException extends InvalidRepositoryException { public MissingRepositoryElementException( String message, String repositoryId ) { super( message, repositoryId ); } public MissingRepositoryElementException( String message ) { super( message, "-unknown-" ); } } maven-maven-3.5.2/maven-compat/src/main/java/org/apache/maven/project/ModelUtils.java000066400000000000000000000277131317160430700305020ustar00rootroot00000000000000package org.apache.maven.project; /* * 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.util.ArrayList; import java.util.Iterator; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import java.util.TreeMap; import org.apache.maven.model.Dependency; import org.apache.maven.model.Plugin; import org.apache.maven.model.PluginContainer; import org.apache.maven.model.PluginExecution; import org.apache.maven.model.Repository; import org.codehaus.plexus.util.xml.Xpp3Dom; /** @deprecated */ @Deprecated public final class ModelUtils { /** * This should be the resulting ordering of plugins after merging: *

* Given: *

     * parent: X -> A -> B -> D -> E
     * child: Y -> A -> C -> D -> F
     * 
* Result: *
     * X -> Y -> A -> B -> C -> D -> E -> F
     * 
*/ public static void mergePluginLists( PluginContainer childContainer, PluginContainer parentContainer, boolean handleAsInheritance ) { if ( ( childContainer == null ) || ( parentContainer == null ) ) { // nothing to do. return; } List parentPlugins = parentContainer.getPlugins(); if ( ( parentPlugins != null ) && !parentPlugins.isEmpty() ) { parentPlugins = new ArrayList<>( parentPlugins ); // If we're processing this merge as an inheritance, we have to build up a list of // plugins that were considered for inheritance. if ( handleAsInheritance ) { for ( Iterator it = parentPlugins.iterator(); it.hasNext(); ) { Plugin plugin = it.next(); String inherited = plugin.getInherited(); if ( ( inherited != null ) && !Boolean.valueOf( inherited ) ) { it.remove(); } } } List assembledPlugins = new ArrayList<>(); Map childPlugins = childContainer.getPluginsAsMap(); for ( Plugin parentPlugin : parentPlugins ) { String parentInherited = parentPlugin.getInherited(); // only merge plugin definition from the parent if at least one // of these is true: // 1. we're not processing the plugins in an inheritance-based merge // 2. the parent's flag is not set // 3. the parent's flag is set to true if ( !handleAsInheritance || ( parentInherited == null ) || Boolean.valueOf( parentInherited ) ) { Plugin childPlugin = childPlugins.get( parentPlugin.getKey() ); if ( ( childPlugin != null ) && !assembledPlugins.contains( childPlugin ) ) { Plugin assembledPlugin = childPlugin; mergePluginDefinitions( childPlugin, parentPlugin, handleAsInheritance ); // fix for MNG-2221 (assembly cache was not being populated for later reference): assembledPlugins.add( assembledPlugin ); } // if we're processing this as an inheritance-based merge, and // the parent's flag is not set, then we need to // clear the inherited flag in the merge result. if ( handleAsInheritance && ( parentInherited == null ) ) { parentPlugin.unsetInheritanceApplied(); } } // very important to use the parentPlugins List, rather than parentContainer.getPlugins() // since this list is a local one, and may have been modified during processing. List results = ModelUtils.orderAfterMerge( assembledPlugins, parentPlugins, childContainer.getPlugins() ); childContainer.setPlugins( results ); childContainer.flushPluginMap(); } } } public static List orderAfterMerge( List merged, List highPrioritySource, List lowPrioritySource ) { List results = new ArrayList<>(); if ( !merged.isEmpty() ) { results.addAll( merged ); } List missingFromResults = new ArrayList<>(); List> sources = new ArrayList<>(); sources.add( highPrioritySource ); sources.add( lowPrioritySource ); for ( List source : sources ) { for ( Plugin item : source ) { if ( results.contains( item ) ) { if ( !missingFromResults.isEmpty() ) { int idx = results.indexOf( item ); if ( idx < 0 ) { idx = 0; } results.addAll( idx, missingFromResults ); missingFromResults.clear(); } } else { missingFromResults.add( item ); } } if ( !missingFromResults.isEmpty() ) { results.addAll( missingFromResults ); missingFromResults.clear(); } } return results; } public static void mergePluginDefinitions( Plugin child, Plugin parent, boolean handleAsInheritance ) { if ( ( child == null ) || ( parent == null ) ) { // nothing to do. return; } if ( parent.isExtensions() ) { child.setExtensions( true ); } if ( ( child.getVersion() == null ) && ( parent.getVersion() != null ) ) { child.setVersion( parent.getVersion() ); } Xpp3Dom childConfiguration = (Xpp3Dom) child.getConfiguration(); Xpp3Dom parentConfiguration = (Xpp3Dom) parent.getConfiguration(); childConfiguration = Xpp3Dom.mergeXpp3Dom( childConfiguration, parentConfiguration ); child.setConfiguration( childConfiguration ); child.setDependencies( mergeDependencyList( child.getDependencies(), parent.getDependencies() ) ); // from here to the end of the method is dealing with merging of the section. String parentInherited = parent.getInherited(); boolean parentIsInherited = ( parentInherited == null ) || Boolean.valueOf( parentInherited ); List parentExecutions = parent.getExecutions(); if ( ( parentExecutions != null ) && !parentExecutions.isEmpty() ) { List mergedExecutions = new ArrayList<>(); Map assembledExecutions = new TreeMap<>(); Map childExecutions = child.getExecutionsAsMap(); for ( PluginExecution parentExecution : parentExecutions ) { String inherited = parentExecution.getInherited(); boolean parentExecInherited = parentIsInherited && ( ( inherited == null ) || Boolean.valueOf( inherited ) ); if ( !handleAsInheritance || parentExecInherited ) { PluginExecution assembled = parentExecution; PluginExecution childExecution = childExecutions.get( parentExecution.getId() ); if ( childExecution != null ) { mergePluginExecutionDefinitions( childExecution, parentExecution ); assembled = childExecution; } else if ( handleAsInheritance && ( parentInherited == null ) ) { parentExecution.unsetInheritanceApplied(); } assembledExecutions.put( assembled.getId(), assembled ); mergedExecutions.add( assembled ); } } for ( PluginExecution childExecution : child.getExecutions() ) { if ( !assembledExecutions.containsKey( childExecution.getId() ) ) { mergedExecutions.add( childExecution ); } } child.setExecutions( mergedExecutions ); child.flushExecutionMap(); } } private static void mergePluginExecutionDefinitions( PluginExecution child, PluginExecution parent ) { if ( child.getPhase() == null ) { child.setPhase( parent.getPhase() ); } List parentGoals = parent.getGoals(); List childGoals = child.getGoals(); List goals = new ArrayList<>(); if ( ( childGoals != null ) && !childGoals.isEmpty() ) { goals.addAll( childGoals ); } if ( parentGoals != null ) { for ( String goal : parentGoals ) { if ( !goals.contains( goal ) ) { goals.add( goal ); } } } child.setGoals( goals ); Xpp3Dom childConfiguration = (Xpp3Dom) child.getConfiguration(); Xpp3Dom parentConfiguration = (Xpp3Dom) parent.getConfiguration(); childConfiguration = Xpp3Dom.mergeXpp3Dom( childConfiguration, parentConfiguration ); child.setConfiguration( childConfiguration ); } public static List mergeRepositoryLists( List dominant, List recessive ) { List repositories = new ArrayList<>(); for ( Repository repository : dominant ) { repositories.add( repository ); } for ( Repository repository : recessive ) { if ( !repositories.contains( repository ) ) { repositories.add( repository ); } } return repositories; } public static void mergeFilterLists( List childFilters, List parentFilters ) { for ( String f : parentFilters ) { if ( !childFilters.contains( f ) ) { childFilters.add( f ); } } } private static List mergeDependencyList( List child, List parent ) { Map depsMap = new LinkedHashMap<>(); if ( parent != null ) { for ( Dependency dependency : parent ) { depsMap.put( dependency.getManagementKey(), dependency ); } } if ( child != null ) { for ( Dependency dependency : child ) { depsMap.put( dependency.getManagementKey(), dependency ); } } return new ArrayList<>( depsMap.values() ); } } ProjectBuilderConfiguration.java000066400000000000000000000033601317160430700337770ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/main/java/org/apache/maven/projectpackage org.apache.maven.project; /* * 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.util.Date; import java.util.Properties; import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.profiles.ProfileManager; /** * @deprecated use {@link ProjectBuildingRequest} instead */ @Deprecated public interface ProjectBuilderConfiguration { ArtifactRepository getLocalRepository(); ProfileManager getGlobalProfileManager(); Properties getUserProperties(); Properties getExecutionProperties(); ProjectBuilderConfiguration setGlobalProfileManager( ProfileManager globalProfileManager ); ProjectBuilderConfiguration setLocalRepository( ArtifactRepository localRepository ); ProjectBuilderConfiguration setUserProperties( Properties userProperties ); ProjectBuilderConfiguration setExecutionProperties( Properties executionProperties ); Date getBuildStartTime(); ProjectBuilderConfiguration setBuildStartTime( Date buildStartTime ); } maven-maven-3.5.2/maven-compat/src/main/java/org/apache/maven/project/ProjectUtils.java000066400000000000000000000075561317160430700310530ustar00rootroot00000000000000package org.apache.maven.project; /* * 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.util.ArrayList; import java.util.Arrays; import java.util.List; import org.apache.maven.artifact.InvalidRepositoryException; import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.repository.ArtifactRepositoryFactory; import org.apache.maven.model.DeploymentRepository; import org.apache.maven.model.Repository; import org.apache.maven.plugin.LegacySupport; import org.apache.maven.repository.RepositorySystem; import org.codehaus.plexus.PlexusContainer; import org.codehaus.plexus.component.repository.exception.ComponentLookupException; import org.eclipse.aether.RepositorySystemSession; // This class needs to stick around because it was exposed the the remote resources plugin started using it instead of // getting the repositories from the project. @Deprecated public final class ProjectUtils { private ProjectUtils() { } public static List buildArtifactRepositories( List repositories, ArtifactRepositoryFactory artifactRepositoryFactory, PlexusContainer c ) throws InvalidRepositoryException { List remoteRepositories = new ArrayList<>(); for ( Repository r : repositories ) { remoteRepositories.add( buildArtifactRepository( r, artifactRepositoryFactory, c ) ); } return remoteRepositories; } public static ArtifactRepository buildDeploymentArtifactRepository( DeploymentRepository repo, ArtifactRepositoryFactory artifactRepositoryFactory, PlexusContainer c ) throws InvalidRepositoryException { return buildArtifactRepository( repo, artifactRepositoryFactory, c ); } public static ArtifactRepository buildArtifactRepository( Repository repo, ArtifactRepositoryFactory artifactRepositoryFactory, PlexusContainer c ) throws InvalidRepositoryException { RepositorySystem repositorySystem = rs( c ); RepositorySystemSession session = rss( c ); ArtifactRepository repository = repositorySystem.buildArtifactRepository( repo ); if ( session != null ) { repositorySystem.injectMirror( session, Arrays.asList( repository ) ); repositorySystem.injectProxy( session, Arrays.asList( repository ) ); repositorySystem.injectAuthentication( session, Arrays.asList( repository ) ); } return repository; } private static RepositorySystem rs( PlexusContainer c ) { try { return c.lookup( RepositorySystem.class ); } catch ( ComponentLookupException e ) { throw new IllegalStateException( e ); } } private static RepositorySystemSession rss( PlexusContainer c ) { try { LegacySupport legacySupport = c.lookup( LegacySupport.class ); return legacySupport.getRepositorySession(); } catch ( ComponentLookupException e ) { throw new IllegalStateException( e ); } } } maven-maven-3.5.2/maven-compat/src/main/java/org/apache/maven/project/inheritance/000077500000000000000000000000001317160430700300355ustar00rootroot00000000000000DefaultModelInheritanceAssembler.java000066400000000000000000000601241317160430700372010ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/main/java/org/apache/maven/project/inheritancepackage org.apache.maven.project.inheritance; /* * 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.util.ArrayList; import java.util.LinkedHashMap; import java.util.LinkedList; import java.util.List; import java.util.Map; import java.util.Properties; import java.util.StringTokenizer; import java.util.TreeMap; import org.apache.maven.model.Build; import org.apache.maven.model.Dependency; import org.apache.maven.model.DependencyManagement; import org.apache.maven.model.DeploymentRepository; import org.apache.maven.model.DistributionManagement; import org.apache.maven.model.Extension; import org.apache.maven.model.Model; import org.apache.maven.model.PluginManagement; import org.apache.maven.model.ReportPlugin; import org.apache.maven.model.ReportSet; import org.apache.maven.model.Reporting; import org.apache.maven.model.Resource; import org.apache.maven.model.Scm; import org.apache.maven.model.Site; import org.apache.maven.project.ModelUtils; import org.codehaus.plexus.component.annotations.Component; import org.codehaus.plexus.util.StringUtils; import org.codehaus.plexus.util.xml.Xpp3Dom; @Component( role = ModelInheritanceAssembler.class ) public class DefaultModelInheritanceAssembler implements ModelInheritanceAssembler { // TODO Remove this! @SuppressWarnings( "unchecked" ) public void assembleBuildInheritance( Build childBuild, Build parentBuild, boolean handleAsInheritance ) { // The build has been set but we want to step in here and fill in // values that have not been set by the child. if ( childBuild.getSourceDirectory() == null ) { childBuild.setSourceDirectory( parentBuild.getSourceDirectory() ); } if ( childBuild.getScriptSourceDirectory() == null ) { childBuild.setScriptSourceDirectory( parentBuild.getScriptSourceDirectory() ); } if ( childBuild.getTestSourceDirectory() == null ) { childBuild.setTestSourceDirectory( parentBuild.getTestSourceDirectory() ); } if ( childBuild.getOutputDirectory() == null ) { childBuild.setOutputDirectory( parentBuild.getOutputDirectory() ); } if ( childBuild.getTestOutputDirectory() == null ) { childBuild.setTestOutputDirectory( parentBuild.getTestOutputDirectory() ); } // Extensions are accumulated mergeExtensionLists( childBuild, parentBuild ); if ( childBuild.getDirectory() == null ) { childBuild.setDirectory( parentBuild.getDirectory() ); } if ( childBuild.getDefaultGoal() == null ) { childBuild.setDefaultGoal( parentBuild.getDefaultGoal() ); } if ( childBuild.getFinalName() == null ) { childBuild.setFinalName( parentBuild.getFinalName() ); } ModelUtils.mergeFilterLists( childBuild.getFilters(), parentBuild.getFilters() ); List resources = childBuild.getResources(); if ( ( resources == null ) || resources.isEmpty() ) { childBuild.setResources( parentBuild.getResources() ); } resources = childBuild.getTestResources(); if ( ( resources == null ) || resources.isEmpty() ) { childBuild.setTestResources( parentBuild.getTestResources() ); } // Plugins are aggregated if Plugin.inherit != false ModelUtils.mergePluginLists( childBuild, parentBuild, handleAsInheritance ); // Plugin management :: aggregate PluginManagement dominantPM = childBuild.getPluginManagement(); PluginManagement recessivePM = parentBuild.getPluginManagement(); if ( ( dominantPM == null ) && ( recessivePM != null ) ) { // FIXME: Filter out the inherited == false stuff! childBuild.setPluginManagement( recessivePM ); } else { ModelUtils.mergePluginLists( childBuild.getPluginManagement(), parentBuild.getPluginManagement(), false ); } } private void assembleScmInheritance( Model child, Model parent, String childPathAdjustment, boolean appendPaths ) { if ( parent.getScm() != null ) { Scm parentScm = parent.getScm(); Scm childScm = child.getScm(); if ( childScm == null ) { childScm = new Scm(); child.setScm( childScm ); } if ( StringUtils.isEmpty( childScm.getConnection() ) && !StringUtils.isEmpty( parentScm.getConnection() ) ) { childScm.setConnection( appendPath( parentScm.getConnection(), child.getArtifactId(), childPathAdjustment, appendPaths ) ); } if ( StringUtils.isEmpty( childScm.getDeveloperConnection() ) && !StringUtils.isEmpty( parentScm.getDeveloperConnection() ) ) { childScm .setDeveloperConnection( appendPath( parentScm.getDeveloperConnection(), child.getArtifactId(), childPathAdjustment, appendPaths ) ); } if ( StringUtils.isEmpty( childScm.getUrl() ) && !StringUtils.isEmpty( parentScm.getUrl() ) ) { childScm.setUrl( appendPath( parentScm.getUrl(), child.getArtifactId(), childPathAdjustment, appendPaths ) ); } } } public void copyModel( Model dest, Model source ) { assembleModelInheritance( dest, source, null, false ); } public void assembleModelInheritance( Model child, Model parent, String childPathAdjustment ) { assembleModelInheritance( child, parent, childPathAdjustment, true ); } public void assembleModelInheritance( Model child, Model parent ) { assembleModelInheritance( child, parent, null, true ); } private void assembleModelInheritance( Model child, Model parent, String childPathAdjustment, boolean appendPaths ) { // cannot inherit from null parent. if ( parent == null ) { return; } // Group id if ( child.getGroupId() == null ) { child.setGroupId( parent.getGroupId() ); } // version if ( child.getVersion() == null ) { // The parent version may have resolved to something different, so we take what we asked for... // instead of - child.setVersion( parent.getVersion() ); if ( child.getParent() != null ) { child.setVersion( child.getParent().getVersion() ); } } // inceptionYear if ( child.getInceptionYear() == null ) { child.setInceptionYear( parent.getInceptionYear() ); } // url if ( child.getUrl() == null ) { if ( parent.getUrl() != null ) { child.setUrl( appendPath( parent.getUrl(), child.getArtifactId(), childPathAdjustment, appendPaths ) ); } else { child.setUrl( parent.getUrl() ); } } assembleDistributionInheritance( child, parent, childPathAdjustment, appendPaths ); // issueManagement if ( child.getIssueManagement() == null ) { child.setIssueManagement( parent.getIssueManagement() ); } // description if ( child.getDescription() == null ) { child.setDescription( parent.getDescription() ); } // Organization if ( child.getOrganization() == null ) { child.setOrganization( parent.getOrganization() ); } // Scm assembleScmInheritance( child, parent, childPathAdjustment, appendPaths ); // ciManagement if ( child.getCiManagement() == null ) { child.setCiManagement( parent.getCiManagement() ); } // developers if ( child.getDevelopers().size() == 0 ) { child.setDevelopers( parent.getDevelopers() ); } // licenses if ( child.getLicenses().size() == 0 ) { child.setLicenses( parent.getLicenses() ); } // developers if ( child.getContributors().size() == 0 ) { child.setContributors( parent.getContributors() ); } // mailingLists if ( child.getMailingLists().size() == 0 ) { child.setMailingLists( parent.getMailingLists() ); } // Build assembleBuildInheritance( child, parent ); assembleDependencyInheritance( child, parent ); child.setRepositories( ModelUtils.mergeRepositoryLists( child.getRepositories(), parent.getRepositories() ) ); // child.setPluginRepositories( // ModelUtils.mergeRepositoryLists( child.getPluginRepositories(), parent.getPluginRepositories() ) ); assembleReportingInheritance( child, parent ); assembleDependencyManagementInheritance( child, parent ); Properties props = new Properties(); props.putAll( parent.getProperties() ); props.putAll( child.getProperties() ); child.setProperties( props ); } // TODO Remove this! @SuppressWarnings( "unchecked" ) private void assembleDependencyManagementInheritance( Model child, Model parent ) { DependencyManagement parentDepMgmt = parent.getDependencyManagement(); DependencyManagement childDepMgmt = child.getDependencyManagement(); if ( parentDepMgmt != null ) { if ( childDepMgmt == null ) { child.setDependencyManagement( parentDepMgmt ); } else { List childDeps = childDepMgmt.getDependencies(); Map mappedChildDeps = new TreeMap<>(); for ( Dependency dep : childDeps ) { mappedChildDeps.put( dep.getManagementKey(), dep ); } for ( Dependency dep : parentDepMgmt.getDependencies() ) { if ( !mappedChildDeps.containsKey( dep.getManagementKey() ) ) { childDepMgmt.addDependency( dep ); } } } } } private void assembleReportingInheritance( Model child, Model parent ) { // Reports :: aggregate Reporting childReporting = child.getReporting(); Reporting parentReporting = parent.getReporting(); if ( parentReporting != null ) { if ( childReporting == null ) { childReporting = new Reporting(); child.setReporting( childReporting ); } childReporting.setExcludeDefaults( parentReporting.isExcludeDefaults() ); if ( StringUtils.isEmpty( childReporting.getOutputDirectory() ) ) { childReporting.setOutputDirectory( parentReporting.getOutputDirectory() ); } mergeReportPluginLists( childReporting, parentReporting, true ); } } private static void mergeReportPluginLists( Reporting child, Reporting parent, boolean handleAsInheritance ) { if ( ( child == null ) || ( parent == null ) ) { // nothing to do. return; } List parentPlugins = parent.getPlugins(); if ( ( parentPlugins != null ) && !parentPlugins.isEmpty() ) { Map assembledPlugins = new TreeMap<>(); Map childPlugins = child.getReportPluginsAsMap(); for ( ReportPlugin parentPlugin : parentPlugins ) { String parentInherited = parentPlugin.getInherited(); if ( !handleAsInheritance || ( parentInherited == null ) || Boolean.valueOf( parentInherited ) ) { ReportPlugin assembledPlugin = parentPlugin; ReportPlugin childPlugin = childPlugins.get( parentPlugin.getKey() ); if ( childPlugin != null ) { assembledPlugin = childPlugin; mergeReportPluginDefinitions( childPlugin, parentPlugin, handleAsInheritance ); } if ( handleAsInheritance && ( parentInherited == null ) ) { assembledPlugin.unsetInheritanceApplied(); } assembledPlugins.put( assembledPlugin.getKey(), assembledPlugin ); } } for ( ReportPlugin childPlugin : childPlugins.values() ) { if ( !assembledPlugins.containsKey( childPlugin.getKey() ) ) { assembledPlugins.put( childPlugin.getKey(), childPlugin ); } } child.setPlugins( new ArrayList<>( assembledPlugins.values() ) ); child.flushReportPluginMap(); } } private static void mergeReportSetDefinitions( ReportSet child, ReportSet parent ) { List parentReports = parent.getReports(); List childReports = child.getReports(); List reports = new ArrayList<>(); if ( ( childReports != null ) && !childReports.isEmpty() ) { reports.addAll( childReports ); } if ( parentReports != null ) { for ( String report : parentReports ) { if ( !reports.contains( report ) ) { reports.add( report ); } } } child.setReports( reports ); Xpp3Dom childConfiguration = (Xpp3Dom) child.getConfiguration(); Xpp3Dom parentConfiguration = (Xpp3Dom) parent.getConfiguration(); childConfiguration = Xpp3Dom.mergeXpp3Dom( childConfiguration, parentConfiguration ); child.setConfiguration( childConfiguration ); } public static void mergeReportPluginDefinitions( ReportPlugin child, ReportPlugin parent, boolean handleAsInheritance ) { if ( ( child == null ) || ( parent == null ) ) { // nothing to do. return; } if ( ( child.getVersion() == null ) && ( parent.getVersion() != null ) ) { child.setVersion( parent.getVersion() ); } // from here to the end of the method is dealing with merging of the section. String parentInherited = parent.getInherited(); boolean parentIsInherited = ( parentInherited == null ) || Boolean.valueOf( parentInherited ); List parentReportSets = parent.getReportSets(); if ( ( parentReportSets != null ) && !parentReportSets.isEmpty() ) { Map assembledReportSets = new TreeMap<>(); Map childReportSets = child.getReportSetsAsMap(); for ( Object parentReportSet1 : parentReportSets ) { ReportSet parentReportSet = (ReportSet) parentReportSet1; if ( !handleAsInheritance || parentIsInherited ) { ReportSet assembledReportSet = parentReportSet; ReportSet childReportSet = childReportSets.get( parentReportSet.getId() ); if ( childReportSet != null ) { mergeReportSetDefinitions( childReportSet, parentReportSet ); assembledReportSet = childReportSet; } else if ( handleAsInheritance && ( parentInherited == null ) ) { parentReportSet.unsetInheritanceApplied(); } assembledReportSets.put( assembledReportSet.getId(), assembledReportSet ); } } for ( Map.Entry entry : childReportSets.entrySet() ) { String id = entry.getKey(); if ( !assembledReportSets.containsKey( id ) ) { assembledReportSets.put( id, entry.getValue() ); } } child.setReportSets( new ArrayList<>( assembledReportSets.values() ) ); child.flushReportSetMap(); } } // TODO Remove this! @SuppressWarnings( "unchecked" ) private void assembleDependencyInheritance( Model child, Model parent ) { Map depsMap = new LinkedHashMap<>(); List deps = parent.getDependencies(); if ( deps != null ) { for ( Dependency dependency : deps ) { depsMap.put( dependency.getManagementKey(), dependency ); } } deps = child.getDependencies(); if ( deps != null ) { for ( Dependency dependency : deps ) { depsMap.put( dependency.getManagementKey(), dependency ); } } child.setDependencies( new ArrayList<>( depsMap.values() ) ); } private void assembleBuildInheritance( Model child, Model parent ) { Build childBuild = child.getBuild(); Build parentBuild = parent.getBuild(); if ( parentBuild != null ) { if ( childBuild == null ) { childBuild = new Build(); child.setBuild( childBuild ); } assembleBuildInheritance( childBuild, parentBuild, true ); } } private void assembleDistributionInheritance( Model child, Model parent, String childPathAdjustment, boolean appendPaths ) { if ( parent.getDistributionManagement() != null ) { DistributionManagement parentDistMgmt = parent.getDistributionManagement(); DistributionManagement childDistMgmt = child.getDistributionManagement(); if ( childDistMgmt == null ) { childDistMgmt = new DistributionManagement(); child.setDistributionManagement( childDistMgmt ); } if ( childDistMgmt.getSite() == null ) { if ( parentDistMgmt.getSite() != null ) { Site site = new Site(); childDistMgmt.setSite( site ); site.setId( parentDistMgmt.getSite().getId() ); site.setName( parentDistMgmt.getSite().getName() ); site.setUrl( parentDistMgmt.getSite().getUrl() ); if ( site.getUrl() != null ) { site.setUrl( appendPath( site.getUrl(), child.getArtifactId(), childPathAdjustment, appendPaths ) ); } } } if ( childDistMgmt.getRepository() == null ) { if ( parentDistMgmt.getRepository() != null ) { DeploymentRepository repository = copyDistributionRepository( parentDistMgmt.getRepository() ); childDistMgmt.setRepository( repository ); } } if ( childDistMgmt.getSnapshotRepository() == null ) { if ( parentDistMgmt.getSnapshotRepository() != null ) { DeploymentRepository repository = copyDistributionRepository( parentDistMgmt.getSnapshotRepository() ); childDistMgmt.setSnapshotRepository( repository ); } } if ( StringUtils.isEmpty( childDistMgmt.getDownloadUrl() ) ) { childDistMgmt.setDownloadUrl( parentDistMgmt.getDownloadUrl() ); } // NOTE: We SHOULD NOT be inheriting status, since this is an assessment of the POM quality. // NOTE: We SHOULD NOT be inheriting relocation, since this relates to a single POM } } private static DeploymentRepository copyDistributionRepository( DeploymentRepository parentRepository ) { DeploymentRepository repository = new DeploymentRepository(); repository.setId( parentRepository.getId() ); repository.setName( parentRepository.getName() ); repository.setUrl( parentRepository.getUrl() ); repository.setLayout( parentRepository.getLayout() ); repository.setUniqueVersion( parentRepository.isUniqueVersion() ); return repository; } // TODO This should eventually be migrated to DefaultPathTranslator. protected String appendPath( String parentPath, String childPath, String pathAdjustment, boolean appendPaths ) { String uncleanPath = parentPath; if ( appendPaths ) { if ( pathAdjustment != null ) { uncleanPath += "/" + pathAdjustment; } if ( childPath != null ) { uncleanPath += "/" + childPath; } } String cleanedPath = ""; int protocolIdx = uncleanPath.indexOf( "://" ); if ( protocolIdx > -1 ) { cleanedPath = uncleanPath.substring( 0, protocolIdx + 3 ); uncleanPath = uncleanPath.substring( protocolIdx + 3 ); } if ( uncleanPath.startsWith( "/" ) ) { cleanedPath += "/"; } return cleanedPath + resolvePath( uncleanPath ); } // TODO Move this to plexus-utils' PathTool. private static String resolvePath( String uncleanPath ) { LinkedList pathElements = new LinkedList<>(); StringTokenizer tokenizer = new StringTokenizer( uncleanPath, "/" ); while ( tokenizer.hasMoreTokens() ) { String token = tokenizer.nextToken(); switch ( token ) { case "": // Empty path entry ("...//.."), remove. break; case "..": if ( pathElements.isEmpty() ) { // FIXME: somehow report to the user // that there are too many '..' elements. // For now, ignore the extra '..'. } else { pathElements.removeLast(); } break; default: pathElements.addLast( token ); break; } } StringBuilder cleanedPath = new StringBuilder(); while ( !pathElements.isEmpty() ) { cleanedPath.append( pathElements.removeFirst() ); if ( !pathElements.isEmpty() ) { cleanedPath.append( '/' ); } } return cleanedPath.toString(); } private static void mergeExtensionLists( Build childBuild, Build parentBuild ) { for ( Extension e : parentBuild.getExtensions() ) { if ( !childBuild.getExtensions().contains( e ) ) { childBuild.addExtension( e ); } } } } ModelInheritanceAssembler.java000066400000000000000000000026011317160430700356700ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/main/java/org/apache/maven/project/inheritancepackage org.apache.maven.project.inheritance; /* * 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 org.apache.maven.model.Build; import org.apache.maven.model.Model; /** * @author Jason van Zyl * @deprecated */ @Deprecated public interface ModelInheritanceAssembler { String ROLE = ModelInheritanceAssembler.class.getName(); void assembleModelInheritance( Model child, Model parent, String childPathAdjustment ); void assembleModelInheritance( Model child, Model parent ); void assembleBuildInheritance( Build childBuild, Build parentBuild, boolean handleAsInheritance ); void copyModel( Model dest, Model source ); } maven-maven-3.5.2/maven-compat/src/main/java/org/apache/maven/project/interpolation/000077500000000000000000000000001317160430700304335ustar00rootroot00000000000000AbstractStringBasedModelInterpolator.java000066400000000000000000000352741317160430700405070ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/main/java/org/apache/maven/project/interpolationpackage org.apache.maven.project.interpolation; /* * 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 org.apache.maven.model.Model; import org.apache.maven.model.io.xpp3.MavenXpp3Reader; import org.apache.maven.model.io.xpp3.MavenXpp3Writer; import org.apache.maven.project.DefaultProjectBuilderConfiguration; import org.apache.maven.project.ProjectBuilderConfiguration; import org.apache.maven.project.path.PathTranslator; import org.codehaus.plexus.component.annotations.Requirement; import org.codehaus.plexus.interpolation.AbstractValueSource; import org.codehaus.plexus.interpolation.InterpolationException; import org.codehaus.plexus.interpolation.InterpolationPostProcessor; import org.codehaus.plexus.interpolation.Interpolator; import org.codehaus.plexus.interpolation.MapBasedValueSource; import org.codehaus.plexus.interpolation.ObjectBasedValueSource; import org.codehaus.plexus.interpolation.PrefixAwareRecursionInterceptor; import org.codehaus.plexus.interpolation.PrefixedObjectValueSource; import org.codehaus.plexus.interpolation.PrefixedValueSourceWrapper; import org.codehaus.plexus.interpolation.RecursionInterceptor; import org.codehaus.plexus.interpolation.ValueSource; import org.codehaus.plexus.logging.AbstractLogEnabled; import org.codehaus.plexus.logging.Logger; import org.codehaus.plexus.personality.plexus.lifecycle.phase.Initializable; import org.codehaus.plexus.personality.plexus.lifecycle.phase.InitializationException; import org.codehaus.plexus.util.xml.pull.XmlPullParserException; import java.io.File; import java.io.IOException; import java.io.StringReader; import java.io.StringWriter; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.List; import java.util.Map; import java.util.Properties; /** * Use a regular expression search to find and resolve expressions within the POM. * * @author jdcasey Created on Feb 3, 2005 * TODO Consolidate this logic with the PluginParameterExpressionEvaluator, minus deprecations/bans. */ @Deprecated public abstract class AbstractStringBasedModelInterpolator extends AbstractLogEnabled implements ModelInterpolator, Initializable { private static final List PROJECT_PREFIXES = Arrays.asList( "pom.", "project." ); private static final List TRANSLATED_PATH_EXPRESSIONS; static { List translatedPrefixes = new ArrayList<>(); // MNG-1927, MNG-2124, MNG-3355: // If the build section is present and the project directory is non-null, we should make // sure interpolation of the directories below uses translated paths. // Afterward, we'll double back and translate any paths that weren't covered during interpolation via the // code below... translatedPrefixes.add( "build.directory" ); translatedPrefixes.add( "build.outputDirectory" ); translatedPrefixes.add( "build.testOutputDirectory" ); translatedPrefixes.add( "build.sourceDirectory" ); translatedPrefixes.add( "build.testSourceDirectory" ); translatedPrefixes.add( "build.scriptSourceDirectory" ); translatedPrefixes.add( "reporting.outputDirectory" ); TRANSLATED_PATH_EXPRESSIONS = translatedPrefixes; } @Requirement private PathTranslator pathTranslator; private Interpolator interpolator; private RecursionInterceptor recursionInterceptor; // for testing. protected AbstractStringBasedModelInterpolator( PathTranslator pathTranslator ) { this.pathTranslator = pathTranslator; } protected AbstractStringBasedModelInterpolator() { } public Model interpolate( Model model, Map context ) throws ModelInterpolationException { return interpolate( model, context, true ); } /** * Serialize the inbound Model instance to a StringWriter, perform the regex replacement to resolve * POM expressions, then re-parse into the resolved Model instance. *

* NOTE: This will result in a different instance of Model being returned!!! * * @param model The inbound Model instance, to serialize and reference for expression resolution * @param context The other context map to be used during resolution * * @return The resolved instance of the inbound Model. This is a different instance! * * @deprecated Use {@link ModelInterpolator#interpolate(Model, File, ProjectBuilderConfiguration, boolean)} instead. */ public Model interpolate( Model model, Map context, boolean strict ) throws ModelInterpolationException { Properties props = new Properties(); props.putAll( context ); return interpolate( model, null, new DefaultProjectBuilderConfiguration().setExecutionProperties( props ), true ); } public Model interpolate( Model model, File projectDir, ProjectBuilderConfiguration config, boolean debugEnabled ) throws ModelInterpolationException { StringWriter sWriter = new StringWriter( 1024 ); MavenXpp3Writer writer = new MavenXpp3Writer(); try { writer.write( sWriter, model ); } catch ( IOException e ) { throw new ModelInterpolationException( "Cannot serialize project model for interpolation.", e ); } String serializedModel = sWriter.toString(); serializedModel = interpolate( serializedModel, model, projectDir, config, debugEnabled ); StringReader sReader = new StringReader( serializedModel ); MavenXpp3Reader modelReader = new MavenXpp3Reader(); try { model = modelReader.read( sReader ); } catch ( IOException | XmlPullParserException e ) { throw new ModelInterpolationException( "Cannot read project model from interpolating filter of serialized version.", e ); } return model; } /** * Interpolates all expressions in the src parameter. *

* The algorithm used for each expression is: *

    *
  • If it starts with either "pom." or "project.", the expression is evaluated against the model.
  • *
  • If the value is null, get the value from the context.
  • *
  • If the value is null, but the context contains the expression, don't replace the expression string * with the value, and continue to find other expressions.
  • *
  • If the value is null, get it from the model properties.
  • *
*/ public String interpolate( String src, Model model, final File projectDir, ProjectBuilderConfiguration config, boolean debug ) throws ModelInterpolationException { try { List valueSources = createValueSources( model, projectDir, config ); List postProcessors = createPostProcessors( model, projectDir, config ); return interpolateInternal( src, valueSources, postProcessors, debug ); } finally { interpolator.clearAnswers(); } } protected List createValueSources( final Model model, final File projectDir, final ProjectBuilderConfiguration config ) { String timestampFormat = DEFAULT_BUILD_TIMESTAMP_FORMAT; Properties modelProperties = model.getProperties(); if ( modelProperties != null ) { timestampFormat = modelProperties.getProperty( BUILD_TIMESTAMP_FORMAT_PROPERTY, timestampFormat ); } ValueSource modelValueSource1 = new PrefixedObjectValueSource( PROJECT_PREFIXES, model, false ); ValueSource modelValueSource2 = new ObjectBasedValueSource( model ); ValueSource basedirValueSource = new PrefixedValueSourceWrapper( new AbstractValueSource( false ) { public Object getValue( String expression ) { if ( projectDir != null && "basedir".equals( expression ) ) { return projectDir.getAbsolutePath(); } return null; } }, PROJECT_PREFIXES, true ); ValueSource baseUriValueSource = new PrefixedValueSourceWrapper( new AbstractValueSource( false ) { public Object getValue( String expression ) { if ( projectDir != null && "baseUri".equals( expression ) ) { return projectDir.getAbsoluteFile().toURI().toString(); } return null; } }, PROJECT_PREFIXES, false ); List valueSources = new ArrayList<>( 9 ); // NOTE: Order counts here! valueSources.add( basedirValueSource ); valueSources.add( baseUriValueSource ); valueSources.add( new BuildTimestampValueSource( config.getBuildStartTime(), timestampFormat ) ); valueSources.add( modelValueSource1 ); valueSources.add( new MapBasedValueSource( config.getUserProperties() ) ); valueSources.add( new MapBasedValueSource( modelProperties ) ); valueSources.add( new MapBasedValueSource( config.getExecutionProperties() ) ); valueSources.add( new AbstractValueSource( false ) { public Object getValue( String expression ) { return config.getExecutionProperties().getProperty( "env." + expression ); } } ); valueSources.add( modelValueSource2 ); return valueSources; } protected List createPostProcessors( final Model model, final File projectDir, final ProjectBuilderConfiguration config ) { return Collections.singletonList( (InterpolationPostProcessor) new PathTranslatingPostProcessor( PROJECT_PREFIXES, TRANSLATED_PATH_EXPRESSIONS, projectDir, pathTranslator ) ); } @SuppressWarnings( "unchecked" ) protected String interpolateInternal( String src, List valueSources, List postProcessors, boolean debug ) throws ModelInterpolationException { if ( !src.contains( "${" ) ) { return src; } Logger logger = getLogger(); String result = src; synchronized ( this ) { for ( ValueSource vs : valueSources ) { interpolator.addValueSource( vs ); } for ( InterpolationPostProcessor postProcessor : postProcessors ) { interpolator.addPostProcessor( postProcessor ); } try { try { result = interpolator.interpolate( result, recursionInterceptor ); } catch ( InterpolationException e ) { throw new ModelInterpolationException( e.getMessage(), e ); } if ( debug ) { List feedback = interpolator.getFeedback(); if ( feedback != null && !feedback.isEmpty() ) { logger.debug( "Maven encountered the following problems during initial POM interpolation:" ); Object last = null; for ( Object next : feedback ) { if ( next instanceof Throwable ) { if ( last == null ) { logger.debug( "", ( (Throwable) next ) ); } else { logger.debug( String.valueOf( last ), ( (Throwable) next ) ); } } else { if ( last != null ) { logger.debug( String.valueOf( last ) ); } last = next; } } if ( last != null ) { logger.debug( String.valueOf( last ) ); } } } interpolator.clearFeedback(); } finally { for ( ValueSource vs : valueSources ) { interpolator.removeValuesSource( vs ); } for ( InterpolationPostProcessor postProcessor : postProcessors ) { interpolator.removePostProcessor( postProcessor ); } } } return result; } protected RecursionInterceptor getRecursionInterceptor() { return recursionInterceptor; } protected void setRecursionInterceptor( RecursionInterceptor recursionInterceptor ) { this.recursionInterceptor = recursionInterceptor; } protected abstract Interpolator createInterpolator(); public void initialize() throws InitializationException { interpolator = createInterpolator(); recursionInterceptor = new PrefixAwareRecursionInterceptor( PROJECT_PREFIXES ); } protected final Interpolator getInterpolator() { return interpolator; } } BuildTimestampValueSource.java000066400000000000000000000033511317160430700363220ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/main/java/org/apache/maven/project/interpolationpackage org.apache.maven.project.interpolation; /* * 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.text.SimpleDateFormat; import java.util.Date; import org.codehaus.plexus.interpolation.AbstractValueSource; /** * */ @Deprecated public class BuildTimestampValueSource extends AbstractValueSource { private final Date startTime; private final String format; private String formattedDate; public BuildTimestampValueSource( Date startTime, String format ) { super( false ); this.startTime = startTime; this.format = format; } public Object getValue( String expression ) { if ( "build.timestamp".equals( expression ) || "maven.build.timestamp".equals( expression ) ) { if ( formattedDate == null && startTime != null ) { formattedDate = new SimpleDateFormat( format ).format( startTime ); } return formattedDate; } return null; } } ModelInterpolationException.java000066400000000000000000000037201317160430700367100ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/main/java/org/apache/maven/project/interpolationpackage org.apache.maven.project.interpolation; /* * 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 jdcasey */ @SuppressWarnings( "serial" ) @Deprecated public class ModelInterpolationException extends Exception { private String expression; private String originalMessage; public ModelInterpolationException( String message ) { super( message ); } public ModelInterpolationException( String message, Throwable cause ) { super( message, cause ); } public ModelInterpolationException( String expression, String message, Throwable cause ) { super( "The POM expression: " + expression + " could not be evaluated. Reason: " + message, cause ); this.expression = expression; this.originalMessage = message; } public ModelInterpolationException( String expression, String message ) { super( "The POM expression: " + expression + " could not be evaluated. Reason: " + message ); this.expression = expression; this.originalMessage = message; } public String getExpression() { return expression; } public String getOriginalMessage() { return originalMessage; } } ModelInterpolator.java000066400000000000000000000043331317160430700346650ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/main/java/org/apache/maven/project/interpolationpackage org.apache.maven.project.interpolation; /* * 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 org.apache.maven.model.Model; import org.apache.maven.project.ProjectBuilderConfiguration; import java.io.File; import java.util.Map; /** * @author jdcasey */ @Deprecated public interface ModelInterpolator { String DEFAULT_BUILD_TIMESTAMP_FORMAT = "yyyyMMdd-HHmm"; String BUILD_TIMESTAMP_FORMAT_PROPERTY = "maven.build.timestamp.format"; String ROLE = ModelInterpolator.class.getName(); /** * @deprecated Use {@link ModelInterpolator#interpolate(Model, File, ProjectBuilderConfiguration, boolean)} instead. */ Model interpolate( Model project, Map context ) throws ModelInterpolationException; /** * @deprecated Use {@link ModelInterpolator#interpolate(Model, File, ProjectBuilderConfiguration, boolean)} instead. */ Model interpolate( Model model, Map context, boolean strict ) throws ModelInterpolationException; Model interpolate( Model model, File projectDir, ProjectBuilderConfiguration config, boolean debugEnabled ) throws ModelInterpolationException; String interpolate( String src, Model model, File projectDir, ProjectBuilderConfiguration config, boolean debugEnabled ) throws ModelInterpolationException; } PathTranslatingPostProcessor.java000066400000000000000000000042631317160430700370750ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/main/java/org/apache/maven/project/interpolationpackage org.apache.maven.project.interpolation; /* * 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 org.apache.maven.project.path.PathTranslator; import org.codehaus.plexus.interpolation.InterpolationPostProcessor; import org.codehaus.plexus.interpolation.util.ValueSourceUtils; import java.io.File; import java.util.List; /** * */ @Deprecated public class PathTranslatingPostProcessor implements InterpolationPostProcessor { private final List unprefixedPathKeys; private final File projectDir; private final PathTranslator pathTranslator; private final List expressionPrefixes; public PathTranslatingPostProcessor( List expressionPrefixes, List unprefixedPathKeys, File projectDir, PathTranslator pathTranslator ) { this.expressionPrefixes = expressionPrefixes; this.unprefixedPathKeys = unprefixedPathKeys; this.projectDir = projectDir; this.pathTranslator = pathTranslator; } public Object execute( String expression, Object value ) { expression = ValueSourceUtils.trimPrefix( expression, expressionPrefixes, true ); if ( projectDir != null && value != null && unprefixedPathKeys.contains( expression ) ) { return pathTranslator.alignToBaseDirectory( String.valueOf( value ), projectDir ); } return value; } } RegexBasedModelInterpolator.java000066400000000000000000000034301317160430700366140ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/main/java/org/apache/maven/project/interpolationpackage org.apache.maven.project.interpolation; /* * 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.util.Properties; import org.apache.maven.project.path.PathTranslator; import org.codehaus.plexus.interpolation.Interpolator; import org.codehaus.plexus.interpolation.RegexBasedInterpolator; /** * Use a regular expression search to find and resolve expressions within the POM. * * @author jdcasey Created on Feb 3, 2005 * TODO Consolidate this logic with the PluginParameterExpressionEvaluator, minus deprecations/bans. */ @Deprecated public class RegexBasedModelInterpolator extends AbstractStringBasedModelInterpolator { public RegexBasedModelInterpolator() throws IOException { } public RegexBasedModelInterpolator( PathTranslator pathTranslator ) { super( pathTranslator ); } public RegexBasedModelInterpolator( Properties envars ) { } protected Interpolator createInterpolator() { return new RegexBasedInterpolator( true ); } } StringSearchModelInterpolator.java000066400000000000000000000432131317160430700372020ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/main/java/org/apache/maven/project/interpolationpackage org.apache.maven.project.interpolation; /* * 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 org.apache.maven.model.Model; import org.apache.maven.project.ProjectBuilderConfiguration; import org.apache.maven.project.path.PathTranslator; import org.codehaus.plexus.component.annotations.Component; import org.codehaus.plexus.interpolation.InterpolationPostProcessor; import org.codehaus.plexus.interpolation.Interpolator; import org.codehaus.plexus.interpolation.StringSearchInterpolator; import org.codehaus.plexus.interpolation.ValueSource; import org.codehaus.plexus.logging.Logger; import java.io.File; import java.lang.reflect.Array; import java.lang.reflect.Field; import java.security.AccessController; import java.security.PrivilegedAction; import java.util.ArrayList; import java.util.Collection; import java.util.LinkedList; import java.util.List; import java.util.Map; import java.util.WeakHashMap; @Deprecated @Component( role = ModelInterpolator.class ) public class StringSearchModelInterpolator extends AbstractStringBasedModelInterpolator { private static final Map, Field[]> FIELDS_BY_CLASS = new WeakHashMap<>(); private static final Map, Boolean> PRIMITIVE_BY_CLASS = new WeakHashMap<>(); public StringSearchModelInterpolator() { } public StringSearchModelInterpolator( PathTranslator pathTranslator ) { super( pathTranslator ); } public Model interpolate( Model model, File projectDir, ProjectBuilderConfiguration config, boolean debugEnabled ) throws ModelInterpolationException { interpolateObject( model, model, projectDir, config, debugEnabled ); return model; } protected void interpolateObject( Object obj, Model model, File projectDir, ProjectBuilderConfiguration config, boolean debugEnabled ) throws ModelInterpolationException { try { List valueSources = createValueSources( model, projectDir, config ); List postProcessors = createPostProcessors( model, projectDir, config ); InterpolateObjectAction action = new InterpolateObjectAction( obj, valueSources, postProcessors, debugEnabled, this, getLogger() ); ModelInterpolationException error = AccessController.doPrivileged( action ); if ( error != null ) { throw error; } } finally { getInterpolator().clearAnswers(); } } protected Interpolator createInterpolator() { StringSearchInterpolator interpolator = new StringSearchInterpolator(); interpolator.setCacheAnswers( true ); return interpolator; } private static final class InterpolateObjectAction implements PrivilegedAction { private final boolean debugEnabled; private final LinkedList interpolationTargets; private final StringSearchModelInterpolator modelInterpolator; private final Logger logger; private final List valueSources; private final List postProcessors; public InterpolateObjectAction( Object target, List valueSources, List postProcessors, boolean debugEnabled, StringSearchModelInterpolator modelInterpolator, Logger logger ) { this.valueSources = valueSources; this.postProcessors = postProcessors; this.debugEnabled = debugEnabled; this.interpolationTargets = new LinkedList<>(); interpolationTargets.add( target ); this.modelInterpolator = modelInterpolator; this.logger = logger; } public ModelInterpolationException run() { while ( !interpolationTargets.isEmpty() ) { Object obj = interpolationTargets.removeFirst(); try { traverseObjectWithParents( obj.getClass(), obj ); } catch ( ModelInterpolationException e ) { return e; } } return null; } @SuppressWarnings( "unchecked" ) private void traverseObjectWithParents( Class cls, Object target ) throws ModelInterpolationException { if ( cls == null ) { return; } if ( cls.isArray() ) { evaluateArray( target ); } else if ( isQualifiedForInterpolation( cls ) ) { Field[] fields = FIELDS_BY_CLASS.get( cls ); if ( fields == null ) { fields = cls.getDeclaredFields(); FIELDS_BY_CLASS.put( cls, fields ); } for ( Field field : fields ) { Class type = field.getType(); if ( isQualifiedForInterpolation( field, type ) ) { boolean isAccessible = field.isAccessible(); field.setAccessible( true ); try { try { if ( String.class == type ) { String value = (String) field.get( target ); if ( value != null ) { String interpolated = modelInterpolator.interpolateInternal( value, valueSources, postProcessors, debugEnabled ); if ( !interpolated.equals( value ) ) { field.set( target, interpolated ); } } } else if ( Collection.class.isAssignableFrom( type ) ) { Collection c = (Collection) field.get( target ); if ( c != null && !c.isEmpty() ) { List originalValues = new ArrayList<>( c ); try { c.clear(); } catch ( UnsupportedOperationException e ) { if ( debugEnabled && logger != null ) { logger.debug( "Skipping interpolation of field: " + field + " in: " + cls.getName() + "; it is an unmodifiable collection." ); } continue; } for ( Object value : originalValues ) { if ( value != null ) { if ( String.class == value.getClass() ) { String interpolated = modelInterpolator.interpolateInternal( (String) value, valueSources, postProcessors, debugEnabled ); if ( !interpolated.equals( value ) ) { c.add( interpolated ); } else { c.add( value ); } } else { c.add( value ); if ( value.getClass().isArray() ) { evaluateArray( value ); } else { interpolationTargets.add( value ); } } } else { // add the null back in...not sure what else to do... c.add( value ); } } } } else if ( Map.class.isAssignableFrom( type ) ) { Map m = (Map) field.get( target ); if ( m != null && !m.isEmpty() ) { for ( Map.Entry entry : m.entrySet() ) { Object value = entry.getValue(); if ( value != null ) { if ( String.class == value.getClass() ) { String interpolated = modelInterpolator.interpolateInternal( (String) value, valueSources, postProcessors, debugEnabled ); if ( !interpolated.equals( value ) ) { try { entry.setValue( interpolated ); } catch ( UnsupportedOperationException e ) { if ( debugEnabled && logger != null ) { logger.debug( "Skipping interpolation of field: " + field + " (key: " + entry.getKey() + ") in: " + cls.getName() + "; it is an unmodifiable collection." ); } } } } else { if ( value.getClass().isArray() ) { evaluateArray( value ); } else { interpolationTargets.add( value ); } } } } } } else { Object value = field.get( target ); if ( value != null ) { if ( field.getType().isArray() ) { evaluateArray( value ); } else { interpolationTargets.add( value ); } } } } catch ( IllegalArgumentException | IllegalAccessException e ) { throw new ModelInterpolationException( "Failed to interpolate field: " + field + " on class: " + cls.getName(), e ); } } finally { field.setAccessible( isAccessible ); } } } traverseObjectWithParents( cls.getSuperclass(), target ); } } private boolean isQualifiedForInterpolation( Class cls ) { return !cls.getPackage().getName().startsWith( "java" ); } private boolean isQualifiedForInterpolation( Field field, Class fieldType ) { if ( !PRIMITIVE_BY_CLASS.containsKey( fieldType ) ) { PRIMITIVE_BY_CLASS.put( fieldType, fieldType.isPrimitive() ); } if ( PRIMITIVE_BY_CLASS.get( fieldType ) ) { return false; } // if ( fieldType.isPrimitive() ) // { // return false; // } if ( "parent".equals( field.getName() ) ) { return false; } return true; } private void evaluateArray( Object target ) throws ModelInterpolationException { int len = Array.getLength( target ); for ( int i = 0; i < len; i++ ) { Object value = Array.get( target, i ); if ( value != null ) { if ( String.class == value.getClass() ) { String interpolated = modelInterpolator.interpolateInternal( (String) value, valueSources, postProcessors, debugEnabled ); if ( !interpolated.equals( value ) ) { Array.set( target, i, interpolated ); } } else { interpolationTargets.add( value ); } } } } } } maven-maven-3.5.2/maven-compat/src/main/java/org/apache/maven/project/path/000077500000000000000000000000001317160430700265005ustar00rootroot00000000000000DefaultPathTranslator.java000066400000000000000000000173541317160430700335510ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/main/java/org/apache/maven/project/pathpackage org.apache.maven.project.path; /* * 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.File; import java.util.ArrayList; import java.util.List; import org.apache.maven.model.Build; import org.apache.maven.model.Model; import org.apache.maven.model.Reporting; import org.apache.maven.model.Resource; import org.codehaus.plexus.component.annotations.Component; @Deprecated @Component( role = PathTranslator.class ) public class DefaultPathTranslator implements PathTranslator { private static final String[] BASEDIR_EXPRESSIONS = {"${basedir}", "${pom.basedir}", "${project.basedir}"}; public void alignToBaseDirectory( Model model, File basedir ) { if ( basedir == null ) { return; } Build build = model.getBuild(); if ( build != null ) { build.setDirectory( alignToBaseDirectory( build.getDirectory(), basedir ) ); build.setSourceDirectory( alignToBaseDirectory( build.getSourceDirectory(), basedir ) ); build.setTestSourceDirectory( alignToBaseDirectory( build.getTestSourceDirectory(), basedir ) ); for ( Resource resource : build.getResources() ) { resource.setDirectory( alignToBaseDirectory( resource.getDirectory(), basedir ) ); } for ( Resource resource : build.getTestResources() ) { resource.setDirectory( alignToBaseDirectory( resource.getDirectory(), basedir ) ); } if ( build.getFilters() != null ) { List filters = new ArrayList<>(); for ( String filter : build.getFilters() ) { filters.add( alignToBaseDirectory( filter, basedir ) ); } build.setFilters( filters ); } build.setOutputDirectory( alignToBaseDirectory( build.getOutputDirectory(), basedir ) ); build.setTestOutputDirectory( alignToBaseDirectory( build.getTestOutputDirectory(), basedir ) ); } Reporting reporting = model.getReporting(); if ( reporting != null ) { reporting.setOutputDirectory( alignToBaseDirectory( reporting.getOutputDirectory(), basedir ) ); } } public String alignToBaseDirectory( String path, File basedir ) { if ( basedir == null ) { return path; } if ( path == null ) { return null; } String s = stripBasedirToken( path ); File file = new File( s ); if ( file.isAbsolute() ) { // path was already absolute, just normalize file separator and we're done s = file.getPath(); } else if ( file.getPath().startsWith( File.separator ) ) { // drive-relative Windows path, don't align with project directory but with drive root s = file.getAbsolutePath(); } else { // an ordinary relative path, align with project directory s = new File( new File( basedir, s ).toURI().normalize() ).getAbsolutePath(); } return s; } private String stripBasedirToken( String s ) { if ( s != null ) { String basedirExpr = null; for ( String expression : BASEDIR_EXPRESSIONS ) { if ( s.startsWith( expression ) ) { basedirExpr = expression; break; } } if ( basedirExpr != null ) { if ( s.length() > basedirExpr.length() ) { // Take out basedir expression and the leading slash s = chopLeadingFileSeparator( s.substring( basedirExpr.length() ) ); } else { s = "."; } } } return s; } /** * Removes the leading directory separator from the specified filesystem path (if any). For platform-independent * behavior, this method accepts both the forward slash and the backward slash as separator. * * @param path The filesystem path, may be null. * @return The altered filesystem path or null if the input path was null. */ private String chopLeadingFileSeparator( String path ) { if ( path != null ) { if ( path.startsWith( "/" ) || path.startsWith( "\\" ) ) { path = path.substring( 1 ); } } return path; } public void unalignFromBaseDirectory( Model model, File basedir ) { if ( basedir == null ) { return; } Build build = model.getBuild(); if ( build != null ) { build.setDirectory( unalignFromBaseDirectory( build.getDirectory(), basedir ) ); build.setSourceDirectory( unalignFromBaseDirectory( build.getSourceDirectory(), basedir ) ); build.setTestSourceDirectory( unalignFromBaseDirectory( build.getTestSourceDirectory(), basedir ) ); for ( Resource resource : build.getResources() ) { resource.setDirectory( unalignFromBaseDirectory( resource.getDirectory(), basedir ) ); } for ( Resource resource : build.getTestResources() ) { resource.setDirectory( unalignFromBaseDirectory( resource.getDirectory(), basedir ) ); } if ( build.getFilters() != null ) { List filters = new ArrayList<>(); for ( String filter : build.getFilters() ) { filters.add( unalignFromBaseDirectory( filter, basedir ) ); } build.setFilters( filters ); } build.setOutputDirectory( unalignFromBaseDirectory( build.getOutputDirectory(), basedir ) ); build.setTestOutputDirectory( unalignFromBaseDirectory( build.getTestOutputDirectory(), basedir ) ); } Reporting reporting = model.getReporting(); if ( reporting != null ) { reporting.setOutputDirectory( unalignFromBaseDirectory( reporting.getOutputDirectory(), basedir ) ); } } public String unalignFromBaseDirectory( String path, File basedir ) { if ( basedir == null ) { return path; } if ( path == null ) { return null; } path = path.trim(); String base = basedir.getAbsolutePath(); if ( path.startsWith( base ) ) { path = chopLeadingFileSeparator( path.substring( base.length() ) ); } if ( path.length() <= 0 ) { path = "."; } if ( !new File( path ).isAbsolute() ) { path = path.replace( '\\', '/' ); } return path; } } maven-maven-3.5.2/maven-compat/src/main/java/org/apache/maven/project/validation/000077500000000000000000000000001317160430700276765ustar00rootroot00000000000000DefaultModelValidator.java000066400000000000000000000051051317160430700346760ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/main/java/org/apache/maven/project/validationpackage org.apache.maven.project.validation; /* * 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 org.apache.maven.model.Model; import org.apache.maven.model.building.DefaultModelBuildingRequest; import org.apache.maven.model.building.ModelBuildingRequest; import org.apache.maven.model.building.ModelProblem; import org.apache.maven.model.building.ModelProblemCollector; import org.apache.maven.model.building.ModelProblemCollectorRequest; import org.codehaus.plexus.component.annotations.Component; import org.codehaus.plexus.component.annotations.Requirement; /** * @author Trygve Laugstøl */ @Component( role = ModelValidator.class ) @Deprecated public class DefaultModelValidator implements ModelValidator { @Requirement private org.apache.maven.model.validation.ModelValidator modelValidator; public ModelValidationResult validate( Model model ) { ModelValidationResult result = new ModelValidationResult(); ModelBuildingRequest request = new DefaultModelBuildingRequest().setValidationLevel( ModelBuildingRequest.VALIDATION_LEVEL_MAVEN_2_0 ); SimpleModelProblemCollector problems = new SimpleModelProblemCollector( result ); modelValidator.validateEffectiveModel( model, request, problems ); return result; } private static class SimpleModelProblemCollector implements ModelProblemCollector { ModelValidationResult result; public SimpleModelProblemCollector( ModelValidationResult result ) { this.result = result; } public void add( ModelProblemCollectorRequest req ) { if ( !ModelProblem.Severity.WARNING.equals( req.getSeverity() ) ) { result.addMessage( req.getMessage() ); } } } } ModelValidationResult.java000066400000000000000000000046601317160430700347420ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/main/java/org/apache/maven/project/validationpackage org.apache.maven.project.validation; /* * 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.util.ArrayList; import java.util.Collections; import java.util.List; /** * @author Trygve Laugstøl */ public class ModelValidationResult { /** */ private static final String NEWLINE = System.getProperty( "line.separator" ); /** */ private List messages; public ModelValidationResult() { messages = new ArrayList<>(); } public int getMessageCount() { return messages.size(); } public String getMessage( int i ) { return messages.get( i ); } public List getMessages() { return Collections.unmodifiableList( messages ); } public void addMessage( String message ) { messages.add( message ); } public String toString() { return render( "" ); } public String render( String indentation ) { if ( messages.size() == 0 ) { return indentation + "There were no validation errors."; } StringBuilder message = new StringBuilder(); // if ( messages.size() == 1 ) // { // message.append( "There was 1 validation error: " ); // } // else // { // message.append( "There was " + messages.size() + " validation errors: " + NEWLINE ); // } // for ( int i = 0; i < messages.size(); i++ ) { message.append( indentation ).append( '[' ).append( i ).append( "] " ).append( messages.get( i ) ).append( NEWLINE ); } return message.toString(); } } maven-maven-3.5.2/maven-compat/src/main/java/org/apache/maven/project/validation/ModelValidator.java000066400000000000000000000022321317160430700334460ustar00rootroot00000000000000package org.apache.maven.project.validation; /* * 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 org.apache.maven.model.Model; /** * Checks the model for missing or invalid values. * * @author Trygve Laugstøl */ @Deprecated public interface ModelValidator { String ROLE = ModelValidator.class.getName(); ModelValidationResult validate( Model model ); } maven-maven-3.5.2/maven-compat/src/main/java/org/apache/maven/reporting/000077500000000000000000000000001317160430700261075ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/main/java/org/apache/maven/reporting/MavenReportException.java000066400000000000000000000023311317160430700330720ustar00rootroot00000000000000package org.apache.maven.reporting; /* * 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. */ /** * An exception occurring during the execution of a Maven report. * * @author Brett Porter * @author Emmanuel Venisse */ public class MavenReportException extends Exception { public MavenReportException( String msg ) { super( msg ); } public MavenReportException( String msg, Exception e ) { super( msg, e ); } } maven-maven-3.5.2/maven-compat/src/main/java/org/apache/maven/repository/000077500000000000000000000000001317160430700263155ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/main/java/org/apache/maven/repository/DefaultMirrorSelector.java000066400000000000000000000160521317160430700334440ustar00rootroot00000000000000package org.apache.maven.repository; /* * 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.MalformedURLException; import java.net.URL; import java.util.List; import org.apache.maven.RepositoryUtils; import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.settings.Mirror; import org.codehaus.plexus.component.annotations.Component; import org.codehaus.plexus.util.StringUtils; @Component( role = MirrorSelector.class ) public class DefaultMirrorSelector implements MirrorSelector { private static final String WILDCARD = "*"; private static final String EXTERNAL_WILDCARD = "external:*"; public Mirror getMirror( ArtifactRepository repository, List mirrors ) { String repoId = repository.getId(); if ( repoId != null && mirrors != null ) { for ( Mirror mirror : mirrors ) { if ( repoId.equals( mirror.getMirrorOf() ) && matchesLayout( repository, mirror ) ) { return mirror; } } for ( Mirror mirror : mirrors ) { if ( matchPattern( repository, mirror.getMirrorOf() ) && matchesLayout( repository, mirror ) ) { return mirror; } } } return null; } /** * This method checks if the pattern matches the originalRepository. Valid patterns: * = * everything external:* = everything not on the localhost and not file based. repo,repo1 = repo * or repo1 *,!repo1 = everything except repo1 * * @param originalRepository to compare for a match. * @param pattern used for match. Currently only '*' is supported. * @return true if the repository is a match to this pattern. */ static boolean matchPattern( ArtifactRepository originalRepository, String pattern ) { boolean result = false; String originalId = originalRepository.getId(); // simple checks first to short circuit processing below. if ( WILDCARD.equals( pattern ) || pattern.equals( originalId ) ) { result = true; } else { // process the list String[] repos = pattern.split( "," ); for ( String repo : repos ) { repo = repo.trim(); // see if this is a negative match if ( repo.length() > 1 && repo.startsWith( "!" ) ) { if ( repo.substring( 1 ).equals( originalId ) ) { // explicitly exclude. Set result and stop processing. result = false; break; } } // check for exact match else if ( repo.equals( originalId ) ) { result = true; break; } // check for external:* else if ( EXTERNAL_WILDCARD.equals( repo ) && isExternalRepo( originalRepository ) ) { result = true; // don't stop processing in case a future segment explicitly excludes this repo } else if ( WILDCARD.equals( repo ) ) { result = true; // don't stop processing in case a future segment explicitly excludes this repo } } } return result; } /** * Checks the URL to see if this repository refers to an external repository * * @param originalRepository * @return true if external. */ static boolean isExternalRepo( ArtifactRepository originalRepository ) { try { URL url = new URL( originalRepository.getUrl() ); return !( url.getHost().equals( "localhost" ) || url.getHost().equals( "127.0.0.1" ) || url.getProtocol().equals( "file" ) ); } catch ( MalformedURLException e ) { // bad url just skip it here. It should have been validated already, but the wagon lookup will deal with it return false; } } static boolean matchesLayout( ArtifactRepository repository, Mirror mirror ) { return matchesLayout( RepositoryUtils.getLayout( repository ), mirror.getMirrorOfLayouts() ); } /** * Checks whether the layouts configured for a mirror match with the layout of the repository. * * @param repoLayout The layout of the repository, may be {@code null}. * @param mirrorLayout The layouts supported by the mirror, may be {@code null}. * @return {@code true} if the layouts associated with the mirror match the layout of the original repository, * {@code false} otherwise. */ static boolean matchesLayout( String repoLayout, String mirrorLayout ) { boolean result = false; // simple checks first to short circuit processing below. if ( StringUtils.isEmpty( mirrorLayout ) || WILDCARD.equals( mirrorLayout ) ) { result = true; } else if ( mirrorLayout.equals( repoLayout ) ) { result = true; } else { // process the list String[] layouts = mirrorLayout.split( "," ); for ( String layout : layouts ) { // see if this is a negative match if ( layout.length() > 1 && layout.startsWith( "!" ) ) { if ( layout.substring( 1 ).equals( repoLayout ) ) { // explicitly exclude. Set result and stop processing. result = false; break; } } // check for exact match else if ( layout.equals( repoLayout ) ) { result = true; break; } else if ( WILDCARD.equals( layout ) ) { result = true; // don't stop processing in case a future segment explicitly excludes this repo } } } return result; } } maven-maven-3.5.2/maven-compat/src/main/java/org/apache/maven/repository/MavenArtifactMetadata.java000066400000000000000000000047061317160430700333540ustar00rootroot00000000000000package org.apache.maven.repository; /* * 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 Oleg Gusakov * */ public class MavenArtifactMetadata { public static final String DEFAULT_TYPE = "jar"; String groupId; String artifactId; String version; String classifier; String type; String scope; transient Object datum; public String getGroupId() { return groupId; } public void setGroupId( String groupId ) { this.groupId = groupId; } public String getArtifactId() { return artifactId; } public void setArtifactId( String artifactId ) { this.artifactId = artifactId; } public String getVersion() { return version; } public void setVersion( String version ) { this.version = version; } public String getClassifier() { return classifier; } public void setClassifier( String classifier ) { this.classifier = classifier; } public String getType() { return type; } public void setType( String type ) { this.type = type; } public Object getDatum() { return datum; } public void setDatum( Object datum ) { this.datum = datum; } public String getScope() { return scope; } public void setScope( String scope ) { this.scope = scope; } @Override public String toString() { return getGroupId() + ":" + getArtifactId() + ":" + getVersion() + ":" + ( getClassifier() == null ? "" : getClassifier() ) + ":" + ( getType() == null ? DEFAULT_TYPE : getType() ); } } maven-maven-3.5.2/maven-compat/src/main/java/org/apache/maven/repository/MetadataGraph.java000066400000000000000000000041621317160430700316650ustar00rootroot00000000000000package org.apache.maven.repository; /* * 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.util.ArrayList; import java.util.Collection; /** * This is the main graph data structure used by the RepositorySystem to present tree and graph objects. * * @author Oleg Gusakov * */ public class MetadataGraph { /** all graph nodes */ Collection nodes; /** entry point for tree-like structures */ MetadataGraphNode entry; public MetadataGraph( MetadataGraphNode entry ) { this(); this.entry = entry; } public MetadataGraph() { nodes = new ArrayList<>( 64 ); } public void addNode( MetadataGraphNode node ) { nodes.add( node ); } /** * find a node by the GAV (metadata) * * @param md */ public MetadataGraphNode findNode( MavenArtifactMetadata md ) { for ( MetadataGraphNode mgn : nodes ) { if ( mgn.metadata.equals( md ) ) { return mgn; } } MetadataGraphNode node = new MetadataGraphNode( md ); addNode( node ); return node; } /** * getter */ public MetadataGraphNode getEntry() { return entry; } /** * getter */ public Collection getNodes() { return nodes; } } maven-maven-3.5.2/maven-compat/src/main/java/org/apache/maven/repository/MetadataGraphNode.java000066400000000000000000000050351317160430700324730ustar00rootroot00000000000000package org.apache.maven.repository; /* * 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.util.ArrayList; import java.util.List; /** * MetadataGraph node - as it's a directed graph - holds adjacency lists for incident and exident nodes * * @author Oleg Gusakov * */ public class MetadataGraphNode { /** node payload */ MavenArtifactMetadata metadata; /** nodes, incident to this (depend on me) */ List inNodes; /** nodes, exident to this (I depend on) */ List exNodes; public MetadataGraphNode() { inNodes = new ArrayList<>( 4 ); exNodes = new ArrayList<>( 8 ); } public MetadataGraphNode( MavenArtifactMetadata metadata ) { this(); this.metadata = metadata; } public MetadataGraphNode addIncident( MetadataGraphNode node ) { inNodes.add( node ); return this; } public MetadataGraphNode addExident( MetadataGraphNode node ) { exNodes.add( node ); return this; } @Override public boolean equals( Object obj ) { if ( obj == null ) { return false; } if ( MetadataGraphNode.class.isAssignableFrom( obj.getClass() ) ) { MetadataGraphNode node2 = (MetadataGraphNode) obj; if ( node2.metadata == null ) { return metadata == null; } return metadata != null && metadata.toString().equals( node2.metadata.toString() ); } else { return super.equals( obj ); } } @Override public int hashCode() { if ( metadata == null ) { return super.hashCode(); } return metadata.toString().hashCode(); } } MetadataResolutionRequest.java000066400000000000000000000126531317160430700342650ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/main/java/org/apache/maven/repositorypackage org.apache.maven.repository; /* * 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.util.List; import java.util.Map; import java.util.Set; import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.repository.ArtifactRepository; /** * * * @author Oleg Gusakov * */ public class MetadataResolutionRequest { private MavenArtifactMetadata mad; private String scope; // Needs to go away private Set artifactDependencies; private ArtifactRepository localRepository; private List remoteRepositories; // This is like a filter but overrides all transitive versions private Map managedVersionMap; /** result type - flat list; the default */ private boolean asList = true; /** result type - dirty tree */ private boolean asDirtyTree = false; /** result type - resolved tree */ private boolean asResolvedTree = false; /** result type - graph */ private boolean asGraph = false; public MetadataResolutionRequest() { } public MetadataResolutionRequest( MavenArtifactMetadata md, ArtifactRepository localRepository, List remoteRepositories ) { this.mad = md; this.localRepository = localRepository; this.remoteRepositories = remoteRepositories; } public MavenArtifactMetadata getArtifactMetadata() { return mad; } public MetadataResolutionRequest setArtifactMetadata( MavenArtifactMetadata md ) { this.mad = md; return this; } public MetadataResolutionRequest setArtifactDependencies( Set artifactDependencies ) { this.artifactDependencies = artifactDependencies; return this; } public Set getArtifactDependencies() { return artifactDependencies; } public ArtifactRepository getLocalRepository() { return localRepository; } public MetadataResolutionRequest setLocalRepository( ArtifactRepository localRepository ) { this.localRepository = localRepository; return this; } /** * @deprecated instead use {@link #getRemoteRepositories()} */ @Deprecated public List getRemoteRepostories() { return remoteRepositories; } public List getRemoteRepositories() { return getRemoteRepostories(); } /** * @deprecated instead use {@link #setRemoteRepositories(List)} */ @Deprecated public MetadataResolutionRequest setRemoteRepostories( List remoteRepostories ) { this.remoteRepositories = remoteRepostories; return this; } public MetadataResolutionRequest setRemoteRepositories( List remoteRepositories ) { return setRemoteRepostories( remoteRepositories ); } public Map getManagedVersionMap() { return managedVersionMap; } public MetadataResolutionRequest setManagedVersionMap( Map managedVersionMap ) { this.managedVersionMap = managedVersionMap; return this; } public String toString() { StringBuilder sb = new StringBuilder() .append( "REQUEST: " ).append( "\n" ) .append( "artifact: " ).append( mad ).append( "\n" ) .append( artifactDependencies ).append( "\n" ) .append( "localRepository: " ).append( localRepository ).append( "\n" ) .append( "remoteRepositories: " ).append( remoteRepositories ).append( "\n" ) ; return sb.toString(); } public boolean isAsList() { return asList; } public MetadataResolutionRequest setAsList( boolean asList ) { this.asList = asList; return this; } public boolean isAsDirtyTree() { return asDirtyTree; } public MetadataResolutionRequest setAsDirtyTree( boolean asDirtyTree ) { this.asDirtyTree = asDirtyTree; return this; } public boolean isAsResolvedTree() { return asResolvedTree; } public MetadataResolutionRequest setAsResolvedTree( boolean asResolvedTree ) { this.asResolvedTree = asResolvedTree; return this; } public boolean isAsGraph() { return asGraph; } public MetadataResolutionRequest setAsGraph( boolean asGraph ) { this.asGraph = asGraph; return this; } public MetadataResolutionRequest setScope( String scope ) { this.scope = scope; return this; } public String getScope() { return scope; } } MetadataResolutionResult.java000066400000000000000000000226541317160430700341150ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/main/java/org/apache/maven/repositorypackage org.apache.maven.repository; /* * 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.util.ArrayList; import java.util.Collections; import java.util.LinkedHashSet; import java.util.List; import java.util.Set; import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.resolver.ArtifactResolutionException; import org.apache.maven.artifact.resolver.CyclicDependencyException; import org.apache.maven.artifact.versioning.OverConstrainedVersionException; /** * * * @author Oleg Gusakov * */ public class MetadataResolutionResult { private Artifact originatingArtifact; private List missingArtifacts; // Exceptions private List exceptions; private List versionRangeViolations; private List metadataResolutionExceptions; private List circularDependencyExceptions; private List errorArtifactExceptions; // file system errors private List repositories; private Set requestedArtifacts; private Set artifacts; private MetadataGraph dirtyTree; private MetadataGraph resolvedTree; private MetadataGraph resolvedGraph; public Artifact getOriginatingArtifact() { return originatingArtifact; } public MetadataResolutionResult ListOriginatingArtifact( final Artifact originatingArtifact ) { this.originatingArtifact = originatingArtifact; return this; } public void addArtifact( Artifact artifact ) { if ( artifacts == null ) { artifacts = new LinkedHashSet<>(); } artifacts.add( artifact ); } public Set getArtifacts() { return artifacts; } public void addRequestedArtifact( Artifact artifact ) { if ( requestedArtifacts == null ) { requestedArtifacts = new LinkedHashSet<>(); } requestedArtifacts.add( artifact ); } public Set getRequestedArtifacts() { return requestedArtifacts; } public boolean hasMissingArtifacts() { return missingArtifacts != null && !missingArtifacts.isEmpty(); } public List getMissingArtifacts() { return missingArtifacts == null ? Collections.emptyList() : missingArtifacts; } public MetadataResolutionResult addMissingArtifact( Artifact artifact ) { missingArtifacts = initList( missingArtifacts ); missingArtifacts.add( artifact ); return this; } public MetadataResolutionResult setUnresolvedArtifacts( final List unresolvedArtifacts ) { this.missingArtifacts = unresolvedArtifacts; return this; } // ------------------------------------------------------------------------ // Exceptions // ------------------------------------------------------------------------ public boolean hasExceptions() { return exceptions != null && !exceptions.isEmpty(); } public List getExceptions() { return exceptions == null ? Collections.emptyList() : exceptions; } // ------------------------------------------------------------------------ // Version Range Violations // ------------------------------------------------------------------------ public boolean hasVersionRangeViolations() { return versionRangeViolations != null; } /** * TODO this needs to accept a {@link OverConstrainedVersionException} as returned by * {@link #getVersionRangeViolation(int)} but it's not used like that in * {@link org.apache.maven.repository.legacy.resolver.DefaultLegacyArtifactCollector} */ public MetadataResolutionResult addVersionRangeViolation( Exception e ) { versionRangeViolations = initList( versionRangeViolations ); versionRangeViolations.add( e ); exceptions = initList( exceptions ); exceptions.add( e ); return this; } public OverConstrainedVersionException getVersionRangeViolation( int i ) { return (OverConstrainedVersionException) versionRangeViolations.get( i ); } public List getVersionRangeViolations() { return versionRangeViolations == null ? Collections.emptyList() : versionRangeViolations; } // ------------------------------------------------------------------------ // Metadata Resolution Exceptions: ArtifactResolutionExceptions // ------------------------------------------------------------------------ public boolean hasMetadataResolutionExceptions() { return metadataResolutionExceptions != null; } public MetadataResolutionResult addMetadataResolutionException( ArtifactResolutionException e ) { metadataResolutionExceptions = initList( metadataResolutionExceptions ); metadataResolutionExceptions.add( e ); exceptions = initList( exceptions ); exceptions.add( e ); return this; } public ArtifactResolutionException getMetadataResolutionException( int i ) { return metadataResolutionExceptions.get( i ); } public List getMetadataResolutionExceptions() { return metadataResolutionExceptions == null ? Collections.emptyList() : metadataResolutionExceptions; } // ------------------------------------------------------------------------ // ErrorArtifactExceptions: ArtifactResolutionExceptions // ------------------------------------------------------------------------ public boolean hasErrorArtifactExceptions() { return errorArtifactExceptions != null; } public MetadataResolutionResult addError( Exception e ) { exceptions = initList( exceptions ); exceptions.add( e ); return this; } public List getErrorArtifactExceptions() { if ( errorArtifactExceptions == null ) { return Collections.emptyList(); } return errorArtifactExceptions; } // ------------------------------------------------------------------------ // Circular Dependency Exceptions // ------------------------------------------------------------------------ public boolean hasCircularDependencyExceptions() { return circularDependencyExceptions != null; } public MetadataResolutionResult addCircularDependencyException( CyclicDependencyException e ) { circularDependencyExceptions = initList( circularDependencyExceptions ); circularDependencyExceptions.add( e ); exceptions = initList( exceptions ); exceptions.add( e ); return this; } public CyclicDependencyException getCircularDependencyException( int i ) { return circularDependencyExceptions.get( i ); } public List getCircularDependencyExceptions() { if ( circularDependencyExceptions == null ) { return Collections.emptyList(); } return circularDependencyExceptions; } // ------------------------------------------------------------------------ // Repositories // ------------------------------------------------------------------------ public List getRepositories() { if ( repositories == null ) { return Collections.emptyList(); } return repositories; } public MetadataResolutionResult setRepositories( final List repositories ) { this.repositories = repositories; return this; } // // Internal // private List initList( final List l ) { if ( l == null ) { return new ArrayList<>(); } return l; } public String toString() { if ( artifacts == null ) return ""; StringBuilder sb = new StringBuilder( 256 ); int i = 1; sb.append( "---------\n" ); sb.append( artifacts.size() ).append( '\n' ); for ( Artifact a : artifacts ) { sb.append( i ).append( ' ' ).append( a ).append( '\n' ); i++; } sb.append( "---------\n" ); return sb.toString(); } public MetadataGraph getResolvedTree() { return resolvedTree; } public void setResolvedTree( MetadataGraph resolvedTree ) { this.resolvedTree = resolvedTree; } } maven-maven-3.5.2/maven-compat/src/main/java/org/apache/maven/repository/MirrorSelector.java000066400000000000000000000027661317160430700321460ustar00rootroot00000000000000package org.apache.maven.repository; /* * 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.util.List; import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.settings.Mirror; /** * Handles the selection of mirrors for repositories. * * @author Benjamin Bentmann */ public interface MirrorSelector { /** * Determines the mirror for the specified repository. * * @param repository The repository to determine the mirror for, must not be {@code null}. * @param mirrors The available mirrors, may be {@code null}. * @return The mirror specification for the repository or {@code null} if no mirror matched. */ Mirror getMirror( ArtifactRepository repository, List mirrors ); } UserLocalArtifactRepository.java000066400000000000000000000043471317160430700345600ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/main/java/org/apache/maven/repositorypackage org.apache.maven.repository; /* * 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.File; import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.metadata.ArtifactMetadata; import org.apache.maven.artifact.repository.ArtifactRepository; public class UserLocalArtifactRepository extends LocalArtifactRepository { private ArtifactRepository localRepository; public UserLocalArtifactRepository( ArtifactRepository localRepository ) { this.localRepository = localRepository; setLayout( localRepository.getLayout() ); } @Override public Artifact find( Artifact artifact ) { File artifactFile = new File( localRepository.getBasedir(), pathOf( artifact ) ); // We need to set the file here or the resolver will fail with an NPE, not fully equipped to deal // with multiple local repository implementations yet. artifact.setFile( artifactFile ); return artifact; } @Override public String getId() { return localRepository.getId(); } @Override public String pathOfLocalRepositoryMetadata( ArtifactMetadata metadata, ArtifactRepository repository ) { return localRepository.pathOfLocalRepositoryMetadata( metadata, repository ); } @Override public String pathOf( Artifact artifact ) { return localRepository.pathOf( artifact ); } @Override public boolean hasLocalMetadata() { return true; } } VersionNotFoundException.java000066400000000000000000000045041317160430700340650ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/main/java/org/apache/maven/repositorypackage org.apache.maven.repository; /* * 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.File; import org.apache.maven.artifact.ArtifactUtils; import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException; import org.apache.maven.model.Dependency; /** * Thrown if a dependency has an invalid version. * * @author Brett Porter */ public class VersionNotFoundException extends Exception { private Dependency dependency; private String projectId; private File pomFile; private InvalidVersionSpecificationException cause; public VersionNotFoundException( String projectId, Dependency dependency, File pomFile, InvalidVersionSpecificationException cause ) { super( projectId + ", " + formatLocationInPom( dependency ) + " " + dependency.getVersion() + ", pom file " + pomFile, cause ); this.projectId = projectId; this.pomFile = pomFile; this.cause = cause; this.dependency = dependency; } private static String formatLocationInPom( Dependency dependency ) { return "Dependency: " + ArtifactUtils.versionlessKey( dependency.getGroupId(), dependency.getArtifactId() ); } public Dependency getDependency() { return dependency; } public String getProjectId() { return projectId; } public File getPomFile() { return pomFile; } public InvalidVersionSpecificationException getCauseException() { return cause; } } maven-maven-3.5.2/maven-compat/src/main/java/org/apache/maven/repository/legacy/000077500000000000000000000000001317160430700275615ustar00rootroot00000000000000ChecksumFailedException.java000066400000000000000000000024641317160430700351010ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/main/java/org/apache/maven/repository/legacypackage org.apache.maven.repository.legacy; /* * 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 org.apache.maven.wagon.TransferFailedException; /** * Occurs when a download checksum fails. * * @author Brett Porter */ public class ChecksumFailedException extends TransferFailedException { public ChecksumFailedException( String s ) { super( s ); } public ChecksumFailedException( String message, Throwable cause ) { super( message, cause ); } } DefaultUpdateCheckManager.java000066400000000000000000000333171317160430700353340ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/main/java/org/apache/maven/repository/legacypackage org.apache.maven.repository.legacy; /* * 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 org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.repository.ArtifactRepositoryPolicy; import org.apache.maven.artifact.repository.Authentication; import org.apache.maven.artifact.repository.metadata.RepositoryMetadata; import org.apache.maven.repository.Proxy; import org.codehaus.plexus.component.annotations.Component; import org.codehaus.plexus.logging.AbstractLogEnabled; import org.codehaus.plexus.logging.Logger; import java.io.File; import java.io.FileInputStream; import java.io.IOException; import java.io.RandomAccessFile; import java.nio.channels.Channels; import java.nio.channels.FileChannel; import java.nio.channels.FileLock; import java.util.Date; import java.util.Properties; @Component( role = UpdateCheckManager.class ) public class DefaultUpdateCheckManager extends AbstractLogEnabled implements UpdateCheckManager { private static final String ERROR_KEY_SUFFIX = ".error"; public DefaultUpdateCheckManager() { } public DefaultUpdateCheckManager( Logger logger ) { enableLogging( logger ); } public static final String LAST_UPDATE_TAG = ".lastUpdated"; private static final String TOUCHFILE_NAME = "resolver-status.properties"; public boolean isUpdateRequired( Artifact artifact, ArtifactRepository repository ) { File file = artifact.getFile(); ArtifactRepositoryPolicy policy = artifact.isSnapshot() ? repository.getSnapshots() : repository.getReleases(); if ( !policy.isEnabled() ) { if ( getLogger().isDebugEnabled() ) { getLogger().debug( "Skipping update check for " + artifact + " (" + file + ") from " + repository.getId() + " (" + repository.getUrl() + ")" ); } return false; } if ( getLogger().isDebugEnabled() ) { getLogger().debug( "Determining update check for " + artifact + " (" + file + ") from " + repository.getId() + " (" + repository.getUrl() + ")" ); } if ( file == null ) { // TODO throw something instead? return true; } Date lastCheckDate; if ( file.exists() ) { lastCheckDate = new Date( file.lastModified() ); } else { File touchfile = getTouchfile( artifact ); lastCheckDate = readLastUpdated( touchfile, getRepositoryKey( repository ) ); } return ( lastCheckDate == null ) || policy.checkOutOfDate( lastCheckDate ); } public boolean isUpdateRequired( RepositoryMetadata metadata, ArtifactRepository repository, File file ) { // Here, we need to determine which policy to use. Release updateInterval will be used when // the metadata refers to a release artifact or meta-version, and snapshot updateInterval will be used when // it refers to a snapshot artifact or meta-version. // NOTE: Release metadata includes version information about artifacts that have been released, to allow // meta-versions like RELEASE and LATEST to resolve, and also to allow retrieval of the range of valid, released // artifacts available. ArtifactRepositoryPolicy policy = metadata.getPolicy( repository ); if ( !policy.isEnabled() ) { if ( getLogger().isDebugEnabled() ) { getLogger().debug( "Skipping update check for " + metadata.getKey() + " (" + file + ") from " + repository.getId() + " (" + repository.getUrl() + ")" ); } return false; } if ( getLogger().isDebugEnabled() ) { getLogger().debug( "Determining update check for " + metadata.getKey() + " (" + file + ") from " + repository.getId() + " (" + repository.getUrl() + ")" ); } if ( file == null ) { // TODO throw something instead? return true; } Date lastCheckDate = readLastUpdated( metadata, repository, file ); return ( lastCheckDate == null ) || policy.checkOutOfDate( lastCheckDate ); } private Date readLastUpdated( RepositoryMetadata metadata, ArtifactRepository repository, File file ) { File touchfile = getTouchfile( metadata, file ); String key = getMetadataKey( repository, file ); return readLastUpdated( touchfile, key ); } public String getError( Artifact artifact, ArtifactRepository repository ) { File touchFile = getTouchfile( artifact ); return getError( touchFile, getRepositoryKey( repository ) ); } public void touch( Artifact artifact, ArtifactRepository repository, String error ) { File file = artifact.getFile(); File touchfile = getTouchfile( artifact ); if ( file.exists() ) { touchfile.delete(); } else { writeLastUpdated( touchfile, getRepositoryKey( repository ), error ); } } public void touch( RepositoryMetadata metadata, ArtifactRepository repository, File file ) { File touchfile = getTouchfile( metadata, file ); String key = getMetadataKey( repository, file ); writeLastUpdated( touchfile, key, null ); } String getMetadataKey( ArtifactRepository repository, File file ) { return repository.getId() + '.' + file.getName() + LAST_UPDATE_TAG; } String getRepositoryKey( ArtifactRepository repository ) { StringBuilder buffer = new StringBuilder( 256 ); Proxy proxy = repository.getProxy(); if ( proxy != null ) { if ( proxy.getUserName() != null ) { int hash = ( proxy.getUserName() + proxy.getPassword() ).hashCode(); buffer.append( hash ).append( '@' ); } buffer.append( proxy.getHost() ).append( ':' ).append( proxy.getPort() ).append( '>' ); } // consider the username&password because a repo manager might block artifacts depending on authorization Authentication auth = repository.getAuthentication(); if ( auth != null ) { int hash = ( auth.getUsername() + auth.getPassword() ).hashCode(); buffer.append( hash ).append( '@' ); } // consider the URL (instead of the id) as this most closely relates to the contents in the repo buffer.append( repository.getUrl() ); return buffer.toString(); } private void writeLastUpdated( File touchfile, String key, String error ) { synchronized ( touchfile.getAbsolutePath().intern() ) { if ( !touchfile.getParentFile().exists() && !touchfile.getParentFile().mkdirs() ) { getLogger().debug( "Failed to create directory: " + touchfile.getParent() + " for tracking artifact metadata resolution." ); return; } FileChannel channel = null; FileLock lock = null; try { Properties props = new Properties(); channel = new RandomAccessFile( touchfile, "rw" ).getChannel(); lock = channel.lock(); if ( touchfile.canRead() ) { getLogger().debug( "Reading resolution-state from: " + touchfile ); props.load( Channels.newInputStream( channel ) ); } props.setProperty( key, Long.toString( System.currentTimeMillis() ) ); if ( error != null ) { props.setProperty( key + ERROR_KEY_SUFFIX, error ); } else { props.remove( key + ERROR_KEY_SUFFIX ); } getLogger().debug( "Writing resolution-state to: " + touchfile ); channel.truncate( 0 ); props.store( Channels.newOutputStream( channel ), "Last modified on: " + new Date() ); lock.release(); lock = null; channel.close(); channel = null; } catch ( IOException e ) { getLogger().debug( "Failed to record lastUpdated information for resolution.\nFile: " + touchfile.toString() + "; key: " + key, e ); } finally { if ( lock != null ) { try { lock.release(); } catch ( IOException e ) { getLogger().debug( "Error releasing exclusive lock for resolution tracking file: " + touchfile, e ); } } if ( channel != null ) { try { channel.close(); } catch ( IOException e ) { getLogger().debug( "Error closing FileChannel for resolution tracking file: " + touchfile, e ); } } } } } Date readLastUpdated( File touchfile, String key ) { getLogger().debug( "Searching for " + key + " in resolution tracking file." ); Properties props = read( touchfile ); if ( props != null ) { String rawVal = props.getProperty( key ); if ( rawVal != null ) { try { return new Date( Long.parseLong( rawVal ) ); } catch ( NumberFormatException e ) { getLogger().debug( "Cannot parse lastUpdated date: \'" + rawVal + "\'. Ignoring.", e ); } } } return null; } private String getError( File touchFile, String key ) { Properties props = read( touchFile ); if ( props != null ) { return props.getProperty( key + ERROR_KEY_SUFFIX ); } return null; } private Properties read( File touchfile ) { if ( !touchfile.canRead() ) { getLogger().debug( "Skipped unreadable resolution tracking file " + touchfile ); return null; } synchronized ( touchfile.getAbsolutePath().intern() ) { FileInputStream in = null; FileLock lock = null; try { Properties props = new Properties(); in = new FileInputStream( touchfile ); lock = in.getChannel().lock( 0, Long.MAX_VALUE, true ); getLogger().debug( "Reading resolution-state from: " + touchfile ); props.load( in ); lock.release(); lock = null; in.close(); in = null; return props; } catch ( IOException e ) { getLogger().debug( "Failed to read resolution tracking file " + touchfile, e ); return null; } finally { if ( lock != null ) { try { lock.release(); } catch ( IOException e ) { getLogger().debug( "Error releasing shared lock for resolution tracking file: " + touchfile, e ); } } if ( in != null ) { try { in.close(); } catch ( IOException e ) { getLogger().debug( "Error closing FileChannel for resolution tracking file: " + touchfile, e ); } } } } } File getTouchfile( Artifact artifact ) { StringBuilder sb = new StringBuilder( 128 ); sb.append( artifact.getArtifactId() ); sb.append( '-' ).append( artifact.getBaseVersion() ); if ( artifact.getClassifier() != null ) { sb.append( '-' ).append( artifact.getClassifier() ); } sb.append( '.' ).append( artifact.getType() ).append( LAST_UPDATE_TAG ); return new File( artifact.getFile().getParentFile(), sb.toString() ); } File getTouchfile( RepositoryMetadata metadata, File file ) { return new File( file.getParent(), TOUCHFILE_NAME ); } } DefaultWagonManager.java000066400000000000000000000767011317160430700342330ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/main/java/org/apache/maven/repository/legacypackage org.apache.maven.repository.legacy; /* * 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.File; import java.io.IOException; import java.lang.reflect.Method; import java.security.NoSuchAlgorithmException; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Properties; import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.metadata.ArtifactMetadata; import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.repository.ArtifactRepositoryPolicy; import org.apache.maven.plugin.LegacySupport; import org.apache.maven.wagon.ConnectionException; import org.apache.maven.wagon.ResourceDoesNotExistException; import org.apache.maven.wagon.TransferFailedException; import org.apache.maven.wagon.UnsupportedProtocolException; import org.apache.maven.wagon.Wagon; import org.apache.maven.wagon.authentication.AuthenticationException; import org.apache.maven.wagon.authentication.AuthenticationInfo; import org.apache.maven.wagon.authorization.AuthorizationException; import org.apache.maven.wagon.events.TransferListener; import org.apache.maven.wagon.observers.ChecksumObserver; import org.apache.maven.wagon.proxy.ProxyInfo; import org.apache.maven.wagon.repository.Repository; import org.codehaus.plexus.PlexusContainer; import org.codehaus.plexus.component.annotations.Component; import org.codehaus.plexus.component.annotations.Requirement; import org.codehaus.plexus.component.repository.exception.ComponentLifecycleException; import org.codehaus.plexus.component.repository.exception.ComponentLookupException; import org.codehaus.plexus.logging.Logger; import org.codehaus.plexus.util.FileUtils; import org.eclipse.aether.ConfigurationProperties; import org.eclipse.aether.util.ConfigUtils; //TODO remove the update check manager //TODO separate into retriever and publisher //TODO remove hardcoding of checksum logic @Component( role = WagonManager.class ) public class DefaultWagonManager implements WagonManager { private static final String[] CHECKSUM_IDS = { "md5", "sha1" }; /** * have to match the CHECKSUM_IDS */ private static final String[] CHECKSUM_ALGORITHMS = { "MD5", "SHA-1" }; @Requirement private Logger logger; @Requirement private PlexusContainer container; @Requirement private UpdateCheckManager updateCheckManager; @Requirement private LegacySupport legacySupport; // // Retriever // @Override public void getArtifact( Artifact artifact, ArtifactRepository repository, TransferListener downloadMonitor, boolean force ) throws TransferFailedException, ResourceDoesNotExistException { String remotePath = repository.pathOf( artifact ); ArtifactRepositoryPolicy policy = artifact.isSnapshot() ? repository.getSnapshots() : repository.getReleases(); if ( !policy.isEnabled() ) { logger.debug( "Skipping disabled repository " + repository.getId() + " for resolution of " + artifact.getId() ); } else if ( artifact.isSnapshot() || !artifact.getFile().exists() ) { if ( force || updateCheckManager.isUpdateRequired( artifact, repository ) ) { logger.debug( "Trying repository " + repository.getId() + " for resolution of " + artifact.getId() + " from " + remotePath ); try { getRemoteFile( repository, artifact.getFile(), remotePath, downloadMonitor, policy.getChecksumPolicy(), false ); updateCheckManager.touch( artifact, repository, null ); } catch ( ResourceDoesNotExistException e ) { updateCheckManager.touch( artifact, repository, null ); throw e; } catch ( TransferFailedException e ) { String error = ( e.getMessage() != null ) ? e.getMessage() : e.getClass().getSimpleName(); updateCheckManager.touch( artifact, repository, error ); throw e; } logger.debug( " Artifact " + artifact.getId() + " resolved to " + artifact.getFile() ); artifact.setResolved( true ); } else if ( !artifact.getFile().exists() ) { String error = updateCheckManager.getError( artifact, repository ); if ( error != null ) { throw new TransferFailedException( "Failure to resolve " + remotePath + " from " + repository.getUrl() + " was cached in the local repository. " + "Resolution will not be reattempted until the update interval of " + repository.getId() + " has elapsed or updates are forced. Original error: " + error ); } else { throw new ResourceDoesNotExistException( "Failure to resolve " + remotePath + " from " + repository.getUrl() + " was cached in the local repository. " + "Resolution will not be reattempted until the update interval of " + repository.getId() + " has elapsed or updates are forced." ); } } } } @Override public void getArtifact( Artifact artifact, List remoteRepositories, TransferListener downloadMonitor, boolean force ) throws TransferFailedException, ResourceDoesNotExistException { TransferFailedException tfe = null; for ( ArtifactRepository repository : remoteRepositories ) { try { getArtifact( artifact, repository, downloadMonitor, force ); if ( artifact.isResolved() ) { artifact.setRepository( repository ); break; } } catch ( ResourceDoesNotExistException e ) { // This one we will eat when looking through remote repositories // because we want to cycle through them all before squawking. logger.debug( "Unable to find artifact " + artifact.getId() + " in repository " + repository.getId() + " (" + repository.getUrl() + ")", e ); } catch ( TransferFailedException e ) { tfe = e; String msg = "Unable to get artifact " + artifact.getId() + " from repository " + repository.getId() + " (" + repository.getUrl() + "): " + e.getMessage(); if ( logger.isDebugEnabled() ) { logger.warn( msg, e ); } else { logger.warn( msg ); } } } // if it already exists locally we were just trying to force it - ignore the update if ( !artifact.getFile().exists() ) { if ( tfe != null ) { throw tfe; } else { throw new ResourceDoesNotExistException( "Unable to download the artifact from any repository" ); } } } @Override public void getArtifactMetadata( ArtifactMetadata metadata, ArtifactRepository repository, File destination, String checksumPolicy ) throws TransferFailedException, ResourceDoesNotExistException { String remotePath = repository.pathOfRemoteRepositoryMetadata( metadata ); getRemoteFile( repository, destination, remotePath, null, checksumPolicy, true ); } @Override public void getArtifactMetadataFromDeploymentRepository( ArtifactMetadata metadata, ArtifactRepository repository, File destination, String checksumPolicy ) throws TransferFailedException, ResourceDoesNotExistException { String remotePath = repository.pathOfRemoteRepositoryMetadata( metadata ); getRemoteFile( repository, destination, remotePath, null, checksumPolicy, true ); } /** * Deal with connecting to a wagon repository taking into account authentication and proxies. * * @param wagon * @param repository * * @throws ConnectionException * @throws AuthenticationException */ private void connectWagon( Wagon wagon, ArtifactRepository repository ) throws ConnectionException, AuthenticationException { // MNG-5509 // See org.eclipse.aether.connector.wagon.WagonRepositoryConnector.connectWagon(Wagon) if ( legacySupport.getRepositorySession() != null ) { String userAgent = ConfigUtils.getString( legacySupport.getRepositorySession(), null, ConfigurationProperties.USER_AGENT ); if ( userAgent == null ) { Properties headers = new Properties(); headers.put( "User-Agent", ConfigUtils.getString( legacySupport.getRepositorySession(), "Maven", ConfigurationProperties.USER_AGENT ) ); try { Method setHttpHeaders = wagon.getClass().getMethod( "setHttpHeaders", Properties.class ); setHttpHeaders.invoke( wagon, headers ); } catch ( NoSuchMethodException e ) { // normal for non-http wagons } catch ( Exception e ) { logger.debug( "Could not set user agent for wagon " + wagon.getClass().getName() + ": " + e ); } } } if ( repository.getProxy() != null && logger.isDebugEnabled() ) { logger.debug( "Using proxy " + repository.getProxy().getHost() + ":" + repository.getProxy().getPort() + " for " + repository.getUrl() ); } if ( repository.getAuthentication() != null && repository.getProxy() != null ) { wagon.connect( new Repository( repository.getId(), repository.getUrl() ), authenticationInfo( repository ), proxyInfo( repository ) ); } else if ( repository.getAuthentication() != null ) { wagon.connect( new Repository( repository.getId(), repository.getUrl() ), authenticationInfo( repository ) ); } else if ( repository.getProxy() != null ) { wagon.connect( new Repository( repository.getId(), repository.getUrl() ), proxyInfo( repository ) ); } else { wagon.connect( new Repository( repository.getId(), repository.getUrl() ) ); } } private AuthenticationInfo authenticationInfo( ArtifactRepository repository ) { AuthenticationInfo ai = new AuthenticationInfo(); ai.setUserName( repository.getAuthentication().getUsername() ); ai.setPassword( repository.getAuthentication().getPassword() ); return ai; } private ProxyInfo proxyInfo( ArtifactRepository repository ) { ProxyInfo proxyInfo = new ProxyInfo(); proxyInfo.setHost( repository.getProxy().getHost() ); proxyInfo.setType( repository.getProxy().getProtocol() ); proxyInfo.setPort( repository.getProxy().getPort() ); proxyInfo.setNonProxyHosts( repository.getProxy().getNonProxyHosts() ); proxyInfo.setUserName( repository.getProxy().getUserName() ); proxyInfo.setPassword( repository.getProxy().getPassword() ); return proxyInfo; } @Override public void getRemoteFile( ArtifactRepository repository, File destination, String remotePath, TransferListener downloadMonitor, String checksumPolicy, boolean force ) throws TransferFailedException, ResourceDoesNotExistException { String protocol = repository.getProtocol(); Wagon wagon; try { wagon = getWagon( protocol ); } catch ( UnsupportedProtocolException e ) { throw new TransferFailedException( "Unsupported Protocol: '" + protocol + "': " + e.getMessage(), e ); } if ( downloadMonitor != null ) { wagon.addTransferListener( downloadMonitor ); } File temp = new File( destination + ".tmp" ); temp.deleteOnExit(); boolean downloaded = false; try { connectWagon( wagon, repository ); boolean firstRun = true; boolean retry = true; // this will run at most twice. The first time, the firstRun flag is turned off, and if the retry flag // is set on the first run, it will be turned off and not re-set on the second try. This is because the // only way the retry flag can be set is if ( firstRun == true ). while ( firstRun || retry ) { ChecksumObserver md5ChecksumObserver = null; ChecksumObserver sha1ChecksumObserver = null; try { // TODO configure on repository int i = 0; md5ChecksumObserver = addChecksumObserver( wagon, CHECKSUM_ALGORITHMS[i++] ); sha1ChecksumObserver = addChecksumObserver( wagon, CHECKSUM_ALGORITHMS[i++] ); // reset the retry flag. retry = false; // This should take care of creating destination directory now on if ( destination.exists() && !force ) { try { downloaded = wagon.getIfNewer( remotePath, temp, destination.lastModified() ); if ( !downloaded ) { // prevent additional checks of this artifact until it expires again destination.setLastModified( System.currentTimeMillis() ); } } catch ( UnsupportedOperationException e ) { // older wagons throw this. Just get() instead wagon.get( remotePath, temp ); downloaded = true; } } else { wagon.get( remotePath, temp ); downloaded = true; } } finally { wagon.removeTransferListener( md5ChecksumObserver ); wagon.removeTransferListener( sha1ChecksumObserver ); } if ( downloaded ) { // keep the checksum files from showing up on the download monitor... if ( downloadMonitor != null ) { wagon.removeTransferListener( downloadMonitor ); } // try to verify the SHA-1 checksum for this file. try { verifyChecksum( sha1ChecksumObserver, destination, temp, remotePath, ".sha1", wagon ); } catch ( ChecksumFailedException e ) { // if we catch a ChecksumFailedException, it means the transfer/read succeeded, but the // checksum doesn't match. This could be a problem with the server (ibiblio HTTP-200 error // page), so we'll try this up to two times. On the second try, we'll handle it as a bona-fide // error, based on the repository's checksum checking policy. if ( firstRun ) { logger.warn( "*** CHECKSUM FAILED - " + e.getMessage() + " - RETRYING" ); retry = true; } else { handleChecksumFailure( checksumPolicy, e.getMessage(), e.getCause() ); } } catch ( ResourceDoesNotExistException sha1TryException ) { logger.debug( "SHA1 not found, trying MD5: " + sha1TryException.getMessage() ); // if this IS NOT a ChecksumFailedException, it was a problem with transfer/read of the checksum // file...we'll try again with the MD5 checksum. try { verifyChecksum( md5ChecksumObserver, destination, temp, remotePath, ".md5", wagon ); } catch ( ChecksumFailedException e ) { // if we also fail to verify based on the MD5 checksum, and the checksum transfer/read // succeeded, then we need to determine whether to retry or handle it as a failure. if ( firstRun ) { retry = true; } else { handleChecksumFailure( checksumPolicy, e.getMessage(), e.getCause() ); } } catch ( ResourceDoesNotExistException md5TryException ) { // this was a failed transfer, and we don't want to retry. handleChecksumFailure( checksumPolicy, "Error retrieving checksum file for " + remotePath, md5TryException ); } } // reinstate the download monitor... if ( downloadMonitor != null ) { wagon.addTransferListener( downloadMonitor ); } } // unset the firstRun flag, so we don't get caught in an infinite loop... firstRun = false; } } catch ( ConnectionException e ) { throw new TransferFailedException( "Connection failed: " + e.getMessage(), e ); } catch ( AuthenticationException e ) { throw new TransferFailedException( "Authentication failed: " + e.getMessage(), e ); } catch ( AuthorizationException e ) { throw new TransferFailedException( "Authorization failed: " + e.getMessage(), e ); } finally { // Remove remaining TransferListener instances (checksum handlers removed in above finally clause) if ( downloadMonitor != null ) { wagon.removeTransferListener( downloadMonitor ); } disconnectWagon( wagon ); releaseWagon( protocol, wagon ); } if ( downloaded ) { if ( !temp.exists() ) { throw new ResourceDoesNotExistException( "Downloaded file does not exist: " + temp ); } // The temporary file is named destination + ".tmp" and is done this way to ensure // that the temporary file is in the same file system as the destination because the // File.renameTo operation doesn't really work across file systems. // So we will attempt to do a File.renameTo for efficiency and atomicity, if this fails // then we will use a brute force copy and delete the temporary file. if ( !temp.renameTo( destination ) ) { try { FileUtils.copyFile( temp, destination ); if ( !temp.delete() ) { temp.deleteOnExit(); } } catch ( IOException e ) { throw new TransferFailedException( "Error copying temporary file to the final destination: " + e.getMessage(), e ); } } } } // // Publisher // @Override public void putArtifact( File source, Artifact artifact, ArtifactRepository deploymentRepository, TransferListener downloadMonitor ) throws TransferFailedException { putRemoteFile( deploymentRepository, source, deploymentRepository.pathOf( artifact ), downloadMonitor ); } @Override public void putArtifactMetadata( File source, ArtifactMetadata artifactMetadata, ArtifactRepository repository ) throws TransferFailedException { logger.info( "Uploading " + artifactMetadata ); putRemoteFile( repository, source, repository.pathOfRemoteRepositoryMetadata( artifactMetadata ), null ); } @Override public void putRemoteFile( ArtifactRepository repository, File source, String remotePath, TransferListener downloadMonitor ) throws TransferFailedException { String protocol = repository.getProtocol(); Wagon wagon; try { wagon = getWagon( protocol ); } catch ( UnsupportedProtocolException e ) { throw new TransferFailedException( "Unsupported Protocol: '" + protocol + "': " + e.getMessage(), e ); } if ( downloadMonitor != null ) { wagon.addTransferListener( downloadMonitor ); } Map checksums = new HashMap<>( 2 ); Map sums = new HashMap<>( 2 ); // TODO configure these on the repository for ( int i = 0; i < CHECKSUM_IDS.length; i++ ) { checksums.put( CHECKSUM_IDS[i], addChecksumObserver( wagon, CHECKSUM_ALGORITHMS[i] ) ); } List temporaryFiles = new ArrayList<>(); try { try { connectWagon( wagon, repository ); wagon.put( source, remotePath ); } finally { if ( downloadMonitor != null ) { wagon.removeTransferListener( downloadMonitor ); } } // Pre-store the checksums as any future puts will overwrite them for ( String extension : checksums.keySet() ) { ChecksumObserver observer = checksums.get( extension ); sums.put( extension, observer.getActualChecksum() ); } // We do this in here so we can checksum the artifact metadata too, otherwise it could be metadata itself for ( String extension : checksums.keySet() ) { // TODO shouldn't need a file intermediatary - improve wagon to take a stream File temp = File.createTempFile( "maven-artifact", null ); temp.deleteOnExit(); FileUtils.fileWrite( temp.getAbsolutePath(), "UTF-8", sums.get( extension ) ); temporaryFiles.add( temp ); wagon.put( temp, remotePath + "." + extension ); } } catch ( ConnectionException e ) { throw new TransferFailedException( "Connection failed: " + e.getMessage(), e ); } catch ( AuthenticationException e ) { throw new TransferFailedException( "Authentication failed: " + e.getMessage(), e ); } catch ( AuthorizationException e ) { throw new TransferFailedException( "Authorization failed: " + e.getMessage(), e ); } catch ( ResourceDoesNotExistException e ) { throw new TransferFailedException( "Resource to deploy not found: " + e.getMessage(), e ); } catch ( IOException e ) { throw new TransferFailedException( "Error creating temporary file for deployment: " + e.getMessage(), e ); } finally { // MNG-4543 cleanupTemporaryFiles( temporaryFiles ); // Remove every checksum listener for ( String id : CHECKSUM_IDS ) { TransferListener checksumListener = checksums.get( id ); if ( checksumListener != null ) { wagon.removeTransferListener( checksumListener ); } } disconnectWagon( wagon ); releaseWagon( protocol, wagon ); } } private void cleanupTemporaryFiles( List files ) { for ( File file : files ) { // really don't care if it failed here only log warning if ( !file.delete() ) { logger.warn( "skip failed to delete temporary file : " + file.getAbsolutePath() ); file.deleteOnExit(); } } } private ChecksumObserver addChecksumObserver( Wagon wagon, String algorithm ) throws TransferFailedException { try { ChecksumObserver checksumObserver = new ChecksumObserver( algorithm ); wagon.addTransferListener( checksumObserver ); return checksumObserver; } catch ( NoSuchAlgorithmException e ) { throw new TransferFailedException( "Unable to add checksum for unsupported algorithm " + algorithm, e ); } } private void handleChecksumFailure( String checksumPolicy, String message, Throwable cause ) throws ChecksumFailedException { if ( ArtifactRepositoryPolicy.CHECKSUM_POLICY_FAIL.equals( checksumPolicy ) ) { throw new ChecksumFailedException( message, cause ); } else if ( !ArtifactRepositoryPolicy.CHECKSUM_POLICY_IGNORE.equals( checksumPolicy ) ) { // warn if it is set to anything other than ignore logger.warn( "*** CHECKSUM FAILED - " + message + " - IGNORING" ); } // otherwise it is ignore } private void verifyChecksum( ChecksumObserver checksumObserver, File destination, File tempDestination, String remotePath, String checksumFileExtension, Wagon wagon ) throws ResourceDoesNotExistException, TransferFailedException, AuthorizationException { try { // grab it first, because it's about to change... String actualChecksum = checksumObserver.getActualChecksum(); File tempChecksumFile = new File( tempDestination + checksumFileExtension + ".tmp" ); tempChecksumFile.deleteOnExit(); wagon.get( remotePath + checksumFileExtension, tempChecksumFile ); String expectedChecksum = FileUtils.fileRead( tempChecksumFile, "UTF-8" ); // remove whitespaces at the end expectedChecksum = expectedChecksum.trim(); // check for 'ALGO (name) = CHECKSUM' like used by openssl if ( expectedChecksum.regionMatches( true, 0, "MD", 0, 2 ) || expectedChecksum.regionMatches( true, 0, "SHA", 0, 3 ) ) { int lastSpacePos = expectedChecksum.lastIndexOf( ' ' ); expectedChecksum = expectedChecksum.substring( lastSpacePos + 1 ); } else { // remove everything after the first space (if available) int spacePos = expectedChecksum.indexOf( ' ' ); if ( spacePos != -1 ) { expectedChecksum = expectedChecksum.substring( 0, spacePos ); } } if ( expectedChecksum.equalsIgnoreCase( actualChecksum ) ) { File checksumFile = new File( destination + checksumFileExtension ); if ( checksumFile.exists() ) { checksumFile.delete(); // ignore if failed as we will overwrite } FileUtils.copyFile( tempChecksumFile, checksumFile ); if ( !tempChecksumFile.delete() ) { tempChecksumFile.deleteOnExit(); } } else { throw new ChecksumFailedException( "Checksum failed on download: local = '" + actualChecksum + "'; remote = '" + expectedChecksum + "'" ); } } catch ( IOException e ) { throw new ChecksumFailedException( "Invalid checksum file", e ); } } private void disconnectWagon( Wagon wagon ) { try { wagon.disconnect(); } catch ( ConnectionException e ) { logger.error( "Problem disconnecting from wagon - ignoring: " + e.getMessage() ); } } private void releaseWagon( String protocol, Wagon wagon ) { try { container.release( wagon ); } catch ( ComponentLifecycleException e ) { logger.error( "Problem releasing wagon - ignoring: " + e.getMessage() ); logger.debug( "", e ); } } @Override @Deprecated public Wagon getWagon( Repository repository ) throws UnsupportedProtocolException { return getWagon( repository.getProtocol() ); } @Override @Deprecated public Wagon getWagon( String protocol ) throws UnsupportedProtocolException { if ( protocol == null ) { throw new UnsupportedProtocolException( "Unspecified protocol" ); } String hint = protocol.toLowerCase( java.util.Locale.ENGLISH ); Wagon wagon; try { wagon = container.lookup( Wagon.class, hint ); } catch ( ComponentLookupException e ) { throw new UnsupportedProtocolException( "Cannot find wagon which supports the requested protocol: " + protocol, e ); } return wagon; } } LegacyRepositorySystem.java000066400000000000000000001031471317160430700350640ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/main/java/org/apache/maven/repository/legacypackage org.apache.maven.repository.legacy; /* * 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.File; import java.io.IOException; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; import java.util.HashMap; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import org.apache.maven.RepositoryUtils; import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.InvalidRepositoryException; import org.apache.maven.artifact.factory.ArtifactFactory; import org.apache.maven.artifact.metadata.ArtifactMetadata; import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.repository.legacy.repository.ArtifactRepositoryFactory; import org.apache.maven.artifact.repository.ArtifactRepositoryPolicy; import org.apache.maven.artifact.repository.Authentication; import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout; import org.apache.maven.artifact.resolver.ArtifactResolutionRequest; import org.apache.maven.artifact.resolver.ArtifactResolutionResult; import org.apache.maven.artifact.resolver.ArtifactResolver; import org.apache.maven.artifact.resolver.filter.ExcludesArtifactFilter; import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException; import org.apache.maven.artifact.versioning.VersionRange; import org.apache.maven.model.Dependency; import org.apache.maven.model.Exclusion; import org.apache.maven.model.Plugin; import org.apache.maven.model.Repository; import org.apache.maven.model.RepositoryPolicy; import org.apache.maven.repository.DelegatingLocalArtifactRepository; import org.apache.maven.repository.LocalArtifactRepository; import org.apache.maven.repository.ArtifactTransferListener; import org.apache.maven.repository.MirrorSelector; import org.apache.maven.repository.Proxy; import org.apache.maven.repository.RepositorySystem; import org.apache.maven.repository.ArtifactDoesNotExistException; import org.apache.maven.repository.ArtifactTransferFailedException; import org.apache.maven.settings.Mirror; import org.apache.maven.settings.Server; import org.apache.maven.settings.building.SettingsProblem; import org.apache.maven.settings.crypto.DefaultSettingsDecryptionRequest; import org.apache.maven.settings.crypto.SettingsDecrypter; import org.apache.maven.settings.crypto.SettingsDecryptionRequest; import org.apache.maven.settings.crypto.SettingsDecryptionResult; import org.apache.maven.wagon.proxy.ProxyInfo; import org.apache.maven.wagon.proxy.ProxyUtils; import org.codehaus.plexus.PlexusContainer; import org.codehaus.plexus.component.annotations.Component; import org.codehaus.plexus.component.annotations.Requirement; import org.codehaus.plexus.component.repository.exception.ComponentLookupException; import org.codehaus.plexus.logging.Logger; import org.codehaus.plexus.util.StringUtils; import org.eclipse.aether.RepositorySystemSession; import org.eclipse.aether.repository.AuthenticationContext; import org.eclipse.aether.repository.AuthenticationSelector; import org.eclipse.aether.repository.ProxySelector; import org.eclipse.aether.repository.RemoteRepository; /** * @author Jason van Zyl */ @Component( role = RepositorySystem.class, hint = "default" ) public class LegacyRepositorySystem implements RepositorySystem { @Requirement private Logger logger; @Requirement private ArtifactFactory artifactFactory; @Requirement private ArtifactResolver artifactResolver; @Requirement private ArtifactRepositoryFactory artifactRepositoryFactory; @Requirement( role = ArtifactRepositoryLayout.class ) private Map layouts; @Requirement private WagonManager wagonManager; @Requirement private PlexusContainer plexus; @Requirement private MirrorSelector mirrorSelector; @Requirement private SettingsDecrypter settingsDecrypter; public Artifact createArtifact( String groupId, String artifactId, String version, String scope, String type ) { return artifactFactory.createArtifact( groupId, artifactId, version, scope, type ); } public Artifact createArtifact( String groupId, String artifactId, String version, String packaging ) { return artifactFactory.createBuildArtifact( groupId, artifactId, version, packaging ); } public Artifact createArtifactWithClassifier( String groupId, String artifactId, String version, String type, String classifier ) { return artifactFactory.createArtifactWithClassifier( groupId, artifactId, version, type, classifier ); } public Artifact createProjectArtifact( String groupId, String artifactId, String metaVersionId ) { return artifactFactory.createProjectArtifact( groupId, artifactId, metaVersionId ); } public Artifact createDependencyArtifact( Dependency d ) { VersionRange versionRange; try { versionRange = VersionRange.createFromVersionSpec( d.getVersion() ); } catch ( InvalidVersionSpecificationException e ) { // MNG-5368: Log a message instead of returning 'null' silently. this.logger.error( String.format( "Invalid version specification '%s' creating dependency artifact '%s'.", d.getVersion(), d ), e ); return null; } Artifact artifact = artifactFactory.createDependencyArtifact( d.getGroupId(), d.getArtifactId(), versionRange, d.getType(), d.getClassifier(), d.getScope(), d.isOptional() ); if ( Artifact.SCOPE_SYSTEM.equals( d.getScope() ) && d.getSystemPath() != null ) { artifact.setFile( new File( d.getSystemPath() ) ); } if ( !d.getExclusions().isEmpty() ) { List exclusions = new ArrayList<>(); for ( Exclusion exclusion : d.getExclusions() ) { exclusions.add( exclusion.getGroupId() + ':' + exclusion.getArtifactId() ); } artifact.setDependencyFilter( new ExcludesArtifactFilter( exclusions ) ); } return artifact; } public Artifact createExtensionArtifact( String groupId, String artifactId, String version ) { VersionRange versionRange; try { versionRange = VersionRange.createFromVersionSpec( version ); } catch ( InvalidVersionSpecificationException e ) { // MNG-5368: Log a message instead of returning 'null' silently. this.logger.error( String.format( "Invalid version specification '%s' creating extension artifact '%s:%s:%s'.", version, groupId, artifactId, version, e ) ); return null; } return artifactFactory.createExtensionArtifact( groupId, artifactId, versionRange ); } public Artifact createParentArtifact( String groupId, String artifactId, String version ) { return artifactFactory.createParentArtifact( groupId, artifactId, version ); } public Artifact createPluginArtifact( Plugin plugin ) { String version = plugin.getVersion(); if ( StringUtils.isEmpty( version ) ) { version = "RELEASE"; } VersionRange versionRange; try { versionRange = VersionRange.createFromVersionSpec( version ); } catch ( InvalidVersionSpecificationException e ) { // MNG-5368: Log a message instead of returning 'null' silently. this.logger.error( String.format( "Invalid version specification '%s' creating plugin artifact '%s'.", version, plugin, e ) ); return null; } return artifactFactory.createPluginArtifact( plugin.getGroupId(), plugin.getArtifactId(), versionRange ); } public ArtifactRepositoryPolicy buildArtifactRepositoryPolicy( RepositoryPolicy policy ) { boolean enabled = true; String updatePolicy = null; String checksumPolicy = null; if ( policy != null ) { enabled = policy.isEnabled(); if ( policy.getUpdatePolicy() != null ) { updatePolicy = policy.getUpdatePolicy(); } if ( policy.getChecksumPolicy() != null ) { checksumPolicy = policy.getChecksumPolicy(); } } return new ArtifactRepositoryPolicy( enabled, updatePolicy, checksumPolicy ); } public ArtifactRepository createDefaultLocalRepository() throws InvalidRepositoryException { return createLocalRepository( RepositorySystem.defaultUserLocalRepository ); } public ArtifactRepository createLocalRepository( File localRepository ) throws InvalidRepositoryException { return createRepository( "file://" + localRepository.toURI().getRawPath(), RepositorySystem.DEFAULT_LOCAL_REPO_ID, true, ArtifactRepositoryPolicy.UPDATE_POLICY_ALWAYS, true, ArtifactRepositoryPolicy.UPDATE_POLICY_ALWAYS, ArtifactRepositoryPolicy.CHECKSUM_POLICY_IGNORE ); } public ArtifactRepository createDefaultRemoteRepository() throws InvalidRepositoryException { return createRepository( RepositorySystem.DEFAULT_REMOTE_REPO_URL, RepositorySystem.DEFAULT_REMOTE_REPO_ID, true, ArtifactRepositoryPolicy.UPDATE_POLICY_DAILY, false, ArtifactRepositoryPolicy.UPDATE_POLICY_DAILY, ArtifactRepositoryPolicy.CHECKSUM_POLICY_WARN ); } public ArtifactRepository createLocalRepository( String url, String repositoryId ) throws IOException { return createRepository( canonicalFileUrl( url ), repositoryId, true, ArtifactRepositoryPolicy.UPDATE_POLICY_ALWAYS, true, ArtifactRepositoryPolicy.UPDATE_POLICY_ALWAYS, ArtifactRepositoryPolicy.CHECKSUM_POLICY_IGNORE ); } private String canonicalFileUrl( String url ) throws IOException { if ( !url.startsWith( "file:" ) ) { url = "file://" + url; } else if ( url.startsWith( "file:" ) && !url.startsWith( "file://" ) ) { url = "file://" + url.substring( "file:".length() ); } // So now we have an url of the form file:// // We want to eliminate any relative path nonsense and lock down the path so we // need to fully resolve it before any sub-modules use the path. This can happen // when you are using a custom settings.xml that contains a relative path entry // for the local repository setting. File localRepository = new File( url.substring( "file://".length() ) ); if ( !localRepository.isAbsolute() ) { url = "file://" + localRepository.getCanonicalPath(); } return url; } public ArtifactResolutionResult resolve( ArtifactResolutionRequest request ) { /* * Probably is not worth it, but here I make sure I restore request * to its original state. */ try { LocalArtifactRepository ideWorkspace = plexus.lookup( LocalArtifactRepository.class, LocalArtifactRepository.IDE_WORKSPACE ); if ( request.getLocalRepository() instanceof DelegatingLocalArtifactRepository ) { DelegatingLocalArtifactRepository delegatingLocalRepository = (DelegatingLocalArtifactRepository) request.getLocalRepository(); LocalArtifactRepository orig = delegatingLocalRepository.getIdeWorkspace(); delegatingLocalRepository.setIdeWorkspace( ideWorkspace ); try { return artifactResolver.resolve( request ); } finally { delegatingLocalRepository.setIdeWorkspace( orig ); } } else { ArtifactRepository localRepository = request.getLocalRepository(); DelegatingLocalArtifactRepository delegatingLocalRepository = new DelegatingLocalArtifactRepository( localRepository ); delegatingLocalRepository.setIdeWorkspace( ideWorkspace ); request.setLocalRepository( delegatingLocalRepository ); try { return artifactResolver.resolve( request ); } finally { request.setLocalRepository( localRepository ); } } } catch ( ComponentLookupException e ) { // no ide workspace artifact resolution } return artifactResolver.resolve( request ); } // public void addProxy( String protocol, String host, int port, String username, String password, // String nonProxyHosts ) // { // ProxyInfo proxyInfo = new ProxyInfo(); // proxyInfo.setHost( host ); // proxyInfo.setType( protocol ); // proxyInfo.setPort( port ); // proxyInfo.setNonProxyHosts( nonProxyHosts ); // proxyInfo.setUserName( username ); // proxyInfo.setPassword( password ); // // proxies.put( protocol, proxyInfo ); // // wagonManager.addProxy( protocol, host, port, username, password, nonProxyHosts ); // } public List getEffectiveRepositories( List repositories ) { if ( repositories == null ) { return null; } Map> reposByKey = new LinkedHashMap<>(); for ( ArtifactRepository repository : repositories ) { String key = repository.getId(); List aliasedRepos = reposByKey.get( key ); if ( aliasedRepos == null ) { aliasedRepos = new ArrayList<>(); reposByKey.put( key, aliasedRepos ); } aliasedRepos.add( repository ); } List effectiveRepositories = new ArrayList<>(); for ( List aliasedRepos : reposByKey.values() ) { List mirroredRepos = new ArrayList<>(); List releasePolicies = new ArrayList<>( aliasedRepos.size() ); for ( ArtifactRepository aliasedRepo : aliasedRepos ) { releasePolicies.add( aliasedRepo.getReleases() ); mirroredRepos.addAll( aliasedRepo.getMirroredRepositories() ); } ArtifactRepositoryPolicy releasePolicy = getEffectivePolicy( releasePolicies ); List snapshotPolicies = new ArrayList<>( aliasedRepos.size() ); for ( ArtifactRepository aliasedRepo : aliasedRepos ) { snapshotPolicies.add( aliasedRepo.getSnapshots() ); } ArtifactRepositoryPolicy snapshotPolicy = getEffectivePolicy( snapshotPolicies ); ArtifactRepository aliasedRepo = aliasedRepos.get( 0 ); ArtifactRepository effectiveRepository = createArtifactRepository( aliasedRepo.getId(), aliasedRepo.getUrl(), aliasedRepo.getLayout(), snapshotPolicy, releasePolicy ); effectiveRepository.setAuthentication( aliasedRepo.getAuthentication() ); effectiveRepository.setProxy( aliasedRepo.getProxy() ); effectiveRepository.setMirroredRepositories( mirroredRepos ); effectiveRepositories.add( effectiveRepository ); } return effectiveRepositories; } private ArtifactRepositoryPolicy getEffectivePolicy( Collection policies ) { ArtifactRepositoryPolicy effectivePolicy = null; for ( ArtifactRepositoryPolicy policy : policies ) { if ( effectivePolicy == null ) { effectivePolicy = new ArtifactRepositoryPolicy( policy ); } else { effectivePolicy.merge( policy ); } } return effectivePolicy; } public Mirror getMirror( ArtifactRepository repository, List mirrors ) { return mirrorSelector.getMirror( repository, mirrors ); } public void injectMirror( List repositories, List mirrors ) { if ( repositories != null && mirrors != null ) { for ( ArtifactRepository repository : repositories ) { Mirror mirror = getMirror( repository, mirrors ); injectMirror( repository, mirror ); } } } private Mirror getMirror( RepositorySystemSession session, ArtifactRepository repository ) { if ( session != null ) { org.eclipse.aether.repository.MirrorSelector selector = session.getMirrorSelector(); if ( selector != null ) { RemoteRepository repo = selector.getMirror( RepositoryUtils.toRepo( repository ) ); if ( repo != null ) { Mirror mirror = new Mirror(); mirror.setId( repo.getId() ); mirror.setUrl( repo.getUrl() ); mirror.setLayout( repo.getContentType() ); return mirror; } } } return null; } public void injectMirror( RepositorySystemSession session, List repositories ) { if ( repositories != null && session != null ) { for ( ArtifactRepository repository : repositories ) { Mirror mirror = getMirror( session, repository ); injectMirror( repository, mirror ); } } } private void injectMirror( ArtifactRepository repository, Mirror mirror ) { if ( mirror != null ) { ArtifactRepository original = createArtifactRepository( repository.getId(), repository.getUrl(), repository.getLayout(), repository.getSnapshots(), repository.getReleases() ); repository.setMirroredRepositories( Collections.singletonList( original ) ); repository.setId( mirror.getId() ); repository.setUrl( mirror.getUrl() ); if ( StringUtils.isNotEmpty( mirror.getLayout() ) ) { repository.setLayout( getLayout( mirror.getLayout() ) ); } } } public void injectAuthentication( List repositories, List servers ) { if ( repositories != null ) { Map serversById = new HashMap<>(); if ( servers != null ) { for ( Server server : servers ) { if ( !serversById.containsKey( server.getId() ) ) { serversById.put( server.getId(), server ); } } } for ( ArtifactRepository repository : repositories ) { Server server = serversById.get( repository.getId() ); if ( server != null ) { SettingsDecryptionRequest request = new DefaultSettingsDecryptionRequest( server ); SettingsDecryptionResult result = settingsDecrypter.decrypt( request ); server = result.getServer(); if ( logger.isDebugEnabled() ) { for ( SettingsProblem problem : result.getProblems() ) { logger.debug( problem.getMessage(), problem.getException() ); } } Authentication authentication = new Authentication( server.getUsername(), server.getPassword() ); authentication.setPrivateKey( server.getPrivateKey() ); authentication.setPassphrase( server.getPassphrase() ); repository.setAuthentication( authentication ); } else { repository.setAuthentication( null ); } } } } private Authentication getAuthentication( RepositorySystemSession session, ArtifactRepository repository ) { if ( session != null ) { AuthenticationSelector selector = session.getAuthenticationSelector(); if ( selector != null ) { RemoteRepository repo = RepositoryUtils.toRepo( repository ); org.eclipse.aether.repository.Authentication auth = selector.getAuthentication( repo ); if ( auth != null ) { repo = new RemoteRepository.Builder( repo ).setAuthentication( auth ).build(); AuthenticationContext authCtx = AuthenticationContext.forRepository( session, repo ); Authentication result = new Authentication( authCtx.get( AuthenticationContext.USERNAME ), authCtx.get( AuthenticationContext.PASSWORD ) ); result.setPrivateKey( authCtx.get( AuthenticationContext.PRIVATE_KEY_PATH ) ); result.setPassphrase( authCtx.get( AuthenticationContext.PRIVATE_KEY_PASSPHRASE ) ); authCtx.close(); return result; } } } return null; } public void injectAuthentication( RepositorySystemSession session, List repositories ) { if ( repositories != null && session != null ) { for ( ArtifactRepository repository : repositories ) { repository.setAuthentication( getAuthentication( session, repository ) ); } } } private org.apache.maven.settings.Proxy getProxy( ArtifactRepository repository, List proxies ) { if ( proxies != null && repository.getProtocol() != null ) { for ( org.apache.maven.settings.Proxy proxy : proxies ) { if ( proxy.isActive() && repository.getProtocol().equalsIgnoreCase( proxy.getProtocol() ) ) { if ( StringUtils.isNotEmpty( proxy.getNonProxyHosts() ) ) { ProxyInfo pi = new ProxyInfo(); pi.setNonProxyHosts( proxy.getNonProxyHosts() ); org.apache.maven.wagon.repository.Repository repo = new org.apache.maven.wagon.repository.Repository( repository.getId(), repository.getUrl() ); if ( !ProxyUtils.validateNonProxyHosts( pi, repo.getHost() ) ) { return proxy; } } else { return proxy; } } } } return null; } public void injectProxy( List repositories, List proxies ) { if ( repositories != null ) { for ( ArtifactRepository repository : repositories ) { org.apache.maven.settings.Proxy proxy = getProxy( repository, proxies ); if ( proxy != null ) { SettingsDecryptionRequest request = new DefaultSettingsDecryptionRequest( proxy ); SettingsDecryptionResult result = settingsDecrypter.decrypt( request ); proxy = result.getProxy(); if ( logger.isDebugEnabled() ) { for ( SettingsProblem problem : result.getProblems() ) { logger.debug( problem.getMessage(), problem.getException() ); } } Proxy p = new Proxy(); p.setHost( proxy.getHost() ); p.setProtocol( proxy.getProtocol() ); p.setPort( proxy.getPort() ); p.setNonProxyHosts( proxy.getNonProxyHosts() ); p.setUserName( proxy.getUsername() ); p.setPassword( proxy.getPassword() ); repository.setProxy( p ); } else { repository.setProxy( null ); } } } } private Proxy getProxy( RepositorySystemSession session, ArtifactRepository repository ) { if ( session != null ) { ProxySelector selector = session.getProxySelector(); if ( selector != null ) { RemoteRepository repo = RepositoryUtils.toRepo( repository ); org.eclipse.aether.repository.Proxy proxy = selector.getProxy( repo ); if ( proxy != null ) { Proxy p = new Proxy(); p.setHost( proxy.getHost() ); p.setProtocol( proxy.getType() ); p.setPort( proxy.getPort() ); if ( proxy.getAuthentication() != null ) { repo = new RemoteRepository.Builder( repo ).setProxy( proxy ).build(); AuthenticationContext authCtx = AuthenticationContext.forProxy( session, repo ); p.setUserName( authCtx.get( AuthenticationContext.USERNAME ) ); p.setPassword( authCtx.get( AuthenticationContext.PASSWORD ) ); p.setNtlmDomain( authCtx.get( AuthenticationContext.NTLM_DOMAIN ) ); p.setNtlmHost( authCtx.get( AuthenticationContext.NTLM_WORKSTATION ) ); authCtx.close(); } return p; } } } return null; } public void injectProxy( RepositorySystemSession session, List repositories ) { if ( repositories != null && session != null ) { for ( ArtifactRepository repository : repositories ) { repository.setProxy( getProxy( session, repository ) ); } } } public void retrieve( ArtifactRepository repository, File destination, String remotePath, ArtifactTransferListener transferListener ) throws ArtifactTransferFailedException, ArtifactDoesNotExistException { try { wagonManager.getRemoteFile( repository, destination, remotePath, TransferListenerAdapter.newAdapter( transferListener ), ArtifactRepositoryPolicy.CHECKSUM_POLICY_WARN, true ); } catch ( org.apache.maven.wagon.TransferFailedException e ) { throw new ArtifactTransferFailedException( getMessage( e, "Error transferring artifact." ), e ); } catch ( org.apache.maven.wagon.ResourceDoesNotExistException e ) { throw new ArtifactDoesNotExistException( getMessage( e, "Requested artifact does not exist." ), e ); } } public void publish( ArtifactRepository repository, File source, String remotePath, ArtifactTransferListener transferListener ) throws ArtifactTransferFailedException { try { wagonManager.putRemoteFile( repository, source, remotePath, TransferListenerAdapter.newAdapter( transferListener ) ); } catch ( org.apache.maven.wagon.TransferFailedException e ) { throw new ArtifactTransferFailedException( getMessage( e, "Error transferring artifact." ), e ); } } // // Artifact Repository Creation // public ArtifactRepository buildArtifactRepository( Repository repo ) throws InvalidRepositoryException { if ( repo != null ) { String id = repo.getId(); if ( StringUtils.isEmpty( id ) ) { throw new InvalidRepositoryException( "Repository identifier missing", "" ); } String url = repo.getUrl(); if ( StringUtils.isEmpty( url ) ) { throw new InvalidRepositoryException( "URL missing for repository " + id, id ); } ArtifactRepositoryPolicy snapshots = buildArtifactRepositoryPolicy( repo.getSnapshots() ); ArtifactRepositoryPolicy releases = buildArtifactRepositoryPolicy( repo.getReleases() ); return createArtifactRepository( id, url, getLayout( repo.getLayout() ), snapshots, releases ); } else { return null; } } private ArtifactRepository createRepository( String url, String repositoryId, boolean releases, String releaseUpdates, boolean snapshots, String snapshotUpdates, String checksumPolicy ) { ArtifactRepositoryPolicy snapshotsPolicy = new ArtifactRepositoryPolicy( snapshots, snapshotUpdates, checksumPolicy ); ArtifactRepositoryPolicy releasesPolicy = new ArtifactRepositoryPolicy( releases, releaseUpdates, checksumPolicy ); return createArtifactRepository( repositoryId, url, null, snapshotsPolicy, releasesPolicy ); } public ArtifactRepository createArtifactRepository( String repositoryId, String url, ArtifactRepositoryLayout repositoryLayout, ArtifactRepositoryPolicy snapshots, ArtifactRepositoryPolicy releases ) { if ( repositoryLayout == null ) { repositoryLayout = layouts.get( "default" ); } ArtifactRepository artifactRepository = artifactRepositoryFactory.createArtifactRepository( repositoryId, url, repositoryLayout, snapshots, releases ); return artifactRepository; } private static String getMessage( Throwable error, String def ) { if ( error == null ) { return def; } String msg = error.getMessage(); if ( StringUtils.isNotEmpty( msg ) ) { return msg; } return getMessage( error.getCause(), def ); } private ArtifactRepositoryLayout getLayout( String id ) { ArtifactRepositoryLayout layout = layouts.get( id ); if ( layout == null ) { layout = new UnknownRepositoryLayout( id, layouts.get( "default" ) ); } return layout; } /** * In the future, the legacy system might encounter repository types for which no layout components exists because * the actual communication with the repository happens via a repository connector. As a minimum, the legacy system * needs to retain the id of this layout so that the content type of the remote repository can still be accurately * described. */ static class UnknownRepositoryLayout implements ArtifactRepositoryLayout { private final String id; private final ArtifactRepositoryLayout fallback; public UnknownRepositoryLayout( String id, ArtifactRepositoryLayout fallback ) { this.id = id; this.fallback = fallback; } public String getId() { return id; } public String pathOf( Artifact artifact ) { return fallback.pathOf( artifact ); } public String pathOfLocalRepositoryMetadata( ArtifactMetadata metadata, ArtifactRepository repository ) { return fallback.pathOfLocalRepositoryMetadata( metadata, repository ); } public String pathOfRemoteRepositoryMetadata( ArtifactMetadata metadata ) { return fallback.pathOfRemoteRepositoryMetadata( metadata ); } @Override public String toString() { return getId(); } } } maven-maven-3.5.2/maven-compat/src/main/java/org/apache/maven/repository/legacy/MavenArtifact.java000066400000000000000000000044531317160430700331560ustar00rootroot00000000000000package org.apache.maven.repository.legacy; /* * 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 org.apache.maven.repository.ArtifactTransferResource; import org.apache.maven.wagon.resource.Resource; class MavenArtifact implements ArtifactTransferResource { private String repositoryUrl; private Resource resource; private long transferStartTime; public MavenArtifact( String repositoryUrl, Resource resource ) { if ( repositoryUrl == null ) { this.repositoryUrl = ""; } else if ( !repositoryUrl.endsWith( "/" ) && repositoryUrl.length() > 0 ) { this.repositoryUrl = repositoryUrl + '/'; } else { this.repositoryUrl = repositoryUrl; } this.resource = resource; this.transferStartTime = System.currentTimeMillis(); } public String getRepositoryUrl() { return repositoryUrl; } public String getName() { String name = resource.getName(); if ( name == null ) { name = ""; } else if ( name.startsWith( "/" ) ) { name = name.substring( 1 ); } return name; } public String getUrl() { return getRepositoryUrl() + getName(); } public long getContentLength() { return resource.getContentLength(); } public long getTransferStartTime() { return transferStartTime; } @Override public String toString() { return getUrl(); } } TransferListenerAdapter.java000066400000000000000000000125451317160430700351470ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/main/java/org/apache/maven/repository/legacypackage org.apache.maven.repository.legacy; /* * 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.util.IdentityHashMap; import java.util.Map; import org.apache.maven.repository.ArtifactTransferEvent; import org.apache.maven.repository.ArtifactTransferListener; import org.apache.maven.repository.ArtifactTransferResource; import org.apache.maven.wagon.events.TransferEvent; import org.apache.maven.wagon.events.TransferListener; import org.apache.maven.wagon.repository.Repository; import org.apache.maven.wagon.resource.Resource; public class TransferListenerAdapter implements TransferListener { private final ArtifactTransferListener listener; private final Map artifacts; private final Map transfers; public static TransferListener newAdapter( ArtifactTransferListener listener ) { if ( listener == null ) { return null; } else { return new TransferListenerAdapter( listener ); } } private TransferListenerAdapter( ArtifactTransferListener listener ) { this.listener = listener; this.artifacts = new IdentityHashMap<>(); this.transfers = new IdentityHashMap<>(); } public void debug( String message ) { } public void transferCompleted( TransferEvent transferEvent ) { ArtifactTransferEvent event = wrap( transferEvent ); Long transferred; synchronized ( transfers ) { transferred = transfers.remove( transferEvent.getResource() ); } if ( transferred != null ) { event.setTransferredBytes( transferred ); } synchronized ( artifacts ) { artifacts.remove( transferEvent.getResource() ); } listener.transferCompleted( event ); } public void transferError( TransferEvent transferEvent ) { synchronized ( transfers ) { transfers.remove( transferEvent.getResource() ); } synchronized ( artifacts ) { artifacts.remove( transferEvent.getResource() ); } } public void transferInitiated( TransferEvent transferEvent ) { listener.transferInitiated( wrap( transferEvent ) ); } public void transferProgress( TransferEvent transferEvent, byte[] buffer, int length ) { Long transferred; synchronized ( transfers ) { transferred = transfers.get( transferEvent.getResource() ); if ( transferred == null ) { transferred = (long) length; } else { transferred = transferred + length; } transfers.put( transferEvent.getResource(), transferred ); } ArtifactTransferEvent event = wrap( transferEvent ); event.setDataBuffer( buffer ); event.setDataOffset( 0 ); event.setDataLength( length ); event.setTransferredBytes( transferred ); listener.transferProgress( event ); } public void transferStarted( TransferEvent transferEvent ) { listener.transferStarted( wrap( transferEvent ) ); } private ArtifactTransferEvent wrap( TransferEvent event ) { if ( event == null ) { return null; } else { String wagon = event.getWagon().getClass().getName(); ArtifactTransferResource artifact = wrap( event.getWagon().getRepository(), event.getResource() ); ArtifactTransferEvent evt; if ( event.getException() != null ) { evt = new ArtifactTransferEvent( wagon, event.getException(), event.getRequestType(), artifact ); } else { evt = new ArtifactTransferEvent( wagon, event.getEventType(), event.getRequestType(), artifact ); } evt.setLocalFile( event.getLocalFile() ); return evt; } } private ArtifactTransferResource wrap( Repository repository, Resource resource ) { if ( resource == null ) { return null; } else { synchronized ( artifacts ) { ArtifactTransferResource artifact = artifacts.get( resource ); if ( artifact == null ) { artifact = new MavenArtifact( repository.getUrl(), resource ); artifacts.put( resource, artifact ); } return artifact; } } } } UpdateCheckManager.java000066400000000000000000000027731317160430700340310ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/main/java/org/apache/maven/repository/legacypackage org.apache.maven.repository.legacy; /* * 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.File; import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.repository.metadata.RepositoryMetadata; public interface UpdateCheckManager { boolean isUpdateRequired( Artifact artifact, ArtifactRepository repository ); void touch( Artifact artifact, ArtifactRepository repository, String error ); String getError( Artifact artifact, ArtifactRepository repository ); boolean isUpdateRequired( RepositoryMetadata metadata, ArtifactRepository repository, File file ); void touch( RepositoryMetadata metadata, ArtifactRepository repository, File file ); } WagonConfigurationException.java000066400000000000000000000036431317160430700360350ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/main/java/org/apache/maven/repository/legacypackage org.apache.maven.repository.legacy; /* * 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 org.apache.maven.wagon.TransferFailedException; public class WagonConfigurationException extends TransferFailedException { static final long serialVersionUID = 1; private final String originalMessage; private final String repositoryId; public WagonConfigurationException( String repositoryId, String message, Throwable cause ) { super( "While configuring wagon for \'" + repositoryId + "\': " + message, cause ); this.repositoryId = repositoryId; this.originalMessage = message; } public WagonConfigurationException( String repositoryId, String message ) { super( "While configuring wagon for \'" + repositoryId + "\': " + message ); this.repositoryId = repositoryId; this.originalMessage = message; } public final String getRepositoryId() { return repositoryId; } public final String getOriginalMessage() { return originalMessage; } } maven-maven-3.5.2/maven-compat/src/main/java/org/apache/maven/repository/legacy/WagonManager.java000066400000000000000000000066261317160430700330040ustar00rootroot00000000000000package org.apache.maven.repository.legacy; /* * 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.File; import java.util.List; import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.metadata.ArtifactMetadata; import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.wagon.ResourceDoesNotExistException; import org.apache.maven.wagon.TransferFailedException; import org.apache.maven.wagon.UnsupportedProtocolException; import org.apache.maven.wagon.Wagon; import org.apache.maven.wagon.events.TransferListener; import org.apache.maven.wagon.repository.Repository; public interface WagonManager { @Deprecated Wagon getWagon( String protocol ) throws UnsupportedProtocolException; @Deprecated Wagon getWagon( Repository repository ) throws UnsupportedProtocolException, WagonConfigurationException; // // Retriever // void getArtifact( Artifact artifact, ArtifactRepository repository, TransferListener transferListener, boolean force ) throws TransferFailedException, ResourceDoesNotExistException; void getArtifact( Artifact artifact, List remoteRepositories, TransferListener transferListener, boolean force ) throws TransferFailedException, ResourceDoesNotExistException; void getRemoteFile( ArtifactRepository repository, File destination, String remotePath, TransferListener downloadMonitor, String checksumPolicy, boolean force ) throws TransferFailedException, ResourceDoesNotExistException; void getArtifactMetadata( ArtifactMetadata metadata, ArtifactRepository remoteRepository, File destination, String checksumPolicy ) throws TransferFailedException, ResourceDoesNotExistException; void getArtifactMetadataFromDeploymentRepository( ArtifactMetadata metadata, ArtifactRepository remoteRepository, File file, String checksumPolicyWarn ) throws TransferFailedException, ResourceDoesNotExistException; // // Deployer // void putArtifact( File source, Artifact artifact, ArtifactRepository deploymentRepository, TransferListener downloadMonitor ) throws TransferFailedException; void putRemoteFile( ArtifactRepository repository, File source, String remotePath, TransferListener downloadMonitor ) throws TransferFailedException; void putArtifactMetadata( File source, ArtifactMetadata artifactMetadata, ArtifactRepository repository ) throws TransferFailedException; } maven-maven-3.5.2/maven-compat/src/main/java/org/apache/maven/repository/legacy/repository/000077500000000000000000000000001317160430700320005ustar00rootroot00000000000000ArtifactRepositoryFactory.java000066400000000000000000000047511317160430700377600ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/main/java/org/apache/maven/repository/legacy/repositorypackage org.apache.maven.repository.legacy.repository; /* * 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 org.apache.maven.artifact.UnknownRepositoryLayoutException; import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.repository.ArtifactRepositoryPolicy; import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout; /** @author jdcasey */ public interface ArtifactRepositoryFactory { String DEFAULT_LAYOUT_ID = "default"; String LOCAL_REPOSITORY_ID = "local"; @Deprecated ArtifactRepositoryLayout getLayout( String layoutId ) throws UnknownRepositoryLayoutException; @Deprecated ArtifactRepository createDeploymentArtifactRepository( String id, String url, String layoutId, boolean uniqueVersion ) throws UnknownRepositoryLayoutException; ArtifactRepository createDeploymentArtifactRepository( String id, String url, ArtifactRepositoryLayout layout, boolean uniqueVersion ); ArtifactRepository createArtifactRepository( String id, String url, String layoutId, ArtifactRepositoryPolicy snapshots, ArtifactRepositoryPolicy releases ) throws UnknownRepositoryLayoutException; ArtifactRepository createArtifactRepository( String id, String url, ArtifactRepositoryLayout repositoryLayout, ArtifactRepositoryPolicy snapshots, ArtifactRepositoryPolicy releases ); void setGlobalUpdatePolicy( String snapshotPolicy ); void setGlobalChecksumPolicy( String checksumPolicy ); } DefaultArtifactRepositoryFactory.java000066400000000000000000000125211317160430700412570ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/main/java/org/apache/maven/repository/legacy/repositorypackage org.apache.maven.repository.legacy.repository; /* * 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.util.Map; import org.apache.maven.artifact.UnknownRepositoryLayoutException; import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.repository.ArtifactRepositoryPolicy; import org.apache.maven.artifact.repository.MavenArtifactRepository; import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout; import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout2; import org.codehaus.plexus.component.annotations.Component; import org.codehaus.plexus.component.annotations.Requirement; /** * @author jdcasey */ @Component( role = ArtifactRepositoryFactory.class ) public class DefaultArtifactRepositoryFactory implements ArtifactRepositoryFactory { // TODO use settings? private String globalUpdatePolicy; private String globalChecksumPolicy; @Requirement( role = ArtifactRepositoryLayout.class ) private Map repositoryLayouts; public ArtifactRepositoryLayout getLayout( String layoutId ) throws UnknownRepositoryLayoutException { return repositoryLayouts.get( layoutId ); } public ArtifactRepository createDeploymentArtifactRepository( String id, String url, String layoutId, boolean uniqueVersion ) throws UnknownRepositoryLayoutException { ArtifactRepositoryLayout layout = repositoryLayouts.get( layoutId ); checkLayout( id, layoutId, layout ); return createDeploymentArtifactRepository( id, url, layout, uniqueVersion ); } private void checkLayout( String repositoryId, String layoutId, ArtifactRepositoryLayout layout ) throws UnknownRepositoryLayoutException { if ( layout == null ) { throw new UnknownRepositoryLayoutException( repositoryId, layoutId ); } } public ArtifactRepository createDeploymentArtifactRepository( String id, String url, ArtifactRepositoryLayout repositoryLayout, boolean uniqueVersion ) { return createArtifactRepository( id, url, repositoryLayout, null, null ); } public ArtifactRepository createArtifactRepository( String id, String url, String layoutId, ArtifactRepositoryPolicy snapshots, ArtifactRepositoryPolicy releases ) throws UnknownRepositoryLayoutException { ArtifactRepositoryLayout layout = repositoryLayouts.get( layoutId ); checkLayout( id, layoutId, layout ); return createArtifactRepository( id, url, layout, snapshots, releases ); } public ArtifactRepository createArtifactRepository( String id, String url, ArtifactRepositoryLayout repositoryLayout, ArtifactRepositoryPolicy snapshots, ArtifactRepositoryPolicy releases ) { if ( snapshots == null ) { snapshots = new ArtifactRepositoryPolicy(); } if ( releases == null ) { releases = new ArtifactRepositoryPolicy(); } if ( globalUpdatePolicy != null ) { snapshots.setUpdatePolicy( globalUpdatePolicy ); releases.setUpdatePolicy( globalUpdatePolicy ); } if ( globalChecksumPolicy != null ) { snapshots.setChecksumPolicy( globalChecksumPolicy ); releases.setChecksumPolicy( globalChecksumPolicy ); } ArtifactRepository repository; if ( repositoryLayout instanceof ArtifactRepositoryLayout2 ) { repository = ( (ArtifactRepositoryLayout2) repositoryLayout ).newMavenArtifactRepository( id, url, snapshots, releases ); } else { repository = new MavenArtifactRepository( id, url, repositoryLayout, snapshots, releases ); } return repository; } public void setGlobalUpdatePolicy( String updatePolicy ) { globalUpdatePolicy = updatePolicy; } public void setGlobalChecksumPolicy( String checksumPolicy ) { globalChecksumPolicy = checksumPolicy; } } maven-maven-3.5.2/maven-compat/src/main/java/org/apache/maven/repository/legacy/resolver/000077500000000000000000000000001317160430700314225ustar00rootroot00000000000000DefaultLegacyArtifactCollector.java000066400000000000000000001153061317160430700402520ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/main/java/org/apache/maven/repository/legacy/resolverpackage org.apache.maven.repository.legacy.resolver; /* * 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.util.ArrayList; import java.util.Collections; import java.util.Iterator; import java.util.LinkedHashMap; import java.util.LinkedHashSet; import java.util.List; import java.util.Map; import java.util.Set; import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.metadata.ArtifactMetadataSource; import org.apache.maven.artifact.metadata.ResolutionGroup; import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.resolver.ArtifactResolutionException; import org.apache.maven.artifact.resolver.ArtifactResolutionRequest; import org.apache.maven.artifact.resolver.ArtifactResolutionResult; import org.apache.maven.artifact.resolver.CyclicDependencyException; import org.apache.maven.artifact.resolver.ResolutionListener; import org.apache.maven.artifact.resolver.ResolutionListenerForDepMgmt; import org.apache.maven.artifact.resolver.ResolutionNode; import org.apache.maven.artifact.resolver.filter.AndArtifactFilter; import org.apache.maven.artifact.resolver.filter.ArtifactFilter; import org.apache.maven.artifact.versioning.ArtifactVersion; import org.apache.maven.artifact.versioning.ManagedVersionMap; import org.apache.maven.artifact.versioning.OverConstrainedVersionException; import org.apache.maven.artifact.versioning.VersionRange; import org.apache.maven.execution.MavenSession; import org.apache.maven.plugin.LegacySupport; import org.apache.maven.repository.legacy.metadata.ArtifactMetadataRetrievalException; import org.apache.maven.repository.legacy.metadata.DefaultMetadataResolutionRequest; import org.apache.maven.repository.legacy.metadata.MetadataResolutionRequest; import org.apache.maven.repository.legacy.resolver.conflict.ConflictResolver; import org.codehaus.plexus.component.annotations.Component; import org.codehaus.plexus.component.annotations.Requirement; import org.codehaus.plexus.logging.Logger; /** * @author Brett Porter * @author Jason van Zyl */ @Component( role = LegacyArtifactCollector.class ) public class DefaultLegacyArtifactCollector implements LegacyArtifactCollector { @Requirement( hint = "nearest" ) private ConflictResolver defaultConflictResolver; @Requirement private Logger logger; @Requirement private LegacySupport legacySupport; private void injectSession( ArtifactResolutionRequest request ) { MavenSession session = legacySupport.getSession(); if ( session != null ) { request.setOffline( session.isOffline() ); request.setForceUpdate( session.getRequest().isUpdateSnapshots() ); request.setServers( session.getRequest().getServers() ); request.setMirrors( session.getRequest().getMirrors() ); request.setProxies( session.getRequest().getProxies() ); } } public ArtifactResolutionResult collect( Set artifacts, Artifact originatingArtifact, Map managedVersions, ArtifactRepository localRepository, List remoteRepositories, ArtifactMetadataSource source, ArtifactFilter filter, List listeners, List conflictResolvers ) { ArtifactResolutionRequest request = new ArtifactResolutionRequest(); request.setLocalRepository( localRepository ); request.setRemoteRepositories( remoteRepositories ); injectSession( request ); return collect( artifacts, originatingArtifact, managedVersions, request, source, filter, listeners, conflictResolvers ); } public ArtifactResolutionResult collect( Set artifacts, Artifact originatingArtifact, Map managedVersions, ArtifactResolutionRequest repositoryRequest, ArtifactMetadataSource source, ArtifactFilter filter, List listeners, List conflictResolvers ) { ArtifactResolutionResult result = new ArtifactResolutionResult(); result.setOriginatingArtifact( originatingArtifact ); if ( conflictResolvers == null ) { conflictResolvers = Collections.singletonList( defaultConflictResolver ); } Map> resolvedArtifacts = new LinkedHashMap<>(); ResolutionNode root = new ResolutionNode( originatingArtifact, repositoryRequest.getRemoteRepositories() ); try { root.addDependencies( artifacts, repositoryRequest.getRemoteRepositories(), filter ); } catch ( CyclicDependencyException e ) { result.addCircularDependencyException( e ); return result; } catch ( OverConstrainedVersionException e ) { result.addVersionRangeViolation( e ); return result; } ManagedVersionMap versionMap = getManagedVersionsMap( originatingArtifact, managedVersions ); try { recurse( result, root, resolvedArtifacts, versionMap, repositoryRequest, source, filter, listeners, conflictResolvers ); } catch ( CyclicDependencyException e ) { logger.debug( "While recursing: " + e.getMessage(), e ); result.addCircularDependencyException( e ); } catch ( OverConstrainedVersionException e ) { logger.debug( "While recursing: " + e.getMessage(), e ); result.addVersionRangeViolation( e ); } catch ( ArtifactResolutionException e ) { logger.debug( "While recursing: " + e.getMessage(), e ); result.addErrorArtifactException( e ); } Set set = new LinkedHashSet<>(); for ( List nodes : resolvedArtifacts.values() ) { for ( ResolutionNode node : nodes ) { if ( !node.equals( root ) && node.isActive() ) { Artifact artifact = node.getArtifact(); try { if ( node.filterTrail( filter ) ) { // If it was optional and not a direct dependency, // we don't add it or its children, just allow the update of the version and artifactScope if ( node.isChildOfRootNode() || !artifact.isOptional() ) { artifact.setDependencyTrail( node.getDependencyTrail() ); set.add( node ); // This is required right now. result.addArtifact( artifact ); } } } catch ( OverConstrainedVersionException e ) { result.addVersionRangeViolation( e ); } } } } result.setArtifactResolutionNodes( set ); return result; } /** * Get the map of managed versions, removing the originating artifact if it is also in managed versions * * @param originatingArtifact artifact we are processing * @param managedVersions original managed versions */ private ManagedVersionMap getManagedVersionsMap( Artifact originatingArtifact, Map managedVersions ) { ManagedVersionMap versionMap; if ( ( managedVersions != null ) && ( managedVersions instanceof ManagedVersionMap ) ) { versionMap = (ManagedVersionMap) managedVersions; } else { versionMap = new ManagedVersionMap( managedVersions ); } // remove the originating artifact if it is also in managed versions to avoid being modified during resolution Artifact managedOriginatingArtifact = versionMap.get( originatingArtifact.getDependencyConflictId() ); if ( managedOriginatingArtifact != null ) { // TODO we probably want to warn the user that he is building an artifact with // different values than in dependencyManagement if ( managedVersions instanceof ManagedVersionMap ) { /* avoid modifying the managedVersions parameter creating a new map */ versionMap = new ManagedVersionMap( managedVersions ); } versionMap.remove( originatingArtifact.getDependencyConflictId() ); } return versionMap; } private void recurse( ArtifactResolutionResult result, ResolutionNode node, Map> resolvedArtifacts, ManagedVersionMap managedVersions, ArtifactResolutionRequest request, ArtifactMetadataSource source, ArtifactFilter filter, List listeners, List conflictResolvers ) throws ArtifactResolutionException { fireEvent( ResolutionListener.TEST_ARTIFACT, listeners, node ); Object key = node.getKey(); // TODO Does this check need to happen here? Had to add the same call // below when we iterate on child nodes -- will that suffice? if ( managedVersions.containsKey( key ) ) { manageArtifact( node, managedVersions, listeners ); } List previousNodes = resolvedArtifacts.get( key ); if ( previousNodes != null ) { for ( ResolutionNode previous : previousNodes ) { try { if ( previous.isActive() ) { // Version mediation VersionRange previousRange = previous.getArtifact().getVersionRange(); VersionRange currentRange = node.getArtifact().getVersionRange(); if ( ( previousRange != null ) && ( currentRange != null ) ) { // TODO shouldn't need to double up on this work, only done for simplicity of handling // recommended // version but the restriction is identical VersionRange newRange = previousRange.restrict( currentRange ); // TODO ick. this forces the OCE that should have come from the previous call. It is still // correct if ( newRange.isSelectedVersionKnown( previous.getArtifact() ) ) { fireEvent( ResolutionListener.RESTRICT_RANGE, listeners, node, previous.getArtifact(), newRange ); } previous.getArtifact().setVersionRange( newRange ); node.getArtifact().setVersionRange( currentRange.restrict( previousRange ) ); // Select an appropriate available version from the (now restricted) range // Note this version was selected before to get the appropriate POM // But it was reset by the call to setVersionRange on restricting the version ResolutionNode[] resetNodes = { previous, node }; for ( int j = 0; j < 2; j++ ) { Artifact resetArtifact = resetNodes[j].getArtifact(); // MNG-2123: if the previous node was not a range, then it wouldn't have any available // versions. We just clobbered the selected version above. (why? i have no idea.) // So since we are here and this is ranges we must go figure out the version (for a // third time...) if ( resetArtifact.getVersion() == null && resetArtifact.getVersionRange() != null ) { // go find the version. This is a total hack. See previous comment. List versions = resetArtifact.getAvailableVersions(); if ( versions == null ) { try { MetadataResolutionRequest metadataRequest = new DefaultMetadataResolutionRequest( request ); metadataRequest.setArtifact( resetArtifact ); versions = source.retrieveAvailableVersions( metadataRequest ); resetArtifact.setAvailableVersions( versions ); } catch ( ArtifactMetadataRetrievalException e ) { resetArtifact.setDependencyTrail( node.getDependencyTrail() ); throw new ArtifactResolutionException( "Unable to get dependency information: " + e.getMessage(), resetArtifact, request.getRemoteRepositories(), e ); } } // end hack // MNG-2861: match version can return null ArtifactVersion selectedVersion = resetArtifact.getVersionRange(). matchVersion( resetArtifact.getAvailableVersions() ); if ( selectedVersion != null ) { resetArtifact.selectVersion( selectedVersion.toString() ); } else { throw new OverConstrainedVersionException( "Unable to find a version in " + resetArtifact.getAvailableVersions() + " to match the range " + resetArtifact.getVersionRange(), resetArtifact ); } fireEvent( ResolutionListener.SELECT_VERSION_FROM_RANGE, listeners, resetNodes[j] ); } } } // Conflict Resolution ResolutionNode resolved = null; for ( Iterator j = conflictResolvers.iterator(); resolved == null && j.hasNext(); ) { ConflictResolver conflictResolver = j.next(); resolved = conflictResolver.resolveConflict( previous, node ); } if ( resolved == null ) { // TODO add better exception that can detail the two conflicting artifacts ArtifactResolutionException are = new ArtifactResolutionException( "Cannot resolve artifact version conflict between " + previous.getArtifact().getVersion() + " and " + node.getArtifact().getVersion(), previous.getArtifact() ); result.addVersionRangeViolation( are ); } if ( ( resolved != previous ) && ( resolved != node ) ) { // TODO add better exception result.addVersionRangeViolation( new ArtifactResolutionException( "Conflict resolver returned unknown resolution node: ", resolved.getArtifact() ) ); } // TODO should this be part of mediation? // previous one is more dominant ResolutionNode nearest; ResolutionNode farthest; if ( resolved == previous ) { nearest = previous; farthest = node; } else { nearest = node; farthest = previous; } if ( checkScopeUpdate( farthest, nearest, listeners ) ) { // if we need to update artifactScope of nearest to use farthest artifactScope, use the // nearest version, but farthest artifactScope nearest.disable(); farthest.getArtifact().setVersion( nearest.getArtifact().getVersion() ); fireEvent( ResolutionListener.OMIT_FOR_NEARER, listeners, nearest, farthest.getArtifact() ); } else { farthest.disable(); fireEvent( ResolutionListener.OMIT_FOR_NEARER, listeners, farthest, nearest.getArtifact() ); } } } catch ( OverConstrainedVersionException e ) { result.addVersionRangeViolation( e ); } } } else { previousNodes = new ArrayList<>(); resolvedArtifacts.put( key, previousNodes ); } previousNodes.add( node ); if ( node.isActive() ) { fireEvent( ResolutionListener.INCLUDE_ARTIFACT, listeners, node ); } // don't pull in the transitive deps of a system-scoped dependency. if ( node.isActive() && !Artifact.SCOPE_SYSTEM.equals( node.getArtifact().getScope() ) ) { fireEvent( ResolutionListener.PROCESS_CHILDREN, listeners, node ); Artifact parentArtifact = node.getArtifact(); for ( Iterator i = node.getChildrenIterator(); i.hasNext(); ) { ResolutionNode child = i.next(); try { // We leave in optional ones, but don't pick up its dependencies if ( !child.isResolved() && ( !child.getArtifact().isOptional() || child.isChildOfRootNode() ) ) { Artifact artifact = child.getArtifact(); artifact.setDependencyTrail( node.getDependencyTrail() ); List childRemoteRepositories = child.getRemoteRepositories(); MetadataResolutionRequest metadataRequest = new DefaultMetadataResolutionRequest( request ); metadataRequest.setArtifact( artifact ); metadataRequest.setRemoteRepositories( childRemoteRepositories ); try { ResolutionGroup rGroup; Object childKey; do { childKey = child.getKey(); if ( managedVersions.containsKey( childKey ) ) { // If this child node is a managed dependency, ensure // we are using the dependency management version // of this child if applicable b/c we want to use the // managed version's POM, *not* any other version's POM. // We retrieve the POM below in the retrieval step. manageArtifact( child, managedVersions, listeners ); // Also, we need to ensure that any exclusions it presents are // added to the artifact before we retrieve the metadata // for the artifact; otherwise we may end up with unwanted // dependencies. Artifact ma = managedVersions.get( childKey ); ArtifactFilter managedExclusionFilter = ma.getDependencyFilter(); if ( null != managedExclusionFilter ) { if ( null != artifact.getDependencyFilter() ) { AndArtifactFilter aaf = new AndArtifactFilter(); aaf.add( artifact.getDependencyFilter() ); aaf.add( managedExclusionFilter ); artifact.setDependencyFilter( aaf ); } else { artifact.setDependencyFilter( managedExclusionFilter ); } } } if ( artifact.getVersion() == null ) { // set the recommended version // TODO maybe its better to just pass the range through to retrieval and use a // transformation? ArtifactVersion version; if ( !artifact.isSelectedVersionKnown() ) { List versions = artifact.getAvailableVersions(); if ( versions == null ) { versions = source.retrieveAvailableVersions( metadataRequest ); artifact.setAvailableVersions( versions ); } Collections.sort( versions ); VersionRange versionRange = artifact.getVersionRange(); version = versionRange.matchVersion( versions ); if ( version == null ) { if ( versions.isEmpty() ) { throw new OverConstrainedVersionException( "No versions are present in the repository for the artifact" + " with a range " + versionRange, artifact, childRemoteRepositories ); } throw new OverConstrainedVersionException( "Couldn't find a version in " + versions + " to match range " + versionRange, artifact, childRemoteRepositories ); } } else { version = artifact.getSelectedVersion(); } artifact.selectVersion( version.toString() ); fireEvent( ResolutionListener.SELECT_VERSION_FROM_RANGE, listeners, child ); } rGroup = source.retrieve( metadataRequest ); if ( rGroup == null ) { break; } } while ( !childKey.equals( child.getKey() ) ); if ( parentArtifact != null && parentArtifact.getDependencyFilter() != null && !parentArtifact.getDependencyFilter().include( artifact ) ) { // MNG-3769: the [probably relocated] artifact is excluded. // We could process exclusions on relocated artifact details in the // MavenMetadataSource.createArtifacts(..) step, BUT that would // require resolving the POM from the repository very early on in // the build. continue; } // TODO might be better to have source.retrieve() throw a specific exception for this // situation // and catch here rather than have it return null if ( rGroup == null ) { // relocated dependency artifact is declared excluded, no need to add and recurse // further continue; } child.addDependencies( rGroup.getArtifacts(), rGroup.getResolutionRepositories(), filter ); } catch ( CyclicDependencyException e ) { // would like to throw this, but we have crappy stuff in the repo fireEvent( ResolutionListener.OMIT_FOR_CYCLE, listeners, new ResolutionNode( e.getArtifact(), childRemoteRepositories, child ) ); } catch ( ArtifactMetadataRetrievalException e ) { artifact.setDependencyTrail( node.getDependencyTrail() ); throw new ArtifactResolutionException( "Unable to get dependency information for " + artifact.getId() + ": " + e.getMessage(), artifact, childRemoteRepositories, e ); } ArtifactResolutionRequest subRequest = new ArtifactResolutionRequest( metadataRequest ); subRequest.setServers( request.getServers() ); subRequest.setMirrors( request.getMirrors() ); subRequest.setProxies( request.getProxies() ); recurse( result, child, resolvedArtifacts, managedVersions, subRequest, source, filter, listeners, conflictResolvers ); } } catch ( OverConstrainedVersionException e ) { result.addVersionRangeViolation( e ); } catch ( ArtifactResolutionException e ) { result.addMetadataResolutionException( e ); } } fireEvent( ResolutionListener.FINISH_PROCESSING_CHILDREN, listeners, node ); } } private void manageArtifact( ResolutionNode node, ManagedVersionMap managedVersions, List listeners ) { Artifact artifact = managedVersions.get( node.getKey() ); // Before we update the version of the artifact, we need to know // whether we are working on a transitive dependency or not. This // allows depMgmt to always override transitive dependencies, while // explicit child override depMgmt (viz. depMgmt should only // provide defaults to children, but should override transitives). // We can do this by calling isChildOfRootNode on the current node. if ( ( artifact.getVersion() != null ) && ( !node.isChildOfRootNode() || node.getArtifact().getVersion() == null ) ) { fireEvent( ResolutionListener.MANAGE_ARTIFACT_VERSION, listeners, node, artifact ); node.getArtifact().setVersion( artifact.getVersion() ); } if ( ( artifact.getScope() != null ) && ( !node.isChildOfRootNode() || node.getArtifact().getScope() == null ) ) { fireEvent( ResolutionListener.MANAGE_ARTIFACT_SCOPE, listeners, node, artifact ); node.getArtifact().setScope( artifact.getScope() ); } if ( Artifact.SCOPE_SYSTEM.equals( node.getArtifact().getScope() ) && ( node.getArtifact().getFile() == null ) && ( artifact.getFile() != null ) ) { fireEvent( ResolutionListener.MANAGE_ARTIFACT_SYSTEM_PATH, listeners, node, artifact ); node.getArtifact().setFile( artifact.getFile() ); } } /** * Check if the artifactScope needs to be updated. More info. * * @param farthest farthest resolution node * @param nearest nearest resolution node * @param listeners */ boolean checkScopeUpdate( ResolutionNode farthest, ResolutionNode nearest, List listeners ) { boolean updateScope = false; Artifact farthestArtifact = farthest.getArtifact(); Artifact nearestArtifact = nearest.getArtifact(); /* farthest is runtime and nearest has lower priority, change to runtime */ if ( Artifact.SCOPE_RUNTIME.equals( farthestArtifact.getScope() ) && ( Artifact.SCOPE_TEST.equals( nearestArtifact.getScope() ) || Artifact.SCOPE_PROVIDED.equals( nearestArtifact.getScope() ) ) ) { updateScope = true; } /* farthest is compile and nearest is not (has lower priority), change to compile */ if ( Artifact.SCOPE_COMPILE.equals( farthestArtifact.getScope() ) && !Artifact.SCOPE_COMPILE.equals( nearestArtifact.getScope() ) ) { updateScope = true; } /* current POM rules all, if nearest is in current pom, do not update its artifactScope */ if ( ( nearest.getDepth() < 2 ) && updateScope ) { updateScope = false; fireEvent( ResolutionListener.UPDATE_SCOPE_CURRENT_POM, listeners, nearest, farthestArtifact ); } if ( updateScope ) { fireEvent( ResolutionListener.UPDATE_SCOPE, listeners, nearest, farthestArtifact ); // previously we cloned the artifact, but it is more efficient to just update the artifactScope // if problems are later discovered that the original object needs its original artifactScope value, // cloning may // again be appropriate nearestArtifact.setScope( farthestArtifact.getScope() ); } return updateScope; } private void fireEvent( int event, List listeners, ResolutionNode node ) { fireEvent( event, listeners, node, null ); } private void fireEvent( int event, List listeners, ResolutionNode node, Artifact replacement ) { fireEvent( event, listeners, node, replacement, null ); } private void fireEvent( int event, List listeners, ResolutionNode node, Artifact replacement, VersionRange newRange ) { for ( ResolutionListener listener : listeners ) { switch ( event ) { case ResolutionListener.TEST_ARTIFACT: listener.testArtifact( node.getArtifact() ); break; case ResolutionListener.PROCESS_CHILDREN: listener.startProcessChildren( node.getArtifact() ); break; case ResolutionListener.FINISH_PROCESSING_CHILDREN: listener.endProcessChildren( node.getArtifact() ); break; case ResolutionListener.INCLUDE_ARTIFACT: listener.includeArtifact( node.getArtifact() ); break; case ResolutionListener.OMIT_FOR_NEARER: listener.omitForNearer( node.getArtifact(), replacement ); break; case ResolutionListener.OMIT_FOR_CYCLE: listener.omitForCycle( node.getArtifact() ); break; case ResolutionListener.UPDATE_SCOPE: listener.updateScope( node.getArtifact(), replacement.getScope() ); break; case ResolutionListener.UPDATE_SCOPE_CURRENT_POM: listener.updateScopeCurrentPom( node.getArtifact(), replacement.getScope() ); break; case ResolutionListener.MANAGE_ARTIFACT_VERSION: if ( listener instanceof ResolutionListenerForDepMgmt ) { ResolutionListenerForDepMgmt asImpl = (ResolutionListenerForDepMgmt) listener; asImpl.manageArtifactVersion( node.getArtifact(), replacement ); } else { listener.manageArtifact( node.getArtifact(), replacement ); } break; case ResolutionListener.MANAGE_ARTIFACT_SCOPE: if ( listener instanceof ResolutionListenerForDepMgmt ) { ResolutionListenerForDepMgmt asImpl = (ResolutionListenerForDepMgmt) listener; asImpl.manageArtifactScope( node.getArtifact(), replacement ); } else { listener.manageArtifact( node.getArtifact(), replacement ); } break; case ResolutionListener.MANAGE_ARTIFACT_SYSTEM_PATH: if ( listener instanceof ResolutionListenerForDepMgmt ) { ResolutionListenerForDepMgmt asImpl = (ResolutionListenerForDepMgmt) listener; asImpl.manageArtifactSystemPath( node.getArtifact(), replacement ); } else { listener.manageArtifact( node.getArtifact(), replacement ); } break; case ResolutionListener.SELECT_VERSION_FROM_RANGE: listener.selectVersionFromRange( node.getArtifact() ); break; case ResolutionListener.RESTRICT_RANGE: if ( node.getArtifact().getVersionRange().hasRestrictions() || replacement.getVersionRange().hasRestrictions() ) { listener.restrictRange( node.getArtifact(), replacement, newRange ); } break; default: throw new IllegalStateException( "Unknown event: " + event ); } } } public ArtifactResolutionResult collect( Set artifacts, Artifact originatingArtifact, Map managedVersions, ArtifactRepository localRepository, List remoteRepositories, ArtifactMetadataSource source, ArtifactFilter filter, List listeners ) { return collect( artifacts, originatingArtifact, managedVersions, localRepository, remoteRepositories, source, filter, listeners, null ); } public ArtifactResolutionResult collect( Set artifacts, Artifact originatingArtifact, ArtifactRepository localRepository, List remoteRepositories, ArtifactMetadataSource source, ArtifactFilter filter, List listeners ) { return collect( artifacts, originatingArtifact, null, localRepository, remoteRepositories, source, filter, listeners ); } } LegacyArtifactCollector.java000066400000000000000000000062521317160430700367440ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/main/java/org/apache/maven/repository/legacy/resolverpackage org.apache.maven.repository.legacy.resolver; /* * 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.util.List; import java.util.Map; import java.util.Set; import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.metadata.ArtifactMetadataSource; import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.resolver.ArtifactResolutionRequest; import org.apache.maven.artifact.resolver.ArtifactResolutionResult; import org.apache.maven.artifact.resolver.ResolutionListener; import org.apache.maven.artifact.resolver.filter.ArtifactFilter; import org.apache.maven.repository.legacy.resolver.conflict.ConflictResolver; /** * Artifact collector - takes a set of original artifacts and resolves all of the best versions to use * along with their metadata. No artifacts are downloaded. * * @author Brett Porter */ @Deprecated public interface LegacyArtifactCollector { ArtifactResolutionResult collect( Set artifacts, Artifact originatingArtifact, Map managedVersions, ArtifactResolutionRequest repositoryRequest, ArtifactMetadataSource source, ArtifactFilter filter, List listeners, List conflictResolvers ); ArtifactResolutionResult collect( Set artifacts, Artifact originatingArtifact, Map managedVersions, ArtifactRepository localRepository, List remoteRepositories, ArtifactMetadataSource source, ArtifactFilter filter, List listeners, List conflictResolvers ); // used by maven-dependency-tree and maven-dependency-plugin @Deprecated ArtifactResolutionResult collect( Set artifacts, Artifact originatingArtifact, Map managedVersions, ArtifactRepository localRepository, List remoteRepositories, ArtifactMetadataSource source, ArtifactFilter filter, List listeners ); } maven-maven-3.5.2/maven-compat/src/main/java/org/apache/maven/repository/legacy/resolver/conflict/000077500000000000000000000000001317160430700332235ustar00rootroot00000000000000ConflictResolver.java000066400000000000000000000033241317160430700372740ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/main/java/org/apache/maven/repository/legacy/resolver/conflictpackage org.apache.maven.repository.legacy.resolver.conflict; /* * 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 org.apache.maven.artifact.resolver.ResolutionNode; /** * Determines which version of an artifact to use when there are conflicting declarations. * * @author Jason van Zyl * @author Mark Hobson */ public interface ConflictResolver { String ROLE = ConflictResolver.class.getName(); /** * Determines which of the specified versions of an artifact to use when there are conflicting declarations. * * @param node1 the first artifact declaration * @param node2 the second artifact declaration * @return the artifact declaration to use: node1; node2; or nullif * this conflict cannot be resolved * @since 3.0 */ ResolutionNode resolveConflict( ResolutionNode node1, ResolutionNode node2 ); } ConflictResolverFactory.java000066400000000000000000000033211317160430700406210ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/main/java/org/apache/maven/repository/legacy/resolver/conflictpackage org.apache.maven.repository.legacy.resolver.conflict; /* * 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. */ /** * A factory that produces conflict resolvers of various types. * * @author Mark Hobson * @see ConflictResolver * @since 3.0 */ public interface ConflictResolverFactory { // constants -------------------------------------------------------------- /** The plexus role for this component. */ String ROLE = ConflictResolverFactory.class.getName(); // methods ---------------------------------------------------------------- /** * Gets a conflict resolver of the specified type. * * @param type the type of conflict resolver to obtain * @return the conflict resolver * @throws ConflictResolverNotFoundException * if the specified type was not found */ ConflictResolver getConflictResolver( String type ) throws ConflictResolverNotFoundException; } ConflictResolverNotFoundException.java000066400000000000000000000031471317160430700426330ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/main/java/org/apache/maven/repository/legacy/resolver/conflictpackage org.apache.maven.repository.legacy.resolver.conflict; /* * 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. */ /** * Indicates that a specified conflict resolver implementation could not be found. * * @author Mark Hobson * @since 3.0 */ public class ConflictResolverNotFoundException extends Exception { // constants -------------------------------------------------------------- /** The serial version ID. */ private static final long serialVersionUID = 3372412184339653914L; // constructors ----------------------------------------------------------- /** * Creates a new ConflictResolverNotFoundException with the specified message. * * @param message the message */ public ConflictResolverNotFoundException( String message ) { super( message ); } } DefaultConflictResolver.java000066400000000000000000000025011317160430700405750ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/main/java/org/apache/maven/repository/legacy/resolver/conflictpackage org.apache.maven.repository.legacy.resolver.conflict; /* * 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 org.codehaus.plexus.component.annotations.Component; /** * The default conflict resolver that delegates to the nearest strategy. * * @author Jason van Zyl * @see NearestConflictResolver * @deprecated As of 3.0, use a specific implementation instead, e.g. {@link NearestConflictResolver} */ @Deprecated @Component( role = ConflictResolver.class ) public class DefaultConflictResolver extends NearestConflictResolver { } DefaultConflictResolverFactory.java000066400000000000000000000056671317160430700421450ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/main/java/org/apache/maven/repository/legacy/resolver/conflictpackage org.apache.maven.repository.legacy.resolver.conflict; /* * 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 org.codehaus.plexus.PlexusConstants; import org.codehaus.plexus.PlexusContainer; import org.codehaus.plexus.component.annotations.Component; import org.codehaus.plexus.component.annotations.Requirement; import org.codehaus.plexus.component.repository.exception.ComponentLookupException; import org.codehaus.plexus.context.Context; import org.codehaus.plexus.context.ContextException; import org.codehaus.plexus.personality.plexus.lifecycle.phase.Contextualizable; /** * A conflict resolver factory that obtains instances from a plexus container. * * @author Mark Hobson * TODO you don't need the container in here with the active maps (jvz). * @since 3.0 */ @Component( role = ConflictResolverFactory.class ) public class DefaultConflictResolverFactory implements ConflictResolverFactory, Contextualizable { // fields ----------------------------------------------------------------- /** * The plexus container used to obtain instances from. */ @Requirement private PlexusContainer container; // ConflictResolverFactory methods ---------------------------------------- /* * @see org.apache.maven.artifact.resolver.conflict.ConflictResolverFactory#getConflictResolver(java.lang.String) */ public ConflictResolver getConflictResolver( String type ) throws ConflictResolverNotFoundException { try { return (ConflictResolver) container.lookup( ConflictResolver.ROLE, type ); } catch ( ComponentLookupException exception ) { throw new ConflictResolverNotFoundException( "Cannot find conflict resolver of type: " + type ); } } // Contextualizable methods ----------------------------------------------- /* * @see org.codehaus.plexus.personality.plexus.lifecycle.phase.Contextualizable#contextualize(org.codehaus.plexus.context.Context) */ public void contextualize( Context context ) throws ContextException { container = (PlexusContainer) context.get( PlexusConstants.PLEXUS_KEY ); } } FarthestConflictResolver.java000066400000000000000000000035341317160430700410000ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/main/java/org/apache/maven/repository/legacy/resolver/conflictpackage org.apache.maven.repository.legacy.resolver.conflict; /* * 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 org.apache.maven.artifact.resolver.ResolutionNode; import org.codehaus.plexus.component.annotations.Component; /** * Resolves conflicting artifacts by always selecting the farthest declaration. Farthest is defined as the * declaration that has the most transitive steps away from the project being built. * * @author Mark Hobson * @since 3.0 */ @Component( role = ConflictResolver.class, hint = "farthest" ) public class FarthestConflictResolver implements ConflictResolver { // ConflictResolver methods ----------------------------------------------- /* * @see org.apache.maven.artifact.resolver.conflict.ConflictResolver#resolveConflict(org.apache.maven.artifact.resolver.ResolutionNode, * org.apache.maven.artifact.resolver.ResolutionNode) */ public ResolutionNode resolveConflict( ResolutionNode node1, ResolutionNode node2 ) { return node1.getDepth() >= node2.getDepth() ? node1 : node2; } } NearestConflictResolver.java000066400000000000000000000036271317160430700406240ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/main/java/org/apache/maven/repository/legacy/resolver/conflictpackage org.apache.maven.repository.legacy.resolver.conflict; /* * 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 org.apache.maven.artifact.resolver.ResolutionNode; import org.codehaus.plexus.component.annotations.Component; /** * Resolves conflicting artifacts by always selecting the nearest declaration. Nearest is defined as the * declaration that has the least transitive steps away from the project being built. * * @author Jason van Zyl * @author Mark Hobson * @since 3.0 */ @Component( role = ConflictResolver.class, hint = "nearest" ) public class NearestConflictResolver implements ConflictResolver { // ConflictResolver methods ----------------------------------------------- /* * @see org.apache.maven.artifact.resolver.conflict.ConflictResolver#resolveConflict(org.apache.maven.artifact.resolver.ResolutionNode, * org.apache.maven.artifact.resolver.ResolutionNode) */ public ResolutionNode resolveConflict( ResolutionNode node1, ResolutionNode node2 ) { return node1.getDepth() <= node2.getDepth() ? node1 : node2; } } NewestConflictResolver.java000066400000000000000000000045531317160430700404670ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/main/java/org/apache/maven/repository/legacy/resolver/conflictpackage org.apache.maven.repository.legacy.resolver.conflict; /* * 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 org.apache.maven.artifact.resolver.ResolutionNode; import org.apache.maven.artifact.versioning.ArtifactVersion; import org.apache.maven.artifact.versioning.OverConstrainedVersionException; import org.codehaus.plexus.component.annotations.Component; /** * Resolves conflicting artifacts by always selecting the newest declaration. Newest is defined as the * declaration whose version is greater according to ArtifactVersion.compareTo. * * @author Mark Hobson * @see ArtifactVersion#compareTo * @since 3.0 */ @Component( role = ConflictResolver.class, hint = "newest" ) public class NewestConflictResolver implements ConflictResolver { // ConflictResolver methods ----------------------------------------------- /* * @see org.apache.maven.artifact.resolver.conflict.ConflictResolver#resolveConflict(org.apache.maven.artifact.resolver.ResolutionNode, * org.apache.maven.artifact.resolver.ResolutionNode) */ public ResolutionNode resolveConflict( ResolutionNode node1, ResolutionNode node2 ) { try { ArtifactVersion version1 = node1.getArtifact().getSelectedVersion(); ArtifactVersion version2 = node2.getArtifact().getSelectedVersion(); return version1.compareTo( version2 ) > 0 ? node1 : node2; } catch ( OverConstrainedVersionException exception ) { // TODO log message or throw exception? return null; } } } OldestConflictResolver.java000066400000000000000000000045511317160430700404520ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/main/java/org/apache/maven/repository/legacy/resolver/conflictpackage org.apache.maven.repository.legacy.resolver.conflict; /* * 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 org.apache.maven.artifact.resolver.ResolutionNode; import org.apache.maven.artifact.versioning.ArtifactVersion; import org.apache.maven.artifact.versioning.OverConstrainedVersionException; import org.codehaus.plexus.component.annotations.Component; /** * Resolves conflicting artifacts by always selecting the oldest declaration. Oldest is defined as the * declaration whose version is less according to ArtifactVersion.compareTo. * * @author Mark Hobson * @see ArtifactVersion#compareTo * @since 3.0 */ @Component( role = ConflictResolver.class, hint = "oldest" ) public class OldestConflictResolver implements ConflictResolver { // ConflictResolver methods ----------------------------------------------- /* * @see org.apache.maven.artifact.resolver.conflict.ConflictResolver#resolveConflict(org.apache.maven.artifact.resolver.ResolutionNode, * org.apache.maven.artifact.resolver.ResolutionNode) */ public ResolutionNode resolveConflict( ResolutionNode node1, ResolutionNode node2 ) { try { ArtifactVersion version1 = node1.getArtifact().getSelectedVersion(); ArtifactVersion version2 = node2.getArtifact().getSelectedVersion(); return version1.compareTo( version2 ) <= 0 ? node1 : node2; } catch ( OverConstrainedVersionException exception ) { // TODO log message or throw exception? return null; } } } maven-maven-3.5.2/maven-compat/src/main/java/org/apache/maven/repository/legacy/resolver/transform/000077500000000000000000000000001317160430700334355ustar00rootroot00000000000000AbstractVersionTransformation.java000066400000000000000000000130471317160430700422660ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/main/java/org/apache/maven/repository/legacy/resolver/transformpackage org.apache.maven.repository.legacy.resolver.transform; /* * 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.util.List; import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.repository.DefaultRepositoryRequest; import org.apache.maven.artifact.repository.RepositoryRequest; import org.apache.maven.artifact.repository.metadata.ArtifactRepositoryMetadata; import org.apache.maven.artifact.repository.metadata.Metadata; import org.apache.maven.artifact.repository.metadata.RepositoryMetadata; import org.apache.maven.artifact.repository.metadata.RepositoryMetadataManager; import org.apache.maven.artifact.repository.metadata.RepositoryMetadataResolutionException; import org.apache.maven.artifact.repository.metadata.SnapshotArtifactRepositoryMetadata; import org.apache.maven.artifact.repository.metadata.Versioning; import org.apache.maven.artifact.resolver.ArtifactNotFoundException; import org.apache.maven.artifact.resolver.ArtifactResolutionException; import org.apache.maven.repository.legacy.WagonManager; import org.codehaus.plexus.component.annotations.Requirement; import org.codehaus.plexus.logging.AbstractLogEnabled; /** * Describes a version transformation during artifact resolution. * * @author Brett Porter * TODO try and refactor to remove abstract methods - not particular happy about current design */ public abstract class AbstractVersionTransformation extends AbstractLogEnabled implements ArtifactTransformation { @Requirement protected RepositoryMetadataManager repositoryMetadataManager; @Requirement protected WagonManager wagonManager; public void transformForResolve( Artifact artifact, List remoteRepositories, ArtifactRepository localRepository ) throws ArtifactResolutionException, ArtifactNotFoundException { RepositoryRequest request = new DefaultRepositoryRequest(); request.setLocalRepository( localRepository ); request.setRemoteRepositories( remoteRepositories ); transformForResolve( artifact, request ); } protected String resolveVersion( Artifact artifact, ArtifactRepository localRepository, List remoteRepositories ) throws RepositoryMetadataResolutionException { RepositoryRequest request = new DefaultRepositoryRequest(); request.setLocalRepository( localRepository ); request.setRemoteRepositories( remoteRepositories ); return resolveVersion( artifact, request ); } protected String resolveVersion( Artifact artifact, RepositoryRequest request ) throws RepositoryMetadataResolutionException { RepositoryMetadata metadata; // Don't use snapshot metadata for LATEST (which isSnapshot returns true for) if ( !artifact.isSnapshot() || Artifact.LATEST_VERSION.equals( artifact.getBaseVersion() ) ) { metadata = new ArtifactRepositoryMetadata( artifact ); } else { metadata = new SnapshotArtifactRepositoryMetadata( artifact ); } repositoryMetadataManager.resolve( metadata, request ); artifact.addMetadata( metadata ); Metadata repoMetadata = metadata.getMetadata(); String version = null; if ( repoMetadata != null && repoMetadata.getVersioning() != null ) { version = constructVersion( repoMetadata.getVersioning(), artifact.getBaseVersion() ); } if ( version == null ) { // use the local copy, or if it doesn't exist - go to the remote repo for it version = artifact.getBaseVersion(); } // TODO also do this logging for other metadata? // TODO figure out way to avoid duplicated message if ( getLogger().isDebugEnabled() ) { if ( !version.equals( artifact.getBaseVersion() ) ) { String message = artifact.getArtifactId() + ": resolved to version " + version; if ( artifact.getRepository() != null ) { message += " from repository " + artifact.getRepository().getId(); } else { message += " from local repository"; } getLogger().debug( message ); } else { // Locally installed file is newer, don't use the resolved version getLogger().debug( artifact.getArtifactId() + ": using locally installed snapshot" ); } } return version; } protected abstract String constructVersion( Versioning versioning, String baseVersion ); } ArtifactTransformation.java000066400000000000000000000072101317160430700407050ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/main/java/org/apache/maven/repository/legacy/resolver/transformpackage org.apache.maven.repository.legacy.resolver.transform; /* * 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.util.List; import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.deployer.ArtifactDeploymentException; import org.apache.maven.artifact.installer.ArtifactInstallationException; import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.repository.RepositoryRequest; import org.apache.maven.artifact.resolver.ArtifactNotFoundException; import org.apache.maven.artifact.resolver.ArtifactResolutionException; /** * @author Jason van Zyl */ public interface ArtifactTransformation { String ROLE = ArtifactTransformation.class.getName(); /** * Take in a artifact and return the transformed artifact for locating in the remote repository. If no * transformation has occurred the original artifact is returned. * * @param artifact Artifact to be transformed. * @param request the repositories to check */ void transformForResolve( Artifact artifact, RepositoryRequest request ) throws ArtifactResolutionException, ArtifactNotFoundException; /** * Take in a artifact and return the transformed artifact for locating in the remote repository. If no * transformation has occurred the original artifact is returned. * * @param artifact Artifact to be transformed. * @param remoteRepositories the repositories to check * @param localRepository the local repository */ void transformForResolve( Artifact artifact, List remoteRepositories, ArtifactRepository localRepository ) throws ArtifactResolutionException, ArtifactNotFoundException; /** * Take in a artifact and return the transformed artifact for locating in the local repository. If no * transformation has occurred the original artifact is returned. * * @param artifact Artifact to be transformed. * @param localRepository the local repository it will be stored in */ void transformForInstall( Artifact artifact, ArtifactRepository localRepository ) throws ArtifactInstallationException; /** * Take in a artifact and return the transformed artifact for distributing to remote repository. If no * transformation has occurred the original artifact is returned. * * @param artifact Artifact to be transformed. * @param remoteRepository the repository to deploy to * @param localRepository the local repository */ void transformForDeployment( Artifact artifact, ArtifactRepository remoteRepository, ArtifactRepository localRepository ) throws ArtifactDeploymentException; } ArtifactTransformationManager.java000066400000000000000000000072461317160430700422110ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/main/java/org/apache/maven/repository/legacy/resolver/transformpackage org.apache.maven.repository.legacy.resolver.transform; /* * 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.util.List; import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.deployer.ArtifactDeploymentException; import org.apache.maven.artifact.installer.ArtifactInstallationException; import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.repository.RepositoryRequest; import org.apache.maven.artifact.resolver.ArtifactNotFoundException; import org.apache.maven.artifact.resolver.ArtifactResolutionException; /** Manages multiple ArtifactTransformation instances and applies them in succession. */ public interface ArtifactTransformationManager { String ROLE = ArtifactTransformationManager.class.getName(); /** * Take in a artifact and return the transformed artifact for locating in the remote repository. If no * transformation has occurred the original artifact is returned. * * @param artifact Artifact to be transformed. * @param request the repositories to check */ void transformForResolve( Artifact artifact, RepositoryRequest request ) throws ArtifactResolutionException, ArtifactNotFoundException; /** * Take in a artifact and return the transformed artifact for locating in the remote repository. If no * transformation has occurred the original artifact is returned. * * @param artifact Artifact to be transformed. * @param remoteRepositories the repositories to check * @param localRepository the local repository */ void transformForResolve( Artifact artifact, List remoteRepositories, ArtifactRepository localRepository ) throws ArtifactResolutionException, ArtifactNotFoundException; /** * Take in a artifact and return the transformed artifact for locating in the local repository. If no * transformation has occurred the original artifact is returned. * * @param artifact Artifact to be transformed. * @param localRepository the local repository it will be stored in */ void transformForInstall( Artifact artifact, ArtifactRepository localRepository ) throws ArtifactInstallationException; /** * Take in a artifact and return the transformed artifact for distributing to a remote repository. If no * transformation has occurred the original artifact is returned. * * @param artifact Artifact to be transformed. * @param remoteRepository the repository to deploy to * @param localRepository the local repository the metadata is stored in */ void transformForDeployment( Artifact artifact, ArtifactRepository remoteRepository, ArtifactRepository localRepository ) throws ArtifactDeploymentException; List getArtifactTransformations(); } DefaultArtifactTransformationManager.java000066400000000000000000000066021317160430700435110ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/main/java/org/apache/maven/repository/legacy/resolver/transformpackage org.apache.maven.repository.legacy.resolver.transform; /* * 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.util.List; import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.deployer.ArtifactDeploymentException; import org.apache.maven.artifact.installer.ArtifactInstallationException; import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.repository.RepositoryRequest; import org.apache.maven.artifact.resolver.ArtifactNotFoundException; import org.apache.maven.artifact.resolver.ArtifactResolutionException; import org.codehaus.plexus.component.annotations.Component; import org.codehaus.plexus.component.annotations.Requirement; /** * @author Jason van Zyl */ @Component( role = ArtifactTransformationManager.class ) public class DefaultArtifactTransformationManager implements ArtifactTransformationManager { @Requirement( role = ArtifactTransformation.class, hints = { "release", "latest", "snapshot" } ) private List artifactTransformations; public void transformForResolve( Artifact artifact, RepositoryRequest request ) throws ArtifactResolutionException, ArtifactNotFoundException { for ( ArtifactTransformation transform : artifactTransformations ) { transform.transformForResolve( artifact, request ); } } public void transformForResolve( Artifact artifact, List remoteRepositories, ArtifactRepository localRepository ) throws ArtifactResolutionException, ArtifactNotFoundException { for ( ArtifactTransformation transform : artifactTransformations ) { transform.transformForResolve( artifact, remoteRepositories, localRepository ); } } public void transformForInstall( Artifact artifact, ArtifactRepository localRepository ) throws ArtifactInstallationException { for ( ArtifactTransformation transform : artifactTransformations ) { transform.transformForInstall( artifact, localRepository ); } } public void transformForDeployment( Artifact artifact, ArtifactRepository remoteRepository, ArtifactRepository localRepository ) throws ArtifactDeploymentException { for ( ArtifactTransformation transform : artifactTransformations ) { transform.transformForDeployment( artifact, remoteRepository, localRepository ); } } public List getArtifactTransformations() { return artifactTransformations; } } LatestArtifactTransformation.java000066400000000000000000000056621317160430700420730ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/main/java/org/apache/maven/repository/legacy/resolver/transformpackage org.apache.maven.repository.legacy.resolver.transform; /* * 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 org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.repository.RepositoryRequest; import org.apache.maven.artifact.repository.metadata.RepositoryMetadataResolutionException; import org.apache.maven.artifact.repository.metadata.Versioning; import org.apache.maven.artifact.resolver.ArtifactNotFoundException; import org.apache.maven.artifact.resolver.ArtifactResolutionException; import org.codehaus.plexus.component.annotations.Component; @Component( role = ArtifactTransformation.class, hint = "latest" ) public class LatestArtifactTransformation extends AbstractVersionTransformation { public void transformForResolve( Artifact artifact, RepositoryRequest request ) throws ArtifactResolutionException, ArtifactNotFoundException { if ( Artifact.LATEST_VERSION.equals( artifact.getVersion() ) ) { try { String version = resolveVersion( artifact, request ); if ( Artifact.LATEST_VERSION.equals( version ) ) { throw new ArtifactNotFoundException( "Unable to determine the latest version", artifact ); } artifact.setBaseVersion( version ); artifact.updateVersion( version, request.getLocalRepository() ); } catch ( RepositoryMetadataResolutionException e ) { throw new ArtifactResolutionException( e.getMessage(), artifact, e ); } } } public void transformForInstall( Artifact artifact, ArtifactRepository localRepository ) { // metadata is added via addPluginArtifactMetadata } public void transformForDeployment( Artifact artifact, ArtifactRepository remoteRepository, ArtifactRepository localRepository ) { // metadata is added via addPluginArtifactMetadata } protected String constructVersion( Versioning versioning, String baseVersion ) { return versioning.getLatest(); } } ReleaseArtifactTransformation.java000066400000000000000000000073641317160430700422200ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/main/java/org/apache/maven/repository/legacy/resolver/transformpackage org.apache.maven.repository.legacy.resolver.transform; /* * 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 org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.metadata.ArtifactMetadata; import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.repository.RepositoryRequest; import org.apache.maven.artifact.repository.metadata.ArtifactRepositoryMetadata; import org.apache.maven.artifact.repository.metadata.RepositoryMetadataResolutionException; import org.apache.maven.artifact.repository.metadata.Versioning; import org.apache.maven.artifact.resolver.ArtifactNotFoundException; import org.apache.maven.artifact.resolver.ArtifactResolutionException; import org.codehaus.plexus.component.annotations.Component; /** * Change the version RELEASE to the appropriate release version from the remote repository. * * @author Brett Porter */ @Component( role = ArtifactTransformation.class, hint = "release" ) public class ReleaseArtifactTransformation extends AbstractVersionTransformation { public void transformForResolve( Artifact artifact, RepositoryRequest request ) throws ArtifactResolutionException, ArtifactNotFoundException { if ( Artifact.RELEASE_VERSION.equals( artifact.getVersion() ) ) { try { String version = resolveVersion( artifact, request ); if ( Artifact.RELEASE_VERSION.equals( version ) ) { throw new ArtifactNotFoundException( "Unable to determine the release version", artifact ); } artifact.setBaseVersion( version ); artifact.updateVersion( version, request.getLocalRepository() ); } catch ( RepositoryMetadataResolutionException e ) { throw new ArtifactResolutionException( e.getMessage(), artifact, e ); } } } public void transformForInstall( Artifact artifact, ArtifactRepository localRepository ) { ArtifactMetadata metadata = createMetadata( artifact ); artifact.addMetadata( metadata ); } public void transformForDeployment( Artifact artifact, ArtifactRepository remoteRepository, ArtifactRepository localRepository ) { ArtifactMetadata metadata = createMetadata( artifact ); artifact.addMetadata( metadata ); } private ArtifactMetadata createMetadata( Artifact artifact ) { Versioning versioning = new Versioning(); versioning.updateTimestamp(); versioning.addVersion( artifact.getVersion() ); if ( artifact.isRelease() ) { versioning.setRelease( artifact.getVersion() ); } return new ArtifactRepositoryMetadata( artifact, versioning ); } protected String constructVersion( Versioning versioning, String baseVersion ) { return versioning.getRelease(); } } SnapshotTransformation.java000066400000000000000000000155031317160430700407530ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/main/java/org/apache/maven/repository/legacy/resolver/transformpackage org.apache.maven.repository.legacy.resolver.transform; /* * 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.text.DateFormat; import java.text.SimpleDateFormat; import java.util.Date; import java.util.GregorianCalendar; import java.util.TimeZone; import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.deployer.ArtifactDeploymentException; import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.repository.RepositoryRequest; import org.apache.maven.artifact.repository.metadata.Metadata; import org.apache.maven.artifact.repository.metadata.RepositoryMetadata; import org.apache.maven.artifact.repository.metadata.RepositoryMetadataResolutionException; import org.apache.maven.artifact.repository.metadata.Snapshot; import org.apache.maven.artifact.repository.metadata.SnapshotArtifactRepositoryMetadata; import org.apache.maven.artifact.repository.metadata.Versioning; import org.apache.maven.artifact.resolver.ArtifactResolutionException; import org.codehaus.plexus.component.annotations.Component; import org.codehaus.plexus.util.StringUtils; /** * @author Brett Porter * @author Michal Maczka */ @Component( role = ArtifactTransformation.class, hint = "snapshot" ) public class SnapshotTransformation extends AbstractVersionTransformation { private static final String DEFAULT_SNAPSHOT_TIMESTAMP_FORMAT = "yyyyMMdd.HHmmss"; private static final TimeZone DEFAULT_SNAPSHOT_TIME_ZONE = TimeZone.getTimeZone( "Etc/UTC" ); private String deploymentTimestamp; public void transformForResolve( Artifact artifact, RepositoryRequest request ) throws ArtifactResolutionException { // Only select snapshots that are unresolved (eg 1.0-SNAPSHOT, not 1.0-20050607.123456) if ( artifact.isSnapshot() && artifact.getBaseVersion().equals( artifact.getVersion() ) ) { try { String version = resolveVersion( artifact, request ); artifact.updateVersion( version, request.getLocalRepository() ); } catch ( RepositoryMetadataResolutionException e ) { throw new ArtifactResolutionException( e.getMessage(), artifact, e ); } } } public void transformForInstall( Artifact artifact, ArtifactRepository localRepository ) { if ( artifact.isSnapshot() ) { Snapshot snapshot = new Snapshot(); snapshot.setLocalCopy( true ); RepositoryMetadata metadata = new SnapshotArtifactRepositoryMetadata( artifact, snapshot ); artifact.addMetadata( metadata ); } } public void transformForDeployment( Artifact artifact, ArtifactRepository remoteRepository, ArtifactRepository localRepository ) throws ArtifactDeploymentException { if ( artifact.isSnapshot() ) { Snapshot snapshot = new Snapshot(); snapshot.setTimestamp( getDeploymentTimestamp() ); // we update the build number anyway so that it doesn't get lost. It requires the timestamp to take effect try { int buildNumber = resolveLatestSnapshotBuildNumber( artifact, localRepository, remoteRepository ); snapshot.setBuildNumber( buildNumber + 1 ); } catch ( RepositoryMetadataResolutionException e ) { throw new ArtifactDeploymentException( "Error retrieving previous build number for artifact '" + artifact.getDependencyConflictId() + "': " + e.getMessage(), e ); } RepositoryMetadata metadata = new SnapshotArtifactRepositoryMetadata( artifact, snapshot ); artifact.setResolvedVersion( constructVersion( metadata.getMetadata().getVersioning(), artifact.getBaseVersion() ) ); artifact.addMetadata( metadata ); } } public String getDeploymentTimestamp() { if ( deploymentTimestamp == null ) { deploymentTimestamp = getUtcDateFormatter().format( new Date() ); } return deploymentTimestamp; } protected String constructVersion( Versioning versioning, String baseVersion ) { String version = null; Snapshot snapshot = versioning.getSnapshot(); if ( snapshot != null ) { if ( snapshot.getTimestamp() != null && snapshot.getBuildNumber() > 0 ) { String newVersion = snapshot.getTimestamp() + "-" + snapshot.getBuildNumber(); version = StringUtils.replace( baseVersion, Artifact.SNAPSHOT_VERSION, newVersion ); } else { version = baseVersion; } } return version; } private int resolveLatestSnapshotBuildNumber( Artifact artifact, ArtifactRepository localRepository, ArtifactRepository remoteRepository ) throws RepositoryMetadataResolutionException { RepositoryMetadata metadata = new SnapshotArtifactRepositoryMetadata( artifact ); getLogger().info( "Retrieving previous build number from " + remoteRepository.getId() ); repositoryMetadataManager.resolveAlways( metadata, localRepository, remoteRepository ); int buildNumber = 0; Metadata repoMetadata = metadata.getMetadata(); if ( ( repoMetadata != null ) && ( repoMetadata.getVersioning() != null && repoMetadata.getVersioning().getSnapshot() != null ) ) { buildNumber = repoMetadata.getVersioning().getSnapshot().getBuildNumber(); } return buildNumber; } public static DateFormat getUtcDateFormatter() { DateFormat utcDateFormatter = new SimpleDateFormat( DEFAULT_SNAPSHOT_TIMESTAMP_FORMAT ); utcDateFormatter.setCalendar( new GregorianCalendar() ); utcDateFormatter.setTimeZone( DEFAULT_SNAPSHOT_TIME_ZONE ); return utcDateFormatter; } } maven-maven-3.5.2/maven-compat/src/main/java/org/apache/maven/repository/metadata/000077500000000000000000000000001317160430700300755ustar00rootroot00000000000000ArtifactMetadata.java000066400000000000000000000227101317160430700340610ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/main/java/org/apache/maven/repository/metadatapackage org.apache.maven.repository.metadata; /* * 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.util.Collection; import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.ArtifactScopeEnum; /** * Artifact Metadata that is resolved independent of Artifact itself. * * @author Oleg Gusakov */ public class ArtifactMetadata { /** * standard glorified artifact coordinates */ protected String groupId; protected String artifactId; protected String version; protected String type; protected ArtifactScopeEnum artifactScope; protected String classifier; /** * explanation: why this MD was chosen over it's siblings * in the resulting structure (classpath for now) */ protected String why; /** dependencies of the artifact behind this metadata */ protected Collection dependencies; /** metadata URI */ protected String uri; /** is metadata found anywhere */ protected boolean resolved = false; /** does the actual artifact for this metadata exists */ protected boolean artifactExists = false; /** artifact URI */ protected String artifactUri; /** error message */ private String error; //------------------------------------------------------------------ /** * */ public ArtifactMetadata( String name ) { if ( name == null ) { return; } int ind1 = name.indexOf( ':' ); int ind2 = name.lastIndexOf( ':' ); if ( ind1 == -1 || ind2 == -1 ) { return; } this.groupId = name.substring( 0, ind1 ); if ( ind1 == ind2 ) { this.artifactId = name.substring( ind1 + 1 ); } else { this.artifactId = name.substring( ind1 + 1, ind2 ); this.version = name.substring( ind2 + 1 ); } } // ------------------------------------------------------------------ public ArtifactMetadata( String groupId, String name, String version ) { this( groupId, name, version, null ); } //------------------------------------------------------------------ public ArtifactMetadata( String groupId, String name, String version, String type ) { this( groupId, name, version, type, null ); } //------------------------------------------------------------------ public ArtifactMetadata( String groupId, String name, String version, String type, ArtifactScopeEnum artifactScope ) { this( groupId, name, version, type, artifactScope, null ); } //------------------------------------------------------------------ public ArtifactMetadata( String groupId, String name, String version, String type, ArtifactScopeEnum artifactScope, String classifier ) { this( groupId, name, version, type, artifactScope, classifier, null ); } //------------------------------------------------------------------ public ArtifactMetadata( String groupId, String name, String version, String type, ArtifactScopeEnum artifactScope, String classifier, String artifactUri ) { this( groupId, name, version, type, artifactScope, classifier, artifactUri, null, true, null ); } //------------------------------------------------------------------ public ArtifactMetadata( String groupId, String name, String version, String type, ArtifactScopeEnum artifactScope, String classifier, String artifactUri, String why, boolean resolved, String error ) { this.groupId = groupId; this.artifactId = name; this.version = version; this.type = type; this.artifactScope = artifactScope; this.classifier = classifier; this.artifactUri = artifactUri; this.why = why; this.resolved = resolved; this.error = error; } //------------------------------------------------------------------ public ArtifactMetadata( String groupId, String name, String version, String type, String scopeString, String classifier, String artifactUri, String why, boolean resolved, String error ) { this( groupId, name, version, type, scopeString == null ? ArtifactScopeEnum.DEFAULT_SCOPE : ArtifactScopeEnum.valueOf( scopeString ), classifier, artifactUri, why, resolved, error ); } //------------------------------------------------------------------ public ArtifactMetadata( Artifact af ) { /* if ( af != null ) { init( af ); } */ } //------------------------------------------------------------------ // public void init( ArtifactMetadata af ) // { // setGroupId( af.getGroupId() ); // setArtifactId( af.getArtifactId() ); // setVersion( af.getVersion() ); // setType( af.getType() ); // setScope( af.getScope() ); // setClassifier( af.getClassifier() ); // //setUri( af.getDownloadUrl() ); // // this.resolved = af.isResolved(); // } //------------------------------------------------------------------ @Override public String toString() { return groupId + ":" + artifactId + ":" + version; } //------------------------------------------------------------------ public String toDomainString() { return groupId + ":" + artifactId; } //------------------------------------------------------------------ public String getGroupId() { return groupId; } public void setGroupId( String groupId ) { this.groupId = groupId; } public String getArtifactId() { return artifactId; } public void setArtifactId( String name ) { this.artifactId = name; } public String getVersion() { return version; } public void setVersion( String version ) { this.version = version; } public String getType() { return type; } public String getCheckedType() { return type == null ? "jar" : type; } public void setType( String type ) { this.type = type; } public ArtifactScopeEnum getArtifactScope() { return artifactScope == null ? ArtifactScopeEnum.DEFAULT_SCOPE : artifactScope; } public void setArtifactScope( ArtifactScopeEnum artifactScope ) { this.artifactScope = artifactScope; } public void setScope( String scope ) { this.artifactScope = scope == null ? ArtifactScopeEnum.DEFAULT_SCOPE : ArtifactScopeEnum.valueOf( scope ); } public String getClassifier() { return classifier; } public void setClassifier( String classifier ) { this.classifier = classifier; } public boolean isResolved() { return resolved; } public void setResolved( boolean resolved ) { this.resolved = resolved; } public String getUri() { return uri; } public void setUri( String uri ) { this.uri = uri; } public String getScope() { return getArtifactScope().getScope(); } public ArtifactScopeEnum getScopeAsEnum() { return artifactScope == null ? ArtifactScopeEnum.DEFAULT_SCOPE : artifactScope; } public boolean isArtifactExists() { return artifactExists; } public void setArtifactExists( boolean artifactExists ) { this.artifactExists = artifactExists; } public Collection getDependencies() { return dependencies; } public void setDependencies( Collection dependencies ) { this.dependencies = dependencies; } public String getArtifactUri() { return artifactUri; } public void setArtifactUri( String artifactUri ) { this.artifactUri = artifactUri; } public String getWhy() { return why; } public void setWhy( String why ) { this.why = why; } //------------------------------------------------------------------- public String getError() { return error; } public void setError( String error ) { this.error = error; } public boolean isError() { return error == null; } //------------------------------------------------------------------ public String getDependencyConflictId() { return groupId + ":" + artifactId; } //------------------------------------------------------------------ //------------------------------------------------------------------ } ClasspathContainer.java000066400000000000000000000104661317160430700344550ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/main/java/org/apache/maven/repository/metadatapackage org.apache.maven.repository.metadata; /* * 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.util.ArrayList; import java.util.Iterator; import java.util.List; import org.apache.maven.artifact.ArtifactScopeEnum; /** * classpath container that is aware of the classpath scope * * @author Oleg Gusakov * */ public class ClasspathContainer implements Iterable { private List classpath; private ArtifactScopeEnum scope; // ------------------------------------------------------------------------------------------- public ClasspathContainer( ArtifactScopeEnum scope ) { this.scope = ArtifactScopeEnum.checkScope( scope ); } // ------------------------------------------------------------------------------------------- public ClasspathContainer( List classpath, ArtifactScopeEnum scope ) { this( scope ); this.classpath = classpath; } // ------------------------------------------------------------------------------------------- public Iterator iterator() { return classpath == null ? null : classpath.iterator(); } // ------------------------------------------------------------------------------------------- public ClasspathContainer add( ArtifactMetadata md ) { if ( classpath == null ) { classpath = new ArrayList<>( 16 ); } classpath.add( md ); return this; } // ------------------------------------------------------------------------------------------- public List getClasspath() { return classpath; } // ------------------------------------------------------------------------------------------- public MetadataTreeNode getClasspathAsTree() throws MetadataResolutionException { if ( classpath == null || classpath.size() < 1 ) { return null; } MetadataTreeNode tree = null; MetadataTreeNode parent = null; for ( ArtifactMetadata md : classpath ) { MetadataTreeNode node = new MetadataTreeNode( md, parent, md.isResolved(), md.getArtifactScope() ); if ( tree == null ) { tree = node; } if ( parent != null ) { parent.setNChildren( 1 ); parent.addChild( 0, node ); } parent = node; } return tree; } public void setClasspath( List classpath ) { this.classpath = classpath; } public ArtifactScopeEnum getScope() { return scope; } public void setScope( ArtifactScopeEnum scope ) { this.scope = scope; } // ------------------------------------------------------------------------------------------- @Override public String toString() { StringBuilder sb = new StringBuilder( 256 ); sb.append( "[scope=" ).append( scope.getScope() ); if ( classpath != null ) { for ( ArtifactMetadata md : classpath ) { sb.append( ": " ).append( md.toString() ).append( '{' ).append( md.getArtifactUri() ).append( '}' ); } } sb.append( ']' ); return sb.toString(); } // ------------------------------------------------------------------------------------------- // ------------------------------------------------------------------------------------------- } ClasspathTransformation.java000066400000000000000000000033211317160430700355310ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/main/java/org/apache/maven/repository/metadatapackage org.apache.maven.repository.metadata; /* * 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 org.apache.maven.artifact.ArtifactScopeEnum; /** * Helper class to conver an Md Graph into some form of a classpath * * @author Oleg Gusakov * */ public interface ClasspathTransformation { String ROLE = ClasspathTransformation.class.getName(); /** * Transform Graph into a Collection of metadata objects that * could serve as a classpath for a particular scope * * @param dirtyGraph - dependency graph * @param scope - which classpath to extract * @param resolve - whether to resolve artifacts. * @return Collection of metadata objects in the linked subgraph of the graph which * contains the graph.getEntry() vertice */ ClasspathContainer transform( MetadataGraph dirtyGraph, ArtifactScopeEnum scope, boolean resolve ) throws MetadataGraphTransformationException; } DefaultClasspathTransformation.java000066400000000000000000000155301317160430700370430ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/main/java/org/apache/maven/repository/metadatapackage org.apache.maven.repository.metadata; /* * 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.util.ArrayList; import java.util.Arrays; import java.util.Comparator; import java.util.List; import org.apache.maven.artifact.ArtifactScopeEnum; import org.codehaus.plexus.component.annotations.Component; import org.codehaus.plexus.component.annotations.Requirement; /** * default implementation of the metadata classpath transformer * * @author Oleg Gusakov * */ @Component( role = ClasspathTransformation.class ) public class DefaultClasspathTransformation implements ClasspathTransformation { @Requirement GraphConflictResolver conflictResolver; //---------------------------------------------------------------------------------------------------- public ClasspathContainer transform( MetadataGraph dirtyGraph, ArtifactScopeEnum scope, boolean resolve ) throws MetadataGraphTransformationException { try { if ( dirtyGraph == null || dirtyGraph.isEmpty() ) { return null; } MetadataGraph cleanGraph = conflictResolver.resolveConflicts( dirtyGraph, scope ); if ( cleanGraph == null || cleanGraph.isEmpty() ) { return null; } ClasspathContainer cpc = new ClasspathContainer( scope ); if ( cleanGraph.isEmptyEdges() ) { // single entry in the classpath, populated from itself ArtifactMetadata amd = cleanGraph.getEntry().getMd(); cpc.add( amd ); } else { ClasspathGraphVisitor v = new ClasspathGraphVisitor( cleanGraph, cpc ); MetadataGraphVertex entry = cleanGraph.getEntry(); // entry point v.visit( entry ); } return cpc; } catch ( GraphConflictResolutionException e ) { throw new MetadataGraphTransformationException( e ); } } //=================================================================================================== /** * Helper class to traverse graph. Required to make the containing method thread-safe * and yet use class level data to lessen stack usage in recursion */ private class ClasspathGraphVisitor { MetadataGraph graph; ClasspathContainer cpc; List visited; // ----------------------------------------------------------------------- protected ClasspathGraphVisitor( MetadataGraph cleanGraph, ClasspathContainer cpc ) { this.cpc = cpc; this.graph = cleanGraph; visited = new ArrayList<>( cleanGraph.getVertices().size() ); } // ----------------------------------------------------------------------- protected void visit( MetadataGraphVertex node ) // , String version, String artifactUri ) { ArtifactMetadata md = node.getMd(); if ( visited.contains( node ) ) { return; } cpc.add( md ); // // TreeSet deps = new TreeSet( // new Comparator() // { // public int compare( MetadataGraphEdge e1 // , MetadataGraphEdge e2 // ) // { // if( e1.getDepth() == e2.getDepth() ) // { // if( e2.getPomOrder() == e1.getPomOrder() ) // return e1.getTarget().toString().compareTo(e2.getTarget().toString() ); // // return e2.getPomOrder() - e1.getPomOrder(); // } // // return e2.getDepth() - e1.getDepth(); // } // } // ); List exits = graph.getExcidentEdges( node ); if ( exits != null && exits.size() > 0 ) { MetadataGraphEdge[] sortedExits = exits.toArray( new MetadataGraphEdge[exits.size()] ); Arrays.sort( sortedExits , new Comparator() { public int compare( MetadataGraphEdge e1 , MetadataGraphEdge e2 ) { if ( e1.getDepth() == e2.getDepth() ) { if ( e2.getPomOrder() == e1.getPomOrder() ) { return e1.getTarget().toString().compareTo( e2.getTarget().toString() ); } return e2.getPomOrder() - e1.getPomOrder(); } return e2.getDepth() - e1.getDepth(); } } ); for ( MetadataGraphEdge e : sortedExits ) { MetadataGraphVertex targetNode = e.getTarget(); targetNode.getMd().setArtifactScope( e.getScope() ); targetNode.getMd().setWhy( e.getSource().getMd().toString() ); visit( targetNode ); } } } //----------------------------------------------------------------------- //----------------------------------------------------------------------- } //---------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------- } DefaultGraphConflictResolutionPolicy.java000066400000000000000000000044531317160430700401630ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/main/java/org/apache/maven/repository/metadatapackage org.apache.maven.repository.metadata; /* * 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 org.apache.maven.artifact.versioning.ArtifactVersion; import org.apache.maven.artifact.versioning.DefaultArtifactVersion; import org.codehaus.plexus.component.annotations.Component; import org.codehaus.plexus.component.annotations.Configuration; /** * @author Oleg Gusakov * */ @Component( role = GraphConflictResolutionPolicy.class ) public class DefaultGraphConflictResolutionPolicy implements GraphConflictResolutionPolicy { /** * artifact, closer to the entry point, is selected */ @Configuration( name = "closer-first", value = "true" ) private boolean closerFirst = true; /** * newer artifact is selected */ @Configuration( name = "newer-first", value = "true" ) private boolean newerFirst = true; public MetadataGraphEdge apply( MetadataGraphEdge e1, MetadataGraphEdge e2 ) { int depth1 = e1.getDepth(); int depth2 = e2.getDepth(); if ( depth1 == depth2 ) { ArtifactVersion v1 = new DefaultArtifactVersion( e1.getVersion() ); ArtifactVersion v2 = new DefaultArtifactVersion( e2.getVersion() ); if ( newerFirst ) { return v1.compareTo( v2 ) > 0 ? e1 : e2; } return v1.compareTo( v2 ) > 0 ? e2 : e1; } if ( closerFirst ) { return depth1 < depth2 ? e1 : e2; } return depth1 < depth2 ? e2 : e1; } } DefaultGraphConflictResolver.java000066400000000000000000000213701317160430700364360ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/main/java/org/apache/maven/repository/metadatapackage org.apache.maven.repository.metadata; /* * 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.util.ArrayList; import java.util.List; import java.util.TreeSet; import org.apache.maven.artifact.ArtifactScopeEnum; import org.codehaus.plexus.component.annotations.Component; import org.codehaus.plexus.component.annotations.Requirement; /** * Default conflict resolver.Implements closer newer first policy by default, but could be configured via plexus * * @author Oleg Gusakov */ @Component( role = GraphConflictResolver.class ) public class DefaultGraphConflictResolver implements GraphConflictResolver { /** * artifact, closer to the entry point, is selected */ @Requirement( role = GraphConflictResolutionPolicy.class ) protected GraphConflictResolutionPolicy policy; // ------------------------------------------------------------------------------------- // ------------------------------------------------------------------------------------- public MetadataGraph resolveConflicts( MetadataGraph graph, ArtifactScopeEnum scope ) throws GraphConflictResolutionException { if ( policy == null ) { throw new GraphConflictResolutionException( "no GraphConflictResolutionPolicy injected" ); } if ( graph == null ) { return null; } final MetadataGraphVertex entry = graph.getEntry(); if ( entry == null ) { return null; } if ( graph.isEmpty() ) { throw new GraphConflictResolutionException( "graph with an entry, but not vertices do not exist" ); } if ( graph.isEmptyEdges() ) { return null; // no edges - nothing to worry about } final TreeSet vertices = graph.getVertices(); try { // edge case - single vertex graph if ( vertices.size() == 1 ) { return new MetadataGraph( entry ); } final ArtifactScopeEnum requestedScope = ArtifactScopeEnum.checkScope( scope ); MetadataGraph res = new MetadataGraph( vertices.size() ); res.setVersionedVertices( false ); res.setScopedVertices( false ); MetadataGraphVertex resEntry = res.addVertex( entry.getMd() ); res.setEntry( resEntry ); res.setScope( requestedScope ); for ( MetadataGraphVertex v : vertices ) { final List ins = graph.getIncidentEdges( v ); final MetadataGraphEdge edge = cleanEdges( v, ins, requestedScope ); if ( edge == null ) { // no edges - don't need this vertex any more if ( entry.equals( v ) ) { // unless it's an entry point. // currently processing the entry point - it should not have any entry incident edges res.getEntry().getMd().setWhy( "This is a graph entry point. No links." ); } else { // System.out.println("--->"+v.getMd().toDomainString() // +" has been terminated on this entry set\n-------------------\n" // +ins // +"\n-------------------\n" // ); } } else { // System.out.println("+++>"+v.getMd().toDomainString()+" still has "+edge.toString() ); // fill in domain md with actual version data ArtifactMetadata md = v.getMd(); ArtifactMetadata newMd = new ArtifactMetadata( md.getGroupId(), md.getArtifactId(), edge.getVersion(), md.getType(), md.getScopeAsEnum(), md.getClassifier(), edge.getArtifactUri(), edge.getSource() == null ? "" : edge.getSource().getMd().toString(), edge.isResolved(), edge.getTarget() == null ? null : edge.getTarget().getMd().getError() ); MetadataGraphVertex newV = res.addVertex( newMd ); MetadataGraphVertex sourceV = res.addVertex( edge.getSource().getMd() ); res.addEdge( sourceV, newV, edge ); } } MetadataGraph linkedRes = findLinkedSubgraph( res ); // System.err.println("Original graph("+graph.getVertices().size()+"):\n"+graph.toString()); // System.err.println("Cleaned("+requestedScope+") graph("+res.getVertices().size()+"):\n"+res.toString()); // System.err.println("Linked("+requestedScope+") // subgraph("+linkedRes.getVertices().size()+"):\n"+linkedRes.toString()); return linkedRes; } catch ( MetadataResolutionException e ) { throw new GraphConflictResolutionException( e ); } } // ------------------------------------------------------------------------------------- private MetadataGraph findLinkedSubgraph( MetadataGraph g ) { if ( g.getVertices().size() == 1 ) { return g; } List visited = new ArrayList<>( g.getVertices().size() ); visit( g.getEntry(), visited, g ); List dropList = new ArrayList<>( g.getVertices().size() ); // collect drop list for ( MetadataGraphVertex v : g.getVertices() ) { if ( !visited.contains( v ) ) { dropList.add( v ); } } if ( dropList.size() < 1 ) { return g; } // now - drop vertices TreeSet vertices = g.getVertices(); for ( MetadataGraphVertex v : dropList ) { vertices.remove( v ); } return g; } // ------------------------------------------------------------------------------------- private void visit( MetadataGraphVertex from, List visited, MetadataGraph graph ) { if ( visited.contains( from ) ) { return; } visited.add( from ); List exitList = graph.getExcidentEdges( from ); // String s = "|---> "+from.getMd().toString()+" - "+(exitList == null ? -1 : exitList.size()) + " exit links"; if ( exitList != null && exitList.size() > 0 ) { for ( MetadataGraphEdge e : graph.getExcidentEdges( from ) ) { visit( e.getTarget(), visited, graph ); } } } // ------------------------------------------------------------------------------------- private MetadataGraphEdge cleanEdges( MetadataGraphVertex v, List edges, ArtifactScopeEnum scope ) { if ( edges == null || edges.isEmpty() ) { return null; } if ( edges.size() == 1 ) { MetadataGraphEdge e = edges.get( 0 ); if ( scope.encloses( e.getScope() ) ) { return e; } return null; } MetadataGraphEdge res = null; for ( MetadataGraphEdge e : edges ) { if ( !scope.encloses( e.getScope() ) ) { continue; } if ( res == null ) { res = e; } else { res = policy.apply( e, res ); } } return res; } // ------------------------------------------------------------------------------------- // ------------------------------------------------------------------------------------- } GraphConflictResolutionException.java000066400000000000000000000026651317160430700373600ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/main/java/org/apache/maven/repository/metadatapackage org.apache.maven.repository.metadata; /* * 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 Oleg Gusakov * */ public class GraphConflictResolutionException extends Exception { private static final long serialVersionUID = 2677613140287940255L; public GraphConflictResolutionException() { } public GraphConflictResolutionException( String message ) { super( message ); } public GraphConflictResolutionException( Throwable cause ) { super( cause ); } public GraphConflictResolutionException( String message, Throwable cause ) { super( message, cause ); } } GraphConflictResolutionPolicy.java000066400000000000000000000023161317160430700366520ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/main/java/org/apache/maven/repository/metadatapackage org.apache.maven.repository.metadata; /* * 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. */ /** * MetadataGraph edge selection policy. Complements * GraphConflictResolver by being injected into it * * @author Oleg Gusakov * */ public interface GraphConflictResolutionPolicy { String ROLE = GraphConflictResolutionPolicy.class.getName(); MetadataGraphEdge apply( MetadataGraphEdge e1, MetadataGraphEdge e2 ); } GraphConflictResolver.java000066400000000000000000000034361317160430700351340ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/main/java/org/apache/maven/repository/metadatapackage org.apache.maven.repository.metadata; /* * 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 org.apache.maven.artifact.ArtifactScopeEnum; /** * Resolves conflicts in the supplied dependency graph. * Different implementations will implement different conflict resolution policies. * * @author Oleg Gusakov */ public interface GraphConflictResolver { String ROLE = GraphConflictResolver.class.getName(); /** * Cleanses the supplied graph by leaving only one directed versioned edge\ * between any two nodes, if multiple exists. Uses scope relationships, defined * in ArtifactScopeEnum * * @param graph the "dirty" graph to be simplified via conflict resolution * @param scope scope for which the graph should be resolved * * @return resulting "clean" graph for the specified scope * * @since 3.0 */ MetadataGraph resolveConflicts( MetadataGraph graph, ArtifactScopeEnum scope ) throws GraphConflictResolutionException; } maven-maven-3.5.2/maven-compat/src/main/java/org/apache/maven/repository/metadata/MetadataGraph.java000066400000000000000000000341551317160430700334520ustar00rootroot00000000000000package org.apache.maven.repository.metadata; /* * 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.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.TreeSet; import org.apache.maven.artifact.ArtifactScopeEnum; /** * maven dependency metadata graph * * @author Oleg Gusakov * */ public class MetadataGraph { public static final int DEFAULT_VERTICES = 32; public static final int DEFAULT_EDGES = 64; // flags to indicate the granularity of vertices private boolean versionedVertices = false; private boolean scopedVertices = false; /** * the entry point we started building the graph from */ MetadataGraphVertex entry; // graph vertices TreeSet vertices; /** * incident and excident edges per node */ Map> incidentEdges; Map> excidentEdges; /** * null in dirty graph, actual * scope for conflict-resolved graph */ ArtifactScopeEnum scope; //------------------------------------------------------------------------ /** * init graph */ public MetadataGraph( int nVertices ) { init( nVertices, 2 * nVertices ); } public MetadataGraph( int nVertices, int nEdges ) { init( nVertices, nEdges ); } //------------------------------------------------------------------------ /** * construct a single vertex */ public MetadataGraph( MetadataGraphVertex entry ) throws MetadataResolutionException { checkVertex( entry ); checkVertices( 1 ); entry.setCompareVersion( versionedVertices ); entry.setCompareScope( scopedVertices ); vertices.add( entry ); this.entry = entry; } //------------------------------------------------------------------------ /** * construct graph from a "dirty" tree */ public MetadataGraph( MetadataTreeNode tree ) throws MetadataResolutionException { this( tree, false, false ); } //------------------------------------------------------------------------ /** * construct graph from a "dirty" tree * * @param tree "dirty" tree root * @param versionedVertices true if graph nodes should be versioned (different versions -> different nodes) * @param scopedVertices true if graph nodes should be versioned and scoped * (different versions and/or scopes -> different nodes) * */ public MetadataGraph( MetadataTreeNode tree, boolean versionedVertices, boolean scopedVertices ) throws MetadataResolutionException { if ( tree == null ) { throw new MetadataResolutionException( "tree is null" ); } setVersionedVertices( versionedVertices ); setScopedVertices( scopedVertices ); this.versionedVertices = scopedVertices || versionedVertices; this.scopedVertices = scopedVertices; int count = countNodes( tree ); init( count, count + ( count / 2 ) ); processTreeNodes( null, tree, 0, 0 ); } //------------------------------------------------------------------------ private void processTreeNodes( MetadataGraphVertex parentVertex, MetadataTreeNode node, int depth, int pomOrder ) throws MetadataResolutionException { if ( node == null ) { return; } MetadataGraphVertex vertex = new MetadataGraphVertex( node.md, versionedVertices, scopedVertices ); if ( !vertices.contains( vertex ) ) { vertices.add( vertex ); } if ( parentVertex != null ) // then create the edge { ArtifactMetadata md = node.getMd(); MetadataGraphEdge e = new MetadataGraphEdge( md.version, md.resolved, md.artifactScope, md.artifactUri, depth, pomOrder ); addEdge( parentVertex, vertex, e ); } else { entry = vertex; } MetadataTreeNode[] kids = node.getChildren(); if ( kids == null || kids.length < 1 ) { return; } for ( int i = 0; i < kids.length; i++ ) { MetadataTreeNode n = kids[i]; processTreeNodes( vertex, n, depth + 1, i ); } } //------------------------------------------------------------------------ public MetadataGraphVertex findVertex( ArtifactMetadata md ) { if ( md == null || vertices == null || vertices.size() < 1 ) { return null; } MetadataGraphVertex v = new MetadataGraphVertex( md ); v.setCompareVersion( versionedVertices ); v.setCompareScope( scopedVertices ); for ( MetadataGraphVertex gv : vertices ) { if ( gv.equals( v ) ) { return gv; } } return null; } //------------------------------------------------------------------------ public MetadataGraphVertex addVertex( ArtifactMetadata md ) { if ( md == null ) { return null; } checkVertices(); MetadataGraphVertex v = findVertex( md ); if ( v != null ) { return v; } v = new MetadataGraphVertex( md ); v.setCompareVersion( versionedVertices ); v.setCompareScope( scopedVertices ); vertices.add( v ); return v; } //------------------------------------------------------------------------ /** * init graph */ private void init( int nVertices, int nEdges ) { int nV = nVertices; if ( nVertices < 1 ) { nV = 1; } checkVertices( nV ); int nE = nVertices; if ( nEdges <= nV ) { nE = 2 * nE; } checkEdges( nE ); } private void checkVertices() { checkVertices( DEFAULT_VERTICES ); } private void checkVertices( int nVertices ) { if ( vertices == null ) { vertices = new TreeSet<>(); } } private void checkEdges() { int count = DEFAULT_EDGES; if ( vertices != null ) { count = vertices.size() + vertices.size() / 2; } checkEdges( count ); } private void checkEdges( int nEdges ) { if ( incidentEdges == null ) { incidentEdges = new HashMap<>( nEdges ); } if ( excidentEdges == null ) { excidentEdges = new HashMap<>( nEdges ); } } //------------------------------------------------------------------------ private static void checkVertex( MetadataGraphVertex v ) throws MetadataResolutionException { if ( v == null ) { throw new MetadataResolutionException( "null vertex" ); } if ( v.getMd() == null ) { throw new MetadataResolutionException( "vertex without metadata" ); } } //------------------------------------------------------------------------ private static void checkEdge( MetadataGraphEdge e ) throws MetadataResolutionException { if ( e == null ) { throw new MetadataResolutionException( "badly formed edge" ); } } //------------------------------------------------------------------------ public List getEdgesBetween( MetadataGraphVertex vFrom, MetadataGraphVertex vTo ) { List edges = getIncidentEdges( vTo ); if ( edges == null || edges.isEmpty() ) { return null; } List res = new ArrayList<>( edges.size() ); for ( MetadataGraphEdge e : edges ) { if ( e.getSource().equals( vFrom ) ) { res.add( e ); } } return res; } //------------------------------------------------------------------------ public MetadataGraph addEdge( MetadataGraphVertex vFrom, MetadataGraphVertex vTo, MetadataGraphEdge e ) throws MetadataResolutionException { checkVertex( vFrom ); checkVertex( vTo ); checkVertices(); checkEdge( e ); checkEdges(); e.setSource( vFrom ); e.setTarget( vTo ); vFrom.setCompareVersion( versionedVertices ); vFrom.setCompareScope( scopedVertices ); List exList = excidentEdges.get( vFrom ); if ( exList == null ) { exList = new ArrayList<>(); excidentEdges.put( vFrom, exList ); } if ( !exList.contains( e ) ) { exList.add( e ); } List inList = incidentEdges.get( vTo ); if ( inList == null ) { inList = new ArrayList<>(); incidentEdges.put( vTo, inList ); } if ( !inList.contains( e ) ) { inList.add( e ); } return this; } //------------------------------------------------------------------------ public MetadataGraph removeVertex( MetadataGraphVertex v ) { if ( vertices != null && v != null ) { vertices.remove( v ); } if ( incidentEdges != null ) { incidentEdges.remove( v ); } if ( excidentEdges != null ) { excidentEdges.remove( v ); } return this; } //------------------------------------------------------------------------ private static int countNodes( MetadataTreeNode tree ) { if ( tree == null ) { return 0; } int count = 1; MetadataTreeNode[] kids = tree.getChildren(); if ( kids == null || kids.length < 1 ) { return count; } for ( MetadataTreeNode n : kids ) { count += countNodes( n ); } return count; } //------------------------------------------------------------------------ public MetadataGraphVertex getEntry() { return entry; } public void setEntry( MetadataGraphVertex entry ) { this.entry = entry; } public TreeSet getVertices() { return vertices; } public List getIncidentEdges( MetadataGraphVertex vertex ) { checkEdges(); return incidentEdges.get( vertex ); } public List getExcidentEdges( MetadataGraphVertex vertex ) { checkEdges(); return excidentEdges.get( vertex ); } public boolean isVersionedVertices() { return versionedVertices; } public void setVersionedVertices( boolean versionedVertices ) { this.versionedVertices = versionedVertices; } public boolean isScopedVertices() { return scopedVertices; } public void setScopedVertices( boolean scopedVertices ) { this.scopedVertices = scopedVertices; // scoped graph is versioned by definition if ( scopedVertices ) { versionedVertices = true; } } public ArtifactScopeEnum getScope() { return scope; } public void setScope( ArtifactScopeEnum scope ) { this.scope = scope; } // ------------------------------------------------------------------------ public boolean isEmpty() { return entry == null || vertices == null || vertices.isEmpty(); } //------------------------------------------------------------------------ public boolean isEmptyEdges() { return isEmpty() || incidentEdges == null || incidentEdges.isEmpty(); } //------------------------------------------------------------------------ @Override public String toString() { StringBuilder sb = new StringBuilder( 512 ); if ( isEmpty() ) { return "empty"; } for ( MetadataGraphVertex v : vertices ) { sb.append( "Vertex: " ).append( v.getMd().toString() ).append( '\n' ); List ins = getIncidentEdges( v ); if ( ins != null ) { for ( MetadataGraphEdge e : ins ) { sb.append( " from : " ).append( e.toString() ).append( '\n' ); } } else { sb.append( " no entries\n" ); } List outs = getExcidentEdges( v ); if ( outs != null ) { for ( MetadataGraphEdge e : outs ) { sb.append( " to : " ).append( e.toString() ).append( '\n' ); } } else { sb.append( " no exit\n" ); } sb.append( "-------------------------------------------------\n" ); } sb.append( "=============================================================\n" ); return sb.toString(); } //------------------------------------------------------------------------ //------------------------------------------------------------------------ } MetadataGraphEdge.java000066400000000000000000000120011317160430700341420ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/main/java/org/apache/maven/repository/metadatapackage org.apache.maven.repository.metadata; /* * 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 org.apache.maven.artifact.ArtifactScopeEnum; /** * metadata graph edge - combination of version, scope and depth define * an edge in the graph * * @author Oleg Gusakov * */ public class MetadataGraphEdge { String version; ArtifactScopeEnum scope; int depth = -1; int pomOrder = -1; boolean resolved = true; String artifactUri; /** * capturing where this link came from * and where it is linked to. * * In the first implementation only source used for explanatory function */ MetadataGraphVertex source; MetadataGraphVertex target; //---------------------------------------------------------------------------- public MetadataGraphEdge( String version, boolean resolved, ArtifactScopeEnum scope, String artifactUri, int depth, int pomOrder ) { super(); this.version = version; this.scope = scope; this.artifactUri = artifactUri; this.depth = depth; this.resolved = resolved; this.pomOrder = pomOrder; } //---------------------------------------------------------------------------- /** * helper for equals */ private static boolean objectsEqual( Object o1, Object o2 ) { if ( o1 == null && o2 == null ) { return true; } if ( o1 == null || o2 == null ) { return false; // as they are not both null } return o1.equals( o2 ); } //---------------------------------------------------------------------------- /** * used to eliminate exact duplicates in the edge list */ @Override public boolean equals( Object o ) { if ( o instanceof MetadataGraphEdge ) { MetadataGraphEdge e = (MetadataGraphEdge) o; return objectsEqual( version, e.version ) && ArtifactScopeEnum.checkScope( scope ).getScope(). equals( ArtifactScopeEnum.checkScope( e.scope ).getScope() ) && depth == e.depth; } return false; } //---------------------------------------------------------------------------- public String getVersion() { return version; } public void setVersion( String version ) { this.version = version; } public ArtifactScopeEnum getScope() { return scope; } public void setScope( ArtifactScopeEnum scope ) { this.scope = scope; } public int getDepth() { return depth; } public void setDepth( int depth ) { this.depth = depth; } public boolean isResolved() { return resolved; } public void setResolved( boolean resolved ) { this.resolved = resolved; } public int getPomOrder() { return pomOrder; } public void setPomOrder( int pomOrder ) { this.pomOrder = pomOrder; } public String getArtifactUri() { return artifactUri; } public void setArtifactUri( String artifactUri ) { this.artifactUri = artifactUri; } public MetadataGraphVertex getSource() { return source; } public void setSource( MetadataGraphVertex source ) { this.source = source; } public MetadataGraphVertex getTarget() { return target; } public void setTarget( MetadataGraphVertex target ) { this.target = target; } @Override public String toString() { return "[ " + "FROM:(" + ( source == null ? "no source" : ( source.md == null ? "no source MD" : source.md.toString() ) ) + ") " + "TO:(" + ( target == null ? "no target" : ( target.md == null ? "no target MD" : target.md.toString() ) ) + ") " + "version=" + version + ", scope=" + ( scope == null ? "null" : scope.getScope() ) + ", depth=" + depth + "]"; } //---------------------------------------------------------------------------- //---------------------------------------------------------------------------- } MetadataGraphTransformationException.java000066400000000000000000000026761317160430700402040ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/main/java/org/apache/maven/repository/metadatapackage org.apache.maven.repository.metadata; /* * 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 Oleg Gusakov */ public class MetadataGraphTransformationException extends Exception { private static final long serialVersionUID = -4029897098314019152L; public MetadataGraphTransformationException() { } public MetadataGraphTransformationException( String message ) { super( message ); } public MetadataGraphTransformationException( Throwable cause ) { super( cause ); } public MetadataGraphTransformationException( String message, Throwable cause ) { super( message, cause ); } } MetadataGraphVertex.java000066400000000000000000000133341317160430700345650ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/main/java/org/apache/maven/repository/metadatapackage org.apache.maven.repository.metadata; /* * 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 org.apache.maven.artifact.ArtifactScopeEnum; /** * metadata graph vertice - just a wrapper around artifact's metadata * * @author Oleg Gusakov */ public class MetadataGraphVertex implements Comparable { ArtifactMetadata md; // indications to use these in comparison private boolean compareVersion = false; private boolean compareScope = false; public MetadataGraphVertex( ArtifactMetadata md ) { super(); this.md = md; } public MetadataGraphVertex( ArtifactMetadata md, boolean compareVersion, boolean compareScope ) { this( md ); this.compareVersion = compareVersion; this.compareScope = compareScope; } public ArtifactMetadata getMd() { return md; } public void setMd( ArtifactMetadata md ) { this.md = md; } // --------------------------------------------------------------------- public boolean isCompareVersion() { return compareVersion; } public void setCompareVersion( boolean compareVersion ) { this.compareVersion = compareVersion; } public boolean isCompareScope() { return compareScope; } public void setCompareScope( boolean compareScope ) { this.compareScope = compareScope; } // --------------------------------------------------------------------- @Override public String toString() { return "[" + ( md == null ? "no metadata" : md.toString() ) + "]"; } // --------------------------------------------------------------------- private static int compareStrings( String s1, String s2 ) { if ( s1 == null && s2 == null ) { return 0; } if ( s1 == null /* && s2 != null */ ) { return -1; } if ( /* s1 != null && */ s2 == null ) { return 1; } return s1.compareTo( s2 ); } // --------------------------------------------------------------------- public int compareTo( MetadataGraphVertex vertex ) { if ( vertex == null || vertex.getMd() == null ) { return 1; } ArtifactMetadata vmd = vertex.getMd(); if ( vmd == null ) { if ( md == null ) { return 0; } else { return 1; } } int g = compareStrings( md.groupId, vmd.groupId ); if ( g == 0 ) { int a = compareStrings( md.artifactId, vmd.artifactId ); if ( a == 0 ) { if ( compareVersion ) { int v = compareStrings( md.version, vmd.version ); if ( v == 0 ) { if ( compareScope ) { String s1 = ArtifactScopeEnum.checkScope( md.artifactScope ).getScope(); String s2 = ArtifactScopeEnum.checkScope( vmd.artifactScope ).getScope(); return s1.compareTo( s2 ); } else { return 0; } } else { return v; } } else { return 0; } } else { return a; } } return g; } // --------------------------------------------------------------------- @Override public boolean equals( Object vo ) { if ( vo == null || !( vo instanceof MetadataGraphVertex ) ) { return false; } return compareTo( (MetadataGraphVertex) vo ) == 0; } // --------------------------------------------------------------------- @Override public int hashCode() { if ( md == null ) { return super.hashCode(); } StringBuilder hashString = new StringBuilder( 128 ); hashString.append( md.groupId ).append( '|' ); hashString.append( md.artifactId ).append( '|' ); if ( compareVersion ) { hashString.append( md.version ).append( '|' ); } if ( compareScope ) { hashString.append( md.getArtifactScope() ).append( '|' ); } return hashString.toString().hashCode(); // BASE64Encoder b64 = new BASE64Encoder(); // return b64.encode( hashString.toString().getBytes() ).hashCode(); } // --------------------------------------------------------------------- // --------------------------------------------------------------------- } MetadataResolution.java000066400000000000000000000047251317160430700344750ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/main/java/org/apache/maven/repository/metadatapackage org.apache.maven.repository.metadata; /* * 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.util.Collection; import org.apache.maven.artifact.repository.ArtifactRepository; /** * * @author Jason van Zyl * */ public class MetadataResolution { /** resolved MD */ private ArtifactMetadata artifactMetadata; /** repositories, added by this POM */ private Collection metadataRepositories; //------------------------------------------------------------------- public MetadataResolution( ArtifactMetadata artifactMetadata ) { this.artifactMetadata = artifactMetadata; } //------------------------------------------------------------------- public MetadataResolution( ArtifactMetadata artifactMetadata, Collection metadataRepositories ) { this( artifactMetadata ); this.metadataRepositories = metadataRepositories; } //------------------------------------------------------------------- public Collection getMetadataRepositories() { return metadataRepositories; } public void setMetadataRepositories( Collection metadataRepositories ) { this.metadataRepositories = metadataRepositories; } //------------------------------------------------------------------- public ArtifactMetadata getArtifactMetadata() { return artifactMetadata; } public void setArtifactMetadata( ArtifactMetadata artifactMetadata ) { this.artifactMetadata = artifactMetadata; } //------------------------------------------------------------------- //------------------------------------------------------------------- } MetadataResolutionException.java000066400000000000000000000027101317160430700363440ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/main/java/org/apache/maven/repository/metadatapackage org.apache.maven.repository.metadata; /* * 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. */ public class MetadataResolutionException extends Exception { public MetadataResolutionException() { // TODO Auto-generated constructor stub } public MetadataResolutionException( String message ) { super( message ); // TODO Auto-generated constructor stub } public MetadataResolutionException( Throwable cause ) { super( cause ); // TODO Auto-generated constructor stub } public MetadataResolutionException( String message, Throwable cause ) { super( message, cause ); // TODO Auto-generated constructor stub } } MetadataResolutionRequest.java000066400000000000000000000050121317160430700360340ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/main/java/org/apache/maven/repository/metadatapackage org.apache.maven.repository.metadata; /* * 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.util.List; import org.apache.maven.artifact.repository.ArtifactRepository; /** @author Oleg Gusakov */ public class MetadataResolutionRequest { protected ArtifactMetadata query; protected ArtifactRepository localRepository; protected List remoteRepositories; //-------------------------------------------------------------------- public MetadataResolutionRequest() { } //-------------------------------------------------------------------- public MetadataResolutionRequest( ArtifactMetadata query, ArtifactRepository localRepository, List remoteRepositories ) { this.query = query; this.localRepository = localRepository; this.remoteRepositories = remoteRepositories; } //-------------------------------------------------------------------- public ArtifactMetadata getQuery() { return query; } public void setQuery( ArtifactMetadata query ) { this.query = query; } public ArtifactRepository getLocalRepository() { return localRepository; } public void setLocalRepository( ArtifactRepository localRepository ) { this.localRepository = localRepository; } public List getRemoteRepositories() { return remoteRepositories; } public void setRemoteRepositories( List remoteRepositories ) { this.remoteRepositories = remoteRepositories; } //-------------------------------------------------------------------- //-------------------------------------------------------------------- } MetadataResolutionRequestTypeEnum.java000066400000000000000000000023351317160430700375300ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/main/java/org/apache/maven/repository/metadatapackage org.apache.maven.repository.metadata; /* * 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. */ public enum MetadataResolutionRequestTypeEnum { tree( 1 ) , graph( 2 ) , classpathCompile( 3 ) , classpathTest( 4 ) , classpathRuntime( 5 ) , versionedGraph( 6 ) , scopedGraph( 7 ) ; private int id; // Constructor MetadataResolutionRequestTypeEnum( int id ) { this.id = id; } int getId() { return id; } } MetadataResolutionResult.java000066400000000000000000000134021317160430700356640ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/main/java/org/apache/maven/repository/metadatapackage org.apache.maven.repository.metadata; /* * 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 org.apache.maven.artifact.ArtifactScopeEnum; import org.codehaus.plexus.PlexusContainer; import org.codehaus.plexus.component.repository.exception.ComponentLookupException; /** * This object is tinted with ClasspathTransformation and GraphConflictResolver. * Get rid of them after debugging * * @author Oleg Gusakov */ public class MetadataResolutionResult { MetadataTreeNode treeRoot; /** * these components are are initialized on demand by * explicit call of the initTreeProcessing() */ ClasspathTransformation classpathTransformation; GraphConflictResolver conflictResolver; //---------------------------------------------------------------------------- public MetadataResolutionResult( ) { } //---------------------------------------------------------------------------- public MetadataResolutionResult( MetadataTreeNode root ) { this.treeRoot = root; } //---------------------------------------------------------------------------- public MetadataTreeNode getTree() { return treeRoot; } //---------------------------------------------------------------------------- public void setTree( MetadataTreeNode root ) { this.treeRoot = root; } public void initTreeProcessing( PlexusContainer plexus ) throws ComponentLookupException { classpathTransformation = plexus.lookup( ClasspathTransformation.class ); conflictResolver = plexus.lookup( GraphConflictResolver.class ); } //---------------------------------------------------------------------------- public MetadataGraph getGraph() throws MetadataResolutionException { return treeRoot == null ? null : new MetadataGraph( treeRoot ); } //---------------------------------------------------------------------------- public MetadataGraph getGraph( ArtifactScopeEnum scope ) throws MetadataResolutionException, GraphConflictResolutionException { if ( treeRoot == null ) { return null; } if ( conflictResolver == null ) { return null; } return conflictResolver.resolveConflicts( getGraph(), scope ); } //---------------------------------------------------------------------------- public MetadataGraph getGraph( MetadataResolutionRequestTypeEnum requestType ) throws MetadataResolutionException, GraphConflictResolutionException { if ( requestType == null ) { return null; } if ( treeRoot == null ) { return null; } if ( conflictResolver == null ) { return null; } if ( requestType.equals( MetadataResolutionRequestTypeEnum.classpathCompile ) ) { return conflictResolver.resolveConflicts( getGraph(), ArtifactScopeEnum.compile ); } else if ( requestType.equals( MetadataResolutionRequestTypeEnum.classpathRuntime ) ) { return conflictResolver.resolveConflicts( getGraph(), ArtifactScopeEnum.runtime ); } else if ( requestType.equals( MetadataResolutionRequestTypeEnum.classpathTest ) ) { return conflictResolver.resolveConflicts( getGraph(), ArtifactScopeEnum.test ); } else if ( requestType.equals( MetadataResolutionRequestTypeEnum.graph ) ) { return getGraph(); } else if ( requestType.equals( MetadataResolutionRequestTypeEnum.versionedGraph ) ) { return new MetadataGraph( getTree(), true, false ); } else if ( requestType.equals( MetadataResolutionRequestTypeEnum.scopedGraph ) ) { return new MetadataGraph( getTree(), true, true ); } return null; } //---------------------------------------------------------------------------- public ClasspathContainer getClasspath( ArtifactScopeEnum scope ) throws MetadataGraphTransformationException, MetadataResolutionException { if ( classpathTransformation == null ) { return null; } MetadataGraph dirtyGraph = getGraph(); if ( dirtyGraph == null ) { return null; } return classpathTransformation.transform( dirtyGraph, scope, false ); } //---------------------------------------------------------------------------- public MetadataTreeNode getClasspathTree( ArtifactScopeEnum scope ) throws MetadataGraphTransformationException, MetadataResolutionException { ClasspathContainer cpc = getClasspath( scope ); if ( cpc == null ) { return null; } return cpc.getClasspathAsTree(); } //---------------------------------------------------------------------------- //---------------------------------------------------------------------------- } MetadataRetrievalException.java000066400000000000000000000032031317160430700361340ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/main/java/org/apache/maven/repository/metadatapackage org.apache.maven.repository.metadata; /* * 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. */ /** * Error while retrieving repository metadata from the repository. * * @author Jason van Zyl */ public class MetadataRetrievalException extends Exception { private ArtifactMetadata artifact; public MetadataRetrievalException( String message ) { this( message, null, null ); } public MetadataRetrievalException( Throwable cause ) { this( null, cause, null ); } public MetadataRetrievalException( String message, Throwable cause ) { this( message, cause, null ); } public MetadataRetrievalException( String message, Throwable cause, ArtifactMetadata artifact ) { super( message, cause ); this.artifact = artifact; } public ArtifactMetadata getArtifactMetadata() { return artifact; } }MetadataSource.java000066400000000000000000000026031317160430700335630ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/main/java/org/apache/maven/repository/metadatapackage org.apache.maven.repository.metadata; /* * 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.util.List; import org.apache.maven.artifact.repository.ArtifactRepository; /** * Provides some metadata operations, like querying the remote repository for a list of versions available for an * artifact. * * @author Jason van Zyl */ public interface MetadataSource { String ROLE = MetadataSource.class.getName(); MetadataResolution retrieve( ArtifactMetadata artifact, ArtifactRepository localRepository, List remoteRepositories ) throws MetadataRetrievalException; }MetadataTreeNode.java000066400000000000000000000100671317160430700340330ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/main/java/org/apache/maven/repository/metadatapackage org.apache.maven.repository.metadata; /* * 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 org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.ArtifactScopeEnum; /** * metadata [dirty] Tree * * @author Oleg Gusakov * */ public class MetadataTreeNode { ArtifactMetadata md; // this node MetadataTreeNode parent; // papa /** default # of children. Used for tree creation optimization only */ int nChildren = 8; MetadataTreeNode[] children; // of cause public int getNChildren() { return nChildren; } public void setNChildren( int children ) { nChildren = children; } //------------------------------------------------------------------------ public MetadataTreeNode() { } //------------------------------------------------------------------------ public MetadataTreeNode( ArtifactMetadata md, MetadataTreeNode parent, boolean resolved, ArtifactScopeEnum scope ) { if ( md != null ) { md.setArtifactScope( ArtifactScopeEnum.checkScope( scope ) ); md.setResolved( resolved ); } this.md = md; this.parent = parent; } //------------------------------------------------------------------------ public MetadataTreeNode( Artifact af, MetadataTreeNode parent, boolean resolved, ArtifactScopeEnum scope ) { this( new ArtifactMetadata( af ), parent, resolved, scope ); } // ------------------------------------------------------------------------ public void addChild( int index, MetadataTreeNode kid ) { if ( kid == null ) { return; } if ( children == null ) { children = new MetadataTreeNode[nChildren]; } children[index % nChildren] = kid; } //------------------------------------------------------------------ @Override public String toString() { return md == null ? "no metadata" : md.toString(); } //------------------------------------------------------------------ public String graphHash() throws MetadataResolutionException { if ( md == null ) { throw new MetadataResolutionException( "treenode without metadata, parent: " + ( parent == null ? "null" : parent.toString() ) ); } return md.groupId + ":" + md.artifactId; } //------------------------------------------------------------------------ public boolean hasChildren() { return children != null; } //------------------------------------------------------------------------ public ArtifactMetadata getMd() { return md; } public void setMd( ArtifactMetadata md ) { this.md = md; } public MetadataTreeNode getParent() { return parent; } public void setParent( MetadataTreeNode parent ) { this.parent = parent; } public MetadataTreeNode[] getChildren() { return children; } public void setChildren( MetadataTreeNode[] children ) { this.children = children; } //------------------------------------------------------------------------ //------------------------------------------------------------------------ } maven-maven-3.5.2/maven-compat/src/main/java/org/apache/maven/usability/000077500000000000000000000000001317160430700261035ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/main/java/org/apache/maven/usability/plugin/000077500000000000000000000000001317160430700274015ustar00rootroot00000000000000ExpressionDocumentationException.java000066400000000000000000000022531317160430700367370ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/main/java/org/apache/maven/usability/pluginpackage org.apache.maven.usability.plugin; /* * 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. */ public class ExpressionDocumentationException extends Exception { static final long serialVersionUID = 1; public ExpressionDocumentationException( String message, Throwable cause ) { super( message, cause ); } public ExpressionDocumentationException( String message ) { super( message ); } } ExpressionDocumenter.java000066400000000000000000000131441317160430700343550ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/main/java/org/apache/maven/usability/pluginpackage org.apache.maven.usability.plugin; /* * 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 org.apache.maven.usability.plugin.io.xpp3.ParamdocXpp3Reader; import org.codehaus.plexus.util.ReaderFactory; import org.codehaus.plexus.util.xml.pull.XmlPullParserException; import java.io.BufferedReader; import java.io.File; import java.io.IOException; import java.io.InputStream; import java.io.Reader; import java.net.MalformedURLException; import java.net.URL; import java.net.URLClassLoader; import java.util.HashMap; import java.util.List; import java.util.Map; public class ExpressionDocumenter { private static final String[] EXPRESSION_ROOTS = { "project", "settings", "session", "plugin", "rootless" }; private static final String EXPRESSION_DOCO_ROOTPATH = "META-INF/maven/plugin-expressions/"; private static Map expressionDocumentation; public static Map load() throws ExpressionDocumentationException { if ( expressionDocumentation == null ) { expressionDocumentation = new HashMap<>(); ClassLoader docLoader = initializeDocLoader(); for ( String root : EXPRESSION_ROOTS ) { try ( InputStream docStream = docLoader.getResourceAsStream( EXPRESSION_DOCO_ROOTPATH + root + ".paramdoc.xml" ) ) { if ( docStream != null ) { Map doco = parseExpressionDocumentation( docStream ); expressionDocumentation.putAll( doco ); } } catch ( IOException e ) { throw new ExpressionDocumentationException( "Failed to read documentation for expression root: " + root, e ); } catch ( XmlPullParserException e ) { throw new ExpressionDocumentationException( "Failed to parse documentation for expression root: " + root, e ); } } } return expressionDocumentation; } /** * * * project.distributionManagementArtifactRepository * * * some-repo * scp://host/path * * * some-snap-repo * scp://host/snapshot-path * * * ]]> * * * * * @throws IOException * @throws XmlPullParserException */ private static Map parseExpressionDocumentation( InputStream docStream ) throws IOException, XmlPullParserException { Reader reader = new BufferedReader( ReaderFactory.newXmlReader( docStream ) ); ParamdocXpp3Reader paramdocReader = new ParamdocXpp3Reader(); ExpressionDocumentation documentation = paramdocReader.read( reader, true ); List expressions = documentation.getExpressions(); Map bySyntax = new HashMap<>(); if ( expressions != null && !expressions.isEmpty() ) { for ( Expression expression : expressions ) { bySyntax.put( expression.getSyntax(), expression ); } } return bySyntax; } private static ClassLoader initializeDocLoader() throws ExpressionDocumentationException { String myResourcePath = ExpressionDocumenter.class.getName().replace( '.', '/' ) + ".class"; URL myResource = ExpressionDocumenter.class.getClassLoader().getResource( myResourcePath ); assert myResource != null : "The resource is this class itself loaded by its own classloader and must exist"; String myClasspathEntry = myResource.getPath(); myClasspathEntry = myClasspathEntry.substring( 0, myClasspathEntry.length() - ( myResourcePath.length() + 2 ) ); if ( myClasspathEntry.startsWith( "file:" ) ) { myClasspathEntry = myClasspathEntry.substring( "file:".length() ); } URL docResource; try { docResource = new File( myClasspathEntry ).toURL(); } catch ( MalformedURLException e ) { throw new ExpressionDocumentationException( "Cannot construct expression documentation classpath" + " resource base.", e ); } return new URLClassLoader( new URL[] { docResource } ); } } maven-maven-3.5.2/maven-compat/src/main/mdo/000077500000000000000000000000001317160430700206165ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/main/mdo/paramdoc.mdo000066400000000000000000000126231317160430700231110ustar00rootroot00000000000000 paramdoc Paramdoc package org.apache.maven.usability.plugin 1.0.0 ExpressionDocumentation The root of a parameter plugin expression document. 1.0.0 expressions The list of plugin parameter expressions described by this document. Expression * 1.0.0 1.0.0 Expression A plugin parameter expression supported by Maven 1.0.0 syntax The syntax of the expression String true 1.0.0 description The description of what this expression references, and what it's generally used for. String true 1.0.0 configuration The place and syntax used to change the value of this expression. String 1.0.0 cliOptions The command-line switches used to change the value of this expression. Properties String * 1.0.0 apiMethods The programmatic methods used to change the value of this expression. Properties String * 1.0.0 deprecation A preferred alternative to this expression, in the case where it's deprecated. String 1.0.0 ban A preferred alternative to this expression, in the case where it's banned from use. String 1.0.0 editable Whether the value of this expression can be changed. boolean true maven-maven-3.5.2/maven-compat/src/main/mdo/profiles.mdo000066400000000000000000000332771317160430700231560ustar00rootroot00000000000000 profiles Profiles package org.apache.maven.profiles ProfilesRoot 1.0.0 Root element of the profiles.xml file. profiles 1.0.0 Profile * activeProfiles 1.0.0 String * Profile 1.0.0 id true 1.0.0 String The ID of this build profile, for activation purposes. activation 1.0.0 Activation properties Extended configuration specific to this profile goes here. Properties String * repositories 1.0.0 Repository * pluginRepositories 1.0.0 Repository * Activation 1.0.0 activeByDefault 1.0.0 boolean Flag specifying whether this profile is active as a default. jdk 1.0.0 String os 1.0.0 ActivationOS property 1.0.0 ActivationProperty file 1.0.0 ActivationFile RepositoryBase 1.0.0 id 1.0.0 String name 1.0.0 String url 1.0.0 String layout 1.0.0 The type of layout this repository uses for locating and storing artifacts - can be "legacy" or "default". String default 1.0.0 Repository RepositoryBase 1.0.0 Repository contains the information needed for establishing connections with remote repository releases 1.0.0 How to handle downloading of releases from this repository RepositoryPolicy snapshots 1.0.0 How to handle downloading of snapshots from this repository RepositoryPolicy 1.0.0 RepositoryPolicy 1.0.0 Download policy enabled 1.0.0 Whether to use this repository for downloading this type of artifact boolean true updatePolicy 1.0.0 The frequency for downloading updates - can be "always", "daily" (default), "interval:XXX" (in minutes) or "never" (only if it doesn't exist locally). String checksumPolicy 1.0.0 What to do when verification of an artifact checksum fails - warn, fail, etc. Valid values are "fail" or "warn" String ActivationProperty 1.0.0 name 1.0.0 String true The name of the property to be used to activate a profile value 1.0.0 String The value of the property to be used to activate a profile ActivationFile 1.0.0 missing 1.0.0 String The name of the file that should be missing to activate a profile exists 1.0.0 String The name of the file that should exist to activate a profile ActivationOS 1.0.0 name 1.0.0 String The name of the OS to be used to activate a profile family 1.0.0 String The general family of the OS to be used to activate a profile (e.g. 'windows') arch 1.0.0 String The architecture of the OS to be used to activate a profile version 1.0.0 String The version of the OS to be used to activate a profile maven-maven-3.5.2/maven-compat/src/main/resources/000077500000000000000000000000001317160430700220515ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/main/resources/META-INF/000077500000000000000000000000001317160430700232115ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/main/resources/META-INF/maven/000077500000000000000000000000001317160430700243175ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/main/resources/META-INF/maven/plugin-expressions/000077500000000000000000000000001317160430700301755ustar00rootroot00000000000000project.paramdoc.xml000066400000000000000000000130671317160430700341020ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/main/resources/META-INF/maven/plugin-expressions project.distributionManagementArtifactRepository repo Repository Name scp://host/path/to/repo repo Repository Name scp://host/path/to/repo ]]> This is the ArtifactRepository used to deploy artifacts built by this Maven. project.artifact project.group project-artifact 0.0.0.0 type ]]> This is the Artifact instance created from the essential project attributes: groupId, artifactId, version, and packaging (with a default packaging of 'jar'). project.parent project.group project-artifact 0.0.0.0 ]]> This is the MavenProject instance for the parent of the current POM. project.file This is the File instance that refers to the location of the current POM on disk. project.artifacts ... ]]> project.parentArtifact project.group project-artifact 0.0.0.0 ]]> This is the Artifact instance for the parent of the current POM. project.pluginArtifacts ... ]]> project.remoteArtifactRepositories ... ]]> project.pluginArtifactRepositories ... ]]> project.attachedArtifacts rootless.paramdoc.xml000066400000000000000000000035231317160430700343020ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/main/resources/META-INF/maven/plugin-expressions localRepository /path/to/local/repository ]]> The ArtifactRepository instance referencing the local artifact repository. -Dmaven.repo.local=/path/to/local/repo Override the local repository location on a per-build basis. reactorProjects This is the current list of projects being built by Maven. settings.paramdoc.xml000066400000000000000000000040241317160430700342650ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/main/resources/META-INF/maven/plugin-expressions settings.offline true ]]> settings.interactiveMode true ]]> maven-maven-3.5.2/maven-compat/src/main/resources/META-INF/maven/plugin.xml000066400000000000000000000225071317160430700263450ustar00rootroot00000000000000 Maven Internal State-Management Plugins org.apache.maven.plugins.internal maven-state-management 2.1 statemgmt false true start-fork Setup the appropriate build state to initiate a forked execution. false false false false false true org.apache.maven.lifecycle.statemgmt.StartForkedExecutionMojo java per-lookup once-per-session project org.apache.maven.project.MavenProject true false The current MavenProject instance, which will have a new executionProject set after execution. session org.apache.maven.execution.MavenSession true false The current MavenSession instance, which will handle the fork context. forkId int true true The current fork identifier. ${forkId} end-fork Restore the non-fork currentProject instance, for use in the forking mojo. false false false false false true org.apache.maven.lifecycle.statemgmt.EndForkedExecutionMojo java per-lookup once-per-session session org.apache.maven.execution.MavenSession true false The current MavenSession instance, which will handle the fork context. forkId int true true The current fork identifier. ${forkId} clear-fork-context Tear down any build state used during the previous forked execution. false false false false false true org.apache.maven.lifecycle.statemgmt.ClearForkedContextMojo java per-lookup once-per-session project org.apache.maven.project.MavenProject true false The current MavenProject instance, which will have the current executionProject cleared after execution. forkId int true true The current fork identifier. ${forkId} resolve-late-bound-plugin Resolve a late-bound plugin during a build, right before it is to be used. false false false false false true org.apache.maven.lifecycle.statemgmt.ResolveLateBoundPluginMojo java per-lookup once-per-session project org.apache.maven.project.MavenProject true false The current MavenProject instance, for building a new MojoBinding instance. session org.apache.maven.execution.MavenSession true false The current MavenSession instance, which will handle the fork context. groupId java.lang.String true true The plugin's groupId. artifactId java.lang.String true true The plugin's artifactId. version java.lang.String false true The plugin's version. goal java.lang.String true true The mojo's goal that we're looking for, as an extra validation step. ${groupId} ${artifactId} ${version} ${goal} org.apache.maven.plugin.loader.PluginLoader pluginLoader org.apache.maven.lifecycle.binding.MojoBindingFactory bindingFactory maven-maven-3.5.2/maven-compat/src/site/000077500000000000000000000000001317160430700200575ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/site/apt/000077500000000000000000000000001317160430700206435ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/site/apt/index.apt000066400000000000000000000024111317160430700224560ustar00rootroot00000000000000~~ 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 ----- 2016-05-29 ----- Maven Compat Maven2 classes maintained as compatibility layer for plugins that need to keep Maven2 compatibility. Plugins should avoid these classes and be updated to use only Maven3 dependencies (and require Maven3): see {{{https://cwiki.apache.org/confluence/display/MAVEN/Plugin+migration+to+Maven3+dependencies} Plugin migration to Maven3 dependencies}} documentation to get hints on how to make the update. maven-maven-3.5.2/maven-compat/src/site/site.xml000066400000000000000000000025231317160430700215470ustar00rootroot00000000000000 maven-maven-3.5.2/maven-compat/src/test/000077500000000000000000000000001317160430700200725ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/test/java/000077500000000000000000000000001317160430700210135ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/test/java/org/000077500000000000000000000000001317160430700216025ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/test/java/org/apache/000077500000000000000000000000001317160430700230235ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/test/java/org/apache/maven/000077500000000000000000000000001317160430700241315ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/test/java/org/apache/maven/artifact/000077500000000000000000000000001317160430700257265ustar00rootroot00000000000000AbstractArtifactComponentTestCase.java000066400000000000000000000324271317160430700352620ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/test/java/org/apache/maven/artifactpackage org.apache.maven.artifact; /* * 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 org.apache.maven.artifact.factory.ArtifactFactory; import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.repository.ArtifactRepositoryPolicy; import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout; import org.apache.maven.execution.DefaultMavenExecutionRequest; import org.apache.maven.execution.DefaultMavenExecutionResult; import org.apache.maven.execution.MavenSession; import org.apache.maven.plugin.LegacySupport; import org.apache.maven.repository.legacy.repository.ArtifactRepositoryFactory; import org.codehaus.plexus.ContainerConfiguration; import org.codehaus.plexus.PlexusConstants; import org.codehaus.plexus.PlexusTestCase; import org.eclipse.aether.DefaultRepositorySystemSession; import org.eclipse.aether.RepositorySystemSession; import org.eclipse.aether.collection.DependencyGraphTransformer; import org.eclipse.aether.collection.DependencyManager; import org.eclipse.aether.collection.DependencySelector; import org.eclipse.aether.collection.DependencyTraverser; import org.eclipse.aether.internal.impl.SimpleLocalRepositoryManagerFactory; import org.eclipse.aether.repository.LocalRepository; import org.eclipse.aether.util.graph.manager.ClassicDependencyManager; import org.eclipse.aether.util.graph.selector.AndDependencySelector; import org.eclipse.aether.util.graph.selector.ExclusionDependencySelector; import org.eclipse.aether.util.graph.selector.OptionalDependencySelector; import org.eclipse.aether.util.graph.selector.ScopeDependencySelector; import org.eclipse.aether.util.graph.transformer.ChainedDependencyGraphTransformer; import org.eclipse.aether.util.graph.transformer.ConflictResolver; import org.eclipse.aether.util.graph.transformer.JavaDependencyContextRefiner; import org.eclipse.aether.util.graph.transformer.JavaScopeDeriver; import org.eclipse.aether.util.graph.transformer.JavaScopeSelector; import org.eclipse.aether.util.graph.transformer.NearestVersionSelector; import org.eclipse.aether.util.graph.transformer.SimpleOptionalitySelector; import org.eclipse.aether.util.graph.traverser.FatArtifactTraverser; import org.eclipse.aether.util.repository.SimpleArtifactDescriptorPolicy; import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import java.io.OutputStreamWriter; import java.io.Writer; import java.util.ArrayList; import java.util.List; /** * @author Jason van Zyl */ public abstract class AbstractArtifactComponentTestCase extends PlexusTestCase { protected ArtifactFactory artifactFactory; protected ArtifactRepositoryFactory artifactRepositoryFactory; @Override protected void customizeContainerConfiguration( ContainerConfiguration containerConfiguration ) { super.customizeContainerConfiguration( containerConfiguration ); containerConfiguration.setAutoWiring( true ); containerConfiguration.setClassPathScanning( PlexusConstants.SCANNING_INDEX ); } @Override protected void setUp() throws Exception { super.setUp(); artifactFactory = lookup( ArtifactFactory.class ); artifactRepositoryFactory = lookup( ArtifactRepositoryFactory.class ); RepositorySystemSession repoSession = initRepoSession(); MavenSession session = new MavenSession( getContainer(), repoSession, new DefaultMavenExecutionRequest(), new DefaultMavenExecutionResult() ); LegacySupport legacySupport = lookup( LegacySupport.class ); legacySupport.setSession( session ); } @Override protected void tearDown() throws Exception { release( artifactFactory ); super.tearDown(); } protected abstract String component(); /** * Return an existing file, not a directory - causes creation to fail. * * @throws Exception */ protected ArtifactRepository badLocalRepository() throws Exception { String path = "target/test-repositories/" + component() + "/bad-local-repository"; File f = new File( getBasedir(), path ); f.createNewFile(); ArtifactRepositoryLayout repoLayout = (ArtifactRepositoryLayout) lookup( ArtifactRepositoryLayout.ROLE, "default" ); return artifactRepositoryFactory.createArtifactRepository( "test", "file://" + f.getPath(), repoLayout, null, null ); } protected String getRepositoryLayout() { return "default"; } protected ArtifactRepository localRepository() throws Exception { String path = "target/test-repositories/" + component() + "/local-repository"; File f = new File( getBasedir(), path ); ArtifactRepositoryLayout repoLayout = (ArtifactRepositoryLayout) lookup( ArtifactRepositoryLayout.ROLE, "default" ); return artifactRepositoryFactory.createArtifactRepository( "local", "file://" + f.getPath(), repoLayout, null, null ); } protected ArtifactRepository remoteRepository() throws Exception { String path = "target/test-repositories/" + component() + "/remote-repository"; File f = new File( getBasedir(), path ); ArtifactRepositoryLayout repoLayout = (ArtifactRepositoryLayout) lookup( ArtifactRepositoryLayout.ROLE, "default" ); return artifactRepositoryFactory.createArtifactRepository( "test", "file://" + f.getPath(), repoLayout, new ArtifactRepositoryPolicy(), new ArtifactRepositoryPolicy() ); } protected ArtifactRepository badRemoteRepository() throws Exception { ArtifactRepositoryLayout repoLayout = (ArtifactRepositoryLayout) lookup( ArtifactRepositoryLayout.ROLE, "default" ); return artifactRepositoryFactory.createArtifactRepository( "test", "http://foo.bar/repository", repoLayout, null, null ); } protected void assertRemoteArtifactPresent( Artifact artifact ) throws Exception { ArtifactRepository remoteRepo = remoteRepository(); String path = remoteRepo.pathOf( artifact ); File file = new File( remoteRepo.getBasedir(), path ); if ( !file.exists() ) { fail( "Remote artifact " + file + " should be present." ); } } protected void assertLocalArtifactPresent( Artifact artifact ) throws Exception { ArtifactRepository localRepo = localRepository(); String path = localRepo.pathOf( artifact ); File file = new File( localRepo.getBasedir(), path ); if ( !file.exists() ) { fail( "Local artifact " + file + " should be present." ); } } protected void assertRemoteArtifactNotPresent( Artifact artifact ) throws Exception { ArtifactRepository remoteRepo = remoteRepository(); String path = remoteRepo.pathOf( artifact ); File file = new File( remoteRepo.getBasedir(), path ); if ( file.exists() ) { fail( "Remote artifact " + file + " should not be present." ); } } protected void assertLocalArtifactNotPresent( Artifact artifact ) throws Exception { ArtifactRepository localRepo = localRepository(); String path = localRepo.pathOf( artifact ); File file = new File( localRepo.getBasedir(), path ); if ( file.exists() ) { fail( "Local artifact " + file + " should not be present." ); } } // ---------------------------------------------------------------------- // // ---------------------------------------------------------------------- protected List remoteRepositories() throws Exception { List remoteRepositories = new ArrayList<>(); remoteRepositories.add( remoteRepository() ); return remoteRepositories; } // ---------------------------------------------------------------------- // Test artifact generation for unit tests // ---------------------------------------------------------------------- protected Artifact createLocalArtifact( String artifactId, String version ) throws Exception { Artifact artifact = createArtifact( artifactId, version ); createArtifact( artifact, localRepository() ); return artifact; } protected Artifact createRemoteArtifact( String artifactId, String version ) throws Exception { Artifact artifact = createArtifact( artifactId, version ); createArtifact( artifact, remoteRepository() ); return artifact; } protected void createLocalArtifact( Artifact artifact ) throws Exception { createArtifact( artifact, localRepository() ); } protected void createRemoteArtifact( Artifact artifact ) throws Exception { createArtifact( artifact, remoteRepository() ); } protected void createArtifact( Artifact artifact, ArtifactRepository repository ) throws Exception { String path = repository.pathOf( artifact ); File artifactFile = new File( repository.getBasedir(), path ); if ( !artifactFile.getParentFile().exists() ) { artifactFile.getParentFile().mkdirs(); } try ( Writer writer = new OutputStreamWriter( new FileOutputStream( artifactFile ), "ISO-8859-1" ) ) { writer.write( artifact.getId() ); } } protected Artifact createArtifact( String artifactId, String version ) throws Exception { return createArtifact( artifactId, version, "jar" ); } protected Artifact createArtifact( String artifactId, String version, String type ) throws Exception { return createArtifact( "org.apache.maven", artifactId, version, type ); } protected Artifact createArtifact( String groupId, String artifactId, String version, String type ) throws Exception { Artifact a = artifactFactory.createBuildArtifact( groupId, artifactId, version, type ); return a; } protected void deleteLocalArtifact( Artifact artifact ) throws Exception { deleteArtifact( artifact, localRepository() ); } protected void deleteArtifact( Artifact artifact, ArtifactRepository repository ) throws Exception { String path = repository.pathOf( artifact ); File artifactFile = new File( repository.getBasedir(), path ); if ( artifactFile.exists() ) { if ( !artifactFile.delete() ) { throw new IOException( "Failure while attempting to delete artifact " + artifactFile ); } } } protected RepositorySystemSession initRepoSession() throws Exception { DefaultRepositorySystemSession session = new DefaultRepositorySystemSession(); session.setArtifactDescriptorPolicy( new SimpleArtifactDescriptorPolicy( true, true ) ); DependencyTraverser depTraverser = new FatArtifactTraverser(); session.setDependencyTraverser( depTraverser ); DependencyManager depManager = new ClassicDependencyManager(); session.setDependencyManager( depManager ); DependencySelector depFilter = new AndDependencySelector( new ScopeDependencySelector( "test", "provided" ), new OptionalDependencySelector(), new ExclusionDependencySelector() ); session.setDependencySelector( depFilter ); DependencyGraphTransformer transformer = new ConflictResolver( new NearestVersionSelector(), new JavaScopeSelector(), new SimpleOptionalitySelector(), new JavaScopeDeriver() ); new ChainedDependencyGraphTransformer( transformer, new JavaDependencyContextRefiner() ); session.setDependencyGraphTransformer( transformer ); LocalRepository localRepo = new LocalRepository( localRepository().getBasedir() ); session.setLocalRepositoryManager( new SimpleLocalRepositoryManagerFactory().newInstance( session, localRepo ) ); return session; } } maven-maven-3.5.2/maven-compat/src/test/java/org/apache/maven/artifact/ArtifactUtilsTest.java000066400000000000000000000053271317160430700322160ustar00rootroot00000000000000package org.apache.maven.artifact; /* * 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.util.ArrayList; import java.util.List; import java.util.Map; import org.apache.maven.artifact.versioning.VersionRange; import junit.framework.TestCase; /** * Tests {@link ArtifactUtils}. * * @author Benjamin Bentmann */ public class ArtifactUtilsTest extends TestCase { private Artifact newArtifact( String aid ) { return new DefaultArtifact( "group", aid, VersionRange.createFromVersion( "1.0" ), "test", "jar", "tests", null ); } public void testIsSnapshot() { assertEquals( false, ArtifactUtils.isSnapshot( null ) ); assertEquals( false, ArtifactUtils.isSnapshot( "" ) ); assertEquals( false, ArtifactUtils.isSnapshot( "1.2.3" ) ); assertEquals( true, ArtifactUtils.isSnapshot( "1.2.3-SNAPSHOT" ) ); assertEquals( true, ArtifactUtils.isSnapshot( "1.2.3-snapshot" ) ); assertEquals( true, ArtifactUtils.isSnapshot( "1.2.3-20090413.094722-2" ) ); } public void testToSnapshotVersion() { assertEquals( "1.2.3", ArtifactUtils.toSnapshotVersion( "1.2.3" ) ); assertEquals( "1.2.3-SNAPSHOT", ArtifactUtils.toSnapshotVersion( "1.2.3-SNAPSHOT" ) ); assertEquals( "1.2.3-SNAPSHOT", ArtifactUtils.toSnapshotVersion( "1.2.3-20090413.094722-2" ) ); } /** * Tests that the ordering of the map resembles the ordering of the input collection of artifacts. */ public void testArtifactMapByVersionlessIdOrdering() throws Exception { List list = new ArrayList<>(); list.add( newArtifact( "b" ) ); list.add( newArtifact( "a" ) ); list.add( newArtifact( "c" ) ); list.add( newArtifact( "e" ) ); list.add( newArtifact( "d" ) ); Map map = ArtifactUtils.artifactMapByVersionlessId( list ); assertNotNull( map ); assertEquals( list, new ArrayList<>( map.values() ) ); } } maven-maven-3.5.2/maven-compat/src/test/java/org/apache/maven/artifact/DefaultArtifactTest.java000066400000000000000000000126771317160430700325100ustar00rootroot00000000000000package org.apache.maven.artifact; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import junit.framework.TestCase; import org.apache.maven.artifact.handler.ArtifactHandlerMock; import org.apache.maven.artifact.versioning.VersionRange; public class DefaultArtifactTest extends TestCase { private DefaultArtifact artifact; private DefaultArtifact snapshotArtifact; private String groupId = "groupid", artifactId = "artifactId", version = "1.0", scope = "artifactScope", type = "type", classifier = "classifier"; private String snapshotSpecVersion = "1.0-SNAPSHOT"; private String snapshotResolvedVersion = "1.0-20070606.010101-1"; private VersionRange versionRange; private VersionRange snapshotVersionRange; private ArtifactHandlerMock artifactHandler; protected void setUp() throws Exception { super.setUp(); artifactHandler = new ArtifactHandlerMock(); versionRange = VersionRange.createFromVersion( version ); artifact = new DefaultArtifact( groupId, artifactId, versionRange, scope, type, classifier, artifactHandler ); snapshotVersionRange = VersionRange.createFromVersion( snapshotResolvedVersion ); snapshotArtifact = new DefaultArtifact( groupId, artifactId, snapshotVersionRange, scope, type, classifier, artifactHandler ); } public void testGetVersionReturnsResolvedVersionOnSnapshot() { assertEquals( snapshotResolvedVersion, snapshotArtifact.getVersion() ); // this is FOUL! // snapshotArtifact.isSnapshot(); assertEquals( snapshotSpecVersion, snapshotArtifact.getBaseVersion() ); } public void testGetDependencyConflictId() { assertEquals( groupId + ":" + artifactId + ":" + type + ":" + classifier, artifact.getDependencyConflictId() ); } public void testGetDependencyConflictIdNullGroupId() { artifact.setGroupId( null ); assertEquals( null + ":" + artifactId + ":" + type + ":" + classifier, artifact.getDependencyConflictId() ); } public void testGetDependencyConflictIdNullClassifier() { artifact = new DefaultArtifact( groupId, artifactId, versionRange, scope, type, null, artifactHandler ); assertEquals( groupId + ":" + artifactId + ":" + type, artifact.getDependencyConflictId() ); } public void testGetDependencyConflictIdNullScope() { artifact.setScope( null ); assertEquals( groupId + ":" + artifactId + ":" + type + ":" + classifier, artifact.getDependencyConflictId() ); } public void testToString() { assertEquals( groupId + ":" + artifactId + ":" + type + ":" + classifier + ":" + version + ":" + scope, artifact.toString() ); } public void testToStringNullGroupId() { artifact.setGroupId( null ); assertEquals( artifactId + ":" + type + ":" + classifier + ":" + version + ":" + scope, artifact.toString() ); } public void testToStringNullClassifier() { artifact = new DefaultArtifact( groupId, artifactId, versionRange, scope, type, null, artifactHandler ); assertEquals( groupId + ":" + artifactId + ":" + type + ":" + version + ":" + scope, artifact.toString() ); } public void testToStringNullScope() { artifact.setScope( null ); assertEquals( groupId + ":" + artifactId + ":" + type + ":" + classifier + ":" + version, artifact.toString() ); } public void testComparisonByVersion() { Artifact artifact1 = new DefaultArtifact( groupId, artifactId, VersionRange.createFromVersion( "5.0" ), scope, type, classifier, artifactHandler ); Artifact artifact2 = new DefaultArtifact( groupId, artifactId, VersionRange.createFromVersion( "12.0" ), scope, type, classifier, artifactHandler ); assertTrue( artifact1.compareTo( artifact2 ) < 0 ); assertTrue( artifact2.compareTo( artifact1 ) > 0 ); Artifact artifact = new DefaultArtifact( groupId, artifactId, VersionRange.createFromVersion( "5.0" ), scope, type, classifier, artifactHandler ); assertTrue( artifact.compareTo( artifact1 ) == 0 ); assertTrue( artifact1.compareTo( artifact ) == 0 ); } public void testNonResolvedVersionRangeConsistentlyYieldsNullVersions() throws Exception { VersionRange vr = VersionRange.createFromVersionSpec( "[1.0,2.0)" ); artifact = new DefaultArtifact( groupId, artifactId, vr, scope, type, null, artifactHandler ); assertEquals( null, artifact.getVersion() ); assertEquals( null, artifact.getBaseVersion() ); } } maven-maven-3.5.2/maven-compat/src/test/java/org/apache/maven/artifact/deployer/000077500000000000000000000000001317160430700275515ustar00rootroot00000000000000ArtifactDeployerTest.java000066400000000000000000000044451317160430700344450ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/test/java/org/apache/maven/artifact/deployerpackage org.apache.maven.artifact.deployer; /* * 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.File; import org.apache.maven.artifact.AbstractArtifactComponentTestCase; import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.repository.ArtifactRepository; import org.codehaus.plexus.util.FileUtils; /** * @author Jason van Zyl */ public class ArtifactDeployerTest extends AbstractArtifactComponentTestCase { private ArtifactDeployer artifactDeployer; protected void setUp() throws Exception { super.setUp(); artifactDeployer = (ArtifactDeployer) lookup( ArtifactDeployer.ROLE ); } protected String component() { return "deployer"; } public void testArtifactInstallation() throws Exception { String artifactBasedir = new File( getBasedir(), "src/test/resources/artifact-install" ).getAbsolutePath(); Artifact artifact = createArtifact( "artifact", "1.0" ); File file = new File( artifactBasedir, "artifact-1.0.jar" ); assertEquals( "dummy", FileUtils.fileRead( file, "UTF-8" ).trim() ); artifactDeployer.deploy( file, artifact, remoteRepository(), localRepository() ); ArtifactRepository remoteRepository = remoteRepository(); File deployedFile = new File( remoteRepository.getBasedir(), remoteRepository.pathOf( artifact ) ); assertTrue( deployedFile.exists() ); assertEquals( "dummy", FileUtils.fileRead( deployedFile, "UTF-8" ).trim() ); } }SimpleArtifactMetadataSource.java000066400000000000000000000057431317160430700360770ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/test/java/org/apache/maven/artifact/deployerpackage org.apache.maven.artifact.deployer; /* * 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.util.Collections; import java.util.List; import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.versioning.ArtifactVersion; import org.apache.maven.artifact.versioning.DefaultArtifactVersion; import org.apache.maven.repository.legacy.metadata.ArtifactMetadataRetrievalException; import org.apache.maven.repository.legacy.metadata.ArtifactMetadataSource; import org.apache.maven.repository.legacy.metadata.MetadataResolutionRequest; import org.apache.maven.repository.legacy.metadata.ResolutionGroup; /** @author Jason van Zyl */ public class SimpleArtifactMetadataSource implements ArtifactMetadataSource { public ResolutionGroup retrieve( Artifact artifact, ArtifactRepository localRepository, List remoteRepositories ) throws ArtifactMetadataRetrievalException { throw new UnsupportedOperationException( "Cannot retrieve metadata in this test case" ); } public List retrieveAvailableVersions( Artifact artifact, ArtifactRepository localRepository, List remoteRepositories ) throws ArtifactMetadataRetrievalException { return Collections.singletonList( new DefaultArtifactVersion( "10.1.3" ) ); } public List retrieveAvailableVersionsFromDeploymentRepository( Artifact artifact, ArtifactRepository localRepository, ArtifactRepository remoteRepository ) throws ArtifactMetadataRetrievalException { return Collections.singletonList( new DefaultArtifactVersion( "10.1.3" ) ); } public ResolutionGroup retrieve( MetadataResolutionRequest request ) throws ArtifactMetadataRetrievalException { return retrieve( request.getArtifact(), request.getLocalRepository(), request.getRemoteRepositories() ); } } maven-maven-3.5.2/maven-compat/src/test/java/org/apache/maven/artifact/factory/000077500000000000000000000000001317160430700273755ustar00rootroot00000000000000DefaultArtifactFactoryTest.java000066400000000000000000000046051317160430700354200ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/test/java/org/apache/maven/artifact/factorypackage org.apache.maven.artifact.factory; /* * 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 org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.versioning.VersionRange; import org.codehaus.plexus.PlexusTestCase; public class DefaultArtifactFactoryTest extends PlexusTestCase { public void testPropagationOfSystemScopeRegardlessOfInheritedScope() throws Exception { ArtifactFactory factory = (ArtifactFactory) lookup( ArtifactFactory.ROLE ); Artifact artifact = factory.createDependencyArtifact( "test-grp", "test-artifact", VersionRange.createFromVersion("1.0"), "type", null, "system", "provided" ); Artifact artifact2 = factory.createDependencyArtifact( "test-grp", "test-artifact-2", VersionRange.createFromVersion("1.0"), "type", null, "system", "test" ); Artifact artifact3 = factory.createDependencyArtifact( "test-grp", "test-artifact-3", VersionRange.createFromVersion("1.0"), "type", null, "system", "runtime" ); Artifact artifact4 = factory.createDependencyArtifact( "test-grp", "test-artifact-4", VersionRange.createFromVersion("1.0"), "type", null, "system", "compile" ); // this one should never happen in practice... Artifact artifact5 = factory.createDependencyArtifact( "test-grp", "test-artifact-5", VersionRange.createFromVersion("1.0"), "type", null, "system", "system" ); assertEquals( "system", artifact.getScope() ); assertEquals( "system", artifact2.getScope() ); assertEquals( "system", artifact3.getScope() ); assertEquals( "system", artifact4.getScope() ); assertEquals( "system", artifact5.getScope() ); } } maven-maven-3.5.2/maven-compat/src/test/java/org/apache/maven/artifact/handler/000077500000000000000000000000001317160430700273435ustar00rootroot00000000000000ArtifactHandlerMock.java000066400000000000000000000044651317160430700340050ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/test/java/org/apache/maven/artifact/handlerpackage org.apache.maven.artifact.handler; /* * 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. */ public class ArtifactHandlerMock implements ArtifactHandler { private String extension, directory, classifier, packaging, language; private boolean includesDependencies, addedToClasspath; public void setExtension( String extension ) { this.extension = extension; } public String getExtension() { return extension; } public void setDirectory( String directory ) { this.directory = directory; } public String getDirectory() { return directory; } public void setClassifier( String classifier ) { this.classifier = classifier; } public String getClassifier() { return classifier; } public void setPackaging( String packaging ) { this.packaging = packaging; } public String getPackaging() { return packaging; } public void setIncludesDependencies( boolean includesDependencies ) { this.includesDependencies = includesDependencies; } public boolean isIncludesDependencies() { return includesDependencies; } public void setLanguage( String language ) { this.language = language; } public String getLanguage() { return language; } public void setAddedToClasspath( boolean addedToClasspath ) { this.addedToClasspath = addedToClasspath; } public boolean isAddedToClasspath() { return addedToClasspath; } } maven-maven-3.5.2/maven-compat/src/test/java/org/apache/maven/artifact/installer/000077500000000000000000000000001317160430700277235ustar00rootroot00000000000000ArtifactInstallerTest.java000066400000000000000000000035471317160430700347730ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/test/java/org/apache/maven/artifact/installerpackage org.apache.maven.artifact.installer; /* * 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.File; import org.apache.maven.artifact.AbstractArtifactComponentTestCase; import org.apache.maven.artifact.Artifact; /** * @author Jason van Zyl */ public class ArtifactInstallerTest extends AbstractArtifactComponentTestCase { private ArtifactInstaller artifactInstaller; protected void setUp() throws Exception { super.setUp(); artifactInstaller = (ArtifactInstaller) lookup( ArtifactInstaller.ROLE ); } protected String component() { return "installer"; } public void testArtifactInstallation() throws Exception { String artifactBasedir = new File( getBasedir(), "src/test/resources/artifact-install" ).getAbsolutePath(); Artifact artifact = createArtifact( "artifact", "1.0" ); File source = new File( artifactBasedir, "artifact-1.0.jar" ); artifactInstaller.install( source, artifact, localRepository() ); assertLocalArtifactPresent( artifact ); } }maven-maven-3.5.2/maven-compat/src/test/java/org/apache/maven/artifact/metadata/000077500000000000000000000000001317160430700275065ustar00rootroot00000000000000TestMetadataSource.java000066400000000000000000000076111317160430700340400ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/test/java/org/apache/maven/artifact/metadatapackage org.apache.maven.artifact.metadata; /* * 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.util.HashSet; import java.util.List; import java.util.Set; import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.factory.ArtifactFactory; import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.versioning.ArtifactVersion; import org.apache.maven.repository.legacy.metadata.MetadataResolutionRequest; import org.codehaus.plexus.component.annotations.Component; import org.codehaus.plexus.component.annotations.Requirement; @Component(role = ArtifactMetadataSource.class, hint="test") public class TestMetadataSource implements ArtifactMetadataSource { @Requirement private ArtifactFactory factory; public ResolutionGroup retrieve( Artifact artifact, ArtifactRepository localRepository, List remoteRepositories ) throws ArtifactMetadataRetrievalException { Set dependencies = new HashSet<>(); if ( "g".equals( artifact.getArtifactId() ) ) { Artifact a = null; try { a = factory.createBuildArtifact( "org.apache.maven", "h", "1.0", "jar" ); dependencies.add( a ); } catch ( Exception e ) { throw new ArtifactMetadataRetrievalException( "Error retrieving metadata", e, a ); } } if ( "i".equals( artifact.getArtifactId() ) ) { Artifact a = null; try { a = factory.createBuildArtifact( "org.apache.maven", "j", "1.0-SNAPSHOT", "jar" ); dependencies.add( a ); } catch ( Exception e ) { throw new ArtifactMetadataRetrievalException( "Error retrieving metadata", e, a ); } } return new ResolutionGroup( artifact, dependencies, remoteRepositories ); } public List retrieveAvailableVersions( Artifact artifact, ArtifactRepository localRepository, List remoteRepositories ) throws ArtifactMetadataRetrievalException { throw new UnsupportedOperationException( "Cannot get available versions in this test case" ); } public List retrieveAvailableVersionsFromDeploymentRepository( Artifact artifact, ArtifactRepository localRepository, ArtifactRepository remoteRepository ) throws ArtifactMetadataRetrievalException { throw new UnsupportedOperationException( "Cannot get available versions in this test case" ); } public ResolutionGroup retrieve( MetadataResolutionRequest request ) throws ArtifactMetadataRetrievalException { return retrieve( request.getArtifact(), request.getLocalRepository(), request.getRemoteRepositories() ); } public List retrieveAvailableVersions( MetadataResolutionRequest request ) throws ArtifactMetadataRetrievalException { return retrieveAvailableVersions( request.getArtifact(), request.getLocalRepository(), request.getRemoteRepositories() ); } } maven-maven-3.5.2/maven-compat/src/test/java/org/apache/maven/artifact/repository/000077500000000000000000000000001317160430700301455ustar00rootroot00000000000000MavenArtifactRepositoryTest.java000066400000000000000000000035131317160430700364170ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/test/java/org/apache/maven/artifact/repositorypackage org.apache.maven.artifact.repository; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import junit.framework.TestCase; public class MavenArtifactRepositoryTest extends TestCase { private static class MavenArtifactRepositorySubclass extends MavenArtifactRepository { String id; public MavenArtifactRepositorySubclass(String id) { this.id = id; } @Override public String getId() { return id; } } public void testHashCodeEquals() { MavenArtifactRepositorySubclass r1 = new MavenArtifactRepositorySubclass( "foo" ); MavenArtifactRepositorySubclass r2 = new MavenArtifactRepositorySubclass( "foo" ); MavenArtifactRepositorySubclass r3 = new MavenArtifactRepositorySubclass( "bar" ); assertTrue( r1.hashCode() == r2.hashCode() ); assertFalse( r1.hashCode() == r3.hashCode() ); assertTrue( r1.equals( r2 ) ); assertTrue( r2.equals( r1 ) ); assertFalse( r1.equals( r3 ) ); assertFalse( r3.equals( r1 ) ); } } maven-maven-3.5.2/maven-compat/src/test/java/org/apache/maven/artifact/resolver/000077500000000000000000000000001317160430700275675ustar00rootroot00000000000000ArtifactResolutionExceptionTest.java000066400000000000000000000056131317160430700367200ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/test/java/org/apache/maven/artifact/resolverpackage org.apache.maven.artifact.resolver; /* * 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.util.Arrays; import java.util.List; import junit.framework.TestCase; /** * Test the artifact resolution exception message * * @author Mauro Talevi */ public class ArtifactResolutionExceptionTest extends TestCase { private static final String LS = System.getProperty( "line.separator" ); public void testMissingArtifactMessageFormat() { String message = "Missing artifact"; String indentation = " "; String groupId = "aGroupId"; String artifactId = "anArtifactId"; String version = "aVersion"; String type = "jar"; String classifier = "aClassifier"; String downloadUrl = "http://somewhere.com/download"; List path = Arrays.asList( "dependency1", "dependency2" ); String expected = "Missing artifact" + LS + LS + " Try downloading the file manually from: " + LS + " http://somewhere.com/download" + LS + LS + " Then, install it using the command: " + LS + " mvn install:install-file -DgroupId=aGroupId -DartifactId=anArtifactId -Dversion=aVersion " + "-Dclassifier=aClassifier -Dpackaging=jar -Dfile=/path/to/file" + LS + LS + " Alternatively, if you host your own repository you can deploy the file there: " + LS + " mvn deploy:deploy-file -DgroupId=aGroupId -DartifactId=anArtifactId" + " -Dversion=aVersion -Dclassifier=aClassifier -Dpackaging=jar -Dfile=/path/to/file" + " -Durl=[url] -DrepositoryId=[id]" + LS + LS + " Path to dependency: " + LS + " \t1) dependency1" + LS + " \t2) dependency2" + LS + LS; String actual = AbstractArtifactResolutionException.constructMissingArtifactMessage( message, indentation, groupId, artifactId, version, type, classifier, downloadUrl, path ); assertEquals( expected, actual ); } } ArtifactResolverTest.java000066400000000000000000000235411317160430700344770ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/test/java/org/apache/maven/artifact/resolverpackage org.apache.maven.artifact.resolver; /* * 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.util.ArrayList; import java.util.Collections; import java.util.HashSet; import java.util.Iterator; import java.util.LinkedHashSet; import java.util.List; import java.util.Set; import org.apache.maven.artifact.AbstractArtifactComponentTestCase; import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException; import org.apache.maven.artifact.metadata.ArtifactMetadataSource; import org.apache.maven.artifact.metadata.ResolutionGroup; import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.versioning.ArtifactVersion; import org.apache.maven.repository.legacy.metadata.MetadataResolutionRequest; // It would be cool if there was a hook that i could use to setup a test environment. // I want to setup a local/remote repositories for testing but i don't want to have // to change them when i change the layout of the repositories. So i want to generate // the structure i want to test by using the artifact handler manager which dictates // the layout used for a particular artifact type. /** * @author Jason van Zyl */ public class ArtifactResolverTest extends AbstractArtifactComponentTestCase { private DefaultArtifactResolver artifactResolver; private Artifact projectArtifact; @Override protected void setUp() throws Exception { super.setUp(); artifactResolver = (DefaultArtifactResolver) lookup( ArtifactResolver.class ); projectArtifact = createLocalArtifact( "project", "3.0" ); } @Override protected void tearDown() throws Exception { artifactFactory = null; projectArtifact = null; super.tearDown(); } @Override protected String component() { return "resolver"; } public void testResolutionOfASingleArtifactWhereTheArtifactIsPresentInTheLocalRepository() throws Exception { Artifact a = createLocalArtifact( "a", "1.0" ); artifactResolver.resolve( a, remoteRepositories(), localRepository() ); assertLocalArtifactPresent( a ); } public void testResolutionOfASingleArtifactWhereTheArtifactIsNotPresentLocallyAndMustBeRetrievedFromTheRemoteRepository() throws Exception { Artifact b = createRemoteArtifact( "b", "1.0-SNAPSHOT" ); deleteLocalArtifact( b ); artifactResolver.resolve( b, remoteRepositories(), localRepository() ); assertLocalArtifactPresent( b ); } @Override protected Artifact createArtifact( String groupId, String artifactId, String version, String type ) throws Exception { // for the anonymous classes return super.createArtifact( groupId, artifactId, version, type ); } public void testTransitiveResolutionWhereAllArtifactsArePresentInTheLocalRepository() throws Exception { Artifact g = createLocalArtifact( "g", "1.0" ); Artifact h = createLocalArtifact( "h", "1.0" ); ArtifactResolutionResult result = artifactResolver.resolveTransitively( Collections.singleton( g ), projectArtifact, remoteRepositories(), localRepository(), null ); printErrors( result ); assertEquals( 2, result.getArtifacts().size() ); assertTrue( result.getArtifacts().contains( g ) ); assertTrue( result.getArtifacts().contains( h ) ); assertLocalArtifactPresent( g ); assertLocalArtifactPresent( h ); } public void testTransitiveResolutionWhereAllArtifactsAreNotPresentInTheLocalRepositoryAndMustBeRetrievedFromTheRemoteRepository() throws Exception { Artifact i = createRemoteArtifact( "i", "1.0-SNAPSHOT" ); deleteLocalArtifact( i ); Artifact j = createRemoteArtifact( "j", "1.0-SNAPSHOT" ); deleteLocalArtifact( j ); ArtifactResolutionResult result = artifactResolver.resolveTransitively( Collections.singleton( i ), projectArtifact, remoteRepositories(), localRepository(), null ); printErrors( result ); assertEquals( 2, result.getArtifacts().size() ); assertTrue( result.getArtifacts().contains( i ) ); assertTrue( result.getArtifacts().contains( j ) ); assertLocalArtifactPresent( i ); assertLocalArtifactPresent( j ); } public void testResolutionFailureWhenArtifactNotPresentInRemoteRepository() throws Exception { Artifact k = createArtifact( "k", "1.0" ); try { artifactResolver.resolve( k, remoteRepositories(), localRepository() ); fail( "Resolution succeeded when it should have failed" ); } catch ( ArtifactNotFoundException expected ) { assertTrue( true ); } } public void testResolutionOfAnArtifactWhereOneRemoteRepositoryIsBadButOneIsGood() throws Exception { Artifact l = createRemoteArtifact( "l", "1.0-SNAPSHOT" ); deleteLocalArtifact( l ); List repositories = new ArrayList<>(); repositories.add( remoteRepository() ); repositories.add( badRemoteRepository() ); artifactResolver.resolve( l, repositories, localRepository() ); assertLocalArtifactPresent( l ); } public void testTransitiveResolutionOrder() throws Exception { Artifact m = createLocalArtifact( "m", "1.0" ); Artifact n = createLocalArtifact( "n", "1.0" ); ArtifactMetadataSource mds = new ArtifactMetadataSource() { public ResolutionGroup retrieve( Artifact artifact, ArtifactRepository localRepository, List remoteRepositories ) throws ArtifactMetadataRetrievalException { Set dependencies = new HashSet<>(); return new ResolutionGroup( artifact, dependencies, remoteRepositories ); } public List retrieveAvailableVersions( Artifact artifact, ArtifactRepository localRepository, List remoteRepositories ) throws ArtifactMetadataRetrievalException { throw new UnsupportedOperationException( "Cannot get available versions in this test case" ); } public List retrieveAvailableVersionsFromDeploymentRepository( Artifact artifact, ArtifactRepository localRepository, ArtifactRepository remoteRepository ) throws ArtifactMetadataRetrievalException { throw new UnsupportedOperationException( "Cannot get available versions in this test case" ); } public ResolutionGroup retrieve( MetadataResolutionRequest request ) throws ArtifactMetadataRetrievalException { return retrieve( request.getArtifact(), request.getLocalRepository(), request.getRemoteRepositories() ); } public List retrieveAvailableVersions( MetadataResolutionRequest request ) throws ArtifactMetadataRetrievalException { return retrieveAvailableVersions( request.getArtifact(), request.getLocalRepository(), request.getRemoteRepositories() ); } }; ArtifactResolutionResult result = null; Set set = new LinkedHashSet<>(); set.add( n ); set.add( m ); result = artifactResolver.resolveTransitively( set, projectArtifact, remoteRepositories(), localRepository(), mds ); printErrors( result ); Iterator i = result.getArtifacts().iterator(); assertEquals( "n should be first", n, i.next() ); assertEquals( "m should be second", m, i.next() ); // inverse order set = new LinkedHashSet<>(); set.add( m ); set.add( n ); result = artifactResolver.resolveTransitively( set, projectArtifact, remoteRepositories(), localRepository(), mds ); printErrors( result ); i = result.getArtifacts().iterator(); assertEquals( "m should be first", m, i.next() ); assertEquals( "n should be second", n, i.next() ); } private void printErrors( ArtifactResolutionResult result ) { if ( result.hasMissingArtifacts() ) { for ( Artifact artifact : result.getMissingArtifacts() ) { System.err.println( "Missing: " + artifact ); } } if ( result.hasExceptions() ) { for ( Exception e : result.getExceptions() ) { e.printStackTrace(); } } } } DefaultArtifactResolverTest.java000066400000000000000000000063701317160430700360050ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/test/java/org/apache/maven/artifact/resolverpackage org.apache.maven.artifact.resolver; /* * 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.util.Collections; import org.apache.maven.artifact.AbstractArtifactComponentTestCase; import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.resolver.DefaultArtifactResolver.DaemonThreadCreator; public class DefaultArtifactResolverTest extends AbstractArtifactComponentTestCase { private DefaultArtifactResolver artifactResolver; private Artifact projectArtifact; @Override protected void setUp() throws Exception { super.setUp(); artifactResolver = (DefaultArtifactResolver) lookup( ArtifactResolver.class ); projectArtifact = createLocalArtifact( "project", "3.0" ); } @Override protected void tearDown() throws Exception { artifactFactory = null; projectArtifact = null; super.tearDown(); } @Override protected String component() { return "resolver"; } public void testMNG4738() throws Exception { Artifact g = createLocalArtifact( "g", "1.0" ); createLocalArtifact( "h", "1.0" ); artifactResolver.resolveTransitively( Collections.singleton( g ), projectArtifact, remoteRepositories(), localRepository(), null ); // we want to see all top-level thread groups ThreadGroup tg = Thread.currentThread().getThreadGroup(); while ( tg.getParent() == null ) { tg = tg.getParent(); } ThreadGroup[] tgList = new ThreadGroup[tg.activeGroupCount()]; tg.enumerate( tgList ); boolean seen = false; for ( ThreadGroup aTgList : tgList ) { if ( !aTgList.getName().equals( DaemonThreadCreator.THREADGROUP_NAME ) ) { continue; } seen = true; tg = aTgList; Thread[] ts = new Thread[tg.activeCount()]; tg.enumerate( ts ); for ( Thread active : ts ) { String name = active.getName(); boolean daemon = active.isDaemon(); assertTrue( name + " is no daemon Thread.", daemon ); } } assertTrue( "Could not find ThreadGroup: " + DaemonThreadCreator.THREADGROUP_NAME, seen ); } public void testLookup() throws Exception { ArtifactResolver resolver = lookup( ArtifactResolver.class, "default" ); } } maven-maven-3.5.2/maven-compat/src/test/java/org/apache/maven/artifact/resolver/TestFileWagon.java000066400000000000000000000061231317160430700331470ustar00rootroot00000000000000package org.apache.maven.artifact.resolver; /* * 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.File; import java.io.InputStream; import org.apache.maven.wagon.ResourceDoesNotExistException; import org.apache.maven.wagon.TransferFailedException; import org.apache.maven.wagon.authorization.AuthorizationException; import org.apache.maven.wagon.events.TransferListener; import org.apache.maven.wagon.providers.file.FileWagon; import org.apache.maven.wagon.resource.Resource; /** * Wagon used for test cases that annotates some methods. Note that this is not a thread-safe implementation. */ public class TestFileWagon extends FileWagon { private TestTransferListener testTransferListener; private boolean insideGet; protected void getTransfer( Resource resource, File destination, InputStream input, boolean closeInput, int maxSize ) throws TransferFailedException { addTransfer( "getTransfer " + resource.getName() ); super.getTransfer( resource, destination, input, closeInput, maxSize ); } public void get( String resourceName, File destination ) throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException { addTransfer( "get " + resourceName ); insideGet = true; super.get( resourceName, destination ); insideGet = false; } private void addTransfer( String resourceName ) { if ( testTransferListener != null ) { testTransferListener.addTransfer( resourceName ); } } public boolean getIfNewer( String resourceName, File destination, long timestamp ) throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException { if ( !insideGet ) { addTransfer( "getIfNewer " + resourceName ); } return super.getIfNewer( resourceName, destination, timestamp ); } public void addTransferListener( TransferListener listener ) { if ( listener instanceof TestTransferListener ) { testTransferListener = (TestTransferListener) listener; } super.addTransferListener( listener ); } } TestTransferListener.java000066400000000000000000000023741317160430700345130ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/test/java/org/apache/maven/artifact/resolverpackage org.apache.maven.artifact.resolver; /* * 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.util.ArrayList; import java.util.List; import org.apache.maven.wagon.observers.AbstractTransferListener; public class TestTransferListener extends AbstractTransferListener { private final List transfers = new ArrayList<>(); public List getTransfers() { return transfers; } public void addTransfer( String name ) { transfers.add( name ); } } maven-maven-3.5.2/maven-compat/src/test/java/org/apache/maven/artifact/resolver/filter/000077500000000000000000000000001317160430700310545ustar00rootroot00000000000000AndArtifactFilterTest.java000066400000000000000000000033741317160430700360350ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/test/java/org/apache/maven/artifact/resolver/filterpackage org.apache.maven.artifact.resolver.filter; /* * 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.util.Arrays; import org.apache.maven.artifact.Artifact; import junit.framework.TestCase; /** * Tests {@link AndArtifactFilter}. * * @author Benjamin Bentmann */ public class AndArtifactFilterTest extends TestCase { private ArtifactFilter newSubFilter() { return new ArtifactFilter() { public boolean include( Artifact artifact ) { return false; } }; } public void testEquals() { AndArtifactFilter filter1 = new AndArtifactFilter(); AndArtifactFilter filter2 = new AndArtifactFilter( Arrays.asList( newSubFilter() ) ); assertFalse( filter1.equals( null ) ); assertTrue( filter1.equals( filter1 ) ); assertEquals( filter1.hashCode(), filter1.hashCode() ); assertFalse( filter1.equals( filter2 ) ); assertFalse( filter2.equals( filter1 ) ); } } FilterHashEqualsTest.java000066400000000000000000000031521317160430700357050ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/test/java/org/apache/maven/artifact/resolver/filterpackage org.apache.maven.artifact.resolver.filter; /* * 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.util.Arrays; import java.util.List; import junit.framework.TestCase; /** * @author Igor Fedorenko */ public class FilterHashEqualsTest extends TestCase { public void testIncludesExcludesArtifactFilter() { List patterns = Arrays.asList( "c", "d", "e" ); IncludesArtifactFilter f1 = new IncludesArtifactFilter( patterns ); IncludesArtifactFilter f2 = new IncludesArtifactFilter( patterns ); assertTrue( f1.equals(f2) ); assertTrue( f2.equals(f1) ); assertTrue( f1.hashCode() == f2.hashCode() ); IncludesArtifactFilter f3 = new IncludesArtifactFilter( Arrays.asList( "d", "c", "e" ) ); assertTrue( f1.equals( f3 ) ); assertTrue( f1.hashCode() == f3.hashCode() ); } } OrArtifactFilterTest.java000066400000000000000000000033661317160430700357140ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/test/java/org/apache/maven/artifact/resolver/filterpackage org.apache.maven.artifact.resolver.filter; /* * 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.util.Arrays; import org.apache.maven.artifact.Artifact; import junit.framework.TestCase; /** * Tests {@link OrArtifactFilter}. * * @author Benjamin Bentmann */ public class OrArtifactFilterTest extends TestCase { private ArtifactFilter newSubFilter() { return new ArtifactFilter() { public boolean include( Artifact artifact ) { return false; } }; } public void testEquals() { OrArtifactFilter filter1 = new OrArtifactFilter(); OrArtifactFilter filter2 = new OrArtifactFilter( Arrays.asList( newSubFilter() ) ); assertFalse( filter1.equals( null ) ); assertTrue( filter1.equals( filter1 ) ); assertEquals( filter1.hashCode(), filter1.hashCode() ); assertFalse( filter1.equals( filter2 ) ); assertFalse( filter2.equals( filter1 ) ); } } ScopeArtifactFilterTest.java000066400000000000000000000076131317160430700364040ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/test/java/org/apache/maven/artifact/resolver/filterpackage org.apache.maven.artifact.resolver.filter; /* * 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 org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.DefaultArtifact; import junit.framework.TestCase; /** * Tests {@link ScopeArtifactFilter}. * * @author Benjamin Bentmann */ public class ScopeArtifactFilterTest extends TestCase { private Artifact newArtifact( String scope ) { return new DefaultArtifact( "g", "a", "1.0", scope, "jar", "", null ); } public void testInclude_Compile() { ScopeArtifactFilter filter = new ScopeArtifactFilter( Artifact.SCOPE_COMPILE ); assertTrue( filter.include( newArtifact( Artifact.SCOPE_COMPILE ) ) ); assertTrue( filter.include( newArtifact( Artifact.SCOPE_SYSTEM ) ) ); assertTrue( filter.include( newArtifact( Artifact.SCOPE_PROVIDED ) ) ); assertFalse( filter.include( newArtifact( Artifact.SCOPE_RUNTIME ) ) ); assertFalse( filter.include( newArtifact( Artifact.SCOPE_TEST ) ) ); } public void testInclude_CompilePlusRuntime() { ScopeArtifactFilter filter = new ScopeArtifactFilter( Artifact.SCOPE_COMPILE_PLUS_RUNTIME ); assertTrue( filter.include( newArtifact( Artifact.SCOPE_COMPILE ) ) ); assertTrue( filter.include( newArtifact( Artifact.SCOPE_SYSTEM ) ) ); assertTrue( filter.include( newArtifact( Artifact.SCOPE_PROVIDED ) ) ); assertTrue( filter.include( newArtifact( Artifact.SCOPE_RUNTIME ) ) ); assertFalse( filter.include( newArtifact( Artifact.SCOPE_TEST ) ) ); } public void testInclude_Runtime() { ScopeArtifactFilter filter = new ScopeArtifactFilter( Artifact.SCOPE_RUNTIME ); assertTrue( filter.include( newArtifact( Artifact.SCOPE_COMPILE ) ) ); assertFalse( filter.include( newArtifact( Artifact.SCOPE_SYSTEM ) ) ); assertFalse( filter.include( newArtifact( Artifact.SCOPE_PROVIDED ) ) ); assertTrue( filter.include( newArtifact( Artifact.SCOPE_RUNTIME ) ) ); assertFalse( filter.include( newArtifact( Artifact.SCOPE_TEST ) ) ); } public void testInclude_RuntimePlusSystem() { ScopeArtifactFilter filter = new ScopeArtifactFilter( Artifact.SCOPE_RUNTIME_PLUS_SYSTEM ); assertTrue( filter.include( newArtifact( Artifact.SCOPE_COMPILE ) ) ); assertTrue( filter.include( newArtifact( Artifact.SCOPE_SYSTEM ) ) ); assertFalse( filter.include( newArtifact( Artifact.SCOPE_PROVIDED ) ) ); assertTrue( filter.include( newArtifact( Artifact.SCOPE_RUNTIME ) ) ); assertFalse( filter.include( newArtifact( Artifact.SCOPE_TEST ) ) ); } public void testInclude_Test() { ScopeArtifactFilter filter = new ScopeArtifactFilter( Artifact.SCOPE_TEST ); assertTrue( filter.include( newArtifact( Artifact.SCOPE_COMPILE ) ) ); assertTrue( filter.include( newArtifact( Artifact.SCOPE_SYSTEM ) ) ); assertTrue( filter.include( newArtifact( Artifact.SCOPE_PROVIDED ) ) ); assertTrue( filter.include( newArtifact( Artifact.SCOPE_RUNTIME ) ) ); assertTrue( filter.include( newArtifact( Artifact.SCOPE_TEST ) ) ); } } maven-maven-3.5.2/maven-compat/src/test/java/org/apache/maven/artifact/testutils/000077500000000000000000000000001317160430700277665ustar00rootroot00000000000000TestFileManager.java000066400000000000000000000134421317160430700335700ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/test/java/org/apache/maven/artifact/testutilspackage org.apache.maven.artifact.testutils; /* * 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. */ /* * 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.File; import java.io.IOException; import java.util.ArrayList; import java.util.Iterator; import java.util.List; import junit.framework.Assert; import org.codehaus.plexus.util.FileUtils; public class TestFileManager { public static final String TEMP_DIR_PATH = System.getProperty( "java.io.tmpdir" ); private List filesToDelete = new ArrayList<>(); private final String baseFilename; private final String fileSuffix; private StackTraceElement callerInfo; private Thread cleanupWarning; private boolean warnAboutCleanup = false; public TestFileManager( String baseFilename, String fileSuffix ) { this.baseFilename = baseFilename; this.fileSuffix = fileSuffix; initializeCleanupMonitoring(); } private void initializeCleanupMonitoring() { callerInfo = new NullPointerException().getStackTrace()[2]; Runnable warning = new Runnable() { public void run() { maybeWarnAboutCleanUp(); } }; cleanupWarning = new Thread( warning ); Runtime.getRuntime().addShutdownHook( cleanupWarning ); } private void maybeWarnAboutCleanUp() { if ( warnAboutCleanup ) { System.out.println( "[WARNING] TestFileManager from: " + callerInfo.getClassName() + " not cleaned up!" ); } } public void markForDeletion( File toDelete ) { filesToDelete.add( toDelete ); warnAboutCleanup = true; } public synchronized File createTempDir() { try { Thread.sleep( 20 ); } catch ( InterruptedException e ) { // ignore } File dir = new File( TEMP_DIR_PATH, baseFilename + System.currentTimeMillis() ); dir.mkdirs(); markForDeletion( dir ); return dir; } public synchronized File createTempFile() throws IOException { File tempFile = File.createTempFile( baseFilename, fileSuffix ); tempFile.deleteOnExit(); markForDeletion( tempFile ); return tempFile; } public void cleanUp() throws IOException { for ( Iterator it = filesToDelete.iterator(); it.hasNext(); ) { File file = (File) it.next(); if ( file.exists() ) { if ( file.isDirectory() ) { FileUtils.deleteDirectory( file ); } else { file.delete(); } } it.remove(); } warnAboutCleanup = false; } public void assertFileExistence( File dir, String filename, boolean shouldExist ) { File file = new File( dir, filename ); if ( shouldExist ) { Assert.assertTrue( file.exists() ); } else { Assert.assertFalse( file.exists() ); } } public void assertFileContents( File dir, String filename, String contentsTest, String encoding ) throws IOException { assertFileExistence( dir, filename, true ); File file = new File( dir, filename ); String contents = FileUtils.fileRead( file, encoding ); Assert.assertEquals( contentsTest, contents ); } public File createFile( File dir, String filename, String contents, String encoding ) throws IOException { File file = new File( dir, filename ); file.getParentFile().mkdirs(); FileUtils.fileWrite( file.getPath(), encoding, contents ); markForDeletion( file ); return file; } public String getFileContents( File file, String encoding ) throws IOException { return FileUtils.fileRead( file, encoding ); } protected void finalize() throws Throwable { maybeWarnAboutCleanUp(); super.finalize(); } public File createFile( String filename, String content, String encoding ) throws IOException { File dir = createTempDir(); return createFile( dir, filename, content, encoding ); } } maven-maven-3.5.2/maven-compat/src/test/java/org/apache/maven/artifact/transform/000077500000000000000000000000001317160430700277415ustar00rootroot00000000000000TransformationManagerTest.java000066400000000000000000000037711317160430700356760ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/test/java/org/apache/maven/artifact/transformpackage org.apache.maven.artifact.transform; /* * 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.util.List; import org.apache.maven.repository.legacy.resolver.transform.ArtifactTransformationManager; import org.apache.maven.repository.legacy.resolver.transform.LatestArtifactTransformation; import org.apache.maven.repository.legacy.resolver.transform.ReleaseArtifactTransformation; import org.apache.maven.repository.legacy.resolver.transform.SnapshotTransformation; import org.codehaus.plexus.PlexusTestCase; /** @author Jason van Zyl */ public class TransformationManagerTest extends PlexusTestCase { public void testTransformationManager() throws Exception { ArtifactTransformationManager tm = lookup( ArtifactTransformationManager.class ); List tms = tm.getArtifactTransformations(); assertEquals( 3, tms.size() ); assertTrue( "We expected the release transformation and got " + tms.get(0), tms.get(0) instanceof ReleaseArtifactTransformation ); assertTrue( "We expected the latest transformation and got " + tms.get(1), tms.get(1) instanceof LatestArtifactTransformation ); assertTrue( "We expected the snapshot transformation and got " + tms.get(2), tms.get(2) instanceof SnapshotTransformation ); } } maven-maven-3.5.2/maven-compat/src/test/java/org/apache/maven/profiles/000077500000000000000000000000001317160430700257545ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/test/java/org/apache/maven/profiles/manager/000077500000000000000000000000001317160430700273665ustar00rootroot00000000000000DefaultProfileManagerTest.java000066400000000000000000000161561317160430700352230ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/test/java/org/apache/maven/profiles/managerpackage org.apache.maven.profiles.manager; /* * 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.util.List; import java.util.Properties; import org.apache.maven.model.Activation; import org.apache.maven.model.ActivationProperty; import org.apache.maven.model.Profile; import org.apache.maven.profiles.DefaultProfileManager; import org.apache.maven.profiles.ProfileManager; import org.codehaus.plexus.PlexusTestCase; public class DefaultProfileManagerTest extends PlexusTestCase { public void setUp() throws Exception { super.setUp(); } public void testShouldActivateDefaultProfile() throws Exception { Profile notActivated = new Profile(); notActivated.setId( "notActivated" ); Activation nonActivation = new Activation(); nonActivation.setJdk( "19.2" ); notActivated.setActivation( nonActivation ); Profile defaultActivated = new Profile(); defaultActivated.setId( "defaultActivated" ); Activation defaultActivation = new Activation(); defaultActivation.setActiveByDefault( true ); defaultActivated.setActivation( defaultActivation ); Properties props = System.getProperties(); ProfileManager profileManager = new DefaultProfileManager( getContainer(), props ); profileManager.addProfile( notActivated ); profileManager.addProfile( defaultActivated ); List active = profileManager.getActiveProfiles(); assertNotNull( active ); assertEquals( 1, active.size() ); assertEquals( "defaultActivated", ( (Profile) active.get( 0 ) ).getId() ); } public void testShouldNotActivateDefaultProfile() throws Exception { Profile syspropActivated = new Profile(); syspropActivated.setId( "syspropActivated" ); Activation syspropActivation = new Activation(); ActivationProperty syspropProperty = new ActivationProperty(); syspropProperty.setName( "java.version" ); syspropActivation.setProperty( syspropProperty ); syspropActivated.setActivation( syspropActivation ); Profile defaultActivated = new Profile(); defaultActivated.setId( "defaultActivated" ); Activation defaultActivation = new Activation(); defaultActivation.setActiveByDefault( true ); defaultActivated.setActivation( defaultActivation ); Properties props = System.getProperties(); ProfileManager profileManager = new DefaultProfileManager( getContainer(), props ); profileManager.addProfile( syspropActivated ); profileManager.addProfile( defaultActivated ); List active = profileManager.getActiveProfiles(); assertNotNull( active ); assertEquals( 1, active.size() ); assertEquals( "syspropActivated", ( (Profile) active.get( 0 ) ).getId() ); } public void testShouldNotActivateReversalOfPresentSystemProperty() throws Exception { Profile syspropActivated = new Profile(); syspropActivated.setId( "syspropActivated" ); Activation syspropActivation = new Activation(); ActivationProperty syspropProperty = new ActivationProperty(); syspropProperty.setName( "!java.version" ); syspropActivation.setProperty( syspropProperty ); syspropActivated.setActivation( syspropActivation ); Properties props = System.getProperties(); ProfileManager profileManager = new DefaultProfileManager( getContainer(), props ); profileManager.addProfile( syspropActivated ); List active = profileManager.getActiveProfiles(); assertNotNull( active ); assertEquals( 0, active.size() ); } public void testShouldOverrideAndActivateInactiveProfile() throws Exception { Profile syspropActivated = new Profile(); syspropActivated.setId( "syspropActivated" ); Activation syspropActivation = new Activation(); ActivationProperty syspropProperty = new ActivationProperty(); syspropProperty.setName( "!java.version" ); syspropActivation.setProperty( syspropProperty ); syspropActivated.setActivation( syspropActivation ); Properties props = System.getProperties(); ProfileManager profileManager = new DefaultProfileManager( getContainer(), props ); profileManager.addProfile( syspropActivated ); profileManager.explicitlyActivate( "syspropActivated" ); List active = profileManager.getActiveProfiles(); assertNotNull( active ); assertEquals( 1, active.size() ); assertEquals( "syspropActivated", ( (Profile) active.get( 0 ) ).getId() ); } public void testShouldOverrideAndDeactivateActiveProfile() throws Exception { Profile syspropActivated = new Profile(); syspropActivated.setId( "syspropActivated" ); Activation syspropActivation = new Activation(); ActivationProperty syspropProperty = new ActivationProperty(); syspropProperty.setName( "java.version" ); syspropActivation.setProperty( syspropProperty ); syspropActivated.setActivation( syspropActivation ); Properties props = System.getProperties(); ProfileManager profileManager = new DefaultProfileManager( getContainer(), props ); profileManager.addProfile( syspropActivated ); profileManager.explicitlyDeactivate( "syspropActivated" ); List active = profileManager.getActiveProfiles(); assertNotNull( active ); assertEquals( 0, active.size() ); } /* public void testOsActivationProfile() throws Exception { Profile osActivated = new Profile(); osActivated.setId( "os-profile" ); Activation osActivation = new Activation(); ActivationOS activationOS = new ActivationOS(); activationOS.setName( "!dddd" ); osActivation.setOs( activationOS ); osActivated.setActivation( osActivation ); Properties props = System.getProperties(); ProfileActivationContext ctx = new ProfileActivationContext( props, false ); ProfileManager profileManager = new DefaultProfileManager( getContainer(), props ); profileManager.addProfile( osActivated ); List active = profileManager.getActiveProfiles( null ); assertNotNull( active ); assertEquals( 1, active.size() ); } */ } maven-maven-3.5.2/maven-compat/src/test/java/org/apache/maven/project/000077500000000000000000000000001317160430700255775ustar00rootroot00000000000000AbstractMavenProjectTestCase.java000066400000000000000000000143771317160430700341140ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/test/java/org/apache/maven/projectpackage org.apache.maven.project; /* * 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.File; import java.io.FileNotFoundException; import java.net.URI; import java.net.URISyntaxException; import java.net.URL; import java.util.Arrays; import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout; import org.apache.maven.model.building.ModelBuildingException; import org.apache.maven.model.building.ModelProblem; import org.apache.maven.repository.RepositorySystem; import org.apache.maven.repository.internal.MavenRepositorySystemUtils; import org.codehaus.plexus.ContainerConfiguration; import org.codehaus.plexus.PlexusConstants; import org.codehaus.plexus.PlexusTestCase; import org.eclipse.aether.DefaultRepositorySystemSession; /** * @author Jason van Zyl */ public abstract class AbstractMavenProjectTestCase extends PlexusTestCase { protected ProjectBuilder projectBuilder; protected RepositorySystem repositorySystem; @Override protected void customizeContainerConfiguration( ContainerConfiguration containerConfiguration ) { super.customizeContainerConfiguration( containerConfiguration ); containerConfiguration.setAutoWiring( true ); containerConfiguration.setClassPathScanning( PlexusConstants.SCANNING_INDEX ); } protected void setUp() throws Exception { super.setUp(); if ( getContainer().hasComponent( ProjectBuilder.class, "test" ) ) { projectBuilder = lookup( ProjectBuilder.class, "test" ); } else { // default over to the main project builder... projectBuilder = lookup( ProjectBuilder.class ); } repositorySystem = lookup( RepositorySystem.class ); } @Override protected void tearDown() throws Exception { projectBuilder = null; super.tearDown(); } protected ProjectBuilder getProjectBuilder() { return projectBuilder; } @Override protected String getCustomConfigurationName() { String name = AbstractMavenProjectTestCase.class.getName().replace( '.', '/' ) + ".xml"; System.out.println( name ); return name; } // ---------------------------------------------------------------------- // Local repository // ---------------------------------------------------------------------- protected File getLocalRepositoryPath() throws FileNotFoundException, URISyntaxException { File markerFile = getFileForClasspathResource( "local-repo/marker.txt" ); return markerFile.getAbsoluteFile().getParentFile(); } protected static File getFileForClasspathResource( String resource ) throws FileNotFoundException { ClassLoader cloader = Thread.currentThread().getContextClassLoader(); URL resourceUrl = cloader.getResource( resource ); if ( resourceUrl == null ) { throw new FileNotFoundException( "Unable to find: " + resource ); } return new File( URI.create( resourceUrl.toString().replaceAll( " ", "%20" ) ) ); } protected ArtifactRepository getLocalRepository() throws Exception { ArtifactRepositoryLayout repoLayout = lookup( ArtifactRepositoryLayout.class, "legacy" ); ArtifactRepository r = repositorySystem.createArtifactRepository( "local", "file://" + getLocalRepositoryPath().getAbsolutePath(), repoLayout, null, null ); return r; } // ---------------------------------------------------------------------- // Project building // ---------------------------------------------------------------------- protected MavenProject getProjectWithDependencies( File pom ) throws Exception { ProjectBuildingRequest configuration = new DefaultProjectBuildingRequest(); configuration.setLocalRepository( getLocalRepository() ); configuration.setRemoteRepositories( Arrays.asList( new ArtifactRepository[] {} ) ); configuration.setProcessPlugins( false ); configuration.setResolveDependencies( true ); initRepoSession( configuration ); try { return projectBuilder.build( pom, configuration ).getProject(); } catch ( Exception e ) { Throwable cause = e.getCause(); if ( cause instanceof ModelBuildingException ) { String message = "In: " + pom + "\n\n"; for ( ModelProblem problem : ( (ModelBuildingException) cause ).getProblems() ) { message += problem + "\n"; } System.out.println( message ); fail( message ); } throw e; } } protected MavenProject getProject( File pom ) throws Exception { ProjectBuildingRequest configuration = new DefaultProjectBuildingRequest(); configuration.setLocalRepository( getLocalRepository() ); initRepoSession( configuration ); return projectBuilder.build( pom, configuration ).getProject(); } protected void initRepoSession( ProjectBuildingRequest request ) { File localRepo = new File( request.getLocalRepository().getBasedir() ); DefaultRepositorySystemSession session = MavenRepositorySystemUtils.newSession(); session.setLocalRepositoryManager( new LegacyLocalRepositoryManager( localRepo ) ); request.setRepositorySession( session ); } } maven-maven-3.5.2/maven-compat/src/test/java/org/apache/maven/project/ClasspathArtifactResolver.java000066400000000000000000000063321317160430700335700ustar00rootroot00000000000000package org.apache.maven.project; /* * 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.FileNotFoundException; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; import java.util.List; import org.codehaus.plexus.component.annotations.Component; import org.eclipse.aether.RepositorySystemSession; import org.eclipse.aether.artifact.Artifact; import org.eclipse.aether.impl.ArtifactResolver; import org.eclipse.aether.resolution.ArtifactRequest; import org.eclipse.aether.resolution.ArtifactResolutionException; import org.eclipse.aether.resolution.ArtifactResult; import org.eclipse.aether.transfer.ArtifactNotFoundException; /** * @author Benjamin Bentmann */ @Component( role = ArtifactResolver.class, hint = "classpath" ) public class ClasspathArtifactResolver implements ArtifactResolver { public List resolveArtifacts( RepositorySystemSession session, Collection requests ) throws ArtifactResolutionException { List results = new ArrayList<>(); for ( ArtifactRequest request : requests ) { ArtifactResult result = new ArtifactResult( request ); results.add( result ); Artifact artifact = request.getArtifact(); if ( "maven-test".equals( artifact.getGroupId() ) ) { String scope = artifact.getArtifactId().substring( "scope-".length() ); try { artifact = artifact.setFile( ProjectClasspathTest.getFileForClasspathResource( ProjectClasspathTest.dir + "transitive-" + scope + "-dep.xml" ) ); result.setArtifact( artifact ); } catch ( FileNotFoundException e ) { throw new IllegalStateException( "Missing test POM for " + artifact ); } } else { result.addException( new ArtifactNotFoundException( artifact, null ) ); throw new ArtifactResolutionException( results ); } } return results; } public ArtifactResult resolveArtifact( RepositorySystemSession session, ArtifactRequest request ) throws ArtifactResolutionException { return resolveArtifacts( session, Collections.singleton( request ) ).get( 0 ); } } maven-maven-3.5.2/maven-compat/src/test/java/org/apache/maven/project/EmptyLifecycleExecutor.java000066400000000000000000000072141317160430700331030ustar00rootroot00000000000000package org.apache.maven.project; /* * 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.util.Collections; import java.util.LinkedHashSet; import java.util.List; import java.util.Set; import org.apache.maven.execution.MavenSession; import org.apache.maven.lifecycle.DefaultLifecycles; import org.apache.maven.lifecycle.LifecycleExecutor; import org.apache.maven.lifecycle.MavenExecutionPlan; import org.apache.maven.model.Plugin; import org.apache.maven.model.PluginExecution; import org.apache.maven.plugin.MojoExecution; /** * A stub implementation that assumes an empty lifecycle to bypass interaction with the plugin manager and to avoid * plugin artifact resolution from repositories. * * @author Benjamin Bentmann */ public class EmptyLifecycleExecutor implements LifecycleExecutor { public MavenExecutionPlan calculateExecutionPlan( MavenSession session, String... tasks ) { return new MavenExecutionPlan( null, new DefaultLifecycles() ); } public MavenExecutionPlan calculateExecutionPlan( MavenSession session, boolean setup, String... tasks ) { return new MavenExecutionPlan( null, new DefaultLifecycles() ); } public void execute( MavenSession session ) { } public Set getPluginsBoundByDefaultToAllLifecycles( String packaging ) { Set plugins; // NOTE: The upper-case packaging name is intentional, that's a special hinting mode used for certain tests if ( "JAR".equals( packaging ) ) { plugins = new LinkedHashSet<>(); plugins.add( newPlugin( "maven-compiler-plugin", "compile", "testCompile" ) ); plugins.add( newPlugin( "maven-resources-plugin", "resources", "testResources" ) ); plugins.add( newPlugin( "maven-surefire-plugin", "test" ) ); plugins.add( newPlugin( "maven-jar-plugin", "jar" ) ); plugins.add( newPlugin( "maven-install-plugin", "install" ) ); plugins.add( newPlugin( "maven-deploy-plugin", "deploy" ) ); } else { plugins = Collections.emptySet(); } return plugins; } private Plugin newPlugin( String artifactId, String... goals ) { Plugin plugin = new Plugin(); plugin.setGroupId( "org.apache.maven.plugins" ); plugin.setArtifactId( artifactId ); for ( String goal : goals ) { PluginExecution pluginExecution = new PluginExecution(); pluginExecution.setId( "default-" + goal ); pluginExecution.addGoal( goal ); plugin.addExecution( pluginExecution ); } return plugin; } public void calculateForkedExecutions( MojoExecution mojoExecution, MavenSession session ) { } public List executeForkedExecutions( MojoExecution mojoExecution, MavenSession session ) { return Collections.emptyList(); } } EmptyLifecyclePluginAnalyzer.java000066400000000000000000000051271317160430700341730ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/test/java/org/apache/maven/projectpackage org.apache.maven.project; /* * 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.util.Collections; import java.util.LinkedHashSet; import java.util.Set; import org.apache.maven.lifecycle.LifeCyclePluginAnalyzer; import org.apache.maven.model.Plugin; import org.apache.maven.model.PluginExecution; /** * @author Benjamin Bentmann */ public class EmptyLifecyclePluginAnalyzer implements LifeCyclePluginAnalyzer { public Set getPluginsBoundByDefaultToAllLifecycles( String packaging ) { Set plugins; // NOTE: The upper-case packaging name is intentional, that's a special hinting mode used for certain tests if ( "JAR".equals( packaging ) ) { plugins = new LinkedHashSet<>(); plugins.add( newPlugin( "maven-compiler-plugin", "compile", "testCompile" ) ); plugins.add( newPlugin( "maven-resources-plugin", "resources", "testResources" ) ); plugins.add( newPlugin( "maven-surefire-plugin", "test" ) ); plugins.add( newPlugin( "maven-jar-plugin", "jar" ) ); plugins.add( newPlugin( "maven-install-plugin", "install" ) ); plugins.add( newPlugin( "maven-deploy-plugin", "deploy" ) ); } else { plugins = Collections.emptySet(); } return plugins; } private Plugin newPlugin( String artifactId, String... goals ) { Plugin plugin = new Plugin(); plugin.setGroupId( "org.apache.maven.plugins" ); plugin.setArtifactId( artifactId ); for ( String goal : goals ) { PluginExecution pluginExecution = new PluginExecution(); pluginExecution.setId( "default-" + goal ); pluginExecution.addGoal( goal ); plugin.addExecution( pluginExecution ); } return plugin; } } LegacyLocalRepositoryManager.java000066400000000000000000000133471317160430700341450ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/test/java/org/apache/maven/projectpackage org.apache.maven.project; /* * 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.File; import org.eclipse.aether.RepositorySystemSession; import org.eclipse.aether.artifact.Artifact; import org.eclipse.aether.metadata.Metadata; import org.eclipse.aether.repository.LocalArtifactRegistration; import org.eclipse.aether.repository.LocalArtifactRequest; import org.eclipse.aether.repository.LocalArtifactResult; import org.eclipse.aether.repository.LocalMetadataRegistration; import org.eclipse.aether.repository.LocalMetadataRequest; import org.eclipse.aether.repository.LocalMetadataResult; import org.eclipse.aether.repository.LocalRepository; import org.eclipse.aether.repository.LocalRepositoryManager; import org.eclipse.aether.repository.RemoteRepository; /** * @author Benjamin Bentmann */ public class LegacyLocalRepositoryManager implements LocalRepositoryManager { private final LocalRepository repository; public LegacyLocalRepositoryManager( File basedir ) { this.repository = new LocalRepository( basedir.getAbsoluteFile(), "legacy" ); } public LocalRepository getRepository() { return repository; } public String getPathForLocalArtifact( Artifact artifact ) { StringBuilder path = new StringBuilder( 128 ); path.append( artifact.getGroupId() ).append( '/' ); path.append( artifact.getExtension() ).append( "s/" ); path.append( artifact.getArtifactId() ).append( '-' ).append( artifact.getVersion() ); if ( artifact.getClassifier().length() > 0 ) { path.append( '-' ).append( artifact.getClassifier() ); } path.append( '.' ).append( artifact.getExtension() ); return path.toString(); } public String getPathForRemoteArtifact( Artifact artifact, RemoteRepository repository, String context ) { return getPathForLocalArtifact( artifact ); } public String getPathForLocalMetadata( Metadata metadata ) { return getPath( metadata, "local" ); } public String getPathForRemoteMetadata( Metadata metadata, RemoteRepository repository, String context ) { return getPath( metadata, getRepositoryKey( repository, context ) ); } String getRepositoryKey( RemoteRepository repository, String context ) { return repository.getId(); } private String getPath( Metadata metadata, String repositoryKey ) { StringBuilder path = new StringBuilder( 128 ); if ( metadata.getGroupId().length() > 0 ) { path.append( metadata.getGroupId().replace( '.', '/' ) ).append( '/' ); if ( metadata.getArtifactId().length() > 0 ) { path.append( metadata.getArtifactId() ).append( '/' ); if ( metadata.getVersion().length() > 0 ) { path.append( metadata.getVersion() ).append( '/' ); } } } path.append( insertRepositoryKey( metadata.getType(), repositoryKey ) ); return path.toString(); } private String insertRepositoryKey( String filename, String repositoryKey ) { String result; int idx = filename.indexOf( '.' ); if ( idx < 0 ) { result = filename + '-' + repositoryKey; } else { result = filename.substring( 0, idx ) + '-' + repositoryKey + filename.substring( idx ); } return result; } public LocalArtifactResult find( RepositorySystemSession session, LocalArtifactRequest request ) { String path = getPathForLocalArtifact( request.getArtifact() ); File file = new File( getRepository().getBasedir(), path ); LocalArtifactResult result = new LocalArtifactResult( request ); if ( file.isFile() ) { result.setFile( file ); result.setAvailable( true ); } return result; } public void add( RepositorySystemSession session, LocalArtifactRegistration request ) { // noop } public LocalMetadataResult find( RepositorySystemSession session, LocalMetadataRequest request ) { LocalMetadataResult result = new LocalMetadataResult( request ); String path; Metadata metadata = request.getMetadata(); String context = request.getContext(); RemoteRepository remote = request.getRepository(); if ( remote != null ) { path = getPathForRemoteMetadata( metadata, remote, context ); } else { path = getPathForLocalMetadata( metadata ); } File file = new File( getRepository().getBasedir(), path ); if ( file.isFile() ) { result.setFile( file ); } return result; } public void add( RepositorySystemSession session, LocalMetadataRegistration request ) { // noop } public String toString() { return String.valueOf( getRepository() ); } } maven-maven-3.5.2/maven-compat/src/test/java/org/apache/maven/project/ModelUtilsTest.java000066400000000000000000000524171317160430700313740ustar00rootroot00000000000000package org.apache.maven.project; /* * 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.StringReader; import java.util.Arrays; import java.util.Collections; import java.util.List; import java.util.Map; import junit.framework.TestCase; import org.apache.maven.model.Build; import org.apache.maven.model.Dependency; import org.apache.maven.model.Plugin; import org.apache.maven.model.PluginContainer; import org.apache.maven.model.PluginExecution; import org.codehaus.plexus.util.xml.Xpp3Dom; import org.codehaus.plexus.util.xml.Xpp3DomBuilder; import org.codehaus.plexus.util.xml.pull.XmlPullParserException; public class ModelUtilsTest extends TestCase { public void testShouldUseMainPluginDependencyVersionOverManagedDepVersion() { Plugin mgtPlugin = createPlugin( "group", "artifact", "1", Collections.EMPTY_MAP ); Dependency mgtDep = createDependency( "g", "a", "2" ); mgtPlugin.addDependency( mgtDep ); Plugin plugin = createPlugin( "group", "artifact", "1", Collections.EMPTY_MAP ); Dependency dep = createDependency( "g", "a", "1" ); plugin.addDependency( dep ); ModelUtils.mergePluginDefinitions( plugin, mgtPlugin, false ); assertEquals( dep.getVersion(), plugin.getDependencies().get( 0 ).getVersion() ); } private Dependency createDependency( String gid, String aid, String ver ) { Dependency dep = new Dependency(); dep.setGroupId( gid ); dep.setArtifactId( aid ); dep.setVersion( ver ); return dep; } public void testShouldNotInheritPluginWithInheritanceSetToFalse() { PluginContainer parent = new PluginContainer(); Plugin parentPlugin = createPlugin( "group", "artifact", "1.0", Collections.EMPTY_MAP ); parentPlugin.setInherited( "false" ); parent.addPlugin( parentPlugin ); PluginContainer child = new PluginContainer(); child.addPlugin( createPlugin( "group3", "artifact3", "1.0", Collections.EMPTY_MAP ) ); ModelUtils.mergePluginLists( child, parent, true ); List results = child.getPlugins(); assertEquals( 1, results.size() ); Plugin result1 = (Plugin) results.get( 0 ); assertEquals( "group3", result1.getGroupId() ); assertEquals( "artifact3", result1.getArtifactId() ); } /** * Test that this is the resulting ordering of plugins after merging: *

* Given: *

*
     *   parent: X -> A -> B -> D -> E
     *   child: Y -> A -> C -> D -> F
     * 
*

* Result: *

*
     *   X -> Y -> A -> B -> C -> D -> E -> F
     * 
*/ public void testShouldPreserveChildOrderingOfPluginsAfterParentMerge() { PluginContainer parent = new PluginContainer(); parent.addPlugin( createPlugin( "group", "artifact", "1.0", Collections.EMPTY_MAP ) ); parent.addPlugin( createPlugin( "group2", "artifact2", "1.0", Collections.singletonMap( "key", "value" ) ) ); PluginContainer child = new PluginContainer(); child.addPlugin( createPlugin( "group3", "artifact3", "1.0", Collections.EMPTY_MAP ) ); child.addPlugin( createPlugin( "group2", "artifact2", "1.0", Collections.singletonMap( "key2", "value2" ) ) ); ModelUtils.mergePluginLists( child, parent, true ); List results = child.getPlugins(); assertEquals( 3, results.size() ); Plugin result1 = (Plugin) results.get( 0 ); assertEquals( "group", result1.getGroupId() ); assertEquals( "artifact", result1.getArtifactId() ); Plugin result2 = (Plugin) results.get( 1 ); assertEquals( "group3", result2.getGroupId() ); assertEquals( "artifact3", result2.getArtifactId() ); Plugin result3 = (Plugin) results.get( 2 ); assertEquals( "group2", result3.getGroupId() ); assertEquals( "artifact2", result3.getArtifactId() ); Xpp3Dom result3Config = (Xpp3Dom) result3.getConfiguration(); assertNotNull( result3Config ); assertEquals( "value", result3Config.getChild( "key" ).getValue() ); assertEquals( "value2", result3Config.getChild( "key2" ).getValue() ); } private Plugin createPlugin( String groupId, String artifactId, String version, Map configuration ) { Plugin plugin = new Plugin(); plugin.setGroupId( groupId ); plugin.setArtifactId( artifactId ); plugin.setVersion( version ); Xpp3Dom config = new Xpp3Dom( "configuration" ); if( configuration != null ) { for ( Object o : configuration.entrySet() ) { Map.Entry entry = (Map.Entry) o; Xpp3Dom param = new Xpp3Dom( String.valueOf( entry.getKey() ) ); param.setValue( String.valueOf( entry.getValue() ) ); config.addChild( param ); } } plugin.setConfiguration( config ); return plugin; } public void testShouldInheritOnePluginWithExecution() { Plugin parent = new Plugin(); parent.setArtifactId( "testArtifact" ); parent.setGroupId( "testGroup" ); parent.setVersion( "1.0" ); PluginExecution parentExecution = new PluginExecution(); parentExecution.setId( "testExecution" ); parent.addExecution( parentExecution ); Plugin child = new Plugin(); child.setArtifactId( "testArtifact" ); child.setGroupId( "testGroup" ); child.setVersion( "1.0" ); ModelUtils.mergePluginDefinitions( child, parent, false ); assertEquals( 1, child.getExecutions().size() ); } public void testShouldMergeInheritedPluginHavingExecutionWithLocalPlugin() { Plugin parent = new Plugin(); parent.setArtifactId( "testArtifact" ); parent.setGroupId( "testGroup" ); parent.setVersion( "1.0" ); PluginExecution parentExecution = new PluginExecution(); parentExecution.setId( "testExecution" ); parent.addExecution( parentExecution ); Plugin child = new Plugin(); child.setArtifactId( "testArtifact" ); child.setGroupId( "testGroup" ); child.setVersion( "1.0" ); PluginExecution childExecution = new PluginExecution(); childExecution.setId( "testExecution2" ); child.addExecution( childExecution ); ModelUtils.mergePluginDefinitions( child, parent, false ); assertEquals( 2, child.getExecutions().size() ); } public void testShouldMergeOnePluginWithInheritExecutionWithoutDuplicatingPluginInList() { Plugin parent = new Plugin(); parent.setArtifactId( "testArtifact" ); parent.setGroupId( "testGroup" ); parent.setVersion( "1.0" ); PluginExecution parentExecution = new PluginExecution(); parentExecution.setId( "testExecution" ); parent.addExecution( parentExecution ); Build parentContainer = new Build(); parentContainer.addPlugin( parent ); Plugin child = new Plugin(); child.setArtifactId( "testArtifact" ); child.setGroupId( "testGroup" ); child.setVersion( "1.0" ); Build childContainer = new Build(); childContainer.addPlugin( child ); ModelUtils.mergePluginLists( childContainer, parentContainer, true ); List plugins = childContainer.getPlugins(); assertEquals( 1, plugins.size() ); Plugin plugin = (Plugin) plugins.get( 0 ); assertEquals( 1, plugin.getExecutions().size() ); } public void testShouldMergePluginWithDifferentExecutionFromParentWithoutDuplicatingPluginInList() { Plugin parent = new Plugin(); parent.setArtifactId( "testArtifact" ); parent.setGroupId( "testGroup" ); parent.setVersion( "1.0" ); PluginExecution parentExecution = new PluginExecution(); parentExecution.setId( "testExecution" ); parent.addExecution( parentExecution ); Build parentContainer = new Build(); parentContainer.addPlugin( parent ); Plugin child = new Plugin(); child.setArtifactId( "testArtifact" ); child.setGroupId( "testGroup" ); child.setVersion( "1.0" ); PluginExecution childExecution = new PluginExecution(); childExecution.setId( "testExecution2" ); child.addExecution( childExecution ); Build childContainer = new Build(); childContainer.addPlugin( child ); ModelUtils.mergePluginLists( childContainer, parentContainer, true ); List plugins = childContainer.getPlugins(); assertEquals( 1, plugins.size() ); Plugin plugin = (Plugin) plugins.get( 0 ); assertEquals( 2, plugin.getExecutions().size() ); } public void testShouldNOTMergeInheritedPluginHavingInheritEqualFalse() { Plugin parent = new Plugin(); parent.setArtifactId( "testArtifact" ); parent.setGroupId( "testGroup" ); parent.setVersion( "1.0" ); parent.setInherited( "false" ); PluginExecution parentExecution = new PluginExecution(); parentExecution.setId( "testExecution" ); parent.addExecution( parentExecution ); Plugin child = new Plugin(); child.setArtifactId( "testArtifact" ); child.setGroupId( "testGroup" ); child.setVersion( "1.0" ); ModelUtils.mergePluginDefinitions( child, parent, true ); assertEquals( 0, child.getExecutions().size() ); } /** * Verifies MNG-1499: The order of the merged list should be the plugins specified by the parent followed by the * child list. */ public void testShouldKeepOriginalPluginOrdering() { Plugin parentPlugin1 = new Plugin(); parentPlugin1.setArtifactId( "testArtifact" ); parentPlugin1.setGroupId( "zzz" ); // This will put this plugin last in the sorted map parentPlugin1.setVersion( "1.0" ); PluginExecution parentExecution1 = new PluginExecution(); parentExecution1.setId( "testExecution" ); parentPlugin1.addExecution( parentExecution1 ); Plugin parentPlugin2 = new Plugin(); parentPlugin2.setArtifactId( "testArtifact" ); parentPlugin2.setGroupId( "yyy" ); parentPlugin2.setVersion( "1.0" ); PluginExecution parentExecution2 = new PluginExecution(); parentExecution2.setId( "testExecution" ); parentPlugin2.addExecution( parentExecution2 ); PluginContainer parentContainer = new PluginContainer(); parentContainer.addPlugin(parentPlugin1); parentContainer.addPlugin(parentPlugin2); Plugin childPlugin1 = new Plugin(); childPlugin1.setArtifactId( "testArtifact" ); childPlugin1.setGroupId( "bbb" ); childPlugin1.setVersion( "1.0" ); PluginExecution childExecution1 = new PluginExecution(); childExecution1.setId( "testExecution" ); childPlugin1.addExecution( childExecution1 ); Plugin childPlugin2 = new Plugin(); childPlugin2.setArtifactId( "testArtifact" ); childPlugin2.setGroupId( "aaa" ); childPlugin2.setVersion( "1.0" ); PluginExecution childExecution2 = new PluginExecution(); childExecution2.setId( "testExecution" ); childPlugin2.addExecution( childExecution2 ); PluginContainer childContainer = new PluginContainer(); childContainer.addPlugin(childPlugin1); childContainer.addPlugin(childPlugin2); ModelUtils.mergePluginLists(childContainer, parentContainer, true); assertEquals( 4, childContainer.getPlugins().size() ); assertSame(parentPlugin1, childContainer.getPlugins().get(0)); assertSame(parentPlugin2, childContainer.getPlugins().get(1)); assertSame(childPlugin1, childContainer.getPlugins().get(2)); assertSame(childPlugin2, childContainer.getPlugins().get(3)); } /** * Verifies MNG-1499: The ordering of plugin executions should also be in the specified order. */ public void testShouldKeepOriginalPluginExecutionOrdering() { Plugin parent = new Plugin(); parent.setArtifactId( "testArtifact" ); parent.setGroupId( "testGroup" ); parent.setVersion( "1.0" ); PluginExecution parentExecution1 = new PluginExecution(); parentExecution1.setId( "zzz" ); // Will show up last in the sorted map PluginExecution parentExecution2 = new PluginExecution(); parentExecution2.setId( "yyy" ); // Will show up last in the sorted map parent.addExecution( parentExecution1 ); parent.addExecution( parentExecution2 ); // this block verifies MNG-1703 Dependency dep = new Dependency(); dep.setGroupId( "depGroupId" ); dep.setArtifactId( "depArtifactId" ); dep.setVersion( "depVersion" ); parent.setDependencies( Collections.singletonList( dep ) ); Plugin child = new Plugin(); child.setArtifactId( "testArtifact" ); child.setGroupId( "testGroup" ); child.setVersion( "1.0" ); PluginExecution childExecution1 = new PluginExecution(); childExecution1.setId( "bbb" ); PluginExecution childExecution2 = new PluginExecution(); childExecution2.setId( "aaa" ); child.addExecution( childExecution1 ); child.addExecution( childExecution2 ); ModelUtils.mergePluginDefinitions( child, parent, false ); assertEquals( 4, child.getExecutions().size() ); assertSame(parentExecution1, child.getExecutions().get(0)); assertSame(parentExecution2, child.getExecutions().get(1)); assertSame(childExecution1, child.getExecutions().get(2)); assertSame(childExecution2, child.getExecutions().get(3)); // this block prevents MNG-1703 assertEquals( 1, child.getDependencies().size() ); Dependency dep2 = child.getDependencies().get( 0 ); assertEquals( dep.getManagementKey(), dep2.getManagementKey() ); } public void testShouldOverwritePluginConfigurationSubItemsByDefault() throws XmlPullParserException, IOException { String parentConfigStr = "onetwo"; Xpp3Dom parentConfig = Xpp3DomBuilder.build( new StringReader( parentConfigStr ) ); Plugin parentPlugin = createPlugin( "group", "artifact", "1", null ); parentPlugin.setConfiguration( parentConfig ); String childConfigStr = "three"; Xpp3Dom childConfig = Xpp3DomBuilder.build( new StringReader( childConfigStr ) ); Plugin childPlugin = createPlugin( "group", "artifact", "1", null ); childPlugin.setConfiguration( childConfig ); ModelUtils.mergePluginDefinitions( childPlugin, parentPlugin, true ); Xpp3Dom result = (Xpp3Dom) childPlugin.getConfiguration(); Xpp3Dom items = result.getChild( "items" ); assertEquals( 1, items.getChildCount() ); Xpp3Dom item = items.getChild( 0 ); assertEquals( "three", item.getValue() ); } public void testShouldMergePluginConfigurationSubItemsWithMergeAttributeSet() throws XmlPullParserException, IOException { String parentConfigStr = "onetwo"; Xpp3Dom parentConfig = Xpp3DomBuilder.build( new StringReader( parentConfigStr ) ); Plugin parentPlugin = createPlugin( "group", "artifact", "1", null ); parentPlugin.setConfiguration( parentConfig ); String childConfigStr = "three"; Xpp3Dom childConfig = Xpp3DomBuilder.build( new StringReader( childConfigStr ) ); Plugin childPlugin = createPlugin( "group", "artifact", "1", null ); childPlugin.setConfiguration( childConfig ); ModelUtils.mergePluginDefinitions( childPlugin, parentPlugin, true ); Xpp3Dom result = (Xpp3Dom) childPlugin.getConfiguration(); Xpp3Dom items = result.getChild( "items" ); assertEquals( 3, items.getChildCount() ); Xpp3Dom[] item = items.getChildren(); List actual = Arrays.asList( item[0].getValue(), item[1].getValue(), item[2].getValue() ); List expected = Arrays.asList( "one", "two", "three" ); Collections.sort( actual ); Collections.sort( expected ); assertEquals( expected, actual ); } public void testShouldNotMergePluginExecutionWhenExecInheritedIsFalseAndTreatAsInheritanceIsTrue() { String gid = "group"; String aid = "artifact"; String ver = "1"; PluginContainer parent = new PluginContainer(); Plugin pParent = createPlugin( gid, aid, ver, Collections.EMPTY_MAP ); pParent.setInherited( Boolean.toString( true ) ); PluginExecution eParent = new PluginExecution(); String testId = "test"; eParent.setId( testId ); eParent.addGoal( "run" ); eParent.setPhase( "initialize" ); eParent.setInherited( Boolean.toString( false ) ); pParent.addExecution( eParent ); parent.addPlugin( pParent ); PluginContainer child = new PluginContainer(); Plugin pChild = createPlugin( gid, aid, ver, Collections.EMPTY_MAP ); PluginExecution eChild = new PluginExecution(); eChild.setId( "child-specified" ); eChild.addGoal( "child" ); eChild.setPhase( "compile" ); pChild.addExecution( eChild ); child.addPlugin( pChild ); ModelUtils.mergePluginDefinitions( pChild, pParent, true ); Map executionMap = pChild.getExecutionsAsMap(); assertNull( "test execution should not be inherited from parent.", executionMap.get( testId ) ); } public void testShouldNotMergePluginExecutionWhenPluginInheritedIsFalseAndTreatAsInheritanceIsTrue() { String gid = "group"; String aid = "artifact"; String ver = "1"; PluginContainer parent = new PluginContainer(); Plugin pParent = createPlugin( gid, aid, ver, Collections.EMPTY_MAP ); pParent.setInherited( Boolean.toString( false ) ); PluginExecution eParent = new PluginExecution(); String testId = "test"; eParent.setId( testId ); eParent.addGoal( "run" ); eParent.setPhase( "initialize" ); eParent.setInherited( Boolean.toString( true ) ); pParent.addExecution( eParent ); parent.addPlugin( pParent ); PluginContainer child = new PluginContainer(); Plugin pChild = createPlugin( gid, aid, ver, Collections.EMPTY_MAP ); PluginExecution eChild = new PluginExecution(); eChild.setId( "child-specified" ); eChild.addGoal( "child" ); eChild.setPhase( "compile" ); pChild.addExecution( eChild ); child.addPlugin( pChild ); ModelUtils.mergePluginDefinitions( pChild, pParent, true ); Map executionMap = pChild.getExecutionsAsMap(); assertNull( "test execution should not be inherited from parent.", executionMap.get( testId ) ); } public void testShouldMergePluginExecutionWhenExecInheritedIsTrueAndTreatAsInheritanceIsTrue() { String gid = "group"; String aid = "artifact"; String ver = "1"; PluginContainer parent = new PluginContainer(); Plugin pParent = createPlugin( gid, aid, ver, Collections.EMPTY_MAP ); pParent.setInherited( Boolean.toString( true ) ); PluginExecution eParent = new PluginExecution(); String testId = "test"; eParent.setId( testId ); eParent.addGoal( "run" ); eParent.setPhase( "initialize" ); eParent.setInherited( Boolean.toString( true ) ); pParent.addExecution( eParent ); parent.addPlugin( pParent ); PluginContainer child = new PluginContainer(); Plugin pChild = createPlugin( gid, aid, ver, Collections.EMPTY_MAP ); PluginExecution eChild = new PluginExecution(); eChild.setId( "child-specified" ); eChild.addGoal( "child" ); eChild.setPhase( "compile" ); pChild.addExecution( eChild ); child.addPlugin( pChild ); ModelUtils.mergePluginDefinitions( pChild, pParent, true ); Map executionMap = pChild.getExecutionsAsMap(); assertNotNull( "test execution should be inherited from parent.", executionMap.get( testId ) ); } } maven-maven-3.5.2/maven-compat/src/test/java/org/apache/maven/project/ProjectClasspathTest.java000066400000000000000000000146641317160430700325660ustar00rootroot00000000000000package org.apache.maven.project; /* * 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.File; import org.apache.maven.artifact.Artifact; import org.apache.maven.repository.RepositorySystem; import org.apache.maven.repository.internal.DefaultArtifactDescriptorReader; import org.eclipse.aether.impl.ArtifactDescriptorReader; import org.eclipse.aether.impl.ArtifactResolver; public class ProjectClasspathTest extends AbstractMavenProjectTestCase { static final String dir = "projects/scope/"; public void setUp() throws Exception { ArtifactResolver resolver = lookup( ArtifactResolver.class, "classpath" ); DefaultArtifactDescriptorReader pomReader = (DefaultArtifactDescriptorReader)lookup(ArtifactDescriptorReader.class); pomReader.setArtifactResolver( resolver ); projectBuilder = lookup( ProjectBuilder.class, "classpath" ); // the metadata source looks up the default impl, so we have to trick it getContainer().addComponent( projectBuilder, ProjectBuilder.class, "default" ); repositorySystem = lookup( RepositorySystem.class ); } @Override protected String getCustomConfigurationName() { return null; } public void testProjectClasspath() throws Exception { File f = getFileForClasspathResource( dir + "project-with-scoped-dependencies.xml" ); MavenProject project = getProjectWithDependencies( f ); Artifact artifact; assertNotNull( "Test project can't be null!", project ); checkArtifactIdScope( project, "provided", "provided" ); checkArtifactIdScope( project, "test", "test" ); checkArtifactIdScope( project, "compile", "compile" ); checkArtifactIdScope( project, "runtime", "runtime" ); checkArtifactIdScope( project, "default", "compile" ); // check all transitive deps of a test dependency are test, except test and provided which is skipped artifact = getArtifact( project, "maven-test-test", "scope-provided" ); assertNull( "Check no provided dependencies are transitive", artifact ); artifact = getArtifact( project, "maven-test-test", "scope-test" ); assertNull( "Check no test dependencies are transitive", artifact ); artifact = getArtifact( project, "maven-test-test", "scope-compile" ); assertNotNull( artifact ); System.out.println( "a = " + artifact ); System.out.println( "b = " + artifact.getScope() ); assertEquals( "Check scope", "test", artifact.getScope() ); artifact = getArtifact( project, "maven-test-test", "scope-default" ); assertEquals( "Check scope", "test", artifact.getScope() ); artifact = getArtifact( project, "maven-test-test", "scope-runtime" ); assertEquals( "Check scope", "test", artifact.getScope() ); // check all transitive deps of a provided dependency are provided scope, except for test checkGroupIdScope( project, "provided", "maven-test-provided" ); artifact = getArtifact( project, "maven-test-provided", "scope-runtime" ); assertEquals( "Check scope", "provided", artifact.getScope() ); // check all transitive deps of a runtime dependency are runtime scope, except for test checkGroupIdScope( project, "runtime", "maven-test-runtime" ); artifact = getArtifact( project, "maven-test-runtime", "scope-runtime" ); assertEquals( "Check scope", "runtime", artifact.getScope() ); // check all transitive deps of a compile dependency are compile scope, except for runtime and test checkGroupIdScope( project, "compile", "maven-test-compile" ); artifact = getArtifact( project, "maven-test-compile", "scope-runtime" ); assertEquals( "Check scope", "runtime", artifact.getScope() ); // check all transitive deps of a default dependency are compile scope, except for runtime and test checkGroupIdScope( project, "compile", "maven-test-default" ); artifact = getArtifact( project, "maven-test-default", "scope-runtime" ); assertEquals( "Check scope", "runtime", artifact.getScope() ); } private void checkGroupIdScope( MavenProject project, String scopeValue, String groupId ) { Artifact artifact; artifact = getArtifact( project, groupId, "scope-compile" ); assertEquals( "Check scope", scopeValue, artifact.getScope() ); artifact = getArtifact( project, groupId, "scope-test" ); assertNull( "Check test dependency is not transitive", artifact ); artifact = getArtifact( project, groupId, "scope-provided" ); assertNull( "Check provided dependency is not transitive", artifact ); artifact = getArtifact( project, groupId, "scope-default" ); assertEquals( "Check scope", scopeValue, artifact.getScope() ); } private void checkArtifactIdScope( MavenProject project, String scope, String scopeValue ) { String artifactId = "scope-" + scope; Artifact artifact = getArtifact( project, "maven-test", artifactId ); assertNotNull( artifact ); assertEquals( "Check scope", scopeValue, artifact.getScope() ); } private Artifact getArtifact( MavenProject project, String groupId, String artifactId ) { System.out.println( "[ Looking for " + groupId + ":" + artifactId + " ]" ); for ( Artifact a : project.getArtifacts() ) { System.out.println( a.toString() ); if ( artifactId.equals( a.getArtifactId() ) && a.getGroupId().equals( groupId ) ) { System.out.println( "RETURN" ); return a; } } System.out.println( "Return null" ); return null; } } maven-maven-3.5.2/maven-compat/src/test/java/org/apache/maven/project/TestArtifactResolver.java000066400000000000000000000025071317160430700325650ustar00rootroot00000000000000package org.apache.maven.project; /* * 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 org.apache.maven.artifact.metadata.ArtifactMetadataSource; import org.apache.maven.artifact.resolver.ArtifactResolver; import org.apache.maven.artifact.resolver.DefaultArtifactResolver; import org.codehaus.plexus.component.annotations.Component; import org.codehaus.plexus.component.annotations.Requirement; @Component(role=ArtifactResolver.class,hint="classpath") public class TestArtifactResolver extends DefaultArtifactResolver { @Requirement(hint="classpath") private ArtifactMetadataSource source; } maven-maven-3.5.2/maven-compat/src/test/java/org/apache/maven/project/TestMavenRepositorySystem.java000066400000000000000000000025061317160430700336600ustar00rootroot00000000000000package org.apache.maven.project; /* * 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 org.apache.maven.artifact.resolver.ArtifactResolver; import org.apache.maven.repository.RepositorySystem; import org.apache.maven.repository.legacy.LegacyRepositorySystem; import org.codehaus.plexus.component.annotations.Component; import org.codehaus.plexus.component.annotations.Requirement; @Component(role = RepositorySystem.class, hint = "classpath") public class TestMavenRepositorySystem extends LegacyRepositorySystem { @Requirement(hint="classpath") private ArtifactResolver artifactResolver; } maven-maven-3.5.2/maven-compat/src/test/java/org/apache/maven/project/TestProjectBuilder.java000066400000000000000000000047661317160430700322340ustar00rootroot00000000000000package org.apache.maven.project; /* * 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.File; import java.io.FileNotFoundException; import java.util.Collections; import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.repository.ArtifactRepository; import org.codehaus.plexus.component.annotations.Component; @Component(role=ProjectBuilder.class,hint="classpath") public class TestProjectBuilder extends DefaultProjectBuilder { @Override public ProjectBuildingResult build( Artifact artifact, ProjectBuildingRequest request ) throws ProjectBuildingException { if ( "maven-test".equals( artifact.getGroupId() ) ) { String scope = artifact.getArtifactId().substring( "scope-".length() ); try { artifact.setFile( ProjectClasspathTest.getFileForClasspathResource( ProjectClasspathTest.dir + "transitive-" + scope + "-dep.xml" ) ); } catch ( FileNotFoundException e ) { throw new IllegalStateException( "Missing test POM for " + artifact ); } } if ( artifact.getFile() == null ) { MavenProject project = new MavenProject(); project.setArtifact( artifact ); return new DefaultProjectBuildingResult( project, null, null ); } return build( artifact.getFile(), request ); } @Override public ProjectBuildingResult build( File pomFile, ProjectBuildingRequest configuration ) throws ProjectBuildingException { ProjectBuildingResult result = super.build( pomFile, configuration ); result.getProject().setRemoteArtifactRepositories( Collections. emptyList() ); return result; } }maven-maven-3.5.2/maven-compat/src/test/java/org/apache/maven/project/inheritance/000077500000000000000000000000001317160430700300705ustar00rootroot00000000000000AbstractProjectInheritanceTestCase.java000066400000000000000000000035611317160430700375610ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/test/java/org/apache/maven/project/inheritancepackage org.apache.maven.project.inheritance; /* * 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.File; import org.apache.maven.project.AbstractMavenProjectTestCase; /** * @author Jason van Zyl */ public abstract class AbstractProjectInheritanceTestCase extends AbstractMavenProjectTestCase { protected String getTestSeries() { String className = getClass().getPackage().getName(); return className.substring( className.lastIndexOf( '.' ) + 1 ); } protected File projectFile( String name ) { return projectFile( "maven", name ); } protected File projectFile( String groupId, String artifactId ) { return new File( getLocalRepositoryPath(), "/" + groupId + "/poms/" + artifactId + "-1.0.pom" ); } // ---------------------------------------------------------------------- // The local repository for this category of tests // ---------------------------------------------------------------------- protected File getLocalRepositoryPath() { return getTestFile("src/test/resources/inheritance-repo/" + getTestSeries() ); } } maven-maven-3.5.2/maven-compat/src/test/java/org/apache/maven/project/inheritance/t00/000077500000000000000000000000001317160430700304735ustar00rootroot00000000000000ProjectInheritanceTest.java000066400000000000000000000067461317160430700357140ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/test/java/org/apache/maven/project/inheritance/t00package org.apache.maven.project.inheritance.t00; /* * 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 org.apache.maven.project.MavenProject; import org.apache.maven.project.inheritance.AbstractProjectInheritanceTestCase; /** * A test which demonstrates maven's recursive inheritance where * a distinct value is taken from each parent contributing to the * the final model of the project being assembled. There is no * overriding going on amongst the models being used in this test: * each model in the lineage is providing a value that is not present * anywhere else in the lineage. We are just making sure that values * down in the lineage are bubbling up where they should. * * @author Jason van Zyl */ public class ProjectInheritanceTest extends AbstractProjectInheritanceTestCase { // ---------------------------------------------------------------------- // // p4 inherits from p3 // p3 inherits from p2 // p2 inherits from p1 // p1 inherits from p0 // p0 inherits from super model // // or we can show it graphically as: // // p4 ---> p3 ---> p2 ---> p1 ---> p0 --> super model // // ---------------------------------------------------------------------- public void testProjectInheritance() throws Exception { MavenProject p4 = getProject( projectFile( "p4" ) ); assertEquals( "p4", p4.getName() ); // ---------------------------------------------------------------------- // Value inherited from p3 // ---------------------------------------------------------------------- assertEquals( "2000", p4.getInceptionYear() ); // ---------------------------------------------------------------------- // Value taken from p2 // ---------------------------------------------------------------------- assertEquals( "mailing-list", p4.getMailingLists().get( 0 ).getName() ); // ---------------------------------------------------------------------- // Value taken from p1 // ---------------------------------------------------------------------- assertEquals( "scm-url/p2/p3/p4", p4.getScm().getUrl() ); // ---------------------------------------------------------------------- // Value taken from p4 // ---------------------------------------------------------------------- assertEquals( "Codehaus", p4.getOrganization().getName() ); // ---------------------------------------------------------------------- // Value taken from super model // ---------------------------------------------------------------------- assertEquals( "4.0.0", p4.getModelVersion() ); assertEquals( "4.0.0", p4.getModelVersion() ); } } maven-maven-3.5.2/maven-compat/src/test/java/org/apache/maven/project/inheritance/t01/000077500000000000000000000000001317160430700304745ustar00rootroot00000000000000ProjectInheritanceTest.java000066400000000000000000000067241317160430700357110ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/test/java/org/apache/maven/project/inheritance/t01package org.apache.maven.project.inheritance.t01; /* * 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 org.apache.maven.project.MavenProject; import org.apache.maven.project.inheritance.AbstractProjectInheritanceTestCase; /** * A test which demonstrates maven's recursive inheritance where * we are testing to make sure that elements stated in a model are * not clobbered by the same elements elsewhere in the lineage. * * @author Jason van Zyl */ public class ProjectInheritanceTest extends AbstractProjectInheritanceTestCase { // ---------------------------------------------------------------------- // // p4 inherits from p3 // p3 inherits from p2 // p2 inherits from p1 // p1 inherits from p0 // p0 inherits from super model // // or we can show it graphically as: // // p4 ---> p3 ---> p2 ---> p1 ---> p0 --> super model // // ---------------------------------------------------------------------- public void testProjectInheritance() throws Exception { // ---------------------------------------------------------------------- // Check p0 value for org name // ---------------------------------------------------------------------- MavenProject p0 = getProject( projectFile( "maven.t01", "p0" ) ); assertEquals( "p0-org", p0.getOrganization().getName() ); // ---------------------------------------------------------------------- // Check p1 value for org name // ---------------------------------------------------------------------- MavenProject p1 = getProject( projectFile( "maven.t01", "p1" ) ); assertEquals( "p1-org", p1.getOrganization().getName() ); // ---------------------------------------------------------------------- // Check p2 value for org name // ---------------------------------------------------------------------- MavenProject p2 = getProject( projectFile( "maven.t01", "p2" ) ); assertEquals( "p2-org", p2.getOrganization().getName() ); // ---------------------------------------------------------------------- // Check p2 value for org name // ---------------------------------------------------------------------- MavenProject p3 = getProject( projectFile( "maven.t01", "p3" ) ); assertEquals( "p3-org", p3.getOrganization().getName() ); // ---------------------------------------------------------------------- // Check p4 value for org name // ---------------------------------------------------------------------- MavenProject p4 = getProject( projectFile( "maven.t01", "p4" ) ); assertEquals( "p4-org", p4.getOrganization().getName() ); } } maven-maven-3.5.2/maven-compat/src/test/java/org/apache/maven/project/inheritance/t02/000077500000000000000000000000001317160430700304755ustar00rootroot00000000000000ProjectInheritanceTest.java000066400000000000000000000140761317160430700357110ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/test/java/org/apache/maven/project/inheritance/t02package org.apache.maven.project.inheritance.t02; /* * 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.File; import java.util.HashMap; import java.util.List; import java.util.Map; import org.apache.maven.model.Build; import org.apache.maven.model.Plugin; import org.apache.maven.project.MavenProject; import org.apache.maven.project.inheritance.AbstractProjectInheritanceTestCase; /** * A test which demonstrates maven's recursive inheritance where * a distinct value is taken from each parent contributing to the * the final model of the project being assembled. There is no * overriding going on amongst the models being used in this test: * each model in the lineage is providing a value that is not present * anywhere else in the lineage. We are just making sure that values * down in the lineage are bubbling up where they should. * * @author Jason van Zyl */ public class ProjectInheritanceTest extends AbstractProjectInheritanceTestCase { // ---------------------------------------------------------------------- // // p4 inherits from p3 // p3 inherits from p2 // p2 inherits from p1 // p1 inherits from p0 // p0 inherits from super model // // or we can show it graphically as: // // p4 ---> p3 ---> p2 ---> p1 ---> p0 --> super model // // ---------------------------------------------------------------------- public void testProjectInheritance() throws Exception { File localRepo = getLocalRepositoryPath(); System.out.println( "Local repository is at: " + localRepo.getAbsolutePath() ); File pom0 = new File( localRepo, "p0/pom.xml" ); File pom1 = new File( pom0.getParentFile(), "p1/pom.xml" ); File pom2 = new File( pom1.getParentFile(), "p2/pom.xml" ); File pom3 = new File( pom2.getParentFile(), "p3/pom.xml" ); File pom4 = new File( pom3.getParentFile(), "p4/pom.xml" ); File pom5 = new File( pom4.getParentFile(), "p5/pom.xml" ); System.out.println( "Location of project-4's POM: " + pom4.getPath() ); // load everything... MavenProject project0 = getProject( pom0 ); MavenProject project1 = getProject( pom1 ); MavenProject project2 = getProject( pom2 ); MavenProject project3 = getProject( pom3 ); MavenProject project4 = getProject( pom4 ); MavenProject project5 = getProject( pom5 ); assertEquals( "p4", project4.getName() ); // ---------------------------------------------------------------------- // Value inherited from p3 // ---------------------------------------------------------------------- assertEquals( "2000", project4.getInceptionYear() ); // ---------------------------------------------------------------------- // Value taken from p2 // ---------------------------------------------------------------------- assertEquals( "mailing-list", project4.getMailingLists().get( 0 ).getName() ); // ---------------------------------------------------------------------- // Value taken from p1 // ---------------------------------------------------------------------- assertEquals( "scm-url/p2/p3/p4", project4.getScm().getUrl() ); // ---------------------------------------------------------------------- // Value taken from p4 // ---------------------------------------------------------------------- assertEquals( "Codehaus", project4.getOrganization().getName() ); // ---------------------------------------------------------------------- // Value taken from super model // ---------------------------------------------------------------------- assertEquals( "4.0.0", project4.getModelVersion() ); Build build = project4.getBuild(); List plugins = build.getPlugins(); Map validPluginCounts = new HashMap<>(); String testPluginArtifactId = "maven-compiler-plugin"; // this is the plugin we're looking for. validPluginCounts.put( testPluginArtifactId, 0 ); // these are injected if -DperformRelease=true validPluginCounts.put( "maven-deploy-plugin", 0 ); validPluginCounts.put( "maven-javadoc-plugin", 0 ); validPluginCounts.put( "maven-source-plugin", 0 ); Plugin testPlugin = null; for ( Plugin plugin : plugins ) { String pluginArtifactId = plugin.getArtifactId(); if ( !validPluginCounts.containsKey( pluginArtifactId ) ) { fail( "Illegal plugin found: " + pluginArtifactId ); } else { if ( pluginArtifactId.equals( testPluginArtifactId ) ) { testPlugin = plugin; } Integer count = validPluginCounts.get( pluginArtifactId ); if ( count > 0 ) { fail( "Multiple copies of plugin: " + pluginArtifactId + " found in POM." ); } else { count = count + 1; validPluginCounts.put( pluginArtifactId, count ); } } } List executions = testPlugin.getExecutions(); assertEquals( 1, executions.size() ); } } maven-maven-3.5.2/maven-compat/src/test/java/org/apache/maven/project/inheritance/t03/000077500000000000000000000000001317160430700304765ustar00rootroot00000000000000ProjectInheritanceTest.java000066400000000000000000000045601317160430700357070ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/test/java/org/apache/maven/project/inheritance/t03package org.apache.maven.project.inheritance.t03; /* * 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.File; import org.apache.maven.project.MavenProject; import org.apache.maven.project.inheritance.AbstractProjectInheritanceTestCase; /** * A test which demonstrates maven's recursive inheritance where * a distinct value is taken from each parent contributing to the * the final model of the project being assembled. There is no * overriding going on amongst the models being used in this test: * each model in the lineage is providing a value that is not present * anywhere else in the lineage. We are just making sure that values * down in the lineage are bubbling up where they should. * * @author Jason van Zyl */ public class ProjectInheritanceTest extends AbstractProjectInheritanceTestCase { // ---------------------------------------------------------------------- // // p1 inherits from p0 // p0 inherits from super model // // or we can show it graphically as: // // p1 ---> p0 --> super model // // ---------------------------------------------------------------------- public void testProjectInheritance() throws Exception { File localRepo = getLocalRepositoryPath(); File pom0 = new File( localRepo, "p0/pom.xml" ); File pom0Basedir = pom0.getParentFile(); File pom1 = new File( pom0Basedir, "p1/pom.xml" ); // load everything... MavenProject project0 = getProject( pom0 ); MavenProject project1 = getProject( pom1 ); assertEquals( pom0Basedir, project1.getParent().getBasedir() ); } } maven-maven-3.5.2/maven-compat/src/test/java/org/apache/maven/project/inheritance/t04/000077500000000000000000000000001317160430700304775ustar00rootroot00000000000000ProjectInheritanceTest.java000066400000000000000000000063171317160430700357120ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/test/java/org/apache/maven/project/inheritance/t04package org.apache.maven.project.inheritance.t04; /* * 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.File; import java.util.Set; import org.apache.maven.artifact.Artifact; import org.apache.maven.project.MavenProject; import org.apache.maven.project.inheritance.AbstractProjectInheritanceTestCase; /** * Verifies the version of a dependency listed in a parent's * dependencyManagement section is chosen over another version of the same * dependency, listed transitively. * * @author Patrick Schneider */ public class ProjectInheritanceTest extends AbstractProjectInheritanceTestCase { // ---------------------------------------------------------------------- // // p1 inherits from p0 // p0 inherits from super model // // or we can show it graphically as: // // p1 ---> p0 --> super model // // p1 has a depMgmt section that specifies versions 1.0 of jars "a" & "b" // jar "a" has a transitive dependency on 2.0 of jar "b", but maven should // prefer to use version 1.0. // // ---------------------------------------------------------------------- public void testDependencyManagementOverridesTransitiveDependencyVersion() throws Exception { File localRepo = getLocalRepositoryPath(); File pom0 = new File( localRepo, "p0/pom.xml" ); File pom0Basedir = pom0.getParentFile(); File pom1 = new File( pom0Basedir, "p1/pom.xml" ); // load the child project, which inherits from p0... MavenProject project0 = getProjectWithDependencies( pom0 ); MavenProject project1 = getProjectWithDependencies( pom1 ); assertEquals( pom0Basedir, project1.getParent().getBasedir() ); Set set = project1.getArtifacts(); assertNotNull( "No artifacts", set ); assertTrue( "No Artifacts", set.size() > 0 ); assertTrue( "Set size should be 3, is " + set.size(), set.size() == 3 ); for ( Object aSet : set ) { Artifact artifact = (Artifact) aSet; System.out.println( "Artifact: " + artifact.getDependencyConflictId() + " " + artifact.getVersion() + " Optional=" + ( artifact.isOptional() ? "true" : "false" ) ); assertTrue( "Incorrect version for " + artifact.getDependencyConflictId(), artifact.getVersion().equals( "1.0" ) ); } } }maven-maven-3.5.2/maven-compat/src/test/java/org/apache/maven/project/inheritance/t05/000077500000000000000000000000001317160430700305005ustar00rootroot00000000000000ProjectInheritanceTest.java000066400000000000000000000052541317160430700357120ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/test/java/org/apache/maven/project/inheritance/t05package org.apache.maven.project.inheritance.t05; /* * 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.File; import java.util.Set; import org.apache.maven.artifact.Artifact; import org.apache.maven.project.MavenProject; import org.apache.maven.project.inheritance.AbstractProjectInheritanceTestCase; /** * A test which demonstrates maven's dependency management * * @author Ralph Goers */ public class ProjectInheritanceTest extends AbstractProjectInheritanceTestCase { // ---------------------------------------------------------------------- // // p1 inherits from p0 // p0 inherits from super model // // or we can show it graphically as: // // p1 ---> p0 --> super model // // ---------------------------------------------------------------------- public void testDependencyManagement() throws Exception { File localRepo = getLocalRepositoryPath(); File pom0 = new File( localRepo, "p0/pom.xml" ); File pom0Basedir = pom0.getParentFile(); File pom1 = new File( pom0Basedir, "p1/pom.xml" ); // load everything... MavenProject project0 = getProjectWithDependencies( pom0 ); MavenProject project1 = getProjectWithDependencies( pom1 ); assertEquals( pom0Basedir, project1.getParent().getBasedir() ); Set set = project1.getArtifacts(); assertNotNull( "No artifacts", set ); assertTrue( "No Artifacts", set.size() > 0 ); for ( Object aSet : set ) { Artifact artifact = (Artifact) aSet; System.out.println( "Artifact: " + artifact.getDependencyConflictId() + " " + artifact.getVersion() + " Scope: " + artifact.getScope() ); assertTrue( "Incorrect version for " + artifact.getDependencyConflictId(), artifact.getVersion().equals( "1.0" ) ); } } } maven-maven-3.5.2/maven-compat/src/test/java/org/apache/maven/project/inheritance/t06/000077500000000000000000000000001317160430700305015ustar00rootroot00000000000000ProjectInheritanceTest.java000066400000000000000000000055131317160430700357110ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/test/java/org/apache/maven/project/inheritance/t06package org.apache.maven.project.inheritance.t06; /* * 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.File; import java.util.Iterator; import java.util.Set; import org.apache.maven.artifact.Artifact; import org.apache.maven.project.MavenProject; import org.apache.maven.project.inheritance.AbstractProjectInheritanceTestCase; /** * A test which demonstrates maven's dependency management * * @author Ralph Goers */ public class ProjectInheritanceTest extends AbstractProjectInheritanceTestCase { // ---------------------------------------------------------------------- // // p1 inherits from p0 // p0 inherits from super model // // or we can show it graphically as: // // p1 ---> p0 --> super model // // ---------------------------------------------------------------------- public void testDependencyManagement() throws Exception { File localRepo = getLocalRepositoryPath(); File pom0 = new File( localRepo, "p0/pom.xml" ); File pom0Basedir = pom0.getParentFile(); File pom1 = new File( pom0Basedir, "p1/pom.xml" ); // load everything... MavenProject project0 = getProjectWithDependencies( pom0 ); MavenProject project1 = getProjectWithDependencies( pom1 ); assertEquals( pom0Basedir, project1.getParent().getBasedir() ); Set set = project1.getArtifacts(); assertNotNull( "No artifacts", set ); assertTrue( "No Artifacts", set.size() > 0 ); Iterator iter = set.iterator(); assertTrue( "Set size should be 4, is " + set.size(), set.size() == 4 ); while ( iter.hasNext() ) { Artifact artifact = (Artifact) iter.next(); System.out.println( "Artifact: " + artifact.getDependencyConflictId() + " " + artifact.getVersion() + " Optional=" + ( artifact.isOptional() ? "true" : "false" ) ); assertTrue( "Incorrect version for " + artifact.getDependencyConflictId(), artifact.getVersion().equals( "1.0" ) ); } } } maven-maven-3.5.2/maven-compat/src/test/java/org/apache/maven/project/inheritance/t07/000077500000000000000000000000001317160430700305025ustar00rootroot00000000000000ProjectInheritanceTest.java000066400000000000000000000055671317160430700357230ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/test/java/org/apache/maven/project/inheritance/t07package org.apache.maven.project.inheritance.t07; /* * 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.File; import java.util.Set; import org.apache.maven.artifact.Artifact; import org.apache.maven.project.MavenProject; import org.apache.maven.project.inheritance.AbstractProjectInheritanceTestCase; /** * A test which demonstrates maven's dependency management * * @author Jason van Zyl */ public class ProjectInheritanceTest extends AbstractProjectInheritanceTestCase { // ---------------------------------------------------------------------- // // p1 inherits from p0 // p0 inherits from super model // // or we can show it graphically as: // // p1 ---> p0 --> super model // // ---------------------------------------------------------------------- public void testDependencyManagement() throws Exception { File localRepo = getLocalRepositoryPath(); File pom0 = new File( localRepo, "p0/pom.xml" ); File pom0Basedir = pom0.getParentFile(); File pom1 = new File( pom0Basedir, "p1/pom.xml" ); // load everything... MavenProject project1 = getProjectWithDependencies( pom1 ); assertEquals( pom0Basedir, project1.getParent().getBasedir() ); System.out.println("Project " + project1.getId() + " " + project1); Set set = project1.getArtifacts(); assertNotNull("No artifacts", set); assertTrue("No Artifacts", set.size() > 0); assertTrue("Set size should be 3, is " + set.size(), set.size() == 3 ); for ( Object aSet : set ) { Artifact artifact = (Artifact) aSet; assertFalse( "", artifact.getArtifactId().equals( "t07-d" ) ); System.out.println( "Artifact: " + artifact.getDependencyConflictId() + " " + artifact.getVersion() + " Optional=" + ( artifact.isOptional() ? "true" : "false" ) ); assertTrue( "Incorrect version for " + artifact.getDependencyConflictId(), artifact.getVersion().equals( "1.0" ) ); } } } maven-maven-3.5.2/maven-compat/src/test/java/org/apache/maven/project/inheritance/t08/000077500000000000000000000000001317160430700305035ustar00rootroot00000000000000ProjectInheritanceTest.java000066400000000000000000000056311317160430700357140ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/test/java/org/apache/maven/project/inheritance/t08package org.apache.maven.project.inheritance.t08; /* * 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.File; import java.util.Iterator; import java.util.Set; import org.apache.maven.artifact.Artifact; import org.apache.maven.project.MavenProject; import org.apache.maven.project.inheritance.AbstractProjectInheritanceTestCase; /** * A test which demonstrates maven's dependency management * * @author Ralph Goers */ public class ProjectInheritanceTest extends AbstractProjectInheritanceTestCase { // ---------------------------------------------------------------------- // // p1 inherits from p0 // p0 inherits from super model // // or we can show it graphically as: // // p1 ---> p0 --> super model // // ---------------------------------------------------------------------- public void testDependencyManagement() throws Exception { File localRepo = getLocalRepositoryPath(); File pom0 = new File( localRepo, "p0/pom.xml" ); File pom0Basedir = pom0.getParentFile(); File pom1 = new File( pom0Basedir, "p1/pom.xml" ); // load everything... MavenProject project0 = getProjectWithDependencies( pom0 ); MavenProject project1 = getProjectWithDependencies( pom1 ); assertEquals( pom0Basedir, project1.getParent().getBasedir() ); System.out.println( "Project " + project1.getId() + " " + project1 ); Set set = project1.getArtifacts(); assertNotNull( "No artifacts", set ); assertTrue( "No Artifacts", set.size() > 0 ); Iterator iter = set.iterator(); assertTrue( "Set size should be 4, is " + set.size(), set.size() == 4 ); while ( iter.hasNext() ) { Artifact artifact = (Artifact) iter.next(); System.out.println( "Artifact: " + artifact.getDependencyConflictId() + " " + artifact.getVersion() + " Optional=" + ( artifact.isOptional() ? "true" : "false" ) ); assertTrue( "Incorrect version for " + artifact.getDependencyConflictId(), artifact.getVersion().equals( "1.0" ) ); } } } maven-maven-3.5.2/maven-compat/src/test/java/org/apache/maven/project/inheritance/t09/000077500000000000000000000000001317160430700305045ustar00rootroot00000000000000ProjectInheritanceTest.java000066400000000000000000000115231317160430700357120ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/test/java/org/apache/maven/project/inheritance/t09package org.apache.maven.project.inheritance.t09; /* * 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.File; import java.util.Map; import org.apache.maven.project.MavenProject; import org.apache.maven.project.inheritance.AbstractProjectInheritanceTestCase; /** * Verifies exclusions listed in dependencyManagement are valid for * transitive dependencies. * * @author Patrick Schneider */ public class ProjectInheritanceTest extends AbstractProjectInheritanceTestCase { // ---------------------------------------------------------------------- // // p1 inherits from p0 // p0 inherits from super model // // or we can show it graphically as: // // p1 ---> p0 --> super model // // ---------------------------------------------------------------------- /** * How the test project is set up: * * 1. dependencyManagement lists dependencies on a & b, * with an exclusion on c in b. * 2. the child project lists a dependency on project a only * 3. a depends on b (which is transitive to the child project), * and b depends on c. * * We should see that the resulting size of collected artifacts is two: * a & b only. */ public void testDependencyManagementExclusionsExcludeTransitively() throws Exception { File localRepo = getLocalRepositoryPath(); File pom0 = new File( localRepo, "p0/pom.xml" ); File pom0Basedir = pom0.getParentFile(); File pom1 = new File( pom0Basedir, "p1/pom.xml" ); // load the child project, which inherits from p0... MavenProject project0 = getProjectWithDependencies( pom0 ); MavenProject project1 = getProjectWithDependencies( pom1 ); assertNotNull("Parent is null", project1.getParent()); assertEquals( pom0Basedir, project1.getParent().getBasedir() ); Map map = project1.getArtifactMap(); assertNotNull("No artifacts", map); assertTrue("No Artifacts", map.size() > 0); assertTrue("Set size should be 2, is " + map.size(), map.size() == 2); assertTrue("maven-test:t09-a is not in the project", map.containsKey( "maven-test:t09-a" )); assertTrue("maven-test:t09-b is not in the project", map.containsKey( "maven-test:t09-b" )); assertFalse("maven-test:t09-c is in the project", map.containsKey( "maven-test:t09-c" )); } /** * Setup exactly the same as the above test, except that the child project * now depends upon d, which has a transitive dependency on c. Even though * we did list an exclusion on c, it was only from within the context of * project b. We will pick up project c in this case because no * restrictions were placed on d. This demonstrates that a, b, c, & d will * all be collected. * * @throws Exception */ public void testDependencyManagementExclusionDoesNotOverrideGloballyForTransitives() throws Exception { File localRepo = getLocalRepositoryPath(); File pom0 = new File( localRepo, "p0/pom.xml" ); File pom0Basedir = pom0.getParentFile(); File pom2 = new File( pom0Basedir, "p2/pom.xml" ); // load the child project, which inherits from p0... MavenProject project0 = getProjectWithDependencies( pom0 ); MavenProject project2 = getProjectWithDependencies( pom2 ); assertEquals( pom0Basedir, project2.getParent().getBasedir() ); Map map = project2.getArtifactMap(); assertNotNull( "No artifacts", map ); assertTrue( "No Artifacts", map.size() > 0 ); assertTrue( "Set size should be 4, is " + map.size(), map.size() == 4 ); assertTrue( "maven-test:t09-a is not in the project", map.containsKey( "maven-test:t09-a" ) ); assertTrue( "maven-test:t09-b is not in the project", map.containsKey( "maven-test:t09-b" ) ); assertTrue( "maven-test:t09-c is not in the project", map.containsKey( "maven-test:t09-c" ) ); assertTrue( "maven-test:t09-d is not in the project", map.containsKey( "maven-test:t09-d" ) ); } } maven-maven-3.5.2/maven-compat/src/test/java/org/apache/maven/project/inheritance/t10/000077500000000000000000000000001317160430700304745ustar00rootroot00000000000000ProjectInheritanceTest.java000066400000000000000000000070211317160430700357000ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/test/java/org/apache/maven/project/inheritance/t10package org.apache.maven.project.inheritance.t10; /* * 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.File; import java.util.Map; import org.apache.maven.artifact.Artifact; import org.apache.maven.project.MavenProject; import org.apache.maven.project.inheritance.AbstractProjectInheritanceTestCase; /** * Verifies scope inheritance of direct and transitive dependencies. * * Should show three behaviors: * * 1. dependencyManagement should override the scope of transitive dependencies. * 2. Direct dependencies should override the scope of dependencyManagement. * 3. Direct dependencies should inherit scope from dependencyManagement when * they do not explicitly state a scope. * * @author Patrick Schneider */ public class ProjectInheritanceTest extends AbstractProjectInheritanceTestCase { // ---------------------------------------------------------------------- // // p1 inherits from p0 // p0 inherits from super model // // or we can show it graphically as: // // p1 ---> p0 --> super model // // ---------------------------------------------------------------------- public void testDependencyManagementOverridesTransitiveDependencyVersion() throws Exception { File localRepo = getLocalRepositoryPath(); File pom0 = new File( localRepo, "p0/pom.xml" ); File pom0Basedir = pom0.getParentFile(); File pom1 = new File( pom0Basedir, "p1/pom.xml" ); // load the child project, which inherits from p0... MavenProject project0 = getProjectWithDependencies( pom0 ); MavenProject project1 = getProjectWithDependencies( pom1 ); assertEquals( pom0Basedir, project1.getParent().getBasedir() ); System.out.println("Project " + project1.getId() + " " + project1); Map map = project1.getArtifactMap(); assertNotNull("No artifacts", map); assertTrue("No Artifacts", map.size() > 0); assertTrue("Set size should be 3, is " + map.size(), map.size() == 3); Artifact a = (Artifact) map.get("maven-test:t10-a"); Artifact b = (Artifact) map.get("maven-test:t10-b"); Artifact c = (Artifact) map.get("maven-test:t10-c"); assertNotNull( a ); assertNotNull( b ); assertNotNull( c ); // inherited from depMgmt System.out.println(a.getScope()); assertTrue("Incorrect scope for " + a.getDependencyConflictId(), a.getScope().equals("test")); // transitive dep, overridden b depMgmt assertTrue("Incorrect scope for " + b.getDependencyConflictId(), b.getScope().equals("runtime")); // direct dep, overrides depMgmt assertTrue("Incorrect scope for " + c.getDependencyConflictId(), c.getScope().equals("runtime")); } }maven-maven-3.5.2/maven-compat/src/test/java/org/apache/maven/project/inheritance/t11/000077500000000000000000000000001317160430700304755ustar00rootroot00000000000000ProjectInheritanceTest.java000066400000000000000000000046111317160430700357030ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/test/java/org/apache/maven/project/inheritance/t11package org.apache.maven.project.inheritance.t11; /* * 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.File; import org.apache.maven.project.MavenProject; import org.apache.maven.project.inheritance.AbstractProjectInheritanceTestCase; /** * Verifies scope of root project is preserved regardless of parent dependency management. * * @author Patrick Schneider * @see MNG-2919 */ public class ProjectInheritanceTest extends AbstractProjectInheritanceTestCase { // ---------------------------------------------------------------------- // // p1 inherits from p0 // p0 inherits from super model // // or we can show it graphically as: // // p1 ---> p0 --> super model // // ---------------------------------------------------------------------- public void testDependencyManagementDoesNotOverrideScopeOfCurrentArtifact() throws Exception { File localRepo = getLocalRepositoryPath(); File pom0 = new File( localRepo, "p0/pom.xml" ); File pom0Basedir = pom0.getParentFile(); File pom1 = new File( pom0Basedir, "p1/pom.xml" ); // load the child project, which inherits from p0... MavenProject project0 = getProjectWithDependencies( pom0 ); MavenProject project1 = getProjectWithDependencies( pom1 ); assertEquals( pom0Basedir, project1.getParent().getBasedir() ); assertNull( "dependencyManagement has overwritten the scope of the currently building child project", project1.getArtifact().getScope() ); } } maven-maven-3.5.2/maven-compat/src/test/java/org/apache/maven/project/inheritance/t12/000077500000000000000000000000001317160430700304765ustar00rootroot00000000000000ProjectInheritanceTest.java000066400000000000000000000046321317160430700357070ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/test/java/org/apache/maven/project/inheritance/t12package org.apache.maven.project.inheritance.t12; /* * 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.File; import java.util.Map; import org.apache.maven.model.Plugin; import org.apache.maven.project.MavenProject; import org.apache.maven.project.inheritance.AbstractProjectInheritanceTestCase; /** * Verifies that plugin execution sections in the parent POM that have * inherit == false are not inherited to the child POM. */ public class ProjectInheritanceTest extends AbstractProjectInheritanceTestCase { // ---------------------------------------------------------------------- // // p1 inherits from p0 // p0 inherits from super model // // or we can show it graphically as: // // p1 ---> p0 --> super model // // ---------------------------------------------------------------------- public void testFalsePluginExecutionInheritValue() throws Exception { File localRepo = getLocalRepositoryPath(); File pom0 = new File( localRepo, "p0/pom.xml" ); File pom0Basedir = pom0.getParentFile(); File pom1 = new File( pom0Basedir, "p1/pom.xml" ); getProjectWithDependencies( pom0 ); MavenProject project1 = getProjectWithDependencies( pom1 ); Map pluginMap = project1.getBuild().getPluginsAsMap(); Plugin compilerPlugin = (Plugin) pluginMap.get( "org.apache.maven.plugins:maven-compiler-plugin" ); assertNotNull( compilerPlugin ); Map executionMap = compilerPlugin.getExecutionsAsMap(); assertNull( "Plugin execution: \'test\' should NOT exist in the compiler plugin specification for the child project!", executionMap.get( "test" ) ); } }maven-maven-3.5.2/maven-compat/src/test/java/org/apache/maven/project/inheritance/t12scm/000077500000000000000000000000001317160430700312015ustar00rootroot00000000000000ProjectInheritanceTest.java000066400000000000000000000130571317160430700364130ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/test/java/org/apache/maven/project/inheritance/t12scmpackage org.apache.maven.project.inheritance.t12scm; /* * 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.File; import org.apache.maven.project.MavenProject; import org.apache.maven.project.inheritance.AbstractProjectInheritanceTestCase; /** * Verifies SCM inheritance uses modules statement from parent. * * @author jdcasey */ public class ProjectInheritanceTest extends AbstractProjectInheritanceTestCase { // ---------------------------------------------------------------------- // // p1 inherits from p0 // p0 inherits from super model // // or we can show it graphically as: // // p1 ---> p0 --> super model // // ---------------------------------------------------------------------- public void testScmInfoCalculatedCorrectlyOnParentAndChildRead() throws Exception { File localRepo = getLocalRepositoryPath(); File pom0 = new File( localRepo, "p0/pom.xml" ); File pom0Basedir = pom0.getParentFile(); File pom1 = new File( pom0Basedir, "modules/p1/pom.xml" ); // load the child project, which inherits from p0... MavenProject project0 = getProject( pom0 ); MavenProject project1 = getProject( pom1 ); System.out.println( "\n\n" ); System.out.println( "Parent SCM URL is: " + project0.getScm().getUrl() ); System.out.println( "Child SCM URL is: " + project1.getScm().getUrl() ); System.out.println(); System.out.println( "Parent SCM connection is: " + project0.getScm().getConnection() ); System.out.println( "Child SCM connection is: " + project1.getScm().getConnection() ); System.out.println(); System.out.println( "Parent SCM developer connection is: " + project0.getScm().getDeveloperConnection() ); System.out.println( "Child SCM developer connection is: " + project1.getScm().getDeveloperConnection() ); assertEquals( project1.getScm().getUrl(), project0.getScm().getUrl() + "/modules/p1" ); assertEquals( project1.getScm().getConnection(), project0.getScm().getConnection() + "/modules/p1" ); assertEquals( project1.getScm().getDeveloperConnection(), project0.getScm() .getDeveloperConnection() + "/modules/p1" ); } public void testScmInfoCalculatedCorrectlyOnChildOnlyRead() throws Exception { File localRepo = getLocalRepositoryPath(); File pom1 = new File( localRepo, "p0/modules/p1/pom.xml" ); // load the child project, which inherits from p0... MavenProject project1 = getProject( pom1 ); System.out.println( "\n\n" ); System.out.println( "Child SCM URL is: " + project1.getScm().getUrl() ); System.out.println( "Child SCM connection is: " + project1.getScm().getConnection() ); System.out.println( "Child SCM developer connection is: " + project1.getScm().getDeveloperConnection() ); assertEquals( "http://host/viewer?path=/p0/modules/p1", project1.getScm().getUrl() ); assertEquals( "scm:svn:http://host/p0/modules/p1", project1.getScm().getConnection() ); assertEquals( "scm:svn:https://host/p0/modules/p1", project1.getScm().getDeveloperConnection() ); } // public void testScmInfoCalculatedCorrectlyOnChildReadFromLocalRepository() // throws Exception // { // File localRepo = getLocalRepositoryPath(); // // ArtifactFactory factory = (ArtifactFactory) lookup( ArtifactFactory.class ); // Artifact artifact = factory.createProjectArtifact( "maven", "p1", "1.0" ); // // ArtifactRepositoryFactory repoFactory = (ArtifactRepositoryFactory) lookup( ArtifactRepositoryFactory.class ); // ArtifactRepository localArtifactRepo = repoFactory.createLocalRepository( localRepo ); // // MavenProject project1 = getProjectBuilder().buildFromRepository( artifact, Collections.EMPTY_LIST, localArtifactRepo ); // // System.out.println( "\n\n" ); // System.out.println( "Child SCM URL is: " + project1.getScm().getUrl() ); // System.out.println( "Child SCM connection is: " + project1.getScm().getConnection() ); // System.out.println( "Child SCM developer connection is: " // + project1.getScm().getDeveloperConnection() ); // // assertEquals( project1.getScm().getUrl(), "http://host/viewer?path=/p0/modules/p1" ); // assertEquals( project1.getScm().getConnection(), "scm:svn:http://host/p0/modules/p1" ); // assertEquals( project1.getScm().getDeveloperConnection(), // "scm:svn:https://host/p0/modules/p1" ); // } } maven-maven-3.5.2/maven-compat/src/test/java/org/apache/maven/project/path/000077500000000000000000000000001317160430700265335ustar00rootroot00000000000000DefaultPathTranslatorTest.java000066400000000000000000000040231317160430700344310ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/test/java/org/apache/maven/project/pathpackage org.apache.maven.project.path; /* * 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.File; import junit.framework.TestCase; @SuppressWarnings( "deprecation" ) public class DefaultPathTranslatorTest extends TestCase { public void testAlignToBasedirWhereBasedirExpressionIsTheCompleteValue() { File basedir = new File( System.getProperty( "java.io.tmpdir" ), "test" ).getAbsoluteFile(); String aligned = new DefaultPathTranslator().alignToBaseDirectory( "${basedir}", basedir ); assertEquals( basedir.getAbsolutePath(), aligned ); } public void testAlignToBasedirWhereBasedirExpressionIsTheValuePrefix() { File basedir = new File( System.getProperty( "java.io.tmpdir" ), "test" ).getAbsoluteFile(); String aligned = new DefaultPathTranslator().alignToBaseDirectory( "${basedir}/dir", basedir ); assertEquals( new File( basedir, "dir" ).getAbsolutePath(), aligned ); } public void testUnalignToBasedirWherePathEqualsBasedir() { File basedir = new File( System.getProperty( "java.io.tmpdir" ), "test" ).getAbsoluteFile(); String unaligned = new DefaultPathTranslator().unalignFromBaseDirectory( basedir.getAbsolutePath(), basedir ); assertEquals( ".", unaligned ); } } maven-maven-3.5.2/maven-compat/src/test/java/org/apache/maven/repository/000077500000000000000000000000001317160430700263505ustar00rootroot00000000000000DefaultMirrorSelectorTest.java000066400000000000000000000027541317160430700342640ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/test/java/org/apache/maven/repositorypackage org.apache.maven.repository; /* * 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 org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.repository.DefaultArtifactRepository; import org.codehaus.plexus.PlexusTestCase; public class DefaultMirrorSelectorTest extends PlexusTestCase { public void testMirrorWithMirrorOfPatternContainingANegationIsNotSelected() { ArtifactRepository repository = new DefaultArtifactRepository( "snapshots.repo", "http://whatever", null ); String pattern = "external:*, !snapshots.repo"; boolean matches = DefaultMirrorSelector.matchPattern( repository, pattern ); System.out.println( matches ); assertFalse( matches ); } } maven-maven-3.5.2/maven-compat/src/test/java/org/apache/maven/repository/LegacyRepositoryLayout.java000066400000000000000000000060211317160430700337140ustar00rootroot00000000000000package org.apache.maven.repository; /* * 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 org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.handler.ArtifactHandler; import org.apache.maven.artifact.metadata.ArtifactMetadata; import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout; import org.codehaus.plexus.component.annotations.Component; /** * @author jdcasey */ @Component(role=ArtifactRepositoryLayout.class, hint="legacy") public class LegacyRepositoryLayout implements ArtifactRepositoryLayout { private static final String PATH_SEPARATOR = "/"; public String getId() { return "legacy"; } public String pathOf( Artifact artifact ) { ArtifactHandler artifactHandler = artifact.getArtifactHandler(); StringBuilder path = new StringBuilder( 128 ); path.append( artifact.getGroupId() ).append( '/' ); path.append( artifactHandler.getDirectory() ).append( '/' ); path.append( artifact.getArtifactId() ).append( '-' ).append( artifact.getVersion() ); if ( artifact.hasClassifier() ) { path.append( '-' ).append( artifact.getClassifier() ); } if ( artifactHandler.getExtension() != null && artifactHandler.getExtension().length() > 0 ) { path.append( '.' ).append( artifactHandler.getExtension() ); } return path.toString(); } public String pathOfLocalRepositoryMetadata( ArtifactMetadata metadata, ArtifactRepository repository ) { return pathOfRepositoryMetadata( metadata, metadata.getLocalFilename( repository ) ); } private String pathOfRepositoryMetadata( ArtifactMetadata metadata, String filename ) { StringBuilder path = new StringBuilder( 128 ); path.append( metadata.getGroupId() ).append( PATH_SEPARATOR ).append( "poms" ).append( PATH_SEPARATOR ); path.append( filename ); return path.toString(); } public String pathOfRemoteRepositoryMetadata( ArtifactMetadata metadata ) { return pathOfRepositoryMetadata( metadata, metadata.getRemoteFilename() ); } } LegacyRepositorySystemTest.java000066400000000000000000000176011317160430700345120ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/test/java/org/apache/maven/repositorypackage org.apache.maven.repository; /* * 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.File; import java.util.Arrays; import java.util.List; import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.resolver.ArtifactResolutionRequest; import org.apache.maven.artifact.resolver.ArtifactResolutionResult; import org.apache.maven.artifact.resolver.ResolutionErrorHandler; import org.apache.maven.execution.DefaultMavenExecutionRequest; import org.apache.maven.execution.DefaultMavenExecutionResult; import org.apache.maven.execution.MavenSession; import org.apache.maven.model.Dependency; import org.apache.maven.model.Repository; import org.apache.maven.model.RepositoryPolicy; import org.apache.maven.plugin.LegacySupport; import org.apache.maven.repository.RepositorySystem; import org.apache.maven.repository.legacy.LegacyRepositorySystem; import org.codehaus.plexus.ContainerConfiguration; import org.codehaus.plexus.PlexusConstants; import org.codehaus.plexus.PlexusTestCase; import org.eclipse.aether.DefaultRepositorySystemSession; import org.eclipse.aether.internal.impl.SimpleLocalRepositoryManagerFactory; import org.eclipse.aether.repository.LocalRepository; /** * Tests {@link LegacyRepositorySystem}. * * @author Benjamin Bentmann */ public class LegacyRepositorySystemTest extends PlexusTestCase { private RepositorySystem repositorySystem; private ResolutionErrorHandler resolutionErrorHandler; @Override protected void customizeContainerConfiguration( ContainerConfiguration containerConfiguration ) { super.customizeContainerConfiguration( containerConfiguration ); containerConfiguration.setAutoWiring( true ); containerConfiguration.setClassPathScanning( PlexusConstants.SCANNING_INDEX ); } @Override protected void setUp() throws Exception { super.setUp(); repositorySystem = lookup( RepositorySystem.class, "default" ); resolutionErrorHandler = lookup( ResolutionErrorHandler.class ); } @Override protected void tearDown() throws Exception { repositorySystem = null; resolutionErrorHandler = null; super.tearDown(); } protected List getRemoteRepositories() throws Exception { File repoDir = new File( getBasedir(), "src/test/remote-repo" ).getAbsoluteFile(); RepositoryPolicy policy = new RepositoryPolicy(); policy.setEnabled( true ); policy.setChecksumPolicy( "ignore" ); policy.setUpdatePolicy( "always" ); Repository repository = new Repository(); repository.setId( RepositorySystem.DEFAULT_REMOTE_REPO_ID ); repository.setUrl( "file://" + repoDir.toURI().getPath() ); repository.setReleases( policy ); repository.setSnapshots( policy ); return Arrays.asList( repositorySystem.buildArtifactRepository( repository ) ); } protected ArtifactRepository getLocalRepository() throws Exception { File repoDir = new File( getBasedir(), "target/local-repo" ).getAbsoluteFile(); return repositorySystem.createLocalRepository( repoDir ); } public void testThatASystemScopedDependencyIsNotResolvedFromRepositories() throws Exception { // // We should get a whole slew of dependencies resolving this artifact transitively // Dependency d = new Dependency(); d.setGroupId( "org.apache.maven.its" ); d.setArtifactId( "b" ); d.setVersion( "0.1" ); d.setScope( Artifact.SCOPE_COMPILE ); Artifact artifact = repositorySystem.createDependencyArtifact( d ); ArtifactResolutionRequest request = new ArtifactResolutionRequest() .setArtifact( artifact ) .setResolveRoot( true ) .setResolveTransitively( true ) .setRemoteRepositories( getRemoteRepositories() ) .setLocalRepository( getLocalRepository() ); DefaultRepositorySystemSession session = new DefaultRepositorySystemSession(); LocalRepository localRepo = new LocalRepository( request.getLocalRepository().getBasedir() ); session.setLocalRepositoryManager( new SimpleLocalRepositoryManagerFactory().newInstance( session, localRepo ) ); LegacySupport legacySupport = lookup( LegacySupport.class ); legacySupport.setSession( new MavenSession( getContainer(), session, new DefaultMavenExecutionRequest(), new DefaultMavenExecutionResult() ) ); ArtifactResolutionResult result = repositorySystem.resolve( request ); resolutionErrorHandler.throwErrors( request, result ); assertEquals( 2, result.getArtifacts().size() ); // // System scoped version which should // d.setScope( Artifact.SCOPE_SYSTEM ); File file = new File( getBasedir(), "src/test/repository-system/maven-core-2.1.0.jar" ); assertTrue( file.exists() ); d.setSystemPath( file.getCanonicalPath() ); artifact = repositorySystem.createDependencyArtifact( d ); // // The request has not set any local or remote repositories as the system scoped dependency being resolved should only // give us the dependency off the disk and nothing more. // request = new ArtifactResolutionRequest() .setArtifact( artifact ) .setResolveRoot( true ) .setResolveTransitively( true ); result = repositorySystem.resolve( request ); resolutionErrorHandler.throwErrors( request, result ); assertEquals( 1, result.getArtifacts().size() ); // // Put in a bogus file to make sure missing files cause the resolution to fail. // file = new File( getBasedir(), "src/test/repository-system/maven-monkey-2.1.0.jar" ); assertFalse( file.exists() ); d.setSystemPath( file.getCanonicalPath() ); artifact = repositorySystem.createDependencyArtifact( d ); // // The request has not set any local or remote repositories as the system scoped dependency being resolved should only // give us the dependency off the disk and nothing more. // request = new ArtifactResolutionRequest() .setArtifact( artifact ) .setResolveRoot( true ) .setResolveTransitively( true ); try { result = repositorySystem.resolve( request ); resolutionErrorHandler.throwErrors( request, result ); } catch( Exception e ) { assertTrue( result.hasMissingArtifacts() ); } } public void testLocalRepositoryBasedir() throws Exception { File localRepoDir = new File( "" ).getAbsoluteFile(); ArtifactRepository localRepo = repositorySystem.createLocalRepository( localRepoDir ); String basedir = localRepo.getBasedir(); assertFalse( basedir.endsWith( "/" ) ); assertFalse( basedir.endsWith( "\\" ) ); assertEquals( localRepoDir, new File( basedir ) ); assertEquals( localRepoDir.getPath(), basedir ); } } maven-maven-3.5.2/maven-compat/src/test/java/org/apache/maven/repository/MirrorProcessorTest.java000066400000000000000000000264011317160430700332300ustar00rootroot00000000000000package org.apache.maven.repository; /* * 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.util.Arrays; import java.util.List; import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.repository.legacy.repository.ArtifactRepositoryFactory; import org.apache.maven.artifact.repository.layout.DefaultRepositoryLayout; import org.apache.maven.settings.Mirror; import org.codehaus.plexus.PlexusTestCase; public class MirrorProcessorTest extends PlexusTestCase { private DefaultMirrorSelector mirrorSelector; private ArtifactRepositoryFactory repositorySystem; protected void setUp() throws Exception { mirrorSelector = (DefaultMirrorSelector) lookup( MirrorSelector.class ); repositorySystem = lookup( ArtifactRepositoryFactory.class ); } @Override protected void tearDown() throws Exception { mirrorSelector = null; repositorySystem = null; super.tearDown(); } public void testExternalURL() { assertTrue( DefaultMirrorSelector.isExternalRepo( getRepo( "foo", "http://somehost" ) ) ); assertTrue( DefaultMirrorSelector.isExternalRepo( getRepo( "foo", "http://somehost:9090/somepath" ) ) ); assertTrue( DefaultMirrorSelector.isExternalRepo( getRepo( "foo", "ftp://somehost" ) ) ); assertTrue( DefaultMirrorSelector.isExternalRepo( getRepo( "foo", "http://192.168.101.1" ) ) ); assertTrue( DefaultMirrorSelector.isExternalRepo( getRepo( "foo", "http://" ) ) ); // these are local assertFalse( DefaultMirrorSelector.isExternalRepo( getRepo( "foo", "http://localhost:8080" ) ) ); assertFalse( DefaultMirrorSelector.isExternalRepo( getRepo( "foo", "http://127.0.0.1:9090" ) ) ); assertFalse( DefaultMirrorSelector.isExternalRepo( getRepo( "foo", "file://localhost/somepath" ) ) ); assertFalse( DefaultMirrorSelector.isExternalRepo( getRepo( "foo", "file://localhost/D:/somepath" ) ) ); assertFalse( DefaultMirrorSelector.isExternalRepo( getRepo( "foo", "http://localhost" ) ) ); assertFalse( DefaultMirrorSelector.isExternalRepo( getRepo( "foo", "http://127.0.0.1" ) ) ); assertFalse( DefaultMirrorSelector.isExternalRepo( getRepo( "foo", "file:///somepath" ) ) ); assertFalse( DefaultMirrorSelector.isExternalRepo( getRepo( "foo", "file://D:/somepath" ) ) ); // not a proper url so returns false; assertFalse( DefaultMirrorSelector.isExternalRepo( getRepo( "foo", "192.168.101.1" ) ) ); assertFalse( DefaultMirrorSelector.isExternalRepo( getRepo( "foo", "" ) ) ); } public void testMirrorLookup() { Mirror mirrorA = newMirror( "a", "a", "http://a" ); Mirror mirrorB = newMirror( "b", "b", "http://b" ); List mirrors = Arrays.asList( mirrorA, mirrorB ); assertSame( mirrorA, mirrorSelector.getMirror( getRepo( "a", "http://a.a" ), mirrors ) ); assertSame( mirrorB, mirrorSelector.getMirror( getRepo( "b", "http://a.a" ), mirrors ) ); assertNull( mirrorSelector.getMirror( getRepo( "c", "http://c.c" ), mirrors ) ); } public void testMirrorWildcardLookup() { Mirror mirrorA = newMirror( "a", "a", "http://a" ); Mirror mirrorB = newMirror( "b", "b", "http://b" ); Mirror mirrorC = newMirror( "c", "*", "http://wildcard" ); List mirrors = Arrays.asList( mirrorA, mirrorB, mirrorC ); assertSame( mirrorA, mirrorSelector.getMirror( getRepo( "a", "http://a.a" ), mirrors ) ); assertSame( mirrorB, mirrorSelector.getMirror( getRepo( "b", "http://a.a" ), mirrors ) ); assertSame( mirrorC, mirrorSelector.getMirror( getRepo( "c", "http://c.c" ), mirrors ) ); } public void testMirrorStopOnFirstMatch() { // exact matches win first Mirror mirrorA2 = newMirror( "a2", "a,b", "http://a2" ); Mirror mirrorA = newMirror( "a", "a", "http://a" ); // make sure repeated entries are skipped Mirror mirrorA3 = newMirror( "a", "a", "http://a3" ); Mirror mirrorB = newMirror( "b", "b", "http://b" ); Mirror mirrorC = newMirror( "c", "d,e", "http://de" ); Mirror mirrorC2 = newMirror( "c", "*", "http://wildcard" ); Mirror mirrorC3 = newMirror( "c", "e,f", "http://ef" ); List mirrors = Arrays.asList( mirrorA2, mirrorA, mirrorA3, mirrorB, mirrorC, mirrorC2, mirrorC3 ); assertSame( mirrorA, mirrorSelector.getMirror( getRepo( "a", "http://a.a" ), mirrors ) ); assertSame( mirrorB, mirrorSelector.getMirror( getRepo( "b", "http://a.a" ), mirrors ) ); assertSame( mirrorC2, mirrorSelector.getMirror( getRepo( "c", "http://c.c" ), mirrors ) ); assertSame( mirrorC, mirrorSelector.getMirror( getRepo( "d", "http://d" ), mirrors ) ); assertSame( mirrorC, mirrorSelector.getMirror( getRepo( "e", "http://e" ), mirrors ) ); assertSame( mirrorC2, mirrorSelector.getMirror( getRepo( "f", "http://f" ), mirrors ) ); } public void testPatterns() { assertTrue( DefaultMirrorSelector.matchPattern( getRepo( "a" ), "*" ) ); assertTrue( DefaultMirrorSelector.matchPattern( getRepo( "a" ), "*," ) ); assertTrue( DefaultMirrorSelector.matchPattern( getRepo( "a" ), ",*," ) ); assertTrue( DefaultMirrorSelector.matchPattern( getRepo( "a" ), "*," ) ); assertTrue( DefaultMirrorSelector.matchPattern( getRepo( "a" ), "a" ) ); assertTrue( DefaultMirrorSelector.matchPattern( getRepo( "a" ), "a," ) ); assertTrue( DefaultMirrorSelector.matchPattern( getRepo( "a" ), ",a," ) ); assertTrue( DefaultMirrorSelector.matchPattern( getRepo( "a" ), "a," ) ); assertFalse( DefaultMirrorSelector.matchPattern( getRepo( "b" ), "a" ) ); assertFalse( DefaultMirrorSelector.matchPattern( getRepo( "b" ), "a," ) ); assertFalse( DefaultMirrorSelector.matchPattern( getRepo( "b" ), ",a" ) ); assertFalse( DefaultMirrorSelector.matchPattern( getRepo( "b" ), ",a," ) ); assertTrue( DefaultMirrorSelector.matchPattern( getRepo( "a" ), "a,b" ) ); assertTrue( DefaultMirrorSelector.matchPattern( getRepo( "b" ), "a,b" ) ); assertFalse( DefaultMirrorSelector.matchPattern( getRepo( "c" ), "a,b" ) ); assertTrue( DefaultMirrorSelector.matchPattern( getRepo( "a" ), "*" ) ); assertTrue( DefaultMirrorSelector.matchPattern( getRepo( "a" ), "*,b" ) ); assertTrue( DefaultMirrorSelector.matchPattern( getRepo( "a" ), "*,!b" ) ); assertFalse( DefaultMirrorSelector.matchPattern( getRepo( "a" ), "*,!a" ) ); assertFalse( DefaultMirrorSelector.matchPattern( getRepo( "a" ), "!a,*" ) ); assertTrue( DefaultMirrorSelector.matchPattern( getRepo( "c" ), "*,!a" ) ); assertTrue( DefaultMirrorSelector.matchPattern( getRepo( "c" ), "!a,*" ) ); assertFalse( DefaultMirrorSelector.matchPattern( getRepo( "c" ), "!a,!c" ) ); assertFalse( DefaultMirrorSelector.matchPattern( getRepo( "d" ), "!a,!c*" ) ); } public void testPatternsWithExternal() { assertTrue( DefaultMirrorSelector.matchPattern( getRepo( "a", "http://localhost" ), "*" ) ); assertFalse( DefaultMirrorSelector.matchPattern( getRepo( "a", "http://localhost" ), "external:*" ) ); assertTrue( DefaultMirrorSelector.matchPattern( getRepo( "a", "http://localhost" ), "external:*,a" ) ); assertFalse( DefaultMirrorSelector.matchPattern( getRepo( "a", "http://localhost" ), "external:*,!a" ) ); assertTrue( DefaultMirrorSelector.matchPattern( getRepo( "a", "http://localhost" ), "a,external:*" ) ); assertFalse( DefaultMirrorSelector.matchPattern( getRepo( "a", "http://localhost" ), "!a,external:*" ) ); assertFalse( DefaultMirrorSelector.matchPattern( getRepo( "c", "http://localhost" ), "!a,external:*" ) ); assertTrue( DefaultMirrorSelector.matchPattern( getRepo( "c", "http://somehost" ), "!a,external:*" ) ); } public void testLayoutPattern() { assertTrue( DefaultMirrorSelector.matchesLayout( "default", null ) ); assertTrue( DefaultMirrorSelector.matchesLayout( "default", "" ) ); assertTrue( DefaultMirrorSelector.matchesLayout( "default", "*" ) ); assertTrue( DefaultMirrorSelector.matchesLayout( "default", "default" ) ); assertFalse( DefaultMirrorSelector.matchesLayout( "default", "legacy" ) ); assertTrue( DefaultMirrorSelector.matchesLayout( "default", "legacy,default" ) ); assertTrue( DefaultMirrorSelector.matchesLayout( "default", "default,legacy" ) ); assertFalse( DefaultMirrorSelector.matchesLayout( "default", "legacy,!default" ) ); assertFalse( DefaultMirrorSelector.matchesLayout( "default", "!default,legacy" ) ); assertFalse( DefaultMirrorSelector.matchesLayout( "default", "*,!default" ) ); assertFalse( DefaultMirrorSelector.matchesLayout( "default", "!default,*" ) ); } public void testMirrorLayoutConsideredForMatching() { ArtifactRepository repo = getRepo( "a" ); Mirror mirrorA = newMirror( "a", "a", null, "http://a" ); Mirror mirrorB = newMirror( "b", "a", "p2", "http://b" ); Mirror mirrorC = newMirror( "c", "*", null, "http://c" ); Mirror mirrorD = newMirror( "d", "*", "p2", "http://d" ); assertSame( mirrorA, mirrorSelector.getMirror( repo, Arrays.asList( mirrorA ) ) ); assertNull( mirrorSelector.getMirror( repo, Arrays.asList( mirrorB ) ) ); assertSame( mirrorC, mirrorSelector.getMirror( repo, Arrays.asList( mirrorC ) ) ); assertNull( mirrorSelector.getMirror( repo, Arrays.asList( mirrorD ) ) ); } /** * Build an ArtifactRepository object. * * @param id * @param url * @return */ private ArtifactRepository getRepo( String id, String url ) { return repositorySystem.createArtifactRepository( id, url, new DefaultRepositoryLayout(), null, null ); } /** * Build an ArtifactRepository object. * * @param id * @return */ private ArtifactRepository getRepo( String id ) { return getRepo( id, "http://something" ); } private Mirror newMirror( String id, String mirrorOf, String url ) { return newMirror( id, mirrorOf, null, url ); } private Mirror newMirror( String id, String mirrorOf, String layouts, String url ) { Mirror mirror = new Mirror(); mirror.setId( id ); mirror.setMirrorOf( mirrorOf ); mirror.setMirrorOfLayouts( layouts ); mirror.setUrl( url ); return mirror; } } maven-maven-3.5.2/maven-compat/src/test/java/org/apache/maven/repository/legacy/000077500000000000000000000000001317160430700276145ustar00rootroot00000000000000DefaultUpdateCheckManagerTest.java000066400000000000000000000216611317160430700362260ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/test/java/org/apache/maven/repository/legacypackage org.apache.maven.repository.legacy; /* * 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.File; import org.apache.maven.artifact.AbstractArtifactComponentTestCase; import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.factory.ArtifactFactory; import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.repository.metadata.ArtifactRepositoryMetadata; import org.apache.maven.artifact.repository.metadata.RepositoryMetadata; import org.apache.maven.repository.legacy.DefaultUpdateCheckManager; import org.codehaus.plexus.logging.Logger; import org.codehaus.plexus.logging.console.ConsoleLogger; public class DefaultUpdateCheckManagerTest extends AbstractArtifactComponentTestCase { DefaultUpdateCheckManager updateCheckManager; @Override protected String component() { return "updateCheckManager"; } @Override protected void setUp() throws Exception { super.setUp(); updateCheckManager = new DefaultUpdateCheckManager( new ConsoleLogger( Logger.LEVEL_DEBUG, "test" ) ); } public void testArtifact() throws Exception { ArtifactRepository remoteRepository = remoteRepository(); ArtifactRepository localRepository = localRepository(); Artifact a = createArtifact( "a", "0.0.1-SNAPSHOT" ); File file = new File( localRepository.getBasedir(), localRepository.pathOf( a ) ); file.delete(); a.setFile( file ); File touchFile = updateCheckManager.getTouchfile( a ); touchFile.delete(); assertTrue( updateCheckManager.isUpdateRequired( a, remoteRepository ) ); file.getParentFile().mkdirs(); file.createNewFile(); updateCheckManager.touch( a, remoteRepository, null ); assertFalse( updateCheckManager.isUpdateRequired( a, remoteRepository ) ); assertNull( updateCheckManager.readLastUpdated( touchFile, updateCheckManager.getRepositoryKey( remoteRepository ) ) ); assertFalse( updateCheckManager.getTouchfile( a ).exists() ); } public void testMissingArtifact() throws Exception { ArtifactRepository remoteRepository = remoteRepository(); ArtifactRepository localRepository = localRepository(); Artifact a = createArtifact( "a", "0.0.1-SNAPSHOT" ); File file = new File( localRepository.getBasedir(), localRepository.pathOf( a ) ); file.delete(); a.setFile( file ); File touchFile = updateCheckManager.getTouchfile( a ); touchFile.delete(); assertTrue( updateCheckManager.isUpdateRequired( a, remoteRepository ) ); updateCheckManager.touch( a, remoteRepository, null ); assertFalse( updateCheckManager.isUpdateRequired( a, remoteRepository ) ); assertFalse( file.exists() ); assertNotNull( updateCheckManager.readLastUpdated( touchFile, updateCheckManager.getRepositoryKey( remoteRepository ) ) ); } public void testPom() throws Exception { ArtifactRepository remoteRepository = remoteRepository(); ArtifactRepository localRepository = localRepository(); Artifact a = createArtifact( "a", "0.0.1", "pom" ); File file = new File( localRepository.getBasedir(), localRepository.pathOf( a ) ); file.delete(); a.setFile( file ); File touchFile = updateCheckManager.getTouchfile( a ); touchFile.delete(); assertTrue( updateCheckManager.isUpdateRequired( a, remoteRepository ) ); file.getParentFile().mkdirs(); file.createNewFile(); updateCheckManager.touch( a, remoteRepository, null ); assertFalse( updateCheckManager.isUpdateRequired( a, remoteRepository ) ); assertNull( updateCheckManager.readLastUpdated( touchFile, updateCheckManager.getRepositoryKey( remoteRepository ) ) ); assertFalse( updateCheckManager.getTouchfile( a ).exists() ); } public void testMissingPom() throws Exception { ArtifactRepository remoteRepository = remoteRepository(); ArtifactRepository localRepository = localRepository(); Artifact a = createArtifact( "a", "0.0.1", "pom" ); File file = new File( localRepository.getBasedir(), localRepository.pathOf( a ) ); file.delete(); a.setFile( file ); File touchFile = updateCheckManager.getTouchfile( a ); touchFile.delete(); assertTrue( updateCheckManager.isUpdateRequired( a, remoteRepository ) ); updateCheckManager.touch( a, remoteRepository, null ); assertFalse( updateCheckManager.isUpdateRequired( a, remoteRepository ) ); assertFalse( file.exists() ); assertNotNull( updateCheckManager.readLastUpdated( touchFile, updateCheckManager.getRepositoryKey( remoteRepository ) ) ); } public void testMetadata() throws Exception { ArtifactRepository remoteRepository = remoteRepository(); ArtifactRepository localRepository = localRepository(); Artifact a = createRemoteArtifact( "a", "0.0.1-SNAPSHOT" ); RepositoryMetadata metadata = new ArtifactRepositoryMetadata( a ); File file = new File( localRepository.getBasedir(), localRepository.pathOfLocalRepositoryMetadata( metadata, localRepository ) ); file.delete(); File touchFile = updateCheckManager.getTouchfile( metadata, file ); touchFile.delete(); assertTrue( updateCheckManager.isUpdateRequired( metadata, remoteRepository, file ) ); file.getParentFile().mkdirs(); file.createNewFile(); updateCheckManager.touch( metadata, remoteRepository, file ); assertFalse( updateCheckManager.isUpdateRequired( metadata, remoteRepository, file ) ); assertNotNull( updateCheckManager.readLastUpdated( touchFile, updateCheckManager.getMetadataKey( remoteRepository, file ) ) ); } public void testMissingMetadata() throws Exception { ArtifactRepository remoteRepository = remoteRepository(); ArtifactRepository localRepository = localRepository(); Artifact a = createRemoteArtifact( "a", "0.0.1-SNAPSHOT" ); RepositoryMetadata metadata = new ArtifactRepositoryMetadata( a ); File file = new File( localRepository.getBasedir(), localRepository.pathOfLocalRepositoryMetadata( metadata, localRepository ) ); file.delete(); File touchFile = updateCheckManager.getTouchfile( metadata, file ); touchFile.delete(); assertTrue( updateCheckManager.isUpdateRequired( metadata, remoteRepository, file ) ); updateCheckManager.touch( metadata, remoteRepository, file ); assertFalse( updateCheckManager.isUpdateRequired( metadata, remoteRepository, file ) ); assertNotNull( updateCheckManager.readLastUpdated( touchFile, updateCheckManager.getMetadataKey( remoteRepository, file ) ) ); } public void testArtifactTouchFileName() throws Exception { ArtifactFactory artifactFactory = (ArtifactFactory) lookup( ArtifactFactory.ROLE ); ArtifactRepository localRepository = localRepository(); Artifact a = artifactFactory.createArtifactWithClassifier( "groupdId", "a", "0.0.1-SNAPSHOT", "jar", null ); File file = new File( localRepository.getBasedir(), localRepository.pathOf( a ) ); a.setFile( file ); assertEquals( "a-0.0.1-SNAPSHOT.jar.lastUpdated", updateCheckManager.getTouchfile( a ).getName() ); a = artifactFactory.createArtifactWithClassifier( "groupdId", "a", "0.0.1-SNAPSHOT", "jar", "classifier" ); file = new File( localRepository.getBasedir(), localRepository.pathOf( a ) ); a.setFile( file ); assertEquals( "a-0.0.1-SNAPSHOT-classifier.jar.lastUpdated", updateCheckManager.getTouchfile( a ).getName() ); } } DefaultWagonManagerTest.java000066400000000000000000000345631317160430700351260ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/test/java/org/apache/maven/repository/legacypackage org.apache.maven.repository.legacy; /* * 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.File; import java.io.IOException; import java.util.ArrayList; import java.util.List; import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.DefaultArtifact; import org.apache.maven.artifact.factory.ArtifactFactory; import org.apache.maven.artifact.metadata.ArtifactMetadata; import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.repository.legacy.repository.ArtifactRepositoryFactory; import org.apache.maven.artifact.repository.ArtifactRepositoryPolicy; import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout; import org.apache.maven.artifact.repository.layout.DefaultRepositoryLayout; import org.apache.maven.artifact.versioning.VersionRange; import org.apache.maven.wagon.ResourceDoesNotExistException; import org.apache.maven.wagon.TransferFailedException; import org.apache.maven.wagon.UnsupportedProtocolException; import org.apache.maven.wagon.Wagon; import org.apache.maven.wagon.authorization.AuthorizationException; import org.apache.maven.wagon.events.TransferEvent; import org.apache.maven.wagon.events.TransferListener; import org.apache.maven.wagon.observers.AbstractTransferListener; import org.apache.maven.wagon.observers.Debug; import org.codehaus.plexus.PlexusTestCase; import org.codehaus.plexus.util.FileUtils; /** * @author Michal Maczka */ public class DefaultWagonManagerTest extends PlexusTestCase { private DefaultWagonManager wagonManager; private TransferListener transferListener = new Debug(); private ArtifactFactory artifactFactory; private ArtifactRepositoryFactory artifactRepositoryFactory; protected void setUp() throws Exception { super.setUp(); wagonManager = (DefaultWagonManager) lookup( WagonManager.class ); artifactFactory = lookup( ArtifactFactory.class ); artifactRepositoryFactory = lookup( ArtifactRepositoryFactory.class ); } @Override protected void tearDown() throws Exception { wagonManager = null; artifactFactory = null; super.tearDown(); } public void testUnnecessaryRepositoryLookup() throws Exception { Artifact artifact = createTestPomArtifact( "target/test-data/get-missing-pom" ); List repos = new ArrayList<>(); repos.add( artifactRepositoryFactory.createArtifactRepository( "repo1", "string://url1", new ArtifactRepositoryLayoutStub(), null, null ) ); repos.add( artifactRepositoryFactory.createArtifactRepository( "repo2", "string://url2", new ArtifactRepositoryLayoutStub(), null, null ) ); StringWagon wagon = (StringWagon) wagonManager.getWagon( "string" ); wagon.addExpectedContent( repos.get( 0 ).getLayout().pathOf( artifact ), "expected" ); wagon.addExpectedContent( repos.get( 1 ).getLayout().pathOf( artifact ), "expected" ); class TransferListener extends AbstractTransferListener { public List events = new ArrayList<>(); @Override public void transferInitiated( TransferEvent transferEvent ) { events.add( transferEvent ); } } TransferListener listener = new TransferListener(); wagonManager.getArtifact( artifact, repos, listener, false ); assertEquals( 1, listener.events.size() ); } public void testGetMissingJar() throws TransferFailedException, UnsupportedProtocolException, IOException { Artifact artifact = createTestArtifact( "target/test-data/get-missing-jar", "jar" ); ArtifactRepository repo = createStringRepo(); try { wagonManager.getArtifact( artifact, repo, null, false ); fail(); } catch ( ResourceDoesNotExistException e ) { assertTrue( true ); } assertFalse( artifact.getFile().exists() ); } public void testGetMissingJarForced() throws TransferFailedException, UnsupportedProtocolException, IOException { Artifact artifact = createTestArtifact( "target/test-data/get-missing-jar", "jar" ); ArtifactRepository repo = createStringRepo(); try { wagonManager.getArtifact( artifact, repo, null, true ); fail(); } catch ( ResourceDoesNotExistException e ) { assertTrue( true ); } assertFalse( artifact.getFile().exists() ); } public void testGetRemoteJar() throws TransferFailedException, ResourceDoesNotExistException, UnsupportedProtocolException, IOException, AuthorizationException { Artifact artifact = createTestArtifact( "target/test-data/get-remote-jar", "jar" ); ArtifactRepository repo = createStringRepo(); StringWagon wagon = (StringWagon) wagonManager.getWagon( "string" ); wagon.addExpectedContent( repo.getLayout().pathOf( artifact ), "expected" ); wagonManager.getArtifact( artifact, repo, null, false ); assertTrue( artifact.getFile().exists() ); assertEquals( "expected", FileUtils.fileRead( artifact.getFile(), "UTF-8" ) ); } private Artifact createTestPomArtifact( String directory ) throws IOException { File testData = getTestFile( directory ); FileUtils.deleteDirectory( testData ); testData.mkdirs(); Artifact artifact = artifactFactory.createProjectArtifact( "test", "test", "1.0" ); artifact.setFile( new File( testData, "test-1.0.pom" ) ); assertFalse( artifact.getFile().exists() ); return artifact; } private Artifact createTestArtifact( String directory, String type ) throws IOException { return createTestArtifact( directory, "1.0", type ); } private Artifact createTestArtifact( String directory, String version, String type ) throws IOException { File testData = getTestFile( directory ); FileUtils.deleteDirectory( testData ); testData.mkdirs(); Artifact artifact = artifactFactory.createBuildArtifact( "test", "test", version, type ); artifact.setFile( new File( testData, "test-" + version + "." + artifact.getArtifactHandler().getExtension() ) ); assertFalse( artifact.getFile().exists() ); return artifact; } private ArtifactRepository createStringRepo() { return artifactRepositoryFactory.createArtifactRepository( "id", "string://url", new ArtifactRepositoryLayoutStub(), null, null ); } /** * Build an ArtifactRepository object. * * @param id * @param url * @return */ private ArtifactRepository getRepo( String id, String url ) { return artifactRepositoryFactory.createArtifactRepository( id, url, new DefaultRepositoryLayout(), null, null ); } /** * Build an ArtifactRepository object. * * @param id * @return */ private ArtifactRepository getRepo( String id ) { return getRepo( id, "http://something" ); } public void testDefaultWagonManager() throws Exception { assertWagon( "a" ); assertWagon( "b" ); assertWagon( "c" ); assertWagon( "string" ); try { assertWagon( "d" ); fail( "Expected :" + UnsupportedProtocolException.class.getName() ); } catch ( UnsupportedProtocolException e ) { // ok assertTrue( true ); } } /** * Check that transfer listeners are properly removed after getArtifact and putArtifact */ public void testWagonTransferListenerRemovedAfterGetArtifactAndPutArtifact() throws Exception { Artifact artifact = createTestArtifact( "target/test-data/transfer-listener", "jar" ); ArtifactRepository repo = createStringRepo(); StringWagon wagon = (StringWagon) wagonManager.getWagon( "string" ); wagon.addExpectedContent( repo.getLayout().pathOf( artifact ), "expected" ); /* getArtifact */ assertFalse( "Transfer listener is registered before test", wagon.getTransferEventSupport().hasTransferListener( transferListener ) ); wagonManager.getArtifact( artifact, repo, transferListener, false ); assertFalse( "Transfer listener still registered after getArtifact", wagon.getTransferEventSupport().hasTransferListener( transferListener ) ); /* putArtifact */ File sampleFile = getTestFile( "target/test-file" ); FileUtils.fileWrite( sampleFile.getAbsolutePath(), "sample file" ); assertFalse( "Transfer listener is registered before test", wagon.getTransferEventSupport().hasTransferListener( transferListener ) ); wagonManager.putArtifact( sampleFile, artifact, repo, transferListener ); assertFalse( "Transfer listener still registered after putArtifact", wagon.getTransferEventSupport().hasTransferListener( transferListener ) ); } /** * Checks the verification of checksums. */ public void xtestChecksumVerification() throws Exception { ArtifactRepositoryPolicy policy = new ArtifactRepositoryPolicy( true, ArtifactRepositoryPolicy.UPDATE_POLICY_ALWAYS, ArtifactRepositoryPolicy.CHECKSUM_POLICY_FAIL ); ArtifactRepository repo = artifactRepositoryFactory.createArtifactRepository( "id", "string://url", new ArtifactRepositoryLayoutStub(), policy, policy ); Artifact artifact = new DefaultArtifact( "sample.group", "sample-art", VersionRange.createFromVersion( "1.0" ), "scope", "jar", "classifier", null ); artifact.setFile( getTestFile( "target/sample-art" ) ); StringWagon wagon = (StringWagon) wagonManager.getWagon( "string" ); wagon.clearExpectedContent(); wagon.addExpectedContent( "path", "lower-case-checksum" ); wagon.addExpectedContent( "path.sha1", "2a25dc564a3b34f68237fc849066cbc7bb7a36a1" ); try { wagonManager.getArtifact( artifact, repo, null, false ); } catch ( ChecksumFailedException e ) { fail( "Checksum verification did not pass: " + e.getMessage() ); } wagon.clearExpectedContent(); wagon.addExpectedContent( "path", "upper-case-checksum" ); wagon.addExpectedContent( "path.sha1", "B7BB97D7D0B9244398D9B47296907F73313663E6" ); try { wagonManager.getArtifact( artifact, repo, null, false ); } catch ( ChecksumFailedException e ) { fail( "Checksum verification did not pass: " + e.getMessage() ); } wagon.clearExpectedContent(); wagon.addExpectedContent( "path", "expected-failure" ); wagon.addExpectedContent( "path.sha1", "b7bb97d7d0b9244398d9b47296907f73313663e6" ); try { wagonManager.getArtifact( artifact, repo, null, false ); fail( "Checksum verification did not fail" ); } catch ( ChecksumFailedException e ) { // expected } wagon.clearExpectedContent(); wagon.addExpectedContent( "path", "lower-case-checksum" ); wagon.addExpectedContent( "path.md5", "50b2cf50a103a965efac62b983035cac" ); try { wagonManager.getArtifact( artifact, repo, null, false ); } catch ( ChecksumFailedException e ) { fail( "Checksum verification did not pass: " + e.getMessage() ); } wagon.clearExpectedContent(); wagon.addExpectedContent( "path", "upper-case-checksum" ); wagon.addExpectedContent( "path.md5", "842F568FCCFEB7E534DC72133D42FFDC" ); try { wagonManager.getArtifact( artifact, repo, null, false ); } catch ( ChecksumFailedException e ) { fail( "Checksum verification did not pass: " + e.getMessage() ); } wagon.clearExpectedContent(); wagon.addExpectedContent( "path", "expected-failure" ); wagon.addExpectedContent( "path.md5", "b7bb97d7d0b9244398d9b47296907f73313663e6" ); try { wagonManager.getArtifact( artifact, repo, null, false ); fail( "Checksum verification did not fail" ); } catch ( ChecksumFailedException e ) { // expected } } public void testPerLookupInstantiation() throws Exception { String protocol = "perlookup"; Wagon one = wagonManager.getWagon( protocol ); Wagon two = wagonManager.getWagon( protocol ); assertNotSame( one, two ); } private void assertWagon( String protocol ) throws Exception { Wagon wagon = wagonManager.getWagon( protocol ); assertNotNull( "Check wagon, protocol=" + protocol, wagon ); } private final class ArtifactRepositoryLayoutStub implements ArtifactRepositoryLayout { public String getId() { return "test"; } public String pathOfRemoteRepositoryMetadata( ArtifactMetadata metadata ) { return "path"; } public String pathOfLocalRepositoryMetadata( ArtifactMetadata metadata, ArtifactRepository repository ) { return "path"; } public String pathOf( Artifact artifact ) { return "path"; } } } LegacyRepositorySystemTest.java000066400000000000000000000061171317160430700357560ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/test/java/org/apache/maven/repository/legacypackage org.apache.maven.repository.legacy; /* * 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.File; import java.util.Arrays; import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.repository.Authentication; import org.apache.maven.repository.RepositorySystem; import org.apache.maven.settings.Server; import org.codehaus.plexus.ContainerConfiguration; import org.codehaus.plexus.PlexusConstants; import org.codehaus.plexus.PlexusTestCase; /** * Tests {@link LegacyRepositorySystem}. * * @author Benjamin Bentmann */ public class LegacyRepositorySystemTest extends PlexusTestCase { private RepositorySystem repositorySystem; @Override protected void customizeContainerConfiguration( ContainerConfiguration containerConfiguration ) { super.customizeContainerConfiguration( containerConfiguration ); containerConfiguration.setAutoWiring( true ); containerConfiguration.setClassPathScanning( PlexusConstants.SCANNING_INDEX ); } @Override protected void setUp() throws Exception { super.setUp(); repositorySystem = lookup( RepositorySystem.class, "default" ); } @Override protected void tearDown() throws Exception { repositorySystem = null; super.tearDown(); } public void testThatLocalRepositoryWithSpacesIsProperlyHandled() throws Exception { File basedir = new File( "target/spacy path" ).getAbsoluteFile(); ArtifactRepository repo = repositorySystem.createLocalRepository( basedir ); assertEquals( basedir, new File( repo.getBasedir() ) ); } public void testAuthenticationHandling() throws Exception { Server server = new Server(); server.setId( "repository" ); server.setUsername( "jason" ); server.setPassword( "abc123" ); ArtifactRepository repository = repositorySystem.createArtifactRepository( "repository", "http://foo", null, null, null ); repositorySystem.injectAuthentication( Arrays.asList( repository ), Arrays.asList( server ) ); Authentication authentication = repository.getAuthentication(); assertNotNull( authentication ); assertEquals( "jason", authentication.getUsername() ); assertEquals( "abc123", authentication.getPassword() ); } } maven-maven-3.5.2/maven-compat/src/test/java/org/apache/maven/repository/legacy/PerLookupWagon.java000066400000000000000000000023501317160430700333730ustar00rootroot00000000000000package org.apache.maven.repository.legacy; /* * 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 org.apache.maven.wagon.Wagon; import org.codehaus.plexus.component.annotations.Component; /** * Wagon with per-lookup instantiation strategy. */ @Component( role = Wagon.class, hint = "perlookup", instantiationStrategy = "per-lookup" ) public class PerLookupWagon extends WagonMock { public String[] getSupportedProtocols() { return new String[] { "perlookup" }; } } maven-maven-3.5.2/maven-compat/src/test/java/org/apache/maven/repository/legacy/StringWagon.java000066400000000000000000000065301317160430700327250ustar00rootroot00000000000000package org.apache.maven.repository.legacy; /* * 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.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.UnsupportedEncodingException; import java.util.HashMap; import java.util.Map; import org.apache.maven.wagon.ConnectionException; import org.apache.maven.wagon.InputData; import org.apache.maven.wagon.OutputData; import org.apache.maven.wagon.ResourceDoesNotExistException; import org.apache.maven.wagon.StreamWagon; import org.apache.maven.wagon.TransferFailedException; import org.apache.maven.wagon.Wagon; import org.apache.maven.wagon.authentication.AuthenticationException; import org.apache.maven.wagon.authorization.AuthorizationException; import org.apache.maven.wagon.resource.Resource; import org.codehaus.plexus.component.annotations.Component; @Component(role=Wagon.class,hint="string") public class StringWagon extends StreamWagon { private Map expectedContent = new HashMap<>(); public void addExpectedContent( String resourceName, String expectedContent ) { this.expectedContent.put( resourceName, expectedContent ); } public String[] getSupportedProtocols() { return new String[] { "string" }; } @Override public void closeConnection() throws ConnectionException { } @Override public void fillInputData( InputData inputData ) throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException { Resource resource = inputData.getResource(); String content = expectedContent.get( resource.getName() ); if ( content != null ) { resource.setContentLength( content.length() ); resource.setLastModified( System.currentTimeMillis() ); try { inputData.setInputStream( new ByteArrayInputStream( content.getBytes( "UTF-8" ) ) ); } catch ( UnsupportedEncodingException e ) { throw new Error( "broken JVM", e ); } } else { throw new ResourceDoesNotExistException( "No content provided for " + resource.getName() ); } } @Override public void fillOutputData( OutputData outputData ) throws TransferFailedException { outputData.setOutputStream( new ByteArrayOutputStream() ); } @Override protected void openConnectionInternal() throws ConnectionException, AuthenticationException { } public void clearExpectedContent() { expectedContent.clear(); } } maven-maven-3.5.2/maven-compat/src/test/java/org/apache/maven/repository/legacy/WagonA.java000066400000000000000000000024431317160430700316360ustar00rootroot00000000000000package org.apache.maven.repository.legacy; import org.apache.maven.wagon.Wagon; import org.codehaus.plexus.component.annotations.Component; /* * 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. */ /** * Wagon for testing, for protocol a * * @author Carlos Sanchez * @author Jason van Zyl */ @Component(role=Wagon.class,hint="a") public class WagonA extends WagonMock { public String[] getSupportedProtocols() { return new String[]{ "a" }; } } maven-maven-3.5.2/maven-compat/src/test/java/org/apache/maven/repository/legacy/WagonB.java000066400000000000000000000025001317160430700316310ustar00rootroot00000000000000package org.apache.maven.repository.legacy; import org.apache.maven.wagon.Wagon; import org.codehaus.plexus.component.annotations.Component; /* * 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. */ /** * Wagon for testing, for protocols b1 and b2 * * @author Carlos Sanchez * @author Jason van Zyl */ @Component(role=Wagon.class,hint="b") public class WagonB extends WagonMock { public String[] getSupportedProtocols() { return new String[]{ "b1", "b2" }; } } maven-maven-3.5.2/maven-compat/src/test/java/org/apache/maven/repository/legacy/WagonC.java000066400000000000000000000024431317160430700316400ustar00rootroot00000000000000package org.apache.maven.repository.legacy; import org.apache.maven.wagon.Wagon; import org.codehaus.plexus.component.annotations.Component; /* * 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. */ /** * Wagon for testing, for protocol c * * @author Carlos Sanchez * @author Jason van Zyl */ @Component(role=Wagon.class,hint="c") public class WagonC extends WagonMock { public String[] getSupportedProtocols() { return new String[]{ "c" }; } } maven-maven-3.5.2/maven-compat/src/test/java/org/apache/maven/repository/legacy/WagonMock.java000066400000000000000000000026711317160430700323520ustar00rootroot00000000000000package org.apache.maven.repository.legacy; /* * 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 org.apache.maven.wagon.providers.file.FileWagon; /** * Mock of a Wagon for testing * * @author Carlos Sanchez */ public class WagonMock extends FileWagon { /** * A field that can be configured in the Wagon * * @component.configuration default="configurableField" */ private String configurableField = null; public void setConfigurableField( String configurableField ) { this.configurableField = configurableField; } public String getConfigurableField() { return configurableField; } } maven-maven-3.5.2/maven-compat/src/test/java/org/apache/maven/repository/legacy/resolver/000077500000000000000000000000001317160430700314555ustar00rootroot00000000000000DefaultArtifactCollectorTest.java000066400000000000000000001304071317160430700400170ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/test/java/org/apache/maven/repository/legacy/resolverpackage org.apache.maven.repository.legacy.resolver; /* * 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 org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.factory.ArtifactFactory; import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException; import org.apache.maven.artifact.metadata.ArtifactMetadataSource; import org.apache.maven.artifact.metadata.ResolutionGroup; import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.resolver.ArtifactResolutionException; import org.apache.maven.artifact.resolver.ArtifactResolutionResult; import org.apache.maven.artifact.resolver.CyclicDependencyException; import org.apache.maven.artifact.resolver.ResolutionListener; import org.apache.maven.artifact.resolver.filter.ArtifactFilter; import org.apache.maven.artifact.resolver.filter.ExclusionSetFilter; import org.apache.maven.artifact.resolver.filter.ScopeArtifactFilter; import org.apache.maven.artifact.versioning.ArtifactVersion; import org.apache.maven.artifact.versioning.DefaultArtifactVersion; import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException; import org.apache.maven.artifact.versioning.OverConstrainedVersionException; import org.apache.maven.artifact.versioning.VersionRange; import org.apache.maven.repository.legacy.metadata.MetadataResolutionRequest; import org.codehaus.plexus.PlexusTestCase; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.HashMap; import java.util.HashSet; import java.util.LinkedHashSet; import java.util.List; import java.util.Map; import java.util.Set; /** * Test the default artifact collector. * * @author Brett Porter */ public class DefaultArtifactCollectorTest extends PlexusTestCase { private LegacyArtifactCollector artifactCollector; private ArtifactFactory artifactFactory; private ArtifactSpec projectArtifact; private Source source; private static final String GROUP_ID = "test"; @Override protected void setUp() throws Exception { super.setUp(); source = new Source(); artifactFactory = (ArtifactFactory) lookup( ArtifactFactory.ROLE ); artifactCollector = lookup( LegacyArtifactCollector.class ); projectArtifact = createArtifactSpec( "project", "1.0", null ); } @Override protected void tearDown() throws Exception { artifactCollector = null; artifactFactory = null; super.tearDown(); } // works, but we don't fail on cycles presently public void disabledtestCircularDependencyNotIncludingCurrentProject() throws ArtifactResolutionException, InvalidVersionSpecificationException { ArtifactSpec a = createArtifactSpec( "a", "1.0" ); ArtifactSpec b = a.addDependency( "b", "1.0" ); b.addDependency( "a", "1.0" ); try { collect( a ); fail( "Should have failed on cyclic dependency not involving project" ); } catch ( CyclicDependencyException expected ) { assertTrue( true ); } } // works, but we don't fail on cycles presently public void disabledtestCircularDependencyIncludingCurrentProject() throws ArtifactResolutionException, InvalidVersionSpecificationException { ArtifactSpec a = createArtifactSpec( "a", "1.0" ); ArtifactSpec b = a.addDependency( "b", "1.0" ); b.addDependency( "project", "1.0" ); try { collect( a ); fail( "Should have failed on cyclic dependency involving project" ); } catch ( CyclicDependencyException expected ) { assertTrue( true ); } } public void testResolveWithFilter() throws ArtifactResolutionException, InvalidVersionSpecificationException { ArtifactSpec a = createArtifactSpec( "a", "1.0" ); ArtifactSpec b = a.addDependency( "b", "1.0" ); ArtifactSpec c = a.addDependency( "c", "3.0" ); b.addDependency( "c", "2.0" ); ArtifactSpec d = b.addDependency( "d", "4.0" ); ArtifactResolutionResult res = collect( a ); assertEquals( "Check artifact list", createSet( new Object[] { a.artifact, b.artifact, c.artifact, d.artifact } ), res.getArtifacts() ); ArtifactFilter filter = new ExclusionSetFilter( new String[] { "b" } ); res = collect( a, filter ); assertEquals( "Check artifact list", createSet( new Object[] { a.artifact, c.artifact } ), res.getArtifacts() ); } public void testResolveCorrectDependenciesWhenDifferentDependenciesOnNearest() throws ArtifactResolutionException, InvalidVersionSpecificationException { ArtifactSpec a = createArtifactSpec( "a", "1.0" ); ArtifactSpec b = a.addDependency( "b", "1.0" ); ArtifactSpec c2 = b.addDependency( "c", "2.0" ); c2.addDependency( "d", "1.0" ); ArtifactSpec e = createArtifactSpec( "e", "1.0" ); ArtifactSpec c1 = e.addDependency( "c", "1.0" ); ArtifactSpec f = c1.addDependency( "f", "1.0" ); ArtifactResolutionResult res = collect( createSet( new Object[] { a.artifact, e.artifact } ) ); assertEquals( "Check artifact list", createSet( new Object[] { a.artifact, b.artifact, e.artifact, c1.artifact, f.artifact } ), res.getArtifacts() ); assertEquals( "Check version", "1.0", getArtifact( "c", res.getArtifacts() ).getVersion() ); } public void disabledtestResolveCorrectDependenciesWhenDifferentDependenciesOnNewest() throws ArtifactResolutionException, InvalidVersionSpecificationException { // TODO use newest conflict resolver ArtifactSpec a = createArtifactSpec( "a", "1.0" ); ArtifactSpec b = a.addDependency( "b", "1.0" ); ArtifactSpec c2 = b.addDependency( "c", "2.0" ); ArtifactSpec d = c2.addDependency( "d", "1.0" ); ArtifactSpec e = createArtifactSpec( "e", "1.0" ); ArtifactSpec c1 = e.addDependency( "c", "1.0" ); c1.addDependency( "f", "1.0" ); ArtifactResolutionResult res = collect( createSet( new Object[] { a.artifact, e.artifact } ) ); assertEquals( "Check artifact list", createSet( new Object[] { a.artifact, b.artifact, e.artifact, c2.artifact, d.artifact } ), res.getArtifacts() ); assertEquals( "Check version", "2.0", getArtifact( "c", res.getArtifacts() ).getVersion() ); } public void disabledtestResolveCorrectDependenciesWhenDifferentDependenciesOnNewestVersionReplaced() throws ArtifactResolutionException, InvalidVersionSpecificationException { // TODO use newest conflict resolver ArtifactSpec a = createArtifactSpec( "a", "1.0" ); ArtifactSpec b1 = a.addDependency( "b", "1.0" ); ArtifactSpec c = a.addDependency( "c", "1.0" ); ArtifactSpec d2 = b1.addDependency( "d", "2.0" ); d2.addDependency( "h", "1.0" ); ArtifactSpec d1 = c.addDependency( "d", "1.0" ); ArtifactSpec b2 = c.addDependency( "b", "2.0" ); ArtifactSpec e = b2.addDependency( "e", "1.0" ); ArtifactSpec g = d1.addDependency( "g", "1.0" ); ArtifactResolutionResult res = collect( createSet( new Object[] { a.artifact } ) ); Object[] artifacts = new Object[] { a.artifact, c.artifact, d1.artifact, b2.artifact, e.artifact, g.artifact }; assertEquals( "Check artifact list", createSet( artifacts ), res.getArtifacts() ); assertEquals( "Check version", "1.0", getArtifact( "d", res.getArtifacts() ).getVersion() ); assertEquals( "Check version", "2.0", getArtifact( "b", res.getArtifacts() ).getVersion() ); } public void testResolveNearestNewestIsNearest() throws ArtifactResolutionException, InvalidVersionSpecificationException { ArtifactSpec a = createArtifactSpec( "a", "1.0" ); ArtifactSpec b = a.addDependency( "b", "1.0" ); ArtifactSpec c = a.addDependency( "c", "3.0" ); b.addDependency( "c", "2.0" ); ArtifactResolutionResult res = collect( a ); assertEquals( "Check artifact list", createSet( new Object[] { a.artifact, b.artifact, c.artifact } ), res.getArtifacts() ); assertEquals( "Check version", "3.0", getArtifact( "c", res.getArtifacts() ).getVersion() ); } public void testResolveNearestOldestIsNearest() throws ArtifactResolutionException, InvalidVersionSpecificationException { ArtifactSpec a = createArtifactSpec( "a", "1.0" ); ArtifactSpec b = a.addDependency( "b", "1.0" ); ArtifactSpec c = a.addDependency( "c", "2.0" ); b.addDependency( "c", "3.0" ); ArtifactResolutionResult res = collect( a ); assertEquals( "Check artifact list", createSet( new Object[] { a.artifact, b.artifact, c.artifact } ), res.getArtifacts() ); assertEquals( "Check version", "2.0", getArtifact( "c", res.getArtifacts() ).getVersion() ); } public void testResolveLocalNewestIsLocal() throws ArtifactResolutionException, InvalidVersionSpecificationException { ArtifactSpec a = createArtifactSpec( "a", "1.0" ); a.addDependency( "b", "2.0" ); ArtifactSpec b = createArtifactSpec( "b", "3.0" ); ArtifactResolutionResult res = collect( createSet( new Object[] { a.artifact, b.artifact } ) ); assertEquals( "Check artifact list", createSet( new Object[] { a.artifact, b.artifact } ), res.getArtifacts() ); assertEquals( "Check version", "3.0", getArtifact( "b", res.getArtifacts() ).getVersion() ); } public void testResolveLocalOldestIsLocal() throws ArtifactResolutionException, InvalidVersionSpecificationException { ArtifactSpec a = createArtifactSpec( "a", "1.0" ); a.addDependency( "b", "3.0" ); ArtifactSpec b = createArtifactSpec( "b", "2.0" ); ArtifactResolutionResult res = collect( createSet( new Object[] { a.artifact, b.artifact } ) ); assertEquals( "Check artifact list", createSet( new Object[] { a.artifact, b.artifact } ), res.getArtifacts() ); assertEquals( "Check version", "2.0", getArtifact( "b", res.getArtifacts() ).getVersion() ); } public void testResolveLocalWithNewerVersionButLesserScope() throws ArtifactResolutionException, InvalidVersionSpecificationException { ArtifactSpec a = createArtifactSpec( "commons-logging", "1.0" ); a.addDependency( "junit", "3.7" ); ArtifactSpec b = createArtifactSpec( "junit", "3.8.1", Artifact.SCOPE_TEST ); ArtifactResolutionResult res = collect( createSet( new Object[] { a.artifact, b.artifact } ) ); assertEquals( "Check artifact list", createSet( new Object[] { a.artifact, b.artifact } ), res.getArtifacts() ); assertEquals( "Check version", "3.8.1", getArtifact( "junit", res.getArtifacts() ).getVersion() ); assertEquals( "Check artifactScope", Artifact.SCOPE_TEST, getArtifact( "junit", res.getArtifacts() ).getScope() ); } public void testResolveLocalWithNewerVersionButLesserScopeResolvedFirst() throws ArtifactResolutionException, InvalidVersionSpecificationException { ArtifactSpec b = createArtifactSpec( "junit", "3.8.1", Artifact.SCOPE_TEST ); ArtifactSpec a = createArtifactSpec( "commons-logging", "1.0" ); a.addDependency( "junit", "3.7" ); ArtifactResolutionResult res = collect( createSet( new Object[] { a.artifact, b.artifact } ) ); assertEquals( "Check artifact list", createSet( new Object[] { a.artifact, b.artifact } ), res.getArtifacts() ); assertEquals( "Check version", "3.8.1", getArtifact( "junit", res.getArtifacts() ).getVersion() ); assertEquals( "Check artifactScope", Artifact.SCOPE_TEST, getArtifact( "junit", res.getArtifacts() ).getScope() ); } public void testResolveNearestWithRanges() throws ArtifactResolutionException, InvalidVersionSpecificationException { ArtifactSpec a = createArtifactSpec( "a", "1.0" ); ArtifactSpec b = a.addDependency( "b", "1.0" ); ArtifactSpec c = a.addDependency( "c", "2.0" ); b.addDependency( "c", "[1.0,3.0]" ); ArtifactResolutionResult res = collect( a ); assertEquals( "Check artifact list", createSet( new Object[] { a.artifact, b.artifact, c.artifact } ), res.getArtifacts() ); assertEquals( "Check version", "2.0", getArtifact( "c", res.getArtifacts() ).getVersion() ); } public void testResolveRangeWithManagedVersion() throws ArtifactResolutionException, InvalidVersionSpecificationException { ArtifactSpec a = createArtifactSpec( "a", "1.0" ); ArtifactSpec b = a.addDependency( "b", "[1.0,3.0]" ); ArtifactSpec managedB = createArtifactSpec( "b", "5.0" ); ArtifactResolutionResult res = collect( a, managedB.artifact ); assertEquals( "Check artifact list", createSet( new Object[] { a.artifact, managedB.artifact } ), res.getArtifacts() ); assertEquals( "Check version", "5.0", getArtifact( "b", res.getArtifacts() ).getVersion() ); } public void testCompatibleRanges() throws ArtifactResolutionException, InvalidVersionSpecificationException { ArtifactSpec a = createArtifactSpec( "a", "1.0" ); ArtifactSpec b = a.addDependency( "b", "1.0" ); a.addDependency( "c", "[2.0,2.5]" ); b.addDependency( "c", "[1.0,3.0]" ); ArtifactSpec c = createArtifactSpec( "c", "2.5" ); ArtifactResolutionResult res = collect( a ); assertEquals( "Check artifact list", createSet( new Object[] { a.artifact, b.artifact, c.artifact } ), res.getArtifacts() ); assertEquals( "Check version", "2.5", getArtifact( "c", res.getArtifacts() ).getVersion() ); } public void testIncompatibleRanges() throws ArtifactResolutionException, InvalidVersionSpecificationException { ArtifactSpec a = createArtifactSpec( "a", "1.0" ); ArtifactSpec b = a.addDependency( "b", "1.0" ); a.addDependency( "c", "[2.4,3.0]" ); b.addDependency( "c", "[1.0,2.0]" ); ArtifactResolutionResult res = collect( a ); assertTrue( res.hasVersionRangeViolations() ); } public void testUnboundedRangeWhenVersionUnavailable() throws ArtifactResolutionException, InvalidVersionSpecificationException { ArtifactSpec a = createArtifactSpec( "a", "1.0" ); ArtifactSpec b = a.addDependency( "b", "1.0" ); a.addDependency( "c", "[2.0,]" ); b.addDependency( "c", "[1.0,]" ); ArtifactResolutionResult res = collect( a ); assertTrue( res.hasVersionRangeViolations() ); } public void testUnboundedRangeBelowLastRelease() throws ArtifactResolutionException, InvalidVersionSpecificationException { ArtifactSpec a = createArtifactSpec( "a", "1.0" ); createArtifactSpec( "c", "1.5" ); ArtifactSpec c = createArtifactSpec( "c", "2.0" ); createArtifactSpec( "c", "1.1" ); a.addDependency( "c", "[1.0,)" ); ArtifactResolutionResult res = collect( a ); assertEquals( "Check artifact list", createSet( new Object[] { a.artifact, c.artifact } ), res.getArtifacts() ); assertEquals( "Check version", "2.0", getArtifact( "c", res.getArtifacts() ).getVersion() ); } public void testUnboundedRangeAboveLastRelease() throws ArtifactResolutionException, InvalidVersionSpecificationException { ArtifactSpec a = createArtifactSpec( "a", "1.0" ); createArtifactSpec( "c", "2.0" ); a.addDependency( "c", "[10.0,)" ); ArtifactResolutionResult res = collect( a ); assertTrue( res.hasVersionRangeViolations() ); } public void testResolveManagedVersion() throws ArtifactResolutionException, InvalidVersionSpecificationException { ArtifactSpec a = createArtifactSpec( "a", "1.0" ); a.addDependency( "b", "3.0", Artifact.SCOPE_RUNTIME ); Artifact managedVersion = createArtifactSpec( "b", "5.0" ).artifact; Artifact modifiedB = createArtifactSpec( "b", "5.0", Artifact.SCOPE_RUNTIME ).artifact; ArtifactResolutionResult res = collect( a, managedVersion ); assertEquals( "Check artifact list", createSet( new Object[] { a.artifact, modifiedB } ), res.getArtifacts() ); } public void testCollectChangesVersionOfOriginatingArtifactIfInDependencyManagementHasDifferentVersion() throws ArtifactResolutionException, InvalidVersionSpecificationException { ArtifactSpec a = createArtifactSpec( "a", "1.0" ); Artifact artifact = projectArtifact.artifact; Artifact managedVersion = createArtifactSpec( artifact.getArtifactId(), "2.0" ).artifact; ArtifactResolutionResult result = collect( a, managedVersion ); assertEquals( "collect has modified version in originating artifact", "1.0", artifact.getVersion() ); Artifact resolvedArtifact = result.getArtifacts().iterator().next(); assertEquals( "Resolved version don't match original artifact version", "1.0", resolvedArtifact.getVersion() ); } public void testResolveCompileScopeOverTestScope() throws ArtifactResolutionException, InvalidVersionSpecificationException { ArtifactSpec a = createArtifactSpec( "a", "1.0" ); ArtifactSpec c = createArtifactSpec( "c", "3.0", Artifact.SCOPE_TEST ); a.addDependency( "c", "2.0", Artifact.SCOPE_COMPILE ); Artifact modifiedC = createArtifactSpec( "c", "3.0", Artifact.SCOPE_COMPILE ).artifact; ArtifactResolutionResult res = collect( createSet( new Object[] { a.artifact, c.artifact } ) ); assertEquals( "Check artifact list", createSet( new Object[] { a.artifact, modifiedC } ), res.getArtifacts() ); Artifact artifact = getArtifact( "c", res.getArtifacts() ); // local wins now, and irrelevant if not local as test/provided aren't transitive // assertEquals( "Check artifactScope", Artifact.SCOPE_COMPILE, artifact.getArtifactScope() ); assertEquals( "Check artifactScope", Artifact.SCOPE_TEST, artifact.getScope() ); } public void testResolveRuntimeScopeOverTestScope() throws ArtifactResolutionException, InvalidVersionSpecificationException { ArtifactSpec a = createArtifactSpec( "a", "1.0" ); ArtifactSpec c = createArtifactSpec( "c", "3.0", Artifact.SCOPE_TEST ); a.addDependency( "c", "2.0", Artifact.SCOPE_RUNTIME ); Artifact modifiedC = createArtifactSpec( "c", "3.0", Artifact.SCOPE_RUNTIME ).artifact; ArtifactResolutionResult res = collect( createSet( new Object[] { a.artifact, c.artifact } ) ); assertEquals( "Check artifact list", createSet( new Object[] { a.artifact, modifiedC } ), res.getArtifacts() ); Artifact artifact = getArtifact( "c", res.getArtifacts() ); // local wins now, and irrelevant if not local as test/provided aren't transitive // assertEquals( "Check artifactScope", Artifact.SCOPE_RUNTIME, artifact.getArtifactScope() ); assertEquals( "Check artifactScope", Artifact.SCOPE_TEST, artifact.getScope() ); } public void testResolveCompileScopeOverRuntimeScope() throws ArtifactResolutionException, InvalidVersionSpecificationException { ArtifactSpec root = createArtifactSpec( "root", "1.0" ); ArtifactSpec a = root.addDependency( "a", "1.0" ); root.addDependency( "c", "3.0", Artifact.SCOPE_RUNTIME ); a.addDependency( "c", "2.0", Artifact.SCOPE_COMPILE ); Artifact modifiedC = createArtifactSpec( "c", "3.0", Artifact.SCOPE_COMPILE ).artifact; ArtifactResolutionResult res = collect( createSet( new Object[] { root.artifact } ) ); assertEquals( "Check artifact list", createSet( new Object[] { a.artifact, root.artifact, modifiedC } ), res.getArtifacts() ); Artifact artifact = getArtifact( "c", res.getArtifacts() ); assertEquals( "Check artifactScope", Artifact.SCOPE_COMPILE, artifact.getScope() ); } public void testResolveCompileScopeOverProvidedScope() throws ArtifactResolutionException, InvalidVersionSpecificationException { ArtifactSpec a = createArtifactSpec( "a", "1.0" ); ArtifactSpec c = createArtifactSpec( "c", "3.0", Artifact.SCOPE_PROVIDED ); a.addDependency( "c", "2.0", Artifact.SCOPE_COMPILE ); Artifact modifiedC = createArtifactSpec( "c", "3.0", Artifact.SCOPE_COMPILE ).artifact; ArtifactResolutionResult res = collect( createSet( new Object[] { a.artifact, c.artifact } ) ); assertEquals( "Check artifact list", createSet( new Object[] { a.artifact, modifiedC } ), res.getArtifacts() ); Artifact artifact = getArtifact( "c", res.getArtifacts() ); // local wins now, and irrelevant if not local as test/provided aren't transitive // assertEquals( "Check artifactScope", Artifact.SCOPE_COMPILE, artifact.getArtifactScope() ); assertEquals( "Check artifactScope", Artifact.SCOPE_PROVIDED, artifact.getScope() ); } public void testResolveRuntimeScopeOverProvidedScope() throws ArtifactResolutionException, InvalidVersionSpecificationException { ArtifactSpec a = createArtifactSpec( "a", "1.0" ); ArtifactSpec c = createArtifactSpec( "c", "3.0", Artifact.SCOPE_PROVIDED ); a.addDependency( "c", "2.0", Artifact.SCOPE_RUNTIME ); Artifact modifiedC = createArtifactSpec( "c", "3.0", Artifact.SCOPE_RUNTIME ).artifact; ArtifactResolutionResult res = collect( createSet( new Object[] { a.artifact, c.artifact } ) ); assertEquals( "Check artifact list", createSet( new Object[] { a.artifact, modifiedC } ), res.getArtifacts() ); Artifact artifact = getArtifact( "c", res.getArtifacts() ); // local wins now, and irrelevant if not local as test/provided aren't transitive // assertEquals( "Check artifactScope", Artifact.SCOPE_RUNTIME, artifact.getArtifactScope() ); assertEquals( "Check artifactScope", Artifact.SCOPE_PROVIDED, artifact.getScope() ); } public void testProvidedScopeNotTransitive() throws ArtifactResolutionException, InvalidVersionSpecificationException { ArtifactSpec a = createArtifactSpec( "a", "1.0", Artifact.SCOPE_PROVIDED ); ArtifactSpec b = createArtifactSpec( "b", "1.0" ); b.addDependency( "c", "3.0", Artifact.SCOPE_PROVIDED ); ArtifactResolutionResult res = collect( createSet( new Object[] { a.artifact, b.artifact } ) ); assertEquals( "Check artifact list", createSet( new Object[] { a.artifact, b.artifact } ), res.getArtifacts() ); } public void testOptionalNotTransitive() throws ArtifactResolutionException, InvalidVersionSpecificationException { ArtifactSpec a = createArtifactSpec( "a", "1.0" ); ArtifactSpec b = createArtifactSpec( "b", "1.0" ); b.addDependency( "c", "3.0", true ); ArtifactResolutionResult res = collect( createSet( new Object[] { a.artifact, b.artifact } ) ); assertEquals( "Check artifact list", createSet( new Object[] { a.artifact, b.artifact } ), res.getArtifacts() ); } public void testOptionalIncludedAtRoot() throws ArtifactResolutionException, InvalidVersionSpecificationException { ArtifactSpec a = createArtifactSpec( "a", "1.0" ); ArtifactSpec b = createArtifactSpec( "b", "1.0", true ); ArtifactResolutionResult res = collect( createSet( new Object[] { a.artifact, b.artifact } ) ); assertEquals( "Check artifact list", createSet( new Object[] { a.artifact, b.artifact } ), res.getArtifacts() ); } public void testScopeUpdate() throws InvalidVersionSpecificationException, ArtifactResolutionException { /* farthest = compile */ checkScopeUpdate( Artifact.SCOPE_COMPILE, Artifact.SCOPE_COMPILE, Artifact.SCOPE_COMPILE ); checkScopeUpdate( Artifact.SCOPE_COMPILE, Artifact.SCOPE_PROVIDED, Artifact.SCOPE_COMPILE ); checkScopeUpdate( Artifact.SCOPE_COMPILE, Artifact.SCOPE_RUNTIME, Artifact.SCOPE_COMPILE ); checkScopeUpdate( Artifact.SCOPE_COMPILE, Artifact.SCOPE_SYSTEM, Artifact.SCOPE_COMPILE ); checkScopeUpdate( Artifact.SCOPE_COMPILE, Artifact.SCOPE_TEST, Artifact.SCOPE_COMPILE ); /* farthest = provided */ checkScopeUpdate( Artifact.SCOPE_PROVIDED, Artifact.SCOPE_COMPILE, Artifact.SCOPE_COMPILE ); checkScopeUpdate( Artifact.SCOPE_PROVIDED, Artifact.SCOPE_PROVIDED, Artifact.SCOPE_PROVIDED ); checkScopeUpdate( Artifact.SCOPE_PROVIDED, Artifact.SCOPE_RUNTIME, Artifact.SCOPE_RUNTIME ); checkScopeUpdate( Artifact.SCOPE_PROVIDED, Artifact.SCOPE_SYSTEM, Artifact.SCOPE_SYSTEM ); checkScopeUpdate( Artifact.SCOPE_PROVIDED, Artifact.SCOPE_TEST, Artifact.SCOPE_TEST ); /* farthest = runtime */ checkScopeUpdate( Artifact.SCOPE_RUNTIME, Artifact.SCOPE_COMPILE, Artifact.SCOPE_COMPILE ); checkScopeUpdate( Artifact.SCOPE_RUNTIME, Artifact.SCOPE_PROVIDED, Artifact.SCOPE_RUNTIME ); checkScopeUpdate( Artifact.SCOPE_RUNTIME, Artifact.SCOPE_RUNTIME, Artifact.SCOPE_RUNTIME ); checkScopeUpdate( Artifact.SCOPE_RUNTIME, Artifact.SCOPE_SYSTEM, Artifact.SCOPE_SYSTEM ); checkScopeUpdate( Artifact.SCOPE_RUNTIME, Artifact.SCOPE_TEST, Artifact.SCOPE_RUNTIME ); /* farthest = system */ checkScopeUpdate( Artifact.SCOPE_SYSTEM, Artifact.SCOPE_COMPILE, Artifact.SCOPE_COMPILE ); checkScopeUpdate( Artifact.SCOPE_SYSTEM, Artifact.SCOPE_PROVIDED, Artifact.SCOPE_PROVIDED ); checkScopeUpdate( Artifact.SCOPE_SYSTEM, Artifact.SCOPE_RUNTIME, Artifact.SCOPE_RUNTIME ); checkScopeUpdate( Artifact.SCOPE_SYSTEM, Artifact.SCOPE_SYSTEM, Artifact.SCOPE_SYSTEM ); checkScopeUpdate( Artifact.SCOPE_SYSTEM, Artifact.SCOPE_TEST, Artifact.SCOPE_TEST ); /* farthest = test */ checkScopeUpdate( Artifact.SCOPE_TEST, Artifact.SCOPE_COMPILE, Artifact.SCOPE_COMPILE ); checkScopeUpdate( Artifact.SCOPE_TEST, Artifact.SCOPE_PROVIDED, Artifact.SCOPE_PROVIDED ); checkScopeUpdate( Artifact.SCOPE_TEST, Artifact.SCOPE_RUNTIME, Artifact.SCOPE_RUNTIME ); checkScopeUpdate( Artifact.SCOPE_TEST, Artifact.SCOPE_SYSTEM, Artifact.SCOPE_SYSTEM ); checkScopeUpdate( Artifact.SCOPE_TEST, Artifact.SCOPE_TEST, Artifact.SCOPE_TEST ); } private void checkScopeUpdate( String farthestScope, String nearestScope, String expectedScope ) throws ArtifactResolutionException, InvalidVersionSpecificationException { checkScopeUpdateDirect( farthestScope, nearestScope, expectedScope ); checkScopeUpdateTransitively( farthestScope, nearestScope, expectedScope ); } private void checkScopeUpdateTransitively( String farthestScope, String nearestScope, String expectedScope ) throws ArtifactResolutionException, InvalidVersionSpecificationException { ArtifactSpec a = createArtifactSpec( "a", "1.0" ); ArtifactSpec b = createArtifactSpec( "b", "1.0", nearestScope ); ArtifactSpec c = createArtifactSpec( "c", "1.0" ); a.addDependency( c ); ArtifactSpec dNearest = createArtifactSpec( "d", "2.0" ); b.addDependency( dNearest ); ArtifactSpec dFarthest = createArtifactSpec( "d", "3.0", farthestScope ); c.addDependency( dFarthest ); /* system and provided dependencies are not transitive */ if ( !Artifact.SCOPE_SYSTEM.equals( nearestScope ) && !Artifact.SCOPE_PROVIDED.equals( nearestScope ) ) { checkScopeUpdate( a, b, expectedScope, "2.0" ); } } private void checkScopeUpdateDirect( String farthestScope, String nearestScope, String expectedScope ) throws ArtifactResolutionException, InvalidVersionSpecificationException { ArtifactSpec a = createArtifactSpec( "a", "1.0" ); ArtifactSpec b = createArtifactSpec( "b", "1.0" ); ArtifactSpec c = createArtifactSpec( "c", "1.0" ); a.addDependency( c ); ArtifactSpec dNearest = createArtifactSpec( "d", "2.0", nearestScope ); b.addDependency( dNearest ); ArtifactSpec dFarthest = createArtifactSpec( "d", "3.0", farthestScope ); c.addDependency( dFarthest ); checkScopeUpdate( a, b, expectedScope, "2.0" ); } private void checkScopeUpdate( ArtifactSpec a, ArtifactSpec b, String expectedScope, String expectedVersion ) throws ArtifactResolutionException, InvalidVersionSpecificationException { ScopeArtifactFilter filter; if ( Artifact.SCOPE_PROVIDED.equals( expectedScope ) ) { filter = new ScopeArtifactFilter( Artifact.SCOPE_COMPILE ); } else if ( Artifact.SCOPE_SYSTEM.equals( expectedScope ) ) { filter = new ScopeArtifactFilter( Artifact.SCOPE_COMPILE ); } else { filter = new ScopeArtifactFilter( expectedScope ); } ArtifactResolutionResult res = collect( createSet( new Object[] { a.artifact, b.artifact } ), filter ); Artifact artifact = getArtifact( "d", res.getArtifacts() ); assertNotNull( "MNG-1895 Dependency was not added to resolution", artifact ); assertEquals( "Check artifactScope", expectedScope, artifact.getScope() ); assertEquals( "Check version", expectedVersion, artifact.getVersion() ); ArtifactSpec d = createArtifactSpec( "d", "1.0" ); res = collect( createSet( new Object[] { a.artifact, b.artifact, d.artifact } ), filter ); artifact = getArtifact( "d", res.getArtifacts() ); assertNotNull( "MNG-1895 Dependency was not added to resolution", artifact ); assertEquals( "Check artifactScope", d.artifact.getScope(), artifact.getScope() ); assertEquals( "Check version", "1.0", artifact.getVersion() ); } public void disabledtestOptionalNotTransitiveButVersionIsInfluential() throws ArtifactResolutionException, InvalidVersionSpecificationException { ArtifactSpec a = createArtifactSpec( "a", "1.0" ); ArtifactSpec b = createArtifactSpec( "b", "1.0" ); b.addDependency( "c", "3.0", true ); ArtifactSpec d = a.addDependency( "d", "1.0" ); ArtifactSpec e = d.addDependency( "e", "1.0" ); e.addDependency( "c", "2.0" ); ArtifactSpec c = createArtifactSpec( "c", "3.0" ); ArtifactResolutionResult res = collect( createSet( new Object[] { a.artifact, b.artifact } ) ); assertEquals( "Check artifact list", createSet( new Object[] { a.artifact, b.artifact, c.artifact, d.artifact, e.artifact } ), res.getArtifacts() ); Artifact artifact = getArtifact( "c", res.getArtifacts() ); assertEquals( "Check version", "3.0", artifact.getVersion() ); } public void testTestScopeNotTransitive() throws ArtifactResolutionException, InvalidVersionSpecificationException { ArtifactSpec a = createArtifactSpec( "a", "1.0", Artifact.SCOPE_TEST ); ArtifactSpec b = createArtifactSpec( "b", "1.0" ); b.addDependency( "c", "3.0", Artifact.SCOPE_TEST ); ArtifactResolutionResult res = collect( createSet( new Object[] { a.artifact, b.artifact } ) ); assertEquals( "Check artifact list", createSet( new Object[] { a.artifact, b.artifact } ), res.getArtifacts() ); } public void testSnapshotNotIncluded() throws ArtifactResolutionException, InvalidVersionSpecificationException { ArtifactSpec a = createArtifactSpec( "a", "1.0" ); a.addDependency( "b", "[1.0,)" ); createArtifactSpec( "b", "1.0-SNAPSHOT" ); ArtifactResolutionResult res = collect( a ); assertTrue( res.hasVersionRangeViolations() ); /* * try { ArtifactResolutionResult res = collect( a ); fail( "Expected b not to resolve: " + res ); } catch ( * OverConstrainedVersionException e ) { assertTrue( e.getMessage().indexOf( "[1.0-SNAPSHOT]" ) < * e.getMessage().indexOf( "[1.0,)" ) ); } */ } public void testOverConstrainedVersionException() throws ArtifactResolutionException, InvalidVersionSpecificationException { ArtifactSpec a = createArtifactSpec( "a", "1.0" ); a.addDependency( "b", "[1.0, 2.0)" ); a.addDependency( "c", "[3.3.0,4.0.0)" ); ArtifactSpec b = createArtifactSpec( "b", "1.0.0" ); b.addDependency( "c", "3.3.0-v3346" ); ArtifactSpec c = createArtifactSpec( "c", "3.2.1-v3235e" ); try { ArtifactResolutionResult res = collect( createSet( new Object[] { a.artifact } ) ); } catch ( OverConstrainedVersionException e ) { assertTrue( "Versions unordered", e.getMessage().contains( "[3.2.1-v3235e, 3.3.0-v3346]" ) ); assertTrue( "DependencyTrail unresolved", e.getMessage().contains( "Path to dependency:" ) ); } } private Artifact getArtifact( String id, Set artifacts ) { for ( Object artifact : artifacts ) { Artifact a = (Artifact) artifact; if ( a.getArtifactId().equals( id ) && a.getGroupId().equals( GROUP_ID ) ) { return a; } } return null; } private ArtifactResolutionResult collect( Set artifacts ) throws ArtifactResolutionException { return collect( artifacts, null ); } private ArtifactResolutionResult collect( Set artifacts, ArtifactFilter filter ) throws ArtifactResolutionException { return artifactCollector.collect( artifacts, projectArtifact.artifact, null, null, null, source, filter, Collections.emptyList(), null ); } private ArtifactResolutionResult collect( ArtifactSpec a ) throws ArtifactResolutionException { return artifactCollector.collect( Collections.singleton( a.artifact ), projectArtifact.artifact, null, null, null, source, null, Collections.emptyList(), null ); } private ArtifactResolutionResult collect( ArtifactSpec a, ArtifactFilter filter ) throws ArtifactResolutionException { return artifactCollector.collect( Collections.singleton( a.artifact ), projectArtifact.artifact, null, null, null, source, filter, Collections.emptyList(), null ); } private ArtifactResolutionResult collect( ArtifactSpec a, Artifact managedVersion ) throws ArtifactResolutionException { Map managedVersions = Collections.singletonMap( managedVersion.getDependencyConflictId(), managedVersion ); return artifactCollector.collect( Collections.singleton( a.artifact ), projectArtifact.artifact, managedVersions, null, null, source, null, Collections.emptyList(), null ); } private ArtifactSpec createArtifactSpec( String id, String version ) throws InvalidVersionSpecificationException { return createArtifactSpec( id, version, Artifact.SCOPE_COMPILE ); } private ArtifactSpec createArtifactSpec( String id, String version, boolean optional ) throws InvalidVersionSpecificationException { return createArtifactSpec( id, version, Artifact.SCOPE_COMPILE, null, optional ); } private ArtifactSpec createArtifactSpec( String id, String version, String scope ) throws InvalidVersionSpecificationException { return createArtifactSpec( id, version, scope, null, false ); } private ArtifactSpec createArtifactSpec( String id, String version, String scope, String inheritedScope, boolean optional ) throws InvalidVersionSpecificationException { VersionRange versionRange = VersionRange.createFromVersionSpec( version ); Artifact artifact = artifactFactory.createDependencyArtifact( GROUP_ID, id, versionRange, "jar", null, scope, inheritedScope, optional ); ArtifactSpec spec = null; if ( artifact != null ) { spec = new ArtifactSpec(); spec.artifact = artifact; source.addArtifact( spec ); } return spec; } @SuppressWarnings( "unchecked" ) private static Set createSet( Object[] x ) { return new LinkedHashSet( Arrays.asList( x ) ); } private class ArtifactSpec { private Artifact artifact; private Set dependencies = new HashSet<>(); public ArtifactSpec addDependency( String id, String version ) throws InvalidVersionSpecificationException { return addDependency( id, version, Artifact.SCOPE_COMPILE ); } public ArtifactSpec addDependency( String id, String version, String scope ) throws InvalidVersionSpecificationException { return addDependency( id, version, scope, false ); } private ArtifactSpec addDependency( ArtifactSpec dep ) throws InvalidVersionSpecificationException { if ( dep != null ) { dependencies.add( dep.artifact ); } return dep; } private ArtifactSpec addDependency( String id, String version, String scope, boolean optional ) throws InvalidVersionSpecificationException { ArtifactSpec dep = createArtifactSpec( id, version, scope, artifact.getScope(), optional ); return addDependency( dep ); } public ArtifactSpec addDependency( String id, String version, boolean optional ) throws InvalidVersionSpecificationException { return addDependency( id, version, Artifact.SCOPE_COMPILE, optional ); } } private class Source implements ArtifactMetadataSource { private Map artifacts = new HashMap<>(); private Map> versions = new HashMap<>(); public ResolutionGroup retrieve( Artifact artifact, ArtifactRepository localRepository, List remoteRepositories ) throws ArtifactMetadataRetrievalException { String key = getKey( artifact ); ArtifactSpec a = (ArtifactSpec) artifacts.get( key ); try { return new ResolutionGroup( artifact, createArtifacts( artifactFactory, a.dependencies, artifact.getScope(), artifact.getDependencyFilter() ), Collections.EMPTY_LIST ); } catch ( InvalidVersionSpecificationException e ) { throw new ArtifactMetadataRetrievalException( "Invalid version creating artifacts", e, artifact ); } } private String getKey( Artifact artifact ) { return artifact.getDependencyConflictId(); } private Set createArtifacts( ArtifactFactory artifactFactory, Set dependencies, String inheritedScope, ArtifactFilter dependencyFilter ) throws InvalidVersionSpecificationException { Set projectArtifacts = new HashSet<>(); for ( Artifact d : dependencies ) { VersionRange versionRange; if ( d.getVersionRange() != null ) { versionRange = d.getVersionRange(); } else { versionRange = VersionRange.createFromVersionSpec( d.getVersion() ); } Artifact artifact; if ( d.getScope().equals( Artifact.SCOPE_TEST ) || d.getScope().equals( Artifact.SCOPE_PROVIDED ) ) { /* don't call createDependencyArtifact as it'll ignore test and provided scopes */ artifact = artifactFactory.createArtifact( d.getGroupId(), d.getArtifactId(), d.getVersion(), d.getScope(), d.getType() ); } else { artifact = artifactFactory.createDependencyArtifact( d.getGroupId(), d.getArtifactId(), versionRange, d.getType(), d.getClassifier(), d.getScope(), inheritedScope, d.isOptional() ); } if ( artifact != null && ( dependencyFilter == null || dependencyFilter.include( artifact ) ) ) { artifact.setDependencyFilter( dependencyFilter ); projectArtifacts.add( artifact ); } } return projectArtifacts; } public void addArtifact( ArtifactSpec spec ) { artifacts.put( getKey( spec.artifact ), spec ); String key = spec.artifact.getDependencyConflictId(); List artifactVersions = versions.get( key ); if ( artifactVersions == null ) { artifactVersions = new ArrayList<>(); versions.put( key, artifactVersions ); } if ( spec.artifact.getVersion() != null ) { artifactVersions.add( new DefaultArtifactVersion( spec.artifact.getVersion() ) ); } } public List retrieveAvailableVersions( Artifact artifact, ArtifactRepository localRepository, List remoteRepositories ) throws ArtifactMetadataRetrievalException { return retrieveAvailableVersions( artifact ); } public List retrieveAvailableVersionsFromDeploymentRepository( Artifact artifact, ArtifactRepository localRepository, ArtifactRepository remoteRepository ) throws ArtifactMetadataRetrievalException { return retrieveAvailableVersions( artifact ); } private List retrieveAvailableVersions( Artifact artifact ) { List artifactVersions = versions.get( artifact.getDependencyConflictId() ); if ( artifactVersions == null ) { artifactVersions = Collections.emptyList(); } return artifactVersions; } public ResolutionGroup retrieve( MetadataResolutionRequest request ) throws ArtifactMetadataRetrievalException { return retrieve( request.getArtifact(), request.getLocalRepository(), request.getRemoteRepositories() ); } public List retrieveAvailableVersions( MetadataResolutionRequest request ) throws ArtifactMetadataRetrievalException { return retrieveAvailableVersions( request.getArtifact(), request.getLocalRepository(), request.getRemoteRepositories() ); } } } maven-maven-3.5.2/maven-compat/src/test/java/org/apache/maven/repository/legacy/resolver/conflict/000077500000000000000000000000001317160430700332565ustar00rootroot00000000000000AbstractConflictResolverTest.java000066400000000000000000000113561317160430700416570ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/test/java/org/apache/maven/repository/legacy/resolver/conflictpackage org.apache.maven.repository.legacy.resolver.conflict; /* * 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 org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.factory.ArtifactFactory; import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.resolver.ResolutionNode; import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException; import org.apache.maven.artifact.versioning.VersionRange; import org.apache.maven.repository.legacy.resolver.conflict.ConflictResolver; import org.codehaus.plexus.PlexusTestCase; import java.util.Collections; /** * Provides a basis for testing conflict resolvers. * * @author Mark Hobson */ public abstract class AbstractConflictResolverTest extends PlexusTestCase { // constants -------------------------------------------------------------- private static final String GROUP_ID = "test"; // fields ----------------------------------------------------------------- protected Artifact a1; protected Artifact a2; protected Artifact b1; private final String roleHint; private ArtifactFactory artifactFactory; private ConflictResolver conflictResolver; // constructors ----------------------------------------------------------- public AbstractConflictResolverTest( String roleHint ) throws Exception { this.roleHint = roleHint; } // TestCase methods ------------------------------------------------------- /* * @see junit.framework.TestCase#setUp() */ protected void setUp() throws Exception { super.setUp(); artifactFactory = (ArtifactFactory) lookup( ArtifactFactory.ROLE ); conflictResolver = (ConflictResolver) lookup( ConflictResolver.ROLE, roleHint ); a1 = createArtifact( "a", "1.0" ); a2 = createArtifact( "a", "2.0" ); b1 = createArtifact( "b", "1.0" ); } /* * @see org.codehaus.plexus.PlexusTestCase#tearDown() */ protected void tearDown() throws Exception { a1 = null; a2 = null; b1 = null; artifactFactory = null; conflictResolver = null; super.tearDown(); } // protected methods ------------------------------------------------------ protected ConflictResolver getConflictResolver() { return conflictResolver; } protected void assertResolveConflict( ResolutionNode expectedNode, ResolutionNode actualNode1, ResolutionNode actualNode2 ) { ResolutionNode resolvedNode = getConflictResolver().resolveConflict( actualNode1, actualNode2 ); assertNotNull( "Expected resolvable", resolvedNode ); assertEquals( "Resolution node", expectedNode, resolvedNode ); } protected Artifact createArtifact( String id, String version ) throws InvalidVersionSpecificationException { return createArtifact( id, version, Artifact.SCOPE_COMPILE ); } protected Artifact createArtifact( String id, String version, String scope ) throws InvalidVersionSpecificationException { return createArtifact( id, version, scope, null, false ); } protected Artifact createArtifact( String id, String version, String scope, String inheritedScope, boolean optional ) throws InvalidVersionSpecificationException { VersionRange versionRange = VersionRange.createFromVersionSpec( version ); return artifactFactory.createDependencyArtifact( GROUP_ID, id, versionRange, "jar", null, scope, inheritedScope, optional ); } protected ResolutionNode createResolutionNode( Artifact Artifact ) { return new ResolutionNode( Artifact, Collections.emptyList() ); } protected ResolutionNode createResolutionNode( Artifact Artifact, ResolutionNode parent ) { return new ResolutionNode( Artifact, Collections.emptyList(), parent ); } } FarthestConflictResolverTest.java000066400000000000000000000055641317160430700417000ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/test/java/org/apache/maven/repository/legacy/resolver/conflictpackage org.apache.maven.repository.legacy.resolver.conflict; /* * 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 org.apache.maven.artifact.resolver.ResolutionNode; /** * Tests FarthestConflictResolver. * * @author Mark Hobson * @see FarthestConflictResolver */ public class FarthestConflictResolverTest extends AbstractConflictResolverTest { // constructors ----------------------------------------------------------- public FarthestConflictResolverTest() throws Exception { super("farthest"); } // tests ------------------------------------------------------------------ /** * Tests that a:2.0 wins in the scenario: *
     * a:1.0
     * b:1.0 -> a:2.0
     * 
*/ public void testDepth() { ResolutionNode a1n = createResolutionNode( a1); ResolutionNode b1n = createResolutionNode( b1); ResolutionNode a2n = createResolutionNode( a2, b1n ); assertResolveConflict( a2n, a1n, a2n ); } /** * Tests that a:2.0 wins in the scenario: *
     * b:1.0 -> a:2.0
     * a:1.0
     * 
*/ public void testDepthReversed() { ResolutionNode b1n = createResolutionNode( b1 ); ResolutionNode a2n = createResolutionNode( a2, b1n ); ResolutionNode a1n = createResolutionNode( a1 ); assertResolveConflict( a2n, a2n, a1n ); } /** * Tests that a:1.0 wins in the scenario: *
     * a:1.0
     * a:2.0
     * 
*/ public void testEqual() { ResolutionNode a1n = createResolutionNode( a1 ); ResolutionNode a2n = createResolutionNode( a2 ); assertResolveConflict( a1n, a1n, a2n ); } /** * Tests that a:2.0 wins in the scenario: *
     * a:2.0
     * a:1.0
     * 
*/ public void testEqualReversed() { ResolutionNode a2n = createResolutionNode( a2); ResolutionNode a1n = createResolutionNode( a1); assertResolveConflict( a2n, a2n, a1n ); } } NearestConflictResolverTest.java000066400000000000000000000055561317160430700415220ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/test/java/org/apache/maven/repository/legacy/resolver/conflictpackage org.apache.maven.repository.legacy.resolver.conflict; /* * 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 org.apache.maven.artifact.resolver.ResolutionNode; /** * Tests NearestConflictResolver. * * @author Mark Hobson * @see NearestConflictResolver */ public class NearestConflictResolverTest extends AbstractConflictResolverTest { // constructors ----------------------------------------------------------- public NearestConflictResolverTest() throws Exception { super("nearest"); } // tests ------------------------------------------------------------------ /** * Tests that a:1.0 wins in the scenario: *
     * a:1.0
     * b:1.0 -> a:2.0
     * 
*/ public void testDepth() { ResolutionNode a1n = createResolutionNode( a1); ResolutionNode b1n = createResolutionNode( b1); ResolutionNode a2n = createResolutionNode( a2, b1n ); assertResolveConflict( a1n, a1n, a2n ); } /** * Tests that a:1.0 wins in the scenario: *
     * b:1.0 -> a:2.0
     * a:1.0
     * 
*/ public void testDepthReversed() { ResolutionNode b1n = createResolutionNode( b1 ); ResolutionNode a2n = createResolutionNode( a2, b1n ); ResolutionNode a1n = createResolutionNode( a1 ); assertResolveConflict( a1n, a2n, a1n ); } /** * Tests that a:1.0 wins in the scenario: *
     * a:1.0
     * a:2.0
     * 
*/ public void testEqual() { ResolutionNode a1n = createResolutionNode( a1 ); ResolutionNode a2n = createResolutionNode( a2 ); assertResolveConflict( a1n, a1n, a2n ); } /** * Tests that a:2.0 wins in the scenario: *
     * a:2.0
     * a:1.0
     * 
*/ public void testEqualReversed() { ResolutionNode a2n = createResolutionNode( a2); ResolutionNode a1n = createResolutionNode( a1 ); assertResolveConflict( a2n, a2n, a1n ); } } NewestConflictResolverTest.java000066400000000000000000000055541317160430700413640ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/test/java/org/apache/maven/repository/legacy/resolver/conflictpackage org.apache.maven.repository.legacy.resolver.conflict; /* * 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 org.apache.maven.artifact.resolver.ResolutionNode; /** * Tests NewestConflictResolver. * * @author Mark Hobson * @see NewestConflictResolver */ public class NewestConflictResolverTest extends AbstractConflictResolverTest { // constructors ----------------------------------------------------------- public NewestConflictResolverTest() throws Exception { super("newest"); } // tests ------------------------------------------------------------------ /** * Tests that a:2.0 wins in the scenario: *
     * a:1.0
     * b:1.0 -> a:2.0
     * 
*/ public void testDepth() { ResolutionNode a1n = createResolutionNode( a1 ); ResolutionNode b1n = createResolutionNode( b1 ); ResolutionNode a2n = createResolutionNode( a2, b1n ); assertResolveConflict( a2n, a1n, a2n ); } /** * Tests that a:2.0 wins in the scenario: *
     * b:1.0 -> a:2.0
     * a:1.0
     * 
*/ public void testDepthReversed() { ResolutionNode b1n = createResolutionNode( b1 ); ResolutionNode a2n = createResolutionNode( a2, b1n ); ResolutionNode a1n = createResolutionNode( a1 ); assertResolveConflict( a2n, a2n, a1n ); } /** * Tests that a:2.0 wins in the scenario: *
     * a:1.0
     * a:2.0
     * 
*/ public void testEqual() { ResolutionNode a1n = createResolutionNode( a1 ); ResolutionNode a2n = createResolutionNode( a2 ); assertResolveConflict( a2n, a1n, a2n ); } /** * Tests that a:2.0 wins in the scenario: *
     * a:2.0
     * a:1.0
     * 
*/ public void testEqualReversed() { ResolutionNode a2n = createResolutionNode( a2 ); ResolutionNode a1n = createResolutionNode( a1 ); assertResolveConflict( a2n, a2n, a1n ); } } OldestConflictResolverTest.java000066400000000000000000000055541317160430700413510ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/test/java/org/apache/maven/repository/legacy/resolver/conflictpackage org.apache.maven.repository.legacy.resolver.conflict; /* * 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 org.apache.maven.artifact.resolver.ResolutionNode; /** * Tests OldestConflictResolver. * * @author Mark Hobson * @see OldestConflictResolver */ public class OldestConflictResolverTest extends AbstractConflictResolverTest { // constructors ----------------------------------------------------------- public OldestConflictResolverTest() throws Exception { super("oldest"); } // tests ------------------------------------------------------------------ /** * Tests that a:1.0 wins in the scenario: *
     * a:1.0
     * b:1.0 -> a:2.0
     * 
*/ public void testDepth() { ResolutionNode a1n = createResolutionNode( a1 ); ResolutionNode b1n = createResolutionNode( b1); ResolutionNode a2n = createResolutionNode( a2, b1n ); assertResolveConflict( a1n, a1n, a2n ); } /** * Tests that a:1.0 wins in the scenario: *
     * b:1.0 -> a:2.0
     * a:1.0
     * 
*/ public void testDepthReversed() { ResolutionNode b1n = createResolutionNode( b1 ); ResolutionNode a2n = createResolutionNode( a2, b1n ); ResolutionNode a1n = createResolutionNode( a1 ); assertResolveConflict( a1n, a2n, a1n ); } /** * Tests that a:1.0 wins in the scenario: *
     * a:1.0
     * a:2.0
     * 
*/ public void testEqual() { ResolutionNode a1n = createResolutionNode( a1 ); ResolutionNode a2n = createResolutionNode( a2 ); assertResolveConflict( a1n, a1n, a2n ); } /** * Tests that a:1.0 wins in the scenario: *
     * a:2.0
     * a:1.0
     * 
*/ public void testEqualReversed() { ResolutionNode a2n = createResolutionNode( a2); ResolutionNode a1n = createResolutionNode( a1 ); assertResolveConflict( a1n, a2n, a1n ); } } maven-maven-3.5.2/maven-compat/src/test/java/org/apache/maven/repository/metadata/000077500000000000000000000000001317160430700301305ustar00rootroot00000000000000DefaultClasspathTransformationTest.java000066400000000000000000000117141317160430700377360ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/test/java/org/apache/maven/repository/metadatapackage org.apache.maven.repository.metadata; /* * 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 org.apache.maven.artifact.ArtifactScopeEnum; import org.apache.maven.repository.metadata.ArtifactMetadata; import org.apache.maven.repository.metadata.ClasspathContainer; import org.apache.maven.repository.metadata.ClasspathTransformation; import org.apache.maven.repository.metadata.MetadataGraph; import org.apache.maven.repository.metadata.MetadataGraphEdge; import org.apache.maven.repository.metadata.MetadataGraphVertex; import org.codehaus.plexus.PlexusTestCase; /** * * @author Oleg Gusakov * */ public class DefaultClasspathTransformationTest extends PlexusTestCase { ClasspathTransformation transform; MetadataGraph graph; MetadataGraphVertex v1; MetadataGraphVertex v2; MetadataGraphVertex v3; MetadataGraphVertex v4; //------------------------------------------------------------------------------------------ @Override protected void setUp() throws Exception { super.setUp(); transform = (ClasspathTransformation) lookup( ClasspathTransformation.ROLE, "default" ); graph = new MetadataGraph( 4, 3 ); /* * v2 * v1< * v3-v4 * */ v1 = graph.addVertex(new ArtifactMetadata("g","a1","1.0")); graph.setEntry(v1); v2 = graph.addVertex(new ArtifactMetadata("g","a2","1.0")); v3 = graph.addVertex(new ArtifactMetadata("g","a3","1.0")); v4 = graph.addVertex(new ArtifactMetadata("g","a4","1.0")); // v1-->v2 graph.addEdge(v1, v2, new MetadataGraphEdge( "1.1", true, null, null, 2, 1 ) ); graph.addEdge(v1, v2, new MetadataGraphEdge( "1.2", true, null, null, 2, 2 ) ); // v1-->v3 graph.addEdge(v1, v3, new MetadataGraphEdge( "1.1", true, null, null, 2, 1 ) ); graph.addEdge(v1, v3, new MetadataGraphEdge( "1.2", true, null, null, 4, 2 ) ); // v3-->v4 graph.addEdge(v3, v4, new MetadataGraphEdge( "1.1", true, ArtifactScopeEnum.runtime, null, 2, 2 ) ); graph.addEdge(v3, v4, new MetadataGraphEdge( "1.2", true, ArtifactScopeEnum.test, null, 2, 2 ) ); } //------------------------------------------------------------------------------------------ public void testCompileClasspathTransform() throws Exception { ClasspathContainer res; res = transform.transform( graph, ArtifactScopeEnum.compile, false ); assertNotNull("null classpath container after compile transform", res ); assertNotNull("null classpath after compile transform", res.getClasspath() ); assertEquals("compile classpath should have 3 entries", 3, res.getClasspath().size() ); } //------------------------------------------------------------------------------------------ public void testRuntimeClasspathTransform() throws Exception { ClasspathContainer res; res = transform.transform( graph, ArtifactScopeEnum.runtime, false ); assertNotNull("null classpath container after runtime transform", res ); assertNotNull("null classpath after runtime transform", res.getClasspath() ); assertEquals("runtime classpath should have 4 entries", 4, res.getClasspath().size() ); ArtifactMetadata md = res.getClasspath().get(3); assertEquals("runtime artifact version should be 1.1", "1.1", md.getVersion() ); } //------------------------------------------------------------------------------------------ public void testTestClasspathTransform() throws Exception { ClasspathContainer res; res = transform.transform( graph, ArtifactScopeEnum.test, false ); assertNotNull("null classpath container after runtime transform", res ); assertNotNull("null classpath after runtime transform", res.getClasspath() ); assertEquals("runtime classpath should have 4 entries", 4, res.getClasspath().size() ); ArtifactMetadata md = res.getClasspath().get(3); assertEquals("test artifact version should be 1.2", "1.2", md.getVersion() ); } //------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------ } DefaultGraphConflictResolutionPolicyTest.java000066400000000000000000000045251317160430700410560ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/test/java/org/apache/maven/repository/metadatapackage org.apache.maven.repository.metadata; /* * 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 org.apache.maven.repository.metadata.GraphConflictResolutionPolicy; import org.apache.maven.repository.metadata.MetadataGraphEdge; import org.codehaus.plexus.PlexusTestCase; /** * * @author Oleg Gusakov * */ public class DefaultGraphConflictResolutionPolicyTest extends PlexusTestCase { GraphConflictResolutionPolicy policy; MetadataGraphEdge e1; MetadataGraphEdge e2; MetadataGraphEdge e3; //------------------------------------------------------------------------------------------ @Override protected void setUp() throws Exception { super.setUp(); policy = (GraphConflictResolutionPolicy) lookup( GraphConflictResolutionPolicy.ROLE, "default" ); e1 = new MetadataGraphEdge( "1.1", true, null, null, 2, 1 ); e2 = new MetadataGraphEdge( "1.2", true, null, null, 3, 2 ); e3 = new MetadataGraphEdge( "1.2", true, null, null, 2, 3 ); } //------------------------------------------------------------------------------------------ public void testDefaultPolicy() throws Exception { MetadataGraphEdge res; res = policy.apply( e1, e2 ); assertEquals( "Wrong depth edge selected", "1.1", res.getVersion() ); res = policy.apply( e1, e3 ); assertEquals( "Wrong version edge selected", "1.2", res.getVersion() ); } //------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------ } DefaultGraphConflictResolverTest.java000066400000000000000000000170071317160430700373330ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/test/java/org/apache/maven/repository/metadatapackage org.apache.maven.repository.metadata; /* * 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 org.apache.maven.artifact.ArtifactScopeEnum; import org.apache.maven.repository.metadata.ArtifactMetadata; import org.apache.maven.repository.metadata.GraphConflictResolver; import org.apache.maven.repository.metadata.MetadataGraph; import org.apache.maven.repository.metadata.MetadataGraphEdge; import org.apache.maven.repository.metadata.MetadataGraphVertex; import org.codehaus.plexus.PlexusTestCase; import org.codehaus.plexus.logging.Logger; /** * * @author Oleg Gusakov * */ public class DefaultGraphConflictResolverTest extends PlexusTestCase { Logger log; GraphConflictResolver resolver; MetadataGraph graph; MetadataGraphVertex v1; MetadataGraphVertex v2; MetadataGraphVertex v3; MetadataGraphVertex v4; //------------------------------------------------------------------------------------------ @Override protected void setUp() throws Exception { super.setUp(); resolver = (GraphConflictResolver) lookup( GraphConflictResolver.ROLE, "default" ); /* * v2 * v1< * v3-v4 * */ graph = new MetadataGraph( 4, 3 ); v1 = graph.addVertex(new ArtifactMetadata("g","a1","1.0")); graph.setEntry(v1); v2 = graph.addVertex(new ArtifactMetadata("g","a2","1.0")); v3 = graph.addVertex(new ArtifactMetadata("g","a3","1.0")); v4 = graph.addVertex(new ArtifactMetadata("g","a4","1.0")); // v1-->v2 graph.addEdge(v1, v2, new MetadataGraphEdge( "1.1", true, null, null, 2, 1 ) ); graph.addEdge(v1, v2, new MetadataGraphEdge( "1.2", true, null, null, 2, 2 ) ); // v1-->v3 graph.addEdge(v1, v3, new MetadataGraphEdge( "1.1", true, null, null, 2, 1 ) ); graph.addEdge(v1, v3, new MetadataGraphEdge( "1.2", true, null, null, 4, 2 ) ); // v3-->v4 graph.addEdge(v3, v4, new MetadataGraphEdge( "1.1", true, ArtifactScopeEnum.runtime, null, 2, 1 ) ); graph.addEdge(v3, v4, new MetadataGraphEdge( "1.2", true, ArtifactScopeEnum.provided, null, 2, 2 ) ); } //------------------------------------------------------------------------------------------ public void testCompileResolution() throws Exception { MetadataGraph res; res = resolver.resolveConflicts( graph, ArtifactScopeEnum.compile ); assertNotNull("null graph after resolver", res ); assertNotNull("no vertices in the resulting graph after resolver", res.getVertices() ); assertNotNull("no edges in the resulting graph after resolver", res.getExcidentEdges(v1) ); assertEquals( "wrong # of vertices in the resulting graph after resolver", 4, res.getVertices().size() ); assertEquals( "wrong # of excident edges in the resulting graph entry after resolver", 2, res.getExcidentEdges(v1).size() ); assertEquals( "wrong # of v2 incident edges in the resulting graph after resolver", 1, res.getIncidentEdges(v2).size() ); assertEquals( "wrong edge v1-v2 in the resulting graph after resolver", "1.2", res.getIncidentEdges(v2).get(0).getVersion() ); assertEquals( "wrong # of edges v1-v3 in the resulting graph after resolver", 1, res.getIncidentEdges(v3).size() ); assertEquals( "wrong edge v1-v3 in the resulting graph after resolver", "1.1", res.getIncidentEdges(v3).get(0).getVersion() ); assertEquals( "wrong # of edges v3-v4 in the resulting graph after resolver", 1, res.getIncidentEdges(v4).size() ); assertEquals( "wrong edge v3-v4 in the resulting graph after resolver", "1.2", res.getIncidentEdges(v4).get(0).getVersion() ); } //------------------------------------------------------------------------------------------ public void testRuntimeResolution() throws Exception { MetadataGraph res; res = resolver.resolveConflicts( graph, ArtifactScopeEnum.runtime ); assertNotNull("null graph after resolver", res ); assertNotNull("no vertices in the resulting graph after resolver", res.getVertices() ); assertNotNull("no edges in the resulting graph after resolver", res.getExcidentEdges(v1) ); assertEquals( "wrong # of vertices in the resulting graph after resolver", 4, res.getVertices().size() ); assertEquals( "wrong # of excident edges in the resulting graph entry after resolver", 2, res.getExcidentEdges(v1).size() ); assertEquals( "wrong # of v2 incident edges in the resulting graph after resolver", 1, res.getIncidentEdges(v2).size() ); assertEquals( "wrong edge v1-v2 in the resulting graph after resolver", "1.2", res.getIncidentEdges(v2).get(0).getVersion() ); assertEquals( "wrong # of edges v1-v3 in the resulting graph after resolver", 1, res.getIncidentEdges(v3).size() ); assertEquals( "wrong edge v1-v3 in the resulting graph after resolver", "1.1", res.getIncidentEdges(v3).get(0).getVersion() ); assertEquals( "wrong # of edges v3-v4 in the resulting graph after resolver", 1, res.getIncidentEdges(v4).size() ); assertEquals( "wrong edge v3-v4 in the resulting graph after resolver", "1.1", res.getIncidentEdges(v4).get(0).getVersion() ); } //------------------------------------------------------------------------------------------ public void testTestResolution() throws Exception { MetadataGraph res; res = resolver.resolveConflicts( graph, ArtifactScopeEnum.test ); assertNotNull("null graph after resolver", res ); assertNotNull("no vertices in the resulting graph after resolver", res.getVertices() ); assertNotNull("no edges in the resulting graph after resolver", res.getExcidentEdges(v1) ); assertEquals( "wrong # of vertices in the resulting graph after resolver", 4, res.getVertices().size() ); assertEquals( "wrong # of excident edges in the resulting graph entry after resolver", 2, res.getExcidentEdges(v1).size() ); assertEquals( "wrong # of v2 incident edges in the resulting graph after resolver", 1, res.getIncidentEdges(v2).size() ); assertEquals( "wrong edge v1-v2 in the resulting graph after resolver", "1.2", res.getIncidentEdges(v2).get(0).getVersion() ); assertEquals( "wrong # of edges v1-v3 in the resulting graph after resolver", 1, res.getIncidentEdges(v3).size() ); assertEquals( "wrong edge v1-v3 in the resulting graph after resolver", "1.1", res.getIncidentEdges(v3).get(0).getVersion() ); assertEquals( "wrong # of edges v3-v4 in the resulting graph after resolver", 1, res.getIncidentEdges(v4).size() ); assertEquals( "wrong edge v3-v4 in the resulting graph after resolver", "1.2", res.getIncidentEdges(v4).get(0).getVersion() ); } //------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------ } TestMetadataSource.java000066400000000000000000000075031317160430700344620ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/test/java/org/apache/maven/repository/metadatapackage org.apache.maven.repository.metadata; /* * 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 org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.factory.ArtifactFactory; import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.versioning.ArtifactVersion; import org.apache.maven.repository.legacy.metadata.ArtifactMetadataRetrievalException; import org.apache.maven.repository.legacy.metadata.ArtifactMetadataSource; import org.apache.maven.repository.legacy.metadata.MetadataResolutionRequest; import org.apache.maven.repository.legacy.metadata.ResolutionGroup; import org.codehaus.plexus.component.annotations.Component; import org.codehaus.plexus.component.annotations.Requirement; import java.util.HashSet; import java.util.List; import java.util.Set; @Component(role = ArtifactMetadataSource.class) public class TestMetadataSource implements ArtifactMetadataSource { @Requirement private ArtifactFactory factory; public ResolutionGroup retrieve( Artifact artifact, ArtifactRepository localRepository, List remoteRepositories ) throws ArtifactMetadataRetrievalException { Set dependencies = new HashSet<>(); if ( "g".equals( artifact.getArtifactId() ) ) { Artifact a = null; try { a = factory.createBuildArtifact( "org.apache.maven", "h", "1.0", "jar" ); dependencies.add( a ); } catch ( Exception e ) { throw new ArtifactMetadataRetrievalException( "Error retrieving metadata", e, a ); } } if ( "i".equals( artifact.getArtifactId() ) ) { Artifact a = null; try { a = factory.createBuildArtifact( "org.apache.maven", "j", "1.0-SNAPSHOT", "jar" ); dependencies.add( a ); } catch ( Exception e ) { throw new ArtifactMetadataRetrievalException( "Error retrieving metadata", e, a ); } } return new ResolutionGroup( artifact, dependencies, remoteRepositories ); } public List retrieveAvailableVersions( Artifact artifact, ArtifactRepository localRepository, List remoteRepositories ) throws ArtifactMetadataRetrievalException { throw new UnsupportedOperationException( "Cannot get available versions in this test case" ); } public List retrieveAvailableVersionsFromDeploymentRepository( Artifact artifact, ArtifactRepository localRepository, ArtifactRepository remoteRepository ) throws ArtifactMetadataRetrievalException { throw new UnsupportedOperationException( "Cannot get available versions in this test case" ); } public ResolutionGroup retrieve( MetadataResolutionRequest request ) throws ArtifactMetadataRetrievalException { return retrieve( request.getArtifact(), request.getLocalRepository(), request.getRemoteRepositories() ); } } maven-maven-3.5.2/maven-compat/src/test/remote-repo/000077500000000000000000000000001317160430700223305ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/test/remote-repo/org/000077500000000000000000000000001317160430700231175ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/test/remote-repo/org/apache/000077500000000000000000000000001317160430700243405ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/test/remote-repo/org/apache/maven/000077500000000000000000000000001317160430700254465ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/test/remote-repo/org/apache/maven/its/000077500000000000000000000000001317160430700262455ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/test/remote-repo/org/apache/maven/its/a/000077500000000000000000000000001317160430700264655ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/test/remote-repo/org/apache/maven/its/a/0.1/000077500000000000000000000000001317160430700267635ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/test/remote-repo/org/apache/maven/its/a/0.1/a-0.1.pom000066400000000000000000000023351317160430700302170ustar00rootroot00000000000000 4.0.0 org.apache.maven.its a 0.1 jar Maven Integration Test :: Dummy Artifact maven-core-it file:///${basedir}/repo maven-maven-3.5.2/maven-compat/src/test/remote-repo/org/apache/maven/its/a/maven-metadata.xml000066400000000000000000000004471317160430700321000ustar00rootroot00000000000000 org.apache.maven.its a 0.1 0.1 20091023222756 maven-maven-3.5.2/maven-compat/src/test/remote-repo/org/apache/maven/its/b/000077500000000000000000000000001317160430700264665ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/test/remote-repo/org/apache/maven/its/b/0.1/000077500000000000000000000000001317160430700267645ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/test/remote-repo/org/apache/maven/its/b/0.1/b-0.1.pom000066400000000000000000000026201317160430700302160ustar00rootroot00000000000000 4.0.0 org.apache.maven.its b 0.1 jar Maven Integration Test :: Dummy Artifact maven-core-it file:///${basedir}/repo org.apache.maven.its a 0.1 maven-maven-3.5.2/maven-compat/src/test/remote-repo/org/apache/maven/its/b/maven-metadata.xml000066400000000000000000000004471317160430700321010ustar00rootroot00000000000000 org.apache.maven.its b 0.1 0.1 20091023222817 maven-maven-3.5.2/maven-compat/src/test/repository-system/000077500000000000000000000000001317160430700236335ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/test/resources/000077500000000000000000000000001317160430700221045ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/test/resources/artifact-install/000077500000000000000000000000001317160430700253455ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/test/resources/inheritance-repo/000077500000000000000000000000001317160430700253405ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/test/resources/inheritance-repo/t00/000077500000000000000000000000001317160430700257435ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/test/resources/inheritance-repo/t00/maven/000077500000000000000000000000001317160430700270515ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/test/resources/inheritance-repo/t00/maven/poms/000077500000000000000000000000001317160430700300275ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/test/resources/inheritance-repo/t00/maven/poms/p0-1.0.pom000066400000000000000000000003671317160430700313650ustar00rootroot00000000000000 4.0.0 maven p0 pom p0 1.0 Codehaus maven-maven-3.5.2/maven-compat/src/test/resources/inheritance-repo/t00/maven/poms/p1-1.0.pom000066400000000000000000000005211317160430700313560ustar00rootroot00000000000000 p0 maven 1.0 4.0.0 maven p1 pom p1 1.0 scm-url maven-maven-3.5.2/maven-compat/src/test/resources/inheritance-repo/t00/maven/poms/p2-1.0.pom000066400000000000000000000006211317160430700313600ustar00rootroot00000000000000 p1 maven 1.0 4.0.0 maven p2 pom p2 1.0 mailing-list maven-maven-3.5.2/maven-compat/src/test/resources/inheritance-repo/t00/maven/poms/p3-1.0.pom000066400000000000000000000005171317160430700313650ustar00rootroot00000000000000 p2 maven 1.0 4.0.0 maven p3 pom p3 1.0 2000 maven-maven-3.5.2/maven-compat/src/test/resources/inheritance-repo/t00/maven/poms/p4-1.0.pom000066400000000000000000000004511317160430700313630ustar00rootroot00000000000000 p3 maven 1.0 4.0.0 maven p4 jar p4 1.0 maven-maven-3.5.2/maven-compat/src/test/resources/inheritance-repo/t01/000077500000000000000000000000001317160430700257445ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/test/resources/inheritance-repo/t01/maven.t01/000077500000000000000000000000001317160430700274555ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/test/resources/inheritance-repo/t01/maven.t01/poms/000077500000000000000000000000001317160430700304335ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/test/resources/inheritance-repo/t01/maven.t01/poms/p0-1.0.pom000066400000000000000000000003721317160430700317650ustar00rootroot00000000000000 4.0.0 maven.t01 p0 pom p0 1.0 p0-org maven-maven-3.5.2/maven-compat/src/test/resources/inheritance-repo/t01/maven.t01/poms/p1-1.0.pom000066400000000000000000000005551317160430700317710ustar00rootroot00000000000000 p0 maven.t01 1.0 4.0.0 maven.t01 p1 pom p1 1.0 p1-org maven-maven-3.5.2/maven-compat/src/test/resources/inheritance-repo/t01/maven.t01/poms/p2-1.0.pom000066400000000000000000000005551317160430700317720ustar00rootroot00000000000000 p1 maven.t01 1.0 4.0.0 maven.t01 p2 pom p2 1.0 p2-org maven-maven-3.5.2/maven-compat/src/test/resources/inheritance-repo/t01/maven.t01/poms/p3-1.0.pom000066400000000000000000000005551317160430700317730ustar00rootroot00000000000000 p2 maven.t01 1.0 4.0.0 maven.t01 p3 pom p3 1.0 p3-org maven-maven-3.5.2/maven-compat/src/test/resources/inheritance-repo/t01/maven.t01/poms/p4-1.0.pom000066400000000000000000000005551317160430700317740ustar00rootroot00000000000000 p3 maven.t01 1.0 4.0.0 maven.t01 p4 jar p4 1.0 p4-org maven-maven-3.5.2/maven-compat/src/test/resources/inheritance-repo/t02/000077500000000000000000000000001317160430700257455ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/test/resources/inheritance-repo/t02/p0/000077500000000000000000000000001317160430700262645ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/test/resources/inheritance-repo/t02/p0/p1/000077500000000000000000000000001317160430700266045ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/test/resources/inheritance-repo/t02/p0/p1/p2/000077500000000000000000000000001317160430700271255ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/test/resources/inheritance-repo/t02/p0/p1/p2/p3/000077500000000000000000000000001317160430700274475ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/test/resources/inheritance-repo/t02/p0/p1/p2/p3/p4/000077500000000000000000000000001317160430700277725ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/test/resources/inheritance-repo/t02/p0/p1/p2/p3/p4/p5/000077500000000000000000000000001317160430700303165ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/test/resources/inheritance-repo/t02/p0/p1/p2/p3/p4/p5/pom.xml000066400000000000000000000020611317160430700316320ustar00rootroot00000000000000 p4 maven.t02 1.0 4.0.0 maven.t02 p5 jar p5 1.0 maven-maven-3.5.2/maven-compat/src/test/resources/inheritance-repo/t02/p0/p1/p2/p3/p4/pom.xml000066400000000000000000000020611317160430700313060ustar00rootroot00000000000000 p3 maven.t02 1.0 4.0.0 maven.t02 p4 pom p4 1.0 maven-maven-3.5.2/maven-compat/src/test/resources/inheritance-repo/t02/p0/p1/p2/p3/pom.xml000066400000000000000000000021271317160430700307660ustar00rootroot00000000000000 p2 maven.t02 1.0 4.0.0 maven.t02 p3 pom p3 1.0 2000 maven-maven-3.5.2/maven-compat/src/test/resources/inheritance-repo/t02/p0/p1/p2/pom.xml000066400000000000000000000022311317160430700304400ustar00rootroot00000000000000 p1 maven.t02 1.0 4.0.0 maven.t02 p2 pom p2 1.0 mailing-list maven-maven-3.5.2/maven-compat/src/test/resources/inheritance-repo/t02/p0/p1/pom.xml000066400000000000000000000027021317160430700301220ustar00rootroot00000000000000 p0 maven.t02 1.0 4.0.0 maven.t02 p1 pom p1 1.0 scm-url maven-compiler-plugin test package compile maven-maven-3.5.2/maven-compat/src/test/resources/inheritance-repo/t02/p0/pom.xml000066400000000000000000000017731317160430700276110ustar00rootroot00000000000000 4.0.0 maven.t02 p0 pom p0 1.0 Codehaus maven-maven-3.5.2/maven-compat/src/test/resources/inheritance-repo/t03/000077500000000000000000000000001317160430700257465ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/test/resources/inheritance-repo/t03/p0/000077500000000000000000000000001317160430700262655ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/test/resources/inheritance-repo/t03/p0/p1/000077500000000000000000000000001317160430700266055ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/test/resources/inheritance-repo/t03/p0/p1/pom.xml000066400000000000000000000025201317160430700301210ustar00rootroot00000000000000 p0 maven.t03 1.0 4.0.0 maven.t03 p1 pom p1 1.0 scm-url maven-antrun-plugin ${project.parent.basedir} maven-maven-3.5.2/maven-compat/src/test/resources/inheritance-repo/t03/p0/pom.xml000066400000000000000000000017731317160430700276120ustar00rootroot00000000000000 4.0.0 maven.t03 p0 pom p0 1.0 Codehaus maven-maven-3.5.2/maven-compat/src/test/resources/inheritance-repo/t04/000077500000000000000000000000001317160430700257475ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/test/resources/inheritance-repo/t04/maven-test/000077500000000000000000000000001317160430700300325ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/test/resources/inheritance-repo/t04/maven-test/jars/000077500000000000000000000000001317160430700307715ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/test/resources/inheritance-repo/t04/maven-test/poms/000077500000000000000000000000001317160430700310105ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/test/resources/inheritance-repo/t04/maven-test/poms/t04-a-1.0.pom000066400000000000000000000010101317160430700326360ustar00rootroot00000000000000 4.0.0 maven-test t04-a jar 1.0 central Fake Maven Central Repository file://dummy maven-test t04-b 2.0 maven-maven-3.5.2/maven-compat/src/test/resources/inheritance-repo/t04/maven-test/poms/t04-b-1.0.pom000066400000000000000000000002601317160430700326450ustar00rootroot00000000000000 4.0.0 maven-test t04-b jar 1.0 maven-maven-3.5.2/maven-compat/src/test/resources/inheritance-repo/t04/maven-test/poms/t04-b-2.0.pom000066400000000000000000000002601317160430700326460ustar00rootroot00000000000000 4.0.0 maven-test t04-b jar 2.0 maven-maven-3.5.2/maven-compat/src/test/resources/inheritance-repo/t04/maven-test/poms/t04-c-1.0.pom000066400000000000000000000002601317160430700326460ustar00rootroot00000000000000 4.0.0 maven-test t04-c jar 1.0 maven-maven-3.5.2/maven-compat/src/test/resources/inheritance-repo/t04/maven-test/poms/t04-c-2.0.pom000066400000000000000000000002601317160430700326470ustar00rootroot00000000000000 4.0.0 maven-test t04-b jar 2.0 maven-maven-3.5.2/maven-compat/src/test/resources/inheritance-repo/t04/p0/000077500000000000000000000000001317160430700262665ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/test/resources/inheritance-repo/t04/p0/p1/000077500000000000000000000000001317160430700266065ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/test/resources/inheritance-repo/t04/p0/p1/pom.xml000066400000000000000000000015541317160430700301300ustar00rootroot00000000000000 p0 maven-t04 1.0 4.0.0 maven-t04 p1 pom p1 1.0 scm-url maven-test t04-a maven-test t04-c 1.0 maven-antrun-plugin ${project.parent.basedir} maven-maven-3.5.2/maven-compat/src/test/resources/inheritance-repo/t04/p0/pom.xml000066400000000000000000000014061317160430700276040ustar00rootroot00000000000000 4.0.0 maven-t04 p0 pom p0 1.0 Codehaus maven-test t04-a 1.0 maven-test t04-b 1.0 maven-test t04-c 2.0 maven-maven-3.5.2/maven-compat/src/test/resources/inheritance-repo/t05/000077500000000000000000000000001317160430700257505ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/test/resources/inheritance-repo/t05/maven-test/000077500000000000000000000000001317160430700300335ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/test/resources/inheritance-repo/t05/maven-test/jars/000077500000000000000000000000001317160430700307725ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/test/resources/inheritance-repo/t05/maven-test/poms/000077500000000000000000000000001317160430700310115ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/test/resources/inheritance-repo/t05/maven-test/poms/t05-a-1.0.pom000066400000000000000000000010741317160430700326520ustar00rootroot00000000000000 4.0.0 maven-test t05-a jar 1.0 central Fake Maven Central Repository file://dummy maven-test t05-b 1.0 jar compile maven-maven-3.5.2/maven-compat/src/test/resources/inheritance-repo/t05/maven-test/poms/t05-a-2.0.pom000066400000000000000000000010741317160430700326530ustar00rootroot00000000000000 4.0.0 maven-test t05-a jar 2.0 central Fake Maven Central Repository file://dummy maven-test t05-b 1.0 jar compile maven-maven-3.5.2/maven-compat/src/test/resources/inheritance-repo/t05/maven-test/poms/t05-b-1.0.pom000066400000000000000000000011561317160430700326540ustar00rootroot00000000000000 4.0.0 maven-test t05-b jar 1.0 maven-test t05-c 1.0 jar compile maven-test t05-d 1.1 jar compile false maven-maven-3.5.2/maven-compat/src/test/resources/inheritance-repo/t05/maven-test/poms/t05-b-1.1.pom000066400000000000000000000011561317160430700326550ustar00rootroot00000000000000 4.0.0 maven-test t05-b jar 1.1 maven-test t05-c 1.0 jar compile maven-test t05-d 1.1 jar compile false maven-maven-3.5.2/maven-compat/src/test/resources/inheritance-repo/t05/maven-test/poms/t05-b-2.0.pom000066400000000000000000000011561317160430700326550ustar00rootroot00000000000000 4.0.0 maven-test t05-b jar 2.0 maven-test t05-c 1.0 jar compile maven-test t05-d 1.1 jar compile false maven-maven-3.5.2/maven-compat/src/test/resources/inheritance-repo/t05/maven-test/poms/t05-c-1.0.pom000066400000000000000000000006601317160430700326540ustar00rootroot00000000000000 4.0.0 maven-test t05-c jar 1.0 maven-test t05-d 1.1 jar compile true maven-maven-3.5.2/maven-compat/src/test/resources/inheritance-repo/t05/maven-test/poms/t05-d-1.0.pom000066400000000000000000000002601317160430700326510ustar00rootroot00000000000000 4.0.0 maven-test t05-d jar 1.0 maven-maven-3.5.2/maven-compat/src/test/resources/inheritance-repo/t05/maven-test/poms/t05-d-1.1.pom000066400000000000000000000002601317160430700326520ustar00rootroot00000000000000 4.0.0 maven-test t05-d jar 1.1 maven-maven-3.5.2/maven-compat/src/test/resources/inheritance-repo/t05/maven-test/poms/t05-d-1.2.pom000066400000000000000000000002601317160430700326530ustar00rootroot00000000000000 4.0.0 maven-test t05-d jar 1.2 maven-maven-3.5.2/maven-compat/src/test/resources/inheritance-repo/t05/p0/000077500000000000000000000000001317160430700262675ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/test/resources/inheritance-repo/t05/p0/p1/000077500000000000000000000000001317160430700266075ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/test/resources/inheritance-repo/t05/p0/p1/pom.xml000066400000000000000000000024771317160430700301360ustar00rootroot00000000000000 p0 maven-t05 1.0 4.0.0 maven-t05 p1 pom p1 1.0 scm-url maven-test t05-b 1.0 maven-test t05-d 1.0 maven-test t05-a 1.0 runtime maven-test t05-c 1.0 runtime maven-antrun-plugin ${project.parent.basedir} maven-maven-3.5.2/maven-compat/src/test/resources/inheritance-repo/t05/p0/pom.xml000066400000000000000000000017001317160430700276020ustar00rootroot00000000000000 4.0.0 maven-t05 p0 pom p0 1.0 Codehaus maven-test t05-a 1.0 maven-test t05-b 1.1 maven-test t05-c 1.0 compile maven-test t05-d 1.2 maven-maven-3.5.2/maven-compat/src/test/resources/inheritance-repo/t06/000077500000000000000000000000001317160430700257515ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/test/resources/inheritance-repo/t06/maven-test/000077500000000000000000000000001317160430700300345ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/test/resources/inheritance-repo/t06/maven-test/jars/000077500000000000000000000000001317160430700307735ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/test/resources/inheritance-repo/t06/maven-test/poms/000077500000000000000000000000001317160430700310125ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/test/resources/inheritance-repo/t06/maven-test/poms/t06-a-1.0.pom000066400000000000000000000010741317160430700326540ustar00rootroot00000000000000 4.0.0 maven-test t06-a jar 1.0 central Fake Maven Central Repository file://dummy maven-test t06-b 1.0 jar compile maven-maven-3.5.2/maven-compat/src/test/resources/inheritance-repo/t06/maven-test/poms/t06-b-1.0.pom000066400000000000000000000011561317160430700326560ustar00rootroot00000000000000 4.0.0 maven-test t06-b jar 1.0 maven-test t06-c 1.0 jar compile maven-test t06-d 1.1 jar compile false maven-maven-3.5.2/maven-compat/src/test/resources/inheritance-repo/t06/maven-test/poms/t06-b-1.1.pom000066400000000000000000000011561317160430700326570ustar00rootroot00000000000000 4.0.0 maven-test t06-b jar 1.0 maven-test t06-c 1.0 jar compile maven-test t06-d 1.1 jar compile false maven-maven-3.5.2/maven-compat/src/test/resources/inheritance-repo/t06/maven-test/poms/t06-c-1.0.pom000066400000000000000000000006601317160430700326560ustar00rootroot00000000000000 4.0.0 maven-test t06-c jar 1.0 maven-test t06-d 1.1 jar compile true maven-maven-3.5.2/maven-compat/src/test/resources/inheritance-repo/t06/maven-test/poms/t06-d-1.0.pom000066400000000000000000000002601317160430700326530ustar00rootroot00000000000000 4.0.0 maven-test t06-d jar 1.0 maven-maven-3.5.2/maven-compat/src/test/resources/inheritance-repo/t06/maven-test/poms/t06-d-1.1.pom000066400000000000000000000002601317160430700326540ustar00rootroot00000000000000 4.0.0 maven-test t06-d jar 1.1 maven-maven-3.5.2/maven-compat/src/test/resources/inheritance-repo/t06/maven-test/poms/t06-d-1.2.pom000066400000000000000000000002601317160430700326550ustar00rootroot00000000000000 4.0.0 maven-test t06-d jar 1.2 maven-maven-3.5.2/maven-compat/src/test/resources/inheritance-repo/t06/p0/000077500000000000000000000000001317160430700262705ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/test/resources/inheritance-repo/t06/p0/p1/000077500000000000000000000000001317160430700266105ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/test/resources/inheritance-repo/t06/p0/p1/pom.xml000066400000000000000000000025041317160430700301260ustar00rootroot00000000000000 p0 maven-t06 1.0 4.0.0 maven-t06 p1 pom p1 1.0 scm-url maven-test t06-b 1.0 maven-test t06-d 1.0 test false maven-test t06-a 1.0 maven-test t06-c 1.0 maven-antrun-plugin ${project.parent.basedir} maven-maven-3.5.2/maven-compat/src/test/resources/inheritance-repo/t06/p0/pom.xml000066400000000000000000000017401317160430700276070ustar00rootroot00000000000000 4.0.0 maven-t06 p0 pom p0 1.0 Codehaus maven-test t06-a 1.0 maven-test t06-b 1.1 maven-test t06-c 1.0 maven-test t06-d 1.2 test false maven-maven-3.5.2/maven-compat/src/test/resources/inheritance-repo/t07/000077500000000000000000000000001317160430700257525ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/test/resources/inheritance-repo/t07/maven-test/000077500000000000000000000000001317160430700300355ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/test/resources/inheritance-repo/t07/maven-test/jars/000077500000000000000000000000001317160430700307745ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/test/resources/inheritance-repo/t07/maven-test/poms/000077500000000000000000000000001317160430700310135ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/test/resources/inheritance-repo/t07/maven-test/poms/t07-a-1.0.pom000066400000000000000000000010741317160430700326560ustar00rootroot00000000000000 4.0.0 maven-test t07-a jar 1.0 central Fake Maven Central Repository file://dummy maven-test t07-b 1.0 jar compile maven-maven-3.5.2/maven-compat/src/test/resources/inheritance-repo/t07/maven-test/poms/t07-b-1.0.pom000066400000000000000000000011551317160430700326570ustar00rootroot00000000000000 4.0.0 maven-test t07-b jar 1.0 maven-test t07-c 1.0 jar compile maven-test t07-d 1.1 jar compile true maven-maven-3.5.2/maven-compat/src/test/resources/inheritance-repo/t07/maven-test/poms/t07-b-1.1.pom000066400000000000000000000011551317160430700326600ustar00rootroot00000000000000 4.0.0 maven-test t07-b jar 1.1 maven-test t07-c 1.0 jar compile maven-test t07-d 1.1 jar compile true maven-maven-3.5.2/maven-compat/src/test/resources/inheritance-repo/t07/maven-test/poms/t07-c-1.0.pom000066400000000000000000000006601317160430700326600ustar00rootroot00000000000000 4.0.0 maven-test t07-c jar 1.0 maven-test t07-d 1.1 jar compile true maven-maven-3.5.2/maven-compat/src/test/resources/inheritance-repo/t07/maven-test/poms/t07-d-1.0.pom000066400000000000000000000002601317160430700326550ustar00rootroot00000000000000 4.0.0 maven-test t07-d jar 1.0 maven-maven-3.5.2/maven-compat/src/test/resources/inheritance-repo/t07/maven-test/poms/t07-d-1.1.pom000066400000000000000000000002601317160430700326560ustar00rootroot00000000000000 4.0.0 maven-test t07-d jar 1.1 maven-maven-3.5.2/maven-compat/src/test/resources/inheritance-repo/t07/maven-test/poms/t07-d-1.2.pom000066400000000000000000000002601317160430700326570ustar00rootroot00000000000000 4.0.0 maven-test t07-d jar 1.2 maven-maven-3.5.2/maven-compat/src/test/resources/inheritance-repo/t07/p0/000077500000000000000000000000001317160430700262715ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/test/resources/inheritance-repo/t07/p0/p1/000077500000000000000000000000001317160430700266115ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/test/resources/inheritance-repo/t07/p0/p1/pom.xml000066400000000000000000000025041317160430700301270ustar00rootroot00000000000000 p0 maven-t07 1.0 4.0.0 maven-t07 p1 pom p1 1.0 scm-url maven-test t07-b 1.0 maven-test t07-d 1.0 test false maven-test t07-a 1.0 maven-test t07-c 1.0 maven-antrun-plugin ${project.parent.basedir} maven-maven-3.5.2/maven-compat/src/test/resources/inheritance-repo/t07/p0/pom.xml000066400000000000000000000017401317160430700276100ustar00rootroot00000000000000 4.0.0 maven-t07 p0 pom p0 1.0 Codehaus maven-test t07-a 1.0 maven-test t07-b 1.1 maven-test t07-c 1.0 maven-test t07-d 1.2 test false maven-maven-3.5.2/maven-compat/src/test/resources/inheritance-repo/t08/000077500000000000000000000000001317160430700257535ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/test/resources/inheritance-repo/t08/maven-test/000077500000000000000000000000001317160430700300365ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/test/resources/inheritance-repo/t08/maven-test/jars/000077500000000000000000000000001317160430700307755ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/test/resources/inheritance-repo/t08/maven-test/poms/000077500000000000000000000000001317160430700310145ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/test/resources/inheritance-repo/t08/maven-test/poms/t08-a-1.0.pom000066400000000000000000000010741317160430700326600ustar00rootroot00000000000000 4.0.0 maven-test t08-a jar 1.0 central Fake Maven Central Repository file://dummy maven-test t08-b 1.0 jar compile maven-maven-3.5.2/maven-compat/src/test/resources/inheritance-repo/t08/maven-test/poms/t08-b-1.0.pom000066400000000000000000000011561317160430700326620ustar00rootroot00000000000000 4.0.0 maven-test t08-b jar 1.0 maven-test t08-c 1.0 jar compile maven-test t08-d 1.1 jar compile false maven-maven-3.5.2/maven-compat/src/test/resources/inheritance-repo/t08/maven-test/poms/t08-b-1.1.pom000066400000000000000000000011561317160430700326630ustar00rootroot00000000000000 4.0.0 maven-test t08-b jar 1.1 maven-test t08-c 1.0 jar compile maven-test t08-d 1.1 jar compile false maven-maven-3.5.2/maven-compat/src/test/resources/inheritance-repo/t08/maven-test/poms/t08-c-1.0.pom000066400000000000000000000006601317160430700326620ustar00rootroot00000000000000 4.0.0 maven-test t08-c jar 1.0 maven-test t08-d 1.1 jar compile true maven-maven-3.5.2/maven-compat/src/test/resources/inheritance-repo/t08/maven-test/poms/t08-d-1.0.pom000066400000000000000000000002601317160430700326570ustar00rootroot00000000000000 4.0.0 maven-test t08-d jar 1.0 maven-maven-3.5.2/maven-compat/src/test/resources/inheritance-repo/t08/maven-test/poms/t08-d-1.1.pom000066400000000000000000000002601317160430700326600ustar00rootroot00000000000000 4.0.0 maven-test t08-d jar 1.1 maven-maven-3.5.2/maven-compat/src/test/resources/inheritance-repo/t08/maven-test/poms/t08-d-1.2.pom000066400000000000000000000002601317160430700326610ustar00rootroot00000000000000 4.0.0 maven-test t08-d jar 1.2 maven-maven-3.5.2/maven-compat/src/test/resources/inheritance-repo/t08/p0/000077500000000000000000000000001317160430700262725ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/test/resources/inheritance-repo/t08/p0/p1/000077500000000000000000000000001317160430700266125ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/test/resources/inheritance-repo/t08/p0/p1/pom.xml000066400000000000000000000027141317160430700301330ustar00rootroot00000000000000 p0 maven-t08 1.0 4.0.0 maven-t08 p1 pom p1 1.0 scm-url maven-test t08-b 1.0 maven-test t08-d 1.0 test true maven-test t08-a 1.0 maven-test t08-c 1.0 maven-test t08-d 1.0 maven-antrun-plugin ${project.parent.basedir} maven-maven-3.5.2/maven-compat/src/test/resources/inheritance-repo/t08/p0/pom.xml000066400000000000000000000017401317160430700276110ustar00rootroot00000000000000 4.0.0 maven-t08 p0 pom p0 1.0 Codehaus maven-test t08-a 1.0 maven-test t08-b 1.1 maven-test t08-c 1.0 maven-test t08-d 1.2 test false maven-maven-3.5.2/maven-compat/src/test/resources/inheritance-repo/t09/000077500000000000000000000000001317160430700257545ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/test/resources/inheritance-repo/t09/maven-test/000077500000000000000000000000001317160430700300375ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/test/resources/inheritance-repo/t09/maven-test/jars/000077500000000000000000000000001317160430700307765ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/test/resources/inheritance-repo/t09/maven-test/poms/000077500000000000000000000000001317160430700310155ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/test/resources/inheritance-repo/t09/maven-test/poms/t09-a-1.0.pom000066400000000000000000000010471317160430700326620ustar00rootroot00000000000000 4.0.0 maven-test t09-a jar 1.0 central Fake Maven Central Repository file://dummy maven-test t09-b 1.0 compile maven-maven-3.5.2/maven-compat/src/test/resources/inheritance-repo/t09/maven-test/poms/t09-b-1.0.pom000066400000000000000000000005731317160430700326660ustar00rootroot00000000000000 4.0.0 maven-test t09-b jar 1.0 maven-test t09-c 1.0 compile maven-maven-3.5.2/maven-compat/src/test/resources/inheritance-repo/t09/maven-test/poms/t09-c-1.0.pom000066400000000000000000000002601317160430700326600ustar00rootroot00000000000000 4.0.0 maven-test t09-c jar 1.0 maven-maven-3.5.2/maven-compat/src/test/resources/inheritance-repo/t09/maven-test/poms/t09-d-1.0.pom000066400000000000000000000005731317160430700326700ustar00rootroot00000000000000 4.0.0 maven-test t09-d jar 1.0 maven-test t09-c 1.0 compile maven-maven-3.5.2/maven-compat/src/test/resources/inheritance-repo/t09/p0/000077500000000000000000000000001317160430700262735ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/test/resources/inheritance-repo/t09/p0/p1/000077500000000000000000000000001317160430700266135ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/test/resources/inheritance-repo/t09/p0/p1/pom.xml000066400000000000000000000013431317160430700301310ustar00rootroot00000000000000 p0 maven-t09 1.0 4.0.0 maven-t09 p1 pom p1 1.0 scm-url maven-test t09-a maven-antrun-plugin ${project.parent.basedir} maven-maven-3.5.2/maven-compat/src/test/resources/inheritance-repo/t09/p0/p2/000077500000000000000000000000001317160430700266145ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/test/resources/inheritance-repo/t09/p0/p2/pom.xml000066400000000000000000000015551317160430700301370ustar00rootroot00000000000000 p0 maven-t09 1.0 4.0.0 maven-t09 p2 pom p2 1.0 scm-url maven-test t09-a maven-test t09-d 1.0 maven-antrun-plugin ${project.parent.basedir} maven-maven-3.5.2/maven-compat/src/test/resources/inheritance-repo/t09/p0/pom.xml000066400000000000000000000014571317160430700276170ustar00rootroot00000000000000 4.0.0 maven-t09 p0 pom p0 1.0 Codehaus maven-test t09-a 1.0 maven-test t09-b 1.0 maven-test t09-c maven-maven-3.5.2/maven-compat/src/test/resources/inheritance-repo/t10/000077500000000000000000000000001317160430700257445ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/test/resources/inheritance-repo/t10/maven-test/000077500000000000000000000000001317160430700300275ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/test/resources/inheritance-repo/t10/maven-test/jars/000077500000000000000000000000001317160430700307665ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/test/resources/inheritance-repo/t10/maven-test/poms/000077500000000000000000000000001317160430700310055ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/test/resources/inheritance-repo/t10/maven-test/poms/t10-a-1.0.pom000066400000000000000000000010471317160430700326420ustar00rootroot00000000000000 4.0.0 maven-test t10-a jar 1.0 central Fake Maven Central Repository file://dummy maven-test t10-b 1.0 compile maven-maven-3.5.2/maven-compat/src/test/resources/inheritance-repo/t10/maven-test/poms/t10-b-1.0.pom000066400000000000000000000002601317160430700326370ustar00rootroot00000000000000 4.0.0 maven-test t10-b jar 1.0 maven-maven-3.5.2/maven-compat/src/test/resources/inheritance-repo/t10/maven-test/poms/t10-c-1.0.pom000066400000000000000000000002601317160430700326400ustar00rootroot00000000000000 4.0.0 maven-test t10-c jar 1.0 maven-maven-3.5.2/maven-compat/src/test/resources/inheritance-repo/t10/p0/000077500000000000000000000000001317160430700262635ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/test/resources/inheritance-repo/t10/p0/p1/000077500000000000000000000000001317160430700266035ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/test/resources/inheritance-repo/t10/p0/p1/pom.xml000066400000000000000000000015551317160430700301260ustar00rootroot00000000000000 p0 maven-t10 1.0 4.0.0 maven-t10 p1 pom p1 1.0 scm-url maven-test t10-a maven-test t10-c runtime maven-antrun-plugin ${project.parent.basedir} maven-maven-3.5.2/maven-compat/src/test/resources/inheritance-repo/t10/p0/pom.xml000066400000000000000000000015331317160430700276020ustar00rootroot00000000000000 4.0.0 maven-t10 p0 pom p0 1.0 Codehaus maven-test t10-a 1.0 test maven-test t10-b 1.0 runtime maven-test t10-c 1.0 test maven-maven-3.5.2/maven-compat/src/test/resources/inheritance-repo/t11/000077500000000000000000000000001317160430700257455ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/test/resources/inheritance-repo/t11/p0/000077500000000000000000000000001317160430700262645ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/test/resources/inheritance-repo/t11/p0/p1/000077500000000000000000000000001317160430700266045ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/test/resources/inheritance-repo/t11/p0/p1/pom.xml000066400000000000000000000005221317160430700301200ustar00rootroot00000000000000 p0 maven 1.0 4.0.0 maven p1 jar p1 1.0 scm-url maven-maven-3.5.2/maven-compat/src/test/resources/inheritance-repo/t11/p0/pom.xml000066400000000000000000000007771317160430700276140ustar00rootroot00000000000000 4.0.0 maven p0 pom p0 1.0 Codehaus maven p1 1.0 test maven-maven-3.5.2/maven-compat/src/test/resources/inheritance-repo/t12/000077500000000000000000000000001317160430700257465ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/test/resources/inheritance-repo/t12/p0/000077500000000000000000000000001317160430700262655ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/test/resources/inheritance-repo/t12/p0/p1/000077500000000000000000000000001317160430700266055ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/test/resources/inheritance-repo/t12/p0/p1/pom.xml000066400000000000000000000011421317160430700301200ustar00rootroot00000000000000 p0 maven 1.0 4.0.0 p1 jar org.apache.maven.plugins maven-compiler-plugin normal compile maven-maven-3.5.2/maven-compat/src/test/resources/inheritance-repo/t12/p0/pom.xml000066400000000000000000000012401317160430700275770ustar00rootroot00000000000000 4.0.0 maven p0 pom 1.0 org.apache.maven.plugins maven-compiler-plugin test false compile install maven-maven-3.5.2/maven-compat/src/test/resources/inheritance-repo/t12scm/000077500000000000000000000000001317160430700264515ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/test/resources/inheritance-repo/t12scm/maven/000077500000000000000000000000001317160430700275575ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/test/resources/inheritance-repo/t12scm/maven/p0/000077500000000000000000000000001317160430700300765ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/test/resources/inheritance-repo/t12scm/maven/p0/1.0/000077500000000000000000000000001317160430700303745ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/test/resources/inheritance-repo/t12scm/maven/p0/1.0/p0-1.0.pom000066400000000000000000000006401317160430700317240ustar00rootroot00000000000000 4.0.0 maven p0 pom 1.0 scm:svn:http://host/p0 scm:svn:https://host/p0 http://host/viewer?path=/p0 modules/p1 maven-maven-3.5.2/maven-compat/src/test/resources/inheritance-repo/t12scm/maven/p1/000077500000000000000000000000001317160430700300775ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/test/resources/inheritance-repo/t12scm/maven/p1/1.0/000077500000000000000000000000001317160430700303755ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/test/resources/inheritance-repo/t12scm/maven/p1/1.0/p1-1.0.pom000066400000000000000000000003711317160430700317270ustar00rootroot00000000000000 p0 maven 1.0 ../../pom.xml 4.0.0 p1 maven-maven-3.5.2/maven-compat/src/test/resources/inheritance-repo/t12scm/p0/000077500000000000000000000000001317160430700267705ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/test/resources/inheritance-repo/t12scm/p0/modules/000077500000000000000000000000001317160430700304405ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/test/resources/inheritance-repo/t12scm/p0/modules/p1/000077500000000000000000000000001317160430700307605ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/test/resources/inheritance-repo/t12scm/p0/modules/p1/pom.xml000066400000000000000000000003671317160430700323030ustar00rootroot00000000000000 p0 maven 1.0 ../../pom.xml 4.0.0 p1 maven-maven-3.5.2/maven-compat/src/test/resources/inheritance-repo/t12scm/p0/pom.xml000066400000000000000000000006341317160430700303100ustar00rootroot00000000000000 4.0.0 maven p0 pom 1.0 scm:svn:http://host/p0 scm:svn:https://host/p0 http://host/viewer?path=/p0 modules/p1 maven-maven-3.5.2/maven-compat/src/test/resources/local-repo/000077500000000000000000000000001317160430700241415ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/test/resources/local-repo/marker.txt000066400000000000000000000000331317160430700261570ustar00rootroot00000000000000this is just a marker file.maven-maven-3.5.2/maven-compat/src/test/resources/local-repo/maven-test/000077500000000000000000000000001317160430700262245ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/test/resources/local-repo/maven-test/jars/000077500000000000000000000000001317160430700271635ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/test/resources/local-repo/maven-test/poms/000077500000000000000000000000001317160430700272025ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/test/resources/local-repo/maven-test/poms/maven-test-a-1.0.pom000066400000000000000000000011121317160430700325070ustar00rootroot00000000000000 4.0.0 maven-test maven-test-a jar 1.0 central Fake Maven Central Repository file://dummy maven-test maven-test-b 1.0 jar compile maven-maven-3.5.2/maven-compat/src/test/resources/local-repo/maven-test/poms/maven-test-b-1.0.pom000066400000000000000000000011421317160430700325130ustar00rootroot00000000000000 4.0.0 maven-test maven-test-b jar 1.0 maven-test maven-test-c 1.0 jar compile maven-test maven-test-d 1.1 jar compile maven-maven-3.5.2/maven-compat/src/test/resources/local-repo/maven-test/poms/maven-test-c-1.0.pom000066400000000000000000000006361317160430700325230ustar00rootroot00000000000000 4.0.0 maven-test maven-test-c jar 1.0 maven-test maven-test-d 1.2 jar compile maven-maven-3.5.2/maven-compat/src/test/resources/local-repo/maven-test/poms/maven-test-d-1.1.pom000066400000000000000000000002671317160430700325250ustar00rootroot00000000000000 4.0.0 maven-test maven-test-d jar 1.1 maven-maven-3.5.2/maven-compat/src/test/resources/local-repo/maven-test/poms/maven-test-d-1.2.pom000066400000000000000000000002671317160430700325260ustar00rootroot00000000000000 4.0.0 maven-test maven-test-d jar 1.1 maven-maven-3.5.2/maven-compat/src/test/resources/local-repo/snapshot-test/000077500000000000000000000000001317160430700267555ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/test/resources/local-repo/snapshot-test/jars/000077500000000000000000000000001317160430700277145ustar00rootroot00000000000000maven-snapshot-a-1.0-SNAPSHOT.jar.snapshot-version000066400000000000000000000000171317160430700405640ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/test/resources/local-repo/snapshot-test/jars20040101.101010maven-snapshot-b-1.0-SNAPSHOT.jar.snapshot-version000066400000000000000000000000171317160430700405650ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/test/resources/local-repo/snapshot-test/jars20040101.101010maven-snapshot-e-1.0-SNAPSHOT.jar.snapshot-version000066400000000000000000000000171317160430700405700ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/test/resources/local-repo/snapshot-test/jars20040101.101010maven-maven-3.5.2/maven-compat/src/test/resources/local-repo/snapshot-test/poms/000077500000000000000000000000001317160430700277335ustar00rootroot00000000000000maven-test-snapshot-resolving-1.0.pom000066400000000000000000000026001317160430700366110ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/test/resources/local-repo/snapshot-test/poms snapshot-test maven-test-snapshot-resolving jar central Fake Maven Central Repository file://dummy snapshot-test maven-snapshot-a 1.0-SNAPSHOT jar compile snapshot-test maven-snapshot-b 1.0-SNAPSHOT jar compile snapshot-test maven-snapshot-c 1.0-SNAPSHOT jar compile snapshot-test maven-snapshot-d 1.0-SNAPSHOT jar compile snapshot-test maven-snapshot-e 1.0-SNAPSHOT jar compile maven-maven-3.5.2/maven-compat/src/test/resources/org/000077500000000000000000000000001317160430700226735ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/test/resources/org/apache/000077500000000000000000000000001317160430700241145ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/test/resources/org/apache/maven/000077500000000000000000000000001317160430700252225ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/test/resources/org/apache/maven/artifact/000077500000000000000000000000001317160430700270175ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/test/resources/org/apache/maven/artifact/deployer/000077500000000000000000000000001317160430700306425ustar00rootroot00000000000000ArtifactDeployerTest.xml000066400000000000000000000014611317160430700354100ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/test/resources/org/apache/maven/artifact/deployer maven-maven-3.5.2/maven-compat/src/test/resources/org/apache/maven/artifact/installer/000077500000000000000000000000001317160430700310145ustar00rootroot00000000000000ArtifactInstallerTest.xml000066400000000000000000000014611317160430700357340ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/test/resources/org/apache/maven/artifact/installer maven-maven-3.5.2/maven-compat/src/test/resources/org/apache/maven/artifact/manager/000077500000000000000000000000001317160430700304315ustar00rootroot00000000000000DefaultWagonManagerTest.xml000066400000000000000000000033751317160430700356170ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/test/resources/org/apache/maven/artifact/manager org.apache.maven.wagon.Wagon a org.apache.maven.artifact.manager.WagonA org.apache.maven.wagon.Wagon b1 org.apache.maven.artifact.manager.WagonB org.apache.maven.wagon.Wagon b2 org.apache.maven.artifact.manager.WagonB org.apache.maven.wagon.Wagon c org.apache.maven.artifact.manager.WagonC org.apache.maven.wagon.Wagon string org.apache.maven.artifact.manager.StringWagon maven-maven-3.5.2/maven-compat/src/test/resources/org/apache/maven/artifact/resolver/000077500000000000000000000000001317160430700306605ustar00rootroot00000000000000ArtifactResolverTest.xml000066400000000000000000000053131317160430700354440ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/test/resources/org/apache/maven/artifact/resolver org.apache.maven.artifact.resolver.ArtifactResolver default org.apache.maven.artifact.resolver.DefaultArtifactResolver false org.codehaus.plexus.logging.Logger default logger org.apache.maven.artifact.factory.ArtifactFactory default artifactFactory org.apache.maven.artifact.resolver.ArtifactCollector default artifactCollector org.apache.maven.artifact.resolver.ResolutionErrorHandler default resolutionErrorHandler org.apache.maven.artifact.metadata.ArtifactMetadataSource test source org.codehaus.plexus.PlexusContainer default container org.apache.maven.plugin.LegacySupport default legacySupport org.eclipse.aether.RepositorySystem default repoSystem ArtifactUpdatePolicyTest.xml000066400000000000000000000021011317160430700362350ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/test/resources/org/apache/maven/artifact/resolver org.apache.maven.wagon.Wagon testfile org.apache.maven.artifact.resolver.TestFileWagon per-lookup maven-maven-3.5.2/maven-compat/src/test/resources/org/apache/maven/project/000077500000000000000000000000001317160430700266705ustar00rootroot00000000000000AbstractMavenProjectTestCase.xml000066400000000000000000000004351317160430700350520ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/test/resources/org/apache/maven/project org.apache.maven.lifecycle.LifeCyclePluginAnalyzer org.apache.maven.project.EmptyLifecyclePluginAnalyzer maven-maven-3.5.2/maven-compat/src/test/resources/pom.xml000066400000000000000000000116161317160430700234260ustar00rootroot00000000000000 4.0.0 org.apache.maven maven-core jar Maven 2.0-SNAPSHOT 2001 org.apache.maven maven-model 2.0-SNAPSHOT jar compile org.apache.maven maven-plugin 2.0-SNAPSHOT jar compile commons-cli commons-cli 1.0-beta-2 jar compile plexus plexus-i18n 1.0-beta-2-SNAPSHOT jar compile ognl ognl 2.5.1 jar compile marmalade marmalade-core 0.1 jar compile marmalade marmalade-el-ognl 0.1 jar compile plexus plexus-compiler-api 1.0 jar compile plexus plexus-compiler-javac 1.0 jar compile surefire surefire-booter 1.1 jar compile maven wagon-api 0.9-SNAPSHOT jar compile org.apache.maven wagon-http-lightweight 0.9-SNAPSHOT jar compile maven wagon-ssh 0.9-SNAPSHOT jar compile jsch jsch 0.1.14 jar compile qdox qdox 1.2 jar compile maven-maven-3.5.2/maven-compat/src/test/resources/projects/000077500000000000000000000000001317160430700237355ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/test/resources/projects/scope/000077500000000000000000000000001317160430700250465ustar00rootroot00000000000000project-with-scoped-dependencies.xml000066400000000000000000000052601317160430700340320ustar00rootroot00000000000000maven-maven-3.5.2/maven-compat/src/test/resources/projects/scope 4.0.0 maven maven-project-test Maven 1.0-beta-9 maven-test scope-default 1.0 maven-test scope-test 1.0 test maven-test scope-runtime 1.0 runtime maven-test scope-compile 1.0 compile maven-test scope-provided 1.0 provided maven-inherited scope-default 1.0 maven-inherited scope-compile 1.0 compile maven-inherited scope-runtime 1.0 runtime maven-inherited scope-test 1.0 test maven-inherited scope-provided 1.0 provided maven-maven-3.5.2/maven-compat/src/test/resources/projects/scope/transitive-compile-dep.xml000066400000000000000000000032401317160430700321530ustar00rootroot00000000000000 4.0.0 maven-test scope-compile 1.0 maven-test-compile scope-default 1.0 maven-test-compile scope-test 1.0 test maven-test-compile scope-runtime 1.0 runtime maven-test-compile scope-compile 1.0 compile maven-maven-3.5.2/maven-compat/src/test/resources/projects/scope/transitive-default-dep.xml000066400000000000000000000032411317160430700321500ustar00rootroot00000000000000 4.0.0 maven-test scope-default 1.0 maven-test-default scope-default 1.0 maven-test-default scope-test 1.0 test maven-test-default scope-runtime 1.0 runtime maven-test-default scope-compile 1.0 compile maven-maven-3.5.2/maven-compat/src/test/resources/projects/scope/transitive-provided-dep.xml000066400000000000000000000032451317160430700323440ustar00rootroot00000000000000 4.0.0 maven-test scope-provided 1.0 maven-test-provided scope-default 1.0 maven-test-provided scope-test 1.0 test maven-test-provided scope-runtime 1.0 runtime maven-test-provided scope-compile 1.0 compile maven-maven-3.5.2/maven-compat/src/test/resources/projects/scope/transitive-runtime-dep.xml000066400000000000000000000032411317160430700322070ustar00rootroot00000000000000 4.0.0 maven-test scope-runtime 1.0 maven-test-runtime scope-default 1.0 maven-test-runtime scope-test 1.0 test maven-test-runtime scope-runtime 1.0 runtime maven-test-runtime scope-compile 1.0 compile maven-maven-3.5.2/maven-compat/src/test/resources/projects/scope/transitive-test-dep.xml000066400000000000000000000032221317160430700315020ustar00rootroot00000000000000 4.0.0 maven-test scope-test 1.0 maven-test-test scope-default 1.0 maven-test-test scope-test 1.0 test maven-test-test scope-runtime 1.0 runtime maven-test-test scope-compile 1.0 compile maven-maven-3.5.2/maven-core/000077500000000000000000000000001317160430700157715ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/lifecycle-executor.txt000066400000000000000000000232321317160430700223270ustar00rootroot00000000000000We have a lifecycle mapping for the packaging of *jar* below. You see that for this packaging we have a *default* lifecycle and a list of phases where each phase is a comma separated list of goals to run and they are in the form groupId:artifactId:version. default org.apache.maven.plugins:maven-resources-plugin:resources org.apache.maven.plugins:maven-compiler-plugin:compile org.apache.maven.plugins:maven-resources-plugin:testResources org.apache.maven.plugins:maven-compiler-plugin:testCompile org.apache.maven.plugins:maven-surefire-plugin:test org.apache.maven.plugins:maven-jar-plugin:jar org.apache.maven.plugins:maven-install-plugin:install org.apache.maven.plugins:maven-deploy-plugin:deploy We need to turn this list of phases into a set of plugin objects that have an xml representation like the following: org.apache.maven.plugins maven-resources-plugin process . . . We need this form so that the model builder can make the first pass at merging. Full merging cannot be done because we don't know what the version of the plugin is yet that the user has requested. For plugins in the default lifecycle they are typically defined in the plugin management section of the parent POM. When the merging is complete we are going to have something that looks like the following: org.apache.maven.plugins maven-resources-plugin 1.0 process . . . Once we have the version of the plugins the appropriate call to the plugin manager can be made to get the MojoDescriptor for the goal that needs to be run. In the MojoDescriptor we are interested in the element and element. From these elements we need to make a component configuration for the MojoExecution. The actual DOM like structure we create is of type PlexusConfiguration and is the type we use with the ComponentConfigurator to initialize fields in a Plexus component. Typically this is done within Plexus with the configuration supplied with component configuration, but in Maven we take configuration values from the POM. So we have to use the ComponentConfigurator outside of Plexus in order to configure the Maven Mojo which is just a Plexus component. We can use the information from the MojoDescriptor along with the merged configuration information that is now present in the POM to create the complete PlexusConfiguration used to populate values in the Maven Mojo. foreach configuration element: - if read only and being set squawk - find the parameter - get value from expression or default - if required and null squawk ${localRepository} ${project.resources} ${project.repositories} ${project.remoteArtifactRepositories} ${basedir}/src/main/appended-resources ${excludeScope} ${includeScope} ${excludeGroupIds} ${remoteresources.skip} ${project.build.directory}/maven-shared-archive-resources ${excludeArtifactIds} ${excludeTransitive} ${includeGroupIds} ${session} ${project} ${includeArtifactIds} appendedResourcesDirectory java.io.File false true attached boolean false true excludeArtifactIds java.lang.String false true excludeGroupIds java.lang.String false true excludeScope java.lang.String false true excludeTransitive boolean false true includeArtifactIds java.lang.String false true includeGroupIds java.lang.String false true includeScope java.lang.String false true localRepository org.apache.maven.artifact.repository.ArtifactRepository true false mavenSession org.apache.maven.execution.MavenSession true false The Maven session. outputDirectory java.io.File false true project org.apache.maven.project.MavenProject true false properties java.util.Map false true remoteArtifactRepositories java.util.List true false repositories java.util.List true false resourceBundles java.util.List true true resources java.util.List true false skip boolean false true supplementalModels java.lang.String[] false true - we need to know what came from the POM, and validate those - plugin in any default values - check to see if anything is missing In the case of something like Modello where it is common to specify the configuration for all the goals outside the execution block we need to account for creating the right configuration element which includes only those configuration elements for a particular goal that that particular goal understands. We need to walk through the parameters of the Mojo in question and only take the configuration options that apply. maven-maven-3.5.2/maven-core/plugin-manager.txt000066400000000000000000000316501317160430700214450ustar00rootroot00000000000000h3. Plugins * Execution model * Metadata model * Metadata tooling ** Metadata extractor ** Metadata reader ** Metadata writer ** Metadata adapter (if required for the target system) * Maven packaging and lifecycle * Maven test harness for plugin execution model * Eclipse IDE tooling for plugin execution model and metadata model - we also seem to have information like the plugin lifecycle model that's burried inside the maven execution model - we also seem to have artifact information tangled inside the plugin model - we have to deal with scripting implementations (groovy, beanshell, ruby) - we need to deal with a shared context for plugins, like the guarded mojos - we need to deal with plugins as core application logic which can also interact with plugins * Along with this comes the testing strategies that make this work * The repository model where plugins can be stored and cataloged * Bridging this into an OSGi system: if this could be done then we can basically take over p2 TODO - dealing with processing of input and adapting GAVs before searching i.e. plugin groups in Maven and default searching - how to deal with resolution from different places like local/remote/workspace - how to incorporate the metadata processor to start with - create a hook to programmatically configure the test - create a plugin processor - directory - jar - hooks for loading - i could make an annotation that marked another class as its plugin discoverer, i could just add it to the the component descriptor and when it's loaded we can add the discoverer, that would be simpler. i could also do this with the lister as well i'l // 1 the metadata -> model plugin/mojo descriptor // 2 tools for doing the mapping // 3 the component model -> interfaces for the plugin // The plugin manager should load up a directory structure of plugins. // - a plugin per directory where the plugin is present with its deps // - a plugin that has its dependencies packaged up with it // - implement filters and create a test where a plugin fails if the right classes are not filtered // - plugins with a dependency the same as the core but different versions, make it fail then fix it /* * * h2. Concerns for the plugin manager * * h3. resolving the dependencies of a plugin - these could be resolved remotely at runtime or, - * they could be resolved from a local repository - i think we need a simple dependency model here * that is more mercury related and not Maven related i.e no POMs - workspace resolver - we need * tools to pre-populate this repository * * h3. create an isolated classloader * * h3. lookup the plugin with a configuration * * h3. execute the plugin * * h3. plugins may have to deal with particular actions when a plugin is - installed - loaded - * unloaded - update - uninstalled * * h3. plugins should be able to have specific metadata for a plugin model and that be translated - * dependencies - resources - configuration - extension points of plugins * * For a particular application plugin there will be a declarative descriptor for that plugin type. * * - nexus - the plugin class - UI to contribute - what JS to hook into the UI - what resources to * load into the UI - having packed or unpacked plugins, and positioning resources if necessary - * maven can work out of the classloader, nexus plugins probably couldn't given the js and image * resources * * We need to look at Maven, and Nexus as use cases and figure out what each of them needs to be * able to do * * - now what is really the difference between this and loading a component in plexus - custom * classloading capability - remote resolution of dependencies - do we want a model for sharing * information among plugins, is this more like an extension point - do we need a sort of bus for * application data - do we need a dictionary for our applications like Apple does. We could easily * hook into this and this is the model we need to follow - how many of our REST services do not map * directory to a method in the application interface? * * - research extension points versus plugins * * from igor: two plugins A and B, both depend on the same library but use different versions, say * lib 1.0 and lib 2.0 when debugger hits a breakpoint inside a class from the library, IDE needs to * know which version of library the class comes from */ This document outlines the concerns of a general plugin manager that would be used in conjunction with any Plexus-based application. The following outlined concerns are an attempt to describe what a plugin manager would need to do for Maven and for Nexus. h2. Concerns for the plugin manager h3. Resolving the dependencies of a plugin A plugin manager would need to know how to find the dependencies of a plugin whether that be from a workspace of an IDE, a local Maven repository, or a remote Maven repository. During development in an IDE we would need layered resolution approach that would allow resolution from the workspace, then the local Maven repository and then from any number of remote Maven repositories. During development from the command line we would need a layered resolution approach that would allow resolution from the local Maven repository and then from any number of remote Maven repositories. In production the resolution for the dependencies could also be layered but would depend on the preferred model for the given application. In the case of Maven no plugin dependencies are shipped with a Maven plugin, but in the case of Nexus we would probably want to include the dependencies for self-containment. h4. Working with POMs during development During the development of a plugin we would want to make it easy for a developer to create a plugin which means we would allow the direct use of a POM to state the dependencies of a given plugin and any tooling we created would be responsible for turning the dependency information in the POM into plugin metadata which described the dependencies of the plugin. We are looking at using Mercury for the resolution and retrieval of the plugin dependencies so during development we would translate the POMs into dependency information that Mercury can understand, and in production we would have the pre-digested format that Mercury could utilize to resolve and retrieve dependencies. We need to be careful that we are using Mercury during development and production so that we don’t get in the situation where Maven 2.x is resolving different then Mercury is. We can still leverage POMs during development but we need to make sure Mercury is doing the work. With respect to development inside an IDE the workspace from which we would like to resolve and retrieve dependencies is a read-only local repository to Mercury which is put at the front-end of the search order of any repository that Mercury will consult for artifacts. h4. Generation of plugin metadata and packaging To create the packaging for a plugin a special Maven packaging would be created with an accompanying life-cycle in order to create the plugin metadata required and create an archive of the plugin that can be consumed at runtime. h3. Creation of an isolated classloader The plugin artifact and its dependency artifacts will be loaded in an isolated ClassRealm which is simply an extension of the standard URLClassLoader. Mercury would be responsible for resolving and retrieving the dependencies which would then be used to populate a ClassRealm where there would be a connection to the host applications ClassRealm as the parent but the search order would be child first, and the parent ClassRealm can optionally choose to limit the searching to particular classes. The application ClassRealm, or parent ClassRealm, should only expose the API in the form of and application interface and model classes that may be required by plugins. For debugging purposes we also need to keep track of what versions of artifacts are being used so that when we are debugging in the IDE we can find the specific sources for a given version of a library so that the developer can debug the correct version of a library being used for a plugin. h3. Discovery all Plexus components Once the ClassRealm is populated with the plugin artifact and its dependency artifacts a discovery operation must be performed on the plugin ClassRealm in order to discover any Plexus components that may be present in any of the artifacts required for the plugins execution. h3. Looking up the plugin with a configuration Once the ClassRealm has been populated and all Plexus components have been discovered a lookup can be performed to retrieve the primary plugin component. Currently the component would need to be looked up and then the BasicComponentConfigurator would need to configure the component with a given Plexus configuration. We will discuss later how we would retrieve the Plexus configuration required for a given plugin. When a plugin has a complete and valid configuration, the plugin would be looked up in the Plexus container and be ready to perform any operations requested of it. h3. Execution of the plugin I still need to do some work here to figure out how a dispatching to a particular plugin would occur because everything needs to be mediated through the host application. For a given action that is possible for a user to perform in the UI we need to know the URI that is to be used with its given parameters. That URI in turn must map internally to a method in a given component which belongs to a plugin. This mapping should actually be more generalized and it shouldn’t matter internally whether this maps to the core application or extension of the application in the form of plugins. In the short term we are working with the model where the URI maps to a resource, and the resource itself is a Plexus component which can itself have a reference to the host application in order to perform its work. This may not occur in the first versions of the plugin API but a resource needs to simply become the mapping mechanism by which parameters are taken from the REST side of the application and mapped into a method call within a given Plexus component. Whether that be the core Nexus application or a component provided by a plugin. At the very least in the short term the resource needs to know how to lookup the component that is required to perform the work. This needs to be made simple, for the time being we can write and test plugins working in the same realm until we get complete isolation working. h3. Plugins need a specific metadata model Each application will have its own model for plugins. Much of this model will be common across applications but there will always be issues specific to a particular applications’s plugins. Some of the issues that need to be taken into consideration: * Plugin dependencies * Plugin resources like JavaScript files or images * Configuration metadata and default configuration values * Extension points that plugins might expose h3. The plugin manager may have to deal with particular actions when a plugin is * installation * activation * update * deactivation * un-installation When a plugin is installed we may want to check the license and make users agree. We may also want to unpack the given plugin in a particular location. We might want to separate between installation and activation, it might be nice to allow a user to activate/deactivate a plugin instead of having to uninstall and reinstall a plugin in particular cases. This would prevent having to reconfigure the plugin again. For example it might be nice to turn off LDAP authentication without having to uninstall the plugin. These particular phases in a plugin’s lifecycle can probably be generalized to all plugins so could be something implemented in all plugins. Here we could have the descriptor either point to methods for each of these phases to execute or we could create a lifecycle in Plexus for these phases. For a particular application plugin there will be a declarative descriptor for that plugin type. h3. Some general notes on Nexus The plugin metadata: * the plugin class * UI to contribute * what JS to hook into the UI * what resources to load into the UI * having packed or unpacked plugins, and positioning resources if necessary * maven can work out of the classloader, nexus plugins probably couldn't given the js and image resources h3. Other issues We need to look at Maven, and Nexus as use cases and figure out what each of them needs to be able to do * now what is really the difference between this and loading a component in plexus * do we want a model for sharing information among plugins, is this more like an extension point * do we need a sort of bus for application data * do we need a dictionary for our applications like Apple does. We could easily hook into this and this is the model we need to follow. Following the model of apple applications the dictionary is what the REST URI should attach to. Not creating custom logic in the resource code. * how many of our REST services do not map directory to a method in the application interface? - an example of adding js - an example of adding a URI maven-maven-3.5.2/maven-core/pom.xml000066400000000000000000000211201317160430700173020ustar00rootroot00000000000000 4.0.0 org.apache.maven maven 3.5.2 maven-core Maven Core Maven Core classes. RedundantThrows,NewlineAtEndOfFile,ParameterNumber,MethodLength,FileLength,JavadocType,MethodName,MagicNumber,ConstantName,VisibilityModifier,InnerAssignment org.apache.maven maven-model org.apache.maven maven-settings org.apache.maven maven-settings-builder org.apache.maven maven-builder-support org.apache.maven maven-repository-metadata org.apache.maven maven-artifact org.apache.maven maven-plugin-api org.apache.maven maven-model-builder org.apache.maven maven-resolver-provider org.apache.maven.resolver maven-resolver-impl org.apache.maven.resolver maven-resolver-api org.apache.maven.resolver maven-resolver-spi org.apache.maven.resolver maven-resolver-util org.apache.maven.shared maven-shared-utils org.eclipse.sisu org.eclipse.sisu.plexus org.eclipse.sisu org.eclipse.sisu.inject com.google.inject guice no_aop com.google.guava guava javax.inject javax.inject org.codehaus.plexus plexus-utils org.codehaus.plexus plexus-classworlds org.codehaus.plexus plexus-component-annotations org.apache.commons commons-lang3 commons-jxpath commons-jxpath test org.mockito mockito-core test src/main/resources true org.apache.rat apache-rat-plugin lifecycle-executor.txt plugin-manager.txt project-builder.txt src/site/resources/design/** org.eclipse.m2e lifecycle-mapping 1.0.0 org.codehaus.mojo buildnumber-maven-plugin [1.2,) create-timestamp org.codehaus.plexus plexus-component-metadata org.eclipse.sisu sisu-maven-plugin org.codehaus.modello modello-maven-plugin 1.1.0 src/main/mdo/toolchains.mdo modello-site-doc pre-site xdoc 1.0.0 src/main/mdo/extension.mdo org.codehaus.mojo buildnumber-maven-plugin create-noncanonicalrev create-timestamp 'NON-CANONICAL_'yyyy-MM-dd'T'HH:mm:ssXXX_'${user.name}' nonCanonicalRevision create-buildnumber create false false ${nonCanonicalRevision} maven-maven-3.5.2/maven-core/src/000077500000000000000000000000001317160430700165605ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/main/000077500000000000000000000000001317160430700175045ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/main/java/000077500000000000000000000000001317160430700204255ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/main/java/org/000077500000000000000000000000001317160430700212145ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/main/java/org/apache/000077500000000000000000000000001317160430700224355ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/000077500000000000000000000000001317160430700235435ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/AbstractMavenLifecycleParticipant.java000066400000000000000000000052121317160430700331570ustar00rootroot00000000000000package org.apache.maven; /* * 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 org.apache.maven.execution.MavenSession; /** * Allows core extensions to participate in Maven build session lifecycle. * * All callback methods (will) follow beforeXXX/afterXXX naming pattern to * indicate at what lifecycle point it is being called. * * @see example * @see MNG-4224 * @since 3.0-alpha-3 */ public abstract class AbstractMavenLifecycleParticipant { /** * Invoked after all MavenProject instances have been created. * * This callback is intended to allow extensions to manipulate MavenProjects * before they are sorted and actual build execution starts. */ public void afterProjectsRead( MavenSession session ) throws MavenExecutionException { // do nothing } /** * Invoked after MavenSession instance has been created. * * This callback is intended to allow extensions to inject execution properties, * activate profiles and perform similar tasks that affect MavenProject * instance construction. */ // TODO This is too early for build extensions, so maybe just remove it? public void afterSessionStart( MavenSession session ) throws MavenExecutionException { // do nothing } /** * Invoked after all projects were built. * * This callback is intended to allow extensions to perform cleanup of any * allocated external resources after the build. It is invoked on best-effort * basis and may be missed due to an Error or RuntimeException in Maven core * code. * @since 3.2.1, MNG-5389 */ public void afterSessionEnd( MavenSession session ) throws MavenExecutionException { // do nothing } } maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/ArtifactFilterManager.java000066400000000000000000000032731317160430700306110ustar00rootroot00000000000000package org.apache.maven; /* * 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.util.Set; import org.apache.maven.artifact.resolver.filter.ArtifactFilter; public interface ArtifactFilterManager { /** * Returns a filter for core + extension artifacts. * * @deprecated use {@code META-INF/maven/extension.xml} to define artifacts exported by Maven core and plugin * extensions. */ ArtifactFilter getArtifactFilter(); /** * Returns a filter for only the core artifacts. */ ArtifactFilter getCoreArtifactFilter(); /** * Exclude an extension artifact (doesn't affect getArtifactFilter's result, only getExtensionArtifactFilter). * * @deprecated use {@code META-INF/maven/extension.xml} to define artifacts exported by Maven core and plugin * extensions. */ void excludeArtifact( String artifactId ); Set getCoreArtifactExcludes(); } maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/ArtifactFilterManagerDelegate.java000066400000000000000000000021471317160430700322430ustar00rootroot00000000000000package org.apache.maven; /* * 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.util.Set; /** * @deprecated use {@code META-INF/maven/extension.xml} to define artifacts exported by Maven core extensions. */ public interface ArtifactFilterManagerDelegate { void addExcludes( Set excludes ); void addCoreExcludes( Set excludes ); } maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/BuildAbort.java000066400000000000000000000021661317160430700264420ustar00rootroot00000000000000package org.apache.maven; /* * 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. */ /** * A special throwable used to signal a graceful abort of the build. */ public class BuildAbort extends Error { public BuildAbort( String message ) { super( message ); } public BuildAbort( String message, Throwable cause ) { super( message, cause ); } } maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/BuildFailureException.java000066400000000000000000000022621317160430700306360ustar00rootroot00000000000000package org.apache.maven; /* * 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. */ /** * One or more builds failed. * * @author Brett Porter */ public class BuildFailureException extends Exception { public BuildFailureException( String message ) { super( message ); } public BuildFailureException( String message, Throwable cause ) { super( message, cause ); } } maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/DefaultArtifactFilterManager.java000066400000000000000000000063441317160430700321200ustar00rootroot00000000000000package org.apache.maven; /* * 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.util.LinkedHashSet; import java.util.List; import java.util.Set; import javax.inject.Inject; import javax.inject.Named; import javax.inject.Singleton; import org.apache.maven.artifact.resolver.filter.ArtifactFilter; import org.apache.maven.artifact.resolver.filter.ExclusionSetFilter; import org.apache.maven.extension.internal.CoreExportsProvider; /** * @author Jason van Zyl */ @Named @Singleton @SuppressWarnings( "deprecation" ) public class DefaultArtifactFilterManager implements ArtifactFilterManager { // this is a live injected collection protected final List delegates; protected Set excludedArtifacts; private final Set coreArtifacts; @Inject public DefaultArtifactFilterManager( List delegates, CoreExportsProvider coreExports ) { this.delegates = delegates; this.coreArtifacts = coreExports.get().getExportedArtifacts(); } private synchronized Set getExcludedArtifacts() { if ( excludedArtifacts == null ) { excludedArtifacts = new LinkedHashSet<>( coreArtifacts ); } return excludedArtifacts; } /** * Returns the artifact filter for the core + extension artifacts. * * @see org.apache.maven.ArtifactFilterManager#getArtifactFilter() */ public ArtifactFilter getArtifactFilter() { Set excludes = new LinkedHashSet<>( getExcludedArtifacts() ); for ( ArtifactFilterManagerDelegate delegate : delegates ) { delegate.addExcludes( excludes ); } return new ExclusionSetFilter( excludes ); } /** * Returns the artifact filter for the standard core artifacts. * * @see org.apache.maven.ArtifactFilterManager#getCoreArtifactFilter() */ public ArtifactFilter getCoreArtifactFilter() { return new ExclusionSetFilter( getCoreArtifactExcludes() ); } public void excludeArtifact( String artifactId ) { getExcludedArtifacts().add( artifactId ); } public Set getCoreArtifactExcludes() { Set excludes = new LinkedHashSet<>( coreArtifacts ); for ( ArtifactFilterManagerDelegate delegate : delegates ) { delegate.addCoreExcludes( excludes ); } return excludes; } } maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/DefaultMaven.java000066400000000000000000000455021317160430700267670ustar00rootroot00000000000000package org.apache.maven; /* * 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.File; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; import java.util.Collections; import java.util.Date; import java.util.HashSet; import java.util.LinkedHashMap; import java.util.LinkedHashSet; import java.util.List; import java.util.Map; import org.apache.maven.artifact.ArtifactUtils; import org.apache.maven.execution.DefaultMavenExecutionResult; import org.apache.maven.execution.ExecutionEvent; import org.apache.maven.execution.MavenExecutionRequest; import org.apache.maven.execution.MavenExecutionResult; import org.apache.maven.execution.MavenSession; import org.apache.maven.execution.ProjectDependencyGraph; import org.apache.maven.graph.GraphBuilder; import org.apache.maven.internal.aether.DefaultRepositorySystemSessionFactory; import org.apache.maven.lifecycle.internal.ExecutionEventCatapult; import org.apache.maven.lifecycle.internal.LifecycleStarter; import org.apache.maven.model.Prerequisites; import org.apache.maven.model.building.ModelProblem; import org.apache.maven.model.building.Result; import org.apache.maven.plugin.LegacySupport; import org.apache.maven.project.MavenProject; import org.apache.maven.project.ProjectBuilder; import org.apache.maven.repository.LocalRepositoryNotAccessibleException; import org.apache.maven.session.scope.internal.SessionScope; import org.codehaus.plexus.PlexusContainer; import org.codehaus.plexus.component.annotations.Component; import org.codehaus.plexus.component.annotations.Requirement; import org.codehaus.plexus.component.repository.exception.ComponentLookupException; import org.codehaus.plexus.logging.Logger; import org.eclipse.aether.DefaultRepositorySystemSession; import org.eclipse.aether.RepositorySystemSession; import org.eclipse.aether.repository.WorkspaceReader; import org.eclipse.aether.util.repository.ChainedWorkspaceReader; import com.google.common.collect.Iterables; /** * @author Jason van Zyl */ @Component( role = Maven.class ) public class DefaultMaven implements Maven { @Requirement private Logger logger; @Requirement protected ProjectBuilder projectBuilder; @Requirement private LifecycleStarter lifecycleStarter; @Requirement protected PlexusContainer container; @Requirement private ExecutionEventCatapult eventCatapult; @Requirement private LegacySupport legacySupport; @Requirement private SessionScope sessionScope; @Requirement private DefaultRepositorySystemSessionFactory repositorySessionFactory; @Requirement( hint = GraphBuilder.HINT ) private GraphBuilder graphBuilder; @Override public MavenExecutionResult execute( MavenExecutionRequest request ) { MavenExecutionResult result; try { result = doExecute( request ); } catch ( OutOfMemoryError e ) { result = addExceptionToResult( new DefaultMavenExecutionResult(), e ); } catch ( RuntimeException e ) { // TODO Hack to make the cycle detection the same for the new graph builder if ( e.getCause() instanceof ProjectCycleException ) { result = addExceptionToResult( new DefaultMavenExecutionResult(), e.getCause() ); } else { result = addExceptionToResult( new DefaultMavenExecutionResult(), new InternalErrorException( "Internal error: " + e, e ) ); } } finally { legacySupport.setSession( null ); } return result; } // // 1) Setup initial properties. // // 2) Validate local repository directory is accessible. // // 3) Create RepositorySystemSession. // // 4) Create MavenSession. // // 5) Execute AbstractLifecycleParticipant.afterSessionStart(session) // // 6) Get reactor projects looking for general POM errors // // 7) Create ProjectDependencyGraph using trimming which takes into account --projects and reactor mode. // This ensures that the projects passed into the ReactorReader are only those specified. // // 8) Create ReactorReader with the getProjectMap( projects ). NOTE that getProjectMap(projects) is the code that // checks for duplicate projects definitions in the build. Ideally this type of duplicate checking should be // part of getting the reactor projects in 6). The duplicate checking is conflated with getProjectMap(projects). // // 9) Execute AbstractLifecycleParticipant.afterProjectsRead(session) // // 10) Create ProjectDependencyGraph without trimming (as trimming was done in 7). A new topological sort is // required after the execution of 9) as the AbstractLifecycleParticipants are free to mutate the MavenProject // instances, which may change dependencies which can, in turn, affect the build order. // // 11) Execute LifecycleStarter.start() // @SuppressWarnings( "checkstyle:methodlength" ) private MavenExecutionResult doExecute( MavenExecutionRequest request ) { request.setStartTime( new Date() ); MavenExecutionResult result = new DefaultMavenExecutionResult(); try { validateLocalRepository( request ); } catch ( LocalRepositoryNotAccessibleException e ) { return addExceptionToResult( result, e ); } // // We enter the session scope right after the MavenSession creation and before any of the // AbstractLifecycleParticipant lookups // so that @SessionScoped components can be @Injected into AbstractLifecycleParticipants. // sessionScope.enter(); try { DefaultRepositorySystemSession repoSession = (DefaultRepositorySystemSession) newRepositorySession( request ); MavenSession session = new MavenSession( container, repoSession, request, result ); sessionScope.seed( MavenSession.class, session ); legacySupport.setSession( session ); return doExecute( request, session, result, repoSession ); } finally { sessionScope.exit(); } } private MavenExecutionResult doExecute( MavenExecutionRequest request, MavenSession session, MavenExecutionResult result, DefaultRepositorySystemSession repoSession ) { try { // CHECKSTYLE_OFF: LineLength for ( AbstractMavenLifecycleParticipant listener : getLifecycleParticipants( Collections.emptyList() ) ) { listener.afterSessionStart( session ); } // CHECKSTYLE_ON: LineLength } catch ( MavenExecutionException e ) { return addExceptionToResult( result, e ); } eventCatapult.fire( ExecutionEvent.Type.ProjectDiscoveryStarted, session, null ); Result graphResult = buildGraph( session, result ); if ( graphResult.hasErrors() ) { return addExceptionToResult( result, Iterables.toArray( graphResult.getProblems(), ModelProblem.class )[0].getException() ); } try { session.setProjectMap( getProjectMap( session.getProjects() ) ); } catch ( DuplicateProjectException e ) { return addExceptionToResult( result, e ); } WorkspaceReader reactorWorkspace; try { reactorWorkspace = container.lookup( WorkspaceReader.class, ReactorReader.HINT ); } catch ( ComponentLookupException e ) { return addExceptionToResult( result, e ); } // // Desired order of precedence for local artifact repositories // // Reactor // Workspace // User Local Repository // repoSession.setWorkspaceReader( ChainedWorkspaceReader.newInstance( reactorWorkspace, repoSession.getWorkspaceReader() ) ); repoSession.setReadOnly(); ClassLoader originalClassLoader = Thread.currentThread().getContextClassLoader(); try { for ( AbstractMavenLifecycleParticipant listener : getLifecycleParticipants( session.getProjects() ) ) { Thread.currentThread().setContextClassLoader( listener.getClass().getClassLoader() ); listener.afterProjectsRead( session ); } } catch ( MavenExecutionException e ) { return addExceptionToResult( result, e ); } finally { Thread.currentThread().setContextClassLoader( originalClassLoader ); } // // The projects need to be topologically after the participants have run their afterProjectsRead(session) // because the participant is free to change the dependencies of a project which can potentially change the // topological order of the projects, and therefore can potentially change the build order. // // Note that participants may affect the topological order of the projects but it is // not expected that a participant will add or remove projects from the session. // graphResult = buildGraph( session, result ); if ( graphResult.hasErrors() ) { return addExceptionToResult( result, Iterables.toArray( graphResult.getProblems(), ModelProblem.class )[0].getException() ); } try { if ( result.hasExceptions() ) { return result; } result.setTopologicallySortedProjects( session.getProjects() ); result.setProject( session.getTopLevelProject() ); validatePrerequisitesForNonMavenPluginProjects( session.getProjects() ); lifecycleStarter.execute( session ); validateActivatedProfiles( session.getProjects(), request.getActiveProfiles() ); if ( session.getResult().hasExceptions() ) { return addExceptionToResult( result, session.getResult().getExceptions().get( 0 ) ); } } finally { try { afterSessionEnd( session.getProjects(), session ); } catch ( MavenExecutionException e ) { return addExceptionToResult( result, e ); } } return result; } private void afterSessionEnd( Collection projects, MavenSession session ) throws MavenExecutionException { ClassLoader originalClassLoader = Thread.currentThread().getContextClassLoader(); try { for ( AbstractMavenLifecycleParticipant listener : getLifecycleParticipants( projects ) ) { Thread.currentThread().setContextClassLoader( listener.getClass().getClassLoader() ); listener.afterSessionEnd( session ); } } finally { Thread.currentThread().setContextClassLoader( originalClassLoader ); } } public RepositorySystemSession newRepositorySession( MavenExecutionRequest request ) { return repositorySessionFactory.newRepositorySession( request ); } private void validateLocalRepository( MavenExecutionRequest request ) throws LocalRepositoryNotAccessibleException { File localRepoDir = request.getLocalRepositoryPath(); logger.debug( "Using local repository at " + localRepoDir ); localRepoDir.mkdirs(); if ( !localRepoDir.isDirectory() ) { throw new LocalRepositoryNotAccessibleException( "Could not create local repository at " + localRepoDir ); } } private Collection getLifecycleParticipants( Collection projects ) { Collection lifecycleListeners = new LinkedHashSet<>(); ClassLoader originalClassLoader = Thread.currentThread().getContextClassLoader(); try { try { lifecycleListeners.addAll( container.lookupList( AbstractMavenLifecycleParticipant.class ) ); } catch ( ComponentLookupException e ) { // this is just silly, lookupList should return an empty list! logger.warn( "Failed to lookup lifecycle participants: " + e.getMessage() ); } Collection scannedRealms = new HashSet<>(); for ( MavenProject project : projects ) { ClassLoader projectRealm = project.getClassRealm(); if ( projectRealm != null && scannedRealms.add( projectRealm ) ) { Thread.currentThread().setContextClassLoader( projectRealm ); try { lifecycleListeners.addAll( container.lookupList( AbstractMavenLifecycleParticipant.class ) ); } catch ( ComponentLookupException e ) { // this is just silly, lookupList should return an empty list! logger.warn( "Failed to lookup lifecycle participants: " + e.getMessage() ); } } } } finally { Thread.currentThread().setContextClassLoader( originalClassLoader ); } return lifecycleListeners; } private MavenExecutionResult addExceptionToResult( MavenExecutionResult result, Throwable e ) { if ( !result.getExceptions().contains( e ) ) { result.addException( e ); } return result; } private void validatePrerequisitesForNonMavenPluginProjects( List projects ) { for ( MavenProject mavenProject : projects ) { if ( !"maven-plugin".equals( mavenProject.getPackaging() ) ) { Prerequisites prerequisites = mavenProject.getPrerequisites(); if ( prerequisites != null && prerequisites.getMaven() != null ) { logger.warn( "The project " + mavenProject.getId() + " uses prerequisites" + " which is only intended for maven-plugin projects " + "but not for non maven-plugin projects. " + "For such purposes you should use the maven-enforcer-plugin. " + "See https://maven.apache.org/enforcer/enforcer-rules/requireMavenVersion.html" ); } } } } private void validateActivatedProfiles( List projects, List activeProfileIds ) { Collection notActivatedProfileIds = new LinkedHashSet<>( activeProfileIds ); for ( MavenProject project : projects ) { for ( List profileIds : project.getInjectedProfileIds().values() ) { notActivatedProfileIds.removeAll( profileIds ); } } for ( String notActivatedProfileId : notActivatedProfileIds ) { logger.warn( "The requested profile \"" + notActivatedProfileId + "\" could not be activated because it does not exist." ); } } private Map getProjectMap( Collection projects ) throws DuplicateProjectException { Map index = new LinkedHashMap<>(); Map> collisions = new LinkedHashMap<>(); for ( MavenProject project : projects ) { String projectId = ArtifactUtils.key( project.getGroupId(), project.getArtifactId(), project.getVersion() ); MavenProject collision = index.get( projectId ); if ( collision == null ) { index.put( projectId, project ); } else { List pomFiles = collisions.get( projectId ); if ( pomFiles == null ) { pomFiles = new ArrayList<>( Arrays.asList( collision.getFile(), project.getFile() ) ); collisions.put( projectId, pomFiles ); } else { pomFiles.add( project.getFile() ); } } } if ( !collisions.isEmpty() ) { throw new DuplicateProjectException( "Two or more projects in the reactor" + " have the same identifier, please make sure that ::" + " is unique for each project: " + collisions, collisions ); } return index; } private Result buildGraph( MavenSession session, MavenExecutionResult result ) { Result graphResult = graphBuilder.build( session ); for ( ModelProblem problem : graphResult.getProblems() ) { if ( problem.getSeverity() == ModelProblem.Severity.WARNING ) { logger.warn( problem.toString() ); } else { logger.error( problem.toString() ); } } if ( !graphResult.hasErrors() ) { ProjectDependencyGraph projectDependencyGraph = graphResult.get(); session.setProjects( projectDependencyGraph.getSortedProjects() ); session.setAllProjects( projectDependencyGraph.getAllProjects() ); session.setProjectDependencyGraph( projectDependencyGraph ); } return graphResult; } @Deprecated // 5 January 2014 protected Logger getLogger() { return logger; } } maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/DefaultProjectDependenciesResolver.java000066400000000000000000000203561317160430700333600ustar00rootroot00000000000000package org.apache.maven; /* * 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.util.Collection; import java.util.Collections; import java.util.HashSet; import java.util.Iterator; import java.util.LinkedHashSet; import java.util.Set; import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.ArtifactUtils; import org.apache.maven.artifact.resolver.ArtifactNotFoundException; import org.apache.maven.artifact.resolver.ArtifactResolutionException; import org.apache.maven.artifact.resolver.ArtifactResolutionRequest; import org.apache.maven.artifact.resolver.ArtifactResolutionResult; import org.apache.maven.artifact.resolver.MultipleArtifactsNotFoundException; import org.apache.maven.artifact.resolver.ResolutionErrorHandler; import org.apache.maven.artifact.resolver.filter.CumulativeScopeArtifactFilter; import org.apache.maven.execution.MavenSession; import org.apache.maven.project.MavenProject; import org.apache.maven.project.artifact.ProjectArtifact; import org.apache.maven.repository.RepositorySystem; import org.codehaus.plexus.component.annotations.Component; import org.codehaus.plexus.component.annotations.Requirement; @Deprecated @Component( role = ProjectDependenciesResolver.class ) public class DefaultProjectDependenciesResolver implements ProjectDependenciesResolver { @Requirement private RepositorySystem repositorySystem; @Requirement private ResolutionErrorHandler resolutionErrorHandler; public Set resolve( MavenProject project, Collection scopesToResolve, MavenSession session ) throws ArtifactResolutionException, ArtifactNotFoundException { return resolve( Collections.singleton( project ), scopesToResolve, session ); } public Set resolve( MavenProject project, Collection scopesToCollect, Collection scopesToResolve, MavenSession session ) throws ArtifactResolutionException, ArtifactNotFoundException { Set mavenProjects = Collections.singleton( project ); return resolveImpl( mavenProjects, scopesToCollect, scopesToResolve, session, getIgnorableArtifacts( mavenProjects ) ); } public Set resolve( Collection projects, Collection scopesToResolve, MavenSession session ) throws ArtifactResolutionException, ArtifactNotFoundException { return resolveImpl( projects, null, scopesToResolve, session, getIgnorableArtifacts( projects ) ); } public Set resolve( MavenProject project, Collection scopesToCollect, Collection scopesToResolve, MavenSession session, Set ignoreableArtifacts ) throws ArtifactResolutionException, ArtifactNotFoundException { return resolveImpl( Collections.singleton( project ), scopesToCollect, scopesToResolve, session, getIgnorableArtifacts( ignoreableArtifacts ) ); } private Set resolveImpl( Collection projects, Collection scopesToCollect, Collection scopesToResolve, MavenSession session, Set projectIds ) throws ArtifactResolutionException, ArtifactNotFoundException { Set resolved = new LinkedHashSet<>(); if ( projects == null || projects.isEmpty() ) { return resolved; } if ( ( scopesToCollect == null || scopesToCollect.isEmpty() ) && ( scopesToResolve == null || scopesToResolve.isEmpty() ) ) { return resolved; } /* Logic for transitive global exclusions List exclusions = new ArrayList(); for ( Dependency d : project.getDependencies() ) { if ( d.getExclusions() != null ) { for ( Exclusion e : d.getExclusions() ) { exclusions.add( e.getGroupId() + ":" + e.getArtifactId() ); } } } ArtifactFilter scopeFilter = new ScopeArtifactFilter( scope ); ArtifactFilter filter; if ( ! exclusions.isEmpty() ) { filter = new AndArtifactFilter( Arrays.asList( new ArtifactFilter[]{ new ExcludesArtifactFilter( exclusions ), scopeFilter } ) ); } else { filter = scopeFilter; } */ CumulativeScopeArtifactFilter resolutionScopeFilter = new CumulativeScopeArtifactFilter( scopesToResolve ); CumulativeScopeArtifactFilter collectionScopeFilter = new CumulativeScopeArtifactFilter( scopesToCollect ); collectionScopeFilter = new CumulativeScopeArtifactFilter( collectionScopeFilter, resolutionScopeFilter ); ArtifactResolutionRequest request = new ArtifactResolutionRequest().setResolveRoot( false ).setResolveTransitively( true ).setCollectionFilter( collectionScopeFilter ).setResolutionFilter( resolutionScopeFilter ).setLocalRepository( session.getLocalRepository() ).setOffline( session.isOffline() ).setForceUpdate( session.getRequest().isUpdateSnapshots() ); request.setServers( session.getRequest().getServers() ); request.setMirrors( session.getRequest().getMirrors() ); request.setProxies( session.getRequest().getProxies() ); for ( MavenProject project : projects ) { request.setArtifact( new ProjectArtifact( project ) ); request.setArtifactDependencies( project.getDependencyArtifacts() ); request.setManagedVersionMap( project.getManagedVersionMap() ); request.setRemoteRepositories( project.getRemoteArtifactRepositories() ); ArtifactResolutionResult result = repositorySystem.resolve( request ); try { resolutionErrorHandler.throwErrors( request, result ); } catch ( MultipleArtifactsNotFoundException e ) { Collection missing = new HashSet<>( e.getMissingArtifacts() ); for ( Iterator it = missing.iterator(); it.hasNext(); ) { String key = ArtifactUtils.key( it.next() ); if ( projectIds.contains( key ) ) { it.remove(); } } if ( !missing.isEmpty() ) { throw e; } } resolved.addAll( result.getArtifacts() ); } return resolved; } private Set getIgnorableArtifacts( Collection projects ) { Set projectIds = new HashSet<>( projects.size() * 2 ); for ( MavenProject p : projects ) { String key = ArtifactUtils.key( p.getGroupId(), p.getArtifactId(), p.getVersion() ); projectIds.add( key ); } return projectIds; } private Set getIgnorableArtifacts( Iterable artifactIterable ) { Set projectIds = new HashSet<>(); for ( Artifact artifact : artifactIterable ) { String key = ArtifactUtils.key( artifact ); projectIds.add( key ); } return projectIds; } } maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/DuplicateProjectException.java000066400000000000000000000036651317160430700315400ustar00rootroot00000000000000package org.apache.maven; /* * 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.File; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; /** * Signals a collision of two or more projects with the same g:a:v during a reactor build. * * @author Benjamin Bentmann */ public class DuplicateProjectException extends MavenExecutionException { private Map> collisions; /** * Creates a new exception with specified details. * * @param message The message text, may be {@code null}. * @param collisions The POM files of the projects that collided, indexed by their g:a:v, may be {@code null}. */ public DuplicateProjectException( String message, Map> collisions ) { super( message, (File) null ); this.collisions = ( collisions != null ) ? collisions : new LinkedHashMap>(); } /** * Gets the POM files of the projects that collided. * * @return The POM files of the projects that collided, indexed by their g:a:v, never {@code null}. */ public Map> getCollisions() { return collisions; } } maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/InternalErrorException.java000066400000000000000000000021621317160430700310540ustar00rootroot00000000000000package org.apache.maven; /* * 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. */ /** * Signals an internal error in Maven itself, e.g. a programming bug. * * @author Benjamin Bentmann */ public class InternalErrorException extends MavenExecutionException { public InternalErrorException( String message, Throwable cause ) { super( message, cause ); } } maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/Maven.java000066400000000000000000000023611317160430700254560ustar00rootroot00000000000000package org.apache.maven; /* * 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 org.apache.maven.execution.MavenExecutionRequest; import org.apache.maven.execution.MavenExecutionResult; /** * The main Maven execution entry point, which will execute a full Maven execution session. * * @author Jason van Zyl * @see org.apache.maven.execution.MavenSession */ public interface Maven { @Deprecated String POMv4 = "pom.xml"; MavenExecutionResult execute( MavenExecutionRequest request ); }maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/MavenExecutionException.java000066400000000000000000000027771317160430700312340ustar00rootroot00000000000000package org.apache.maven; /* * 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.File; import org.apache.maven.project.ProjectBuildingException; /** * @author Jason van Zyl */ public class MavenExecutionException extends Exception { private File pomFile; public MavenExecutionException( String message, File pomFile ) { super( message ); this.pomFile = pomFile; } public MavenExecutionException( String message, File pomFile, ProjectBuildingException cause ) { super( message, cause ); this.pomFile = pomFile; } public MavenExecutionException( String message, Throwable cause ) { super( message, cause ); } public File getPomFile() { return pomFile; } } maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/MissingModuleException.java000066400000000000000000000026151317160430700310500ustar00rootroot00000000000000package org.apache.maven; /* * 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.File; public class MissingModuleException extends MavenExecutionException { private File moduleFile; private final String moduleName; public MissingModuleException( String moduleName, File moduleFile, File pomFile ) { super( "The module: " + moduleName + " cannot be found in file: " + moduleFile, pomFile ); this.moduleName = moduleName; this.moduleFile = moduleFile; } public File getModuleFile() { return moduleFile; } public String getModuleName() { return moduleName; } } maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/ProjectBuildFailureException.java000066400000000000000000000033441317160430700321670ustar00rootroot00000000000000package org.apache.maven; /* * 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 org.apache.maven.plugin.MojoFailureException; /** * Exception which occurs when a normal (i.e. non-aggregator) mojo fails to * execute. In this case, the mojo failed while executing against a particular * project instance, so we can wrap the {@link MojoFailureException} with context * information including projectId that caused the failure. * * @author jdcasey * */ public class ProjectBuildFailureException extends BuildFailureException { private final String projectId; public ProjectBuildFailureException( String projectId, MojoFailureException cause ) { super( "Build for project: " + projectId + " failed during execution of mojo.", cause ); this.projectId = projectId; } public MojoFailureException getMojoFailureException() { return (MojoFailureException) getCause(); } public String getProjectId() { return projectId; } } maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/ProjectCycleException.java000066400000000000000000000023001317160430700306460ustar00rootroot00000000000000package org.apache.maven; /* * 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 org.codehaus.plexus.util.dag.CycleDetectedException; /** * @author jdcasey */ public class ProjectCycleException extends BuildFailureException { public ProjectCycleException( String message ) { super( message ); } public ProjectCycleException( String message, CycleDetectedException cause ) { super( message, cause ); } } maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/ProjectDependenciesResolver.java000066400000000000000000000115671317160430700320570ustar00rootroot00000000000000package org.apache.maven; /* * 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.util.Collection; import java.util.Set; import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.resolver.ArtifactNotFoundException; import org.apache.maven.artifact.resolver.ArtifactResolutionException; import org.apache.maven.execution.MavenSession; import org.apache.maven.project.MavenProject; @Deprecated /** * @deprecated As of 3.2.2, and there is no direct replacement. This is an internal class which was not marked as such, * but should have been. * @author jvanzyl * */ public interface ProjectDependenciesResolver { /** * Resolves the transitive dependencies of the specified project. * * @param project The project whose dependencies should be resolved, must not be {@code null}. * @param scopesToResolve The dependency scopes that should be resolved, may be {@code null}. * @param session The current build session, must not be {@code null}. * @return The transitive dependencies of the specified project that match the requested scopes, never {@code null}. */ Set resolve( MavenProject project, Collection scopesToResolve, MavenSession session ) throws ArtifactResolutionException, ArtifactNotFoundException; /** * Resolves the transitive dependencies of the specified project. * * @param project The project whose dependencies should be resolved, must not be {@code null}. * @param scopesToCollect The dependency scopes that should be collected, may be {@code null}. * @param scopesToResolve The dependency scopes that should be collected and also resolved, may be {@code null}. * @param session The current build session, must not be {@code null}. * @return The transitive dependencies of the specified project that match the requested scopes, never {@code null}. */ Set resolve( MavenProject project, Collection scopesToCollect, Collection scopesToResolve, MavenSession session ) throws ArtifactResolutionException, ArtifactNotFoundException; /** * Resolves the transitive dependencies of the specified project. * * @param project The project whose dependencies should be resolved, must not be {@code null}. * @param scopesToCollect The dependency scopes that should be collected, may be {@code null}. * @param scopesToResolve The dependency scopes that should be collected and also resolved, may be {@code null}. * @param session The current build session, must not be {@code null}. * @param ignoreableArtifacts Artifacts that need not be resolved * @return The transitive dependencies of the specified project that match the requested scopes, never {@code null}. */ Set resolve( MavenProject project, Collection scopesToCollect, Collection scopesToResolve, MavenSession session, Set ignoreableArtifacts ) throws ArtifactResolutionException, ArtifactNotFoundException; /** * Resolves the transitive dependencies of the specified projects. Note that dependencies which can't be resolved * from any repository but are present among the set of specified projects will not cause an exception. Instead, * those unresolved artifacts will be returned in the result set, allowing the caller to take special care of * artifacts that haven't been build yet. * * @param projects The projects whose dependencies should be resolved, may be {@code null}. * @param scopes The dependency scopes that should be resolved, may be {@code null}. * @param session The current build session, must not be {@code null}. * @return The transitive dependencies of the specified projects that match the requested scopes, never * {@code null}. */ Set resolve( Collection projects, Collection scopes, MavenSession session ) throws ArtifactResolutionException, ArtifactNotFoundException; } maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/ReactorReader.java000066400000000000000000000213311317160430700271300ustar00rootroot00000000000000package org.apache.maven; /* * 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.File; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; import java.util.Collections; import java.util.HashMap; import java.util.HashSet; import java.util.List; import java.util.Map; import javax.inject.Inject; import javax.inject.Named; import org.apache.maven.artifact.ArtifactUtils; import org.apache.maven.execution.MavenSession; import org.apache.maven.model.Model; import org.apache.maven.project.MavenProject; import org.apache.maven.repository.internal.MavenWorkspaceReader; import org.eclipse.aether.artifact.Artifact; import org.eclipse.aether.repository.WorkspaceRepository; import org.eclipse.aether.util.artifact.ArtifactIdUtils; /** * An implementation of a workspace reader that knows how to search the Maven reactor for artifacts, either as packaged * jar if it has been built, or only compile output directory if packaging hasn't happened yet. * * @author Jason van Zyl */ @Named( ReactorReader.HINT ) @SessionScoped class ReactorReader implements MavenWorkspaceReader { public static final String HINT = "reactor"; private static final Collection COMPILE_PHASE_TYPES = Arrays.asList( "jar", "ejb-client", "war", "rar", "ejb3", "par", "sar", "wsr", "har", "app-client" ); private Map projectsByGAV; private Map> projectsByGA; private WorkspaceRepository repository; @Inject public ReactorReader( MavenSession session ) { projectsByGAV = session.getProjectMap(); projectsByGA = new HashMap<>( projectsByGAV.size() * 2 ); for ( MavenProject project : projectsByGAV.values() ) { String key = ArtifactUtils.versionlessKey( project.getGroupId(), project.getArtifactId() ); List projects = projectsByGA.get( key ); if ( projects == null ) { projects = new ArrayList<>( 1 ); projectsByGA.put( key, projects ); } projects.add( project ); } repository = new WorkspaceRepository( "reactor", new HashSet<>( projectsByGAV.keySet() ) ); } // // Public API // public WorkspaceRepository getRepository() { return repository; } public File findArtifact( Artifact artifact ) { String projectKey = ArtifactUtils.key( artifact.getGroupId(), artifact.getArtifactId(), artifact.getVersion() ); MavenProject project = projectsByGAV.get( projectKey ); if ( project != null ) { File file = find( project, artifact ); if ( file == null && project != project.getExecutionProject() ) { file = find( project.getExecutionProject(), artifact ); } return file; } return null; } public List findVersions( Artifact artifact ) { String key = ArtifactUtils.versionlessKey( artifact.getGroupId(), artifact.getArtifactId() ); List projects = projectsByGA.get( key ); if ( projects == null || projects.isEmpty() ) { return Collections.emptyList(); } List versions = new ArrayList<>(); for ( MavenProject project : projects ) { if ( find( project, artifact ) != null ) { versions.add( project.getVersion() ); } } return Collections.unmodifiableList( versions ); } @Override public Model findModel( Artifact artifact ) { String projectKey = ArtifactUtils.key( artifact.getGroupId(), artifact.getArtifactId(), artifact.getVersion() ); MavenProject project = projectsByGAV.get( projectKey ); return project == null ? null : project.getModel(); } // // Implementation // private File find( MavenProject project, Artifact artifact ) { if ( "pom".equals( artifact.getExtension() ) ) { return project.getFile(); } Artifact projectArtifact = findMatchingArtifact( project, artifact ); if ( hasArtifactFileFromPackagePhase( projectArtifact ) ) { return projectArtifact.getFile(); } else if ( !hasBeenPackaged( project ) ) { // fallback to loose class files only if artifacts haven't been packaged yet // and only for plain old jars. Not war files, not ear files, not anything else. if ( isTestArtifact( artifact ) ) { if ( project.hasLifecyclePhase( "test-compile" ) ) { return new File( project.getBuild().getTestOutputDirectory() ); } } else { String type = artifact.getProperty( "type", "" ); if ( project.hasLifecyclePhase( "compile" ) && COMPILE_PHASE_TYPES.contains( type ) ) { return new File( project.getBuild().getOutputDirectory() ); } } } // The fall-through indicates that the artifact cannot be found; // for instance if package produced nothing or classifier problems. return null; } private boolean hasArtifactFileFromPackagePhase( Artifact projectArtifact ) { return projectArtifact != null && projectArtifact.getFile() != null && projectArtifact.getFile().exists(); } private boolean hasBeenPackaged( MavenProject project ) { return project.hasLifecyclePhase( "package" ) || project.hasLifecyclePhase( "install" ) || project.hasLifecyclePhase( "deploy" ); } /** * Tries to resolve the specified artifact from the artifacts of the given project. * * @param project The project to try to resolve the artifact from, must not be null. * @param requestedArtifact The artifact to resolve, must not be null. * @return The matching artifact from the project or null if not found. Note that this */ private Artifact findMatchingArtifact( MavenProject project, Artifact requestedArtifact ) { String requestedRepositoryConflictId = ArtifactIdUtils.toVersionlessId( requestedArtifact ); Artifact mainArtifact = RepositoryUtils.toArtifact( project.getArtifact() ); if ( requestedRepositoryConflictId.equals( ArtifactIdUtils.toVersionlessId( mainArtifact ) ) ) { return mainArtifact; } for ( Artifact attachedArtifact : RepositoryUtils.toArtifacts( project.getAttachedArtifacts() ) ) { if ( attachedArtifactComparison( requestedArtifact, attachedArtifact ) ) { return attachedArtifact; } } return null; } private boolean attachedArtifactComparison( Artifact requested, Artifact attached ) { // // We are taking as much as we can from the DefaultArtifact.equals(). The requested artifact has no file so // we want to remove that from the comparison. // return requested.getArtifactId().equals( attached.getArtifactId() ) && requested.getGroupId().equals( attached.getGroupId() ) && requested.getVersion().equals( attached.getVersion() ) && requested.getExtension().equals( attached.getExtension() ) && requested.getClassifier().equals( attached.getClassifier() ); } /** * Determines whether the specified artifact refers to test classes. * * @param artifact The artifact to check, must not be {@code null}. * @return {@code true} if the artifact refers to test classes, {@code false} otherwise. */ private static boolean isTestArtifact( Artifact artifact ) { return ( "test-jar".equals( artifact.getProperty( "type", "" ) ) ) || ( "jar".equals( artifact.getExtension() ) && "tests".equals( artifact.getClassifier() ) ); } } maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/RepositoryUtils.java000066400000000000000000000336401317160430700276140ustar00rootroot00000000000000package org.apache.maven; /* * 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.util.ArrayList; import java.util.Collection; import java.util.Collections; import java.util.List; import java.util.Map; import org.apache.maven.artifact.handler.ArtifactHandler; import org.apache.maven.artifact.handler.DefaultArtifactHandler; import org.apache.maven.artifact.handler.manager.ArtifactHandlerManager; import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.repository.ArtifactRepositoryPolicy; import org.eclipse.aether.artifact.Artifact; import org.eclipse.aether.artifact.ArtifactProperties; import org.eclipse.aether.artifact.ArtifactType; import org.eclipse.aether.artifact.ArtifactTypeRegistry; import org.eclipse.aether.artifact.DefaultArtifact; import org.eclipse.aether.artifact.DefaultArtifactType; import org.eclipse.aether.graph.Dependency; import org.eclipse.aether.graph.DependencyFilter; import org.eclipse.aether.graph.DependencyNode; import org.eclipse.aether.graph.Exclusion; import org.eclipse.aether.repository.Authentication; import org.eclipse.aether.repository.Proxy; import org.eclipse.aether.repository.RemoteRepository; import org.eclipse.aether.repository.RepositoryPolicy; import org.eclipse.aether.util.repository.AuthenticationBuilder; /** * Warning: This is an internal utility class that is only public for technical reasons, it is not part * of the public API. In particular, this class can be changed or deleted without prior notice. * * @author Benjamin Bentmann */ public class RepositoryUtils { private static String nullify( String string ) { return ( string == null || string.length() <= 0 ) ? null : string; } private static org.apache.maven.artifact.Artifact toArtifact( Dependency dependency ) { if ( dependency == null ) { return null; } org.apache.maven.artifact.Artifact result = toArtifact( dependency.getArtifact() ); result.setScope( dependency.getScope() ); result.setOptional( dependency.isOptional() ); return result; } public static org.apache.maven.artifact.Artifact toArtifact( Artifact artifact ) { if ( artifact == null ) { return null; } ArtifactHandler handler = newHandler( artifact ); /* * NOTE: From Artifact.hasClassifier(), an empty string and a null both denote "no classifier". However, some * plugins only check for null, so be sure to nullify an empty classifier. */ org.apache.maven.artifact.Artifact result = new org.apache.maven.artifact.DefaultArtifact( artifact.getGroupId(), artifact.getArtifactId(), artifact.getVersion(), null, artifact.getProperty( ArtifactProperties.TYPE, artifact.getExtension() ), nullify( artifact.getClassifier() ), handler ); result.setFile( artifact.getFile() ); result.setResolved( artifact.getFile() != null ); List trail = new ArrayList<>( 1 ); trail.add( result.getId() ); result.setDependencyTrail( trail ); return result; } public static void toArtifacts( Collection artifacts, Collection nodes, List trail, DependencyFilter filter ) { for ( DependencyNode node : nodes ) { org.apache.maven.artifact.Artifact artifact = toArtifact( node.getDependency() ); List nodeTrail = new ArrayList<>( trail.size() + 1 ); nodeTrail.addAll( trail ); nodeTrail.add( artifact.getId() ); if ( filter == null || filter.accept( node, Collections.emptyList() ) ) { artifact.setDependencyTrail( nodeTrail ); artifacts.add( artifact ); } toArtifacts( artifacts, node.getChildren(), nodeTrail, filter ); } } public static Artifact toArtifact( org.apache.maven.artifact.Artifact artifact ) { if ( artifact == null ) { return null; } String version = artifact.getVersion(); if ( version == null && artifact.getVersionRange() != null ) { version = artifact.getVersionRange().toString(); } Map props = null; if ( org.apache.maven.artifact.Artifact.SCOPE_SYSTEM.equals( artifact.getScope() ) ) { String localPath = ( artifact.getFile() != null ) ? artifact.getFile().getPath() : ""; props = Collections.singletonMap( ArtifactProperties.LOCAL_PATH, localPath ); } Artifact result = new DefaultArtifact( artifact.getGroupId(), artifact.getArtifactId(), artifact.getClassifier(), artifact.getArtifactHandler().getExtension(), version, props, newArtifactType( artifact.getType(), artifact.getArtifactHandler() ) ); result = result.setFile( artifact.getFile() ); return result; } public static Dependency toDependency( org.apache.maven.artifact.Artifact artifact, Collection exclusions ) { if ( artifact == null ) { return null; } Artifact result = toArtifact( artifact ); List excl = null; if ( exclusions != null ) { excl = new ArrayList<>( exclusions.size() ); for ( org.apache.maven.model.Exclusion exclusion : exclusions ) { excl.add( toExclusion( exclusion ) ); } } return new Dependency( result, artifact.getScope(), artifact.isOptional(), excl ); } public static List toRepos( List repos ) { if ( repos == null ) { return null; } List results = new ArrayList<>( repos.size() ); for ( ArtifactRepository repo : repos ) { results.add( toRepo( repo ) ); } return results; } public static RemoteRepository toRepo( ArtifactRepository repo ) { RemoteRepository result = null; if ( repo != null ) { RemoteRepository.Builder builder = new RemoteRepository.Builder( repo.getId(), getLayout( repo ), repo.getUrl() ); builder.setSnapshotPolicy( toPolicy( repo.getSnapshots() ) ); builder.setReleasePolicy( toPolicy( repo.getReleases() ) ); builder.setAuthentication( toAuthentication( repo.getAuthentication() ) ); builder.setProxy( toProxy( repo.getProxy() ) ); builder.setMirroredRepositories( toRepos( repo.getMirroredRepositories() ) ); result = builder.build(); } return result; } public static String getLayout( ArtifactRepository repo ) { try { return repo.getLayout().getId(); } catch ( LinkageError e ) { /* * NOTE: getId() was added in 3.x and is as such not implemented by plugins compiled against 2.x APIs. */ String className = repo.getLayout().getClass().getSimpleName(); if ( className.endsWith( "RepositoryLayout" ) ) { String layout = className.substring( 0, className.length() - "RepositoryLayout".length() ); if ( layout.length() > 0 ) { layout = Character.toLowerCase( layout.charAt( 0 ) ) + layout.substring( 1 ); return layout; } } return ""; } } private static RepositoryPolicy toPolicy( ArtifactRepositoryPolicy policy ) { RepositoryPolicy result = null; if ( policy != null ) { result = new RepositoryPolicy( policy.isEnabled(), policy.getUpdatePolicy(), policy.getChecksumPolicy() ); } return result; } private static Authentication toAuthentication( org.apache.maven.artifact.repository.Authentication auth ) { Authentication result = null; if ( auth != null ) { AuthenticationBuilder authBuilder = new AuthenticationBuilder(); authBuilder.addUsername( auth.getUsername() ).addPassword( auth.getPassword() ); authBuilder.addPrivateKey( auth.getPrivateKey(), auth.getPassphrase() ); result = authBuilder.build(); } return result; } private static Proxy toProxy( org.apache.maven.repository.Proxy proxy ) { Proxy result = null; if ( proxy != null ) { AuthenticationBuilder authBuilder = new AuthenticationBuilder(); authBuilder.addUsername( proxy.getUserName() ).addPassword( proxy.getPassword() ); result = new Proxy( proxy.getProtocol(), proxy.getHost(), proxy.getPort(), authBuilder.build() ); } return result; } public static ArtifactHandler newHandler( Artifact artifact ) { String type = artifact.getProperty( ArtifactProperties.TYPE, artifact.getExtension() ); DefaultArtifactHandler handler = new DefaultArtifactHandler( type ); handler.setExtension( artifact.getExtension() ); handler.setLanguage( artifact.getProperty( ArtifactProperties.LANGUAGE, null ) ); String addedToClasspath = artifact.getProperty( ArtifactProperties.CONSTITUTES_BUILD_PATH, "" ); handler.setAddedToClasspath( Boolean.parseBoolean( addedToClasspath ) ); String includesDependencies = artifact.getProperty( ArtifactProperties.INCLUDES_DEPENDENCIES, "" ); handler.setIncludesDependencies( Boolean.parseBoolean( includesDependencies ) ); return handler; } public static ArtifactType newArtifactType( String id, ArtifactHandler handler ) { return new DefaultArtifactType( id, handler.getExtension(), handler.getClassifier(), handler.getLanguage(), handler.isAddedToClasspath(), handler.isIncludesDependencies() ); } public static Dependency toDependency( org.apache.maven.model.Dependency dependency, ArtifactTypeRegistry stereotypes ) { ArtifactType stereotype = stereotypes.get( dependency.getType() ); if ( stereotype == null ) { stereotype = new DefaultArtifactType( dependency.getType() ); } boolean system = dependency.getSystemPath() != null && dependency.getSystemPath().length() > 0; Map props = null; if ( system ) { props = Collections.singletonMap( ArtifactProperties.LOCAL_PATH, dependency.getSystemPath() ); } Artifact artifact = new DefaultArtifact( dependency.getGroupId(), dependency.getArtifactId(), dependency.getClassifier(), null, dependency.getVersion(), props, stereotype ); List exclusions = new ArrayList<>( dependency.getExclusions().size() ); for ( org.apache.maven.model.Exclusion exclusion : dependency.getExclusions() ) { exclusions.add( toExclusion( exclusion ) ); } Dependency result = new Dependency( artifact, dependency.getScope(), dependency.getOptional() != null ? dependency.isOptional() : null, exclusions ); return result; } private static Exclusion toExclusion( org.apache.maven.model.Exclusion exclusion ) { return new Exclusion( exclusion.getGroupId(), exclusion.getArtifactId(), "*", "*" ); } public static ArtifactTypeRegistry newArtifactTypeRegistry( ArtifactHandlerManager handlerManager ) { return new MavenArtifactTypeRegistry( handlerManager ); } static class MavenArtifactTypeRegistry implements ArtifactTypeRegistry { private final ArtifactHandlerManager handlerManager; public MavenArtifactTypeRegistry( ArtifactHandlerManager handlerManager ) { this.handlerManager = handlerManager; } public ArtifactType get( String stereotypeId ) { ArtifactHandler handler = handlerManager.getArtifactHandler( stereotypeId ); return newArtifactType( stereotypeId, handler ); } } public static Collection toArtifacts( Collection artifactsToConvert ) { List artifacts = new ArrayList<>(); for ( org.apache.maven.artifact.Artifact a : artifactsToConvert ) { artifacts.add( toArtifact( a ) ); } return artifacts; } } maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/SessionScoped.java000066400000000000000000000025211317160430700271670ustar00rootroot00000000000000package org.apache.maven; /* * 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 java.lang.annotation.ElementType.TYPE; import static java.lang.annotation.RetentionPolicy.RUNTIME; import java.lang.annotation.Retention; import java.lang.annotation.Target; import com.google.inject.ScopeAnnotation; /** * Indicates that annotated component should be instantiated before session execution starts * and discarded after session execution completes. * * @author Jason van Zyl * @since 3.2.0 */ @Target( { TYPE } ) @Retention( RUNTIME ) @ScopeAnnotation public @interface SessionScoped { } maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/artifact/000077500000000000000000000000001317160430700253405ustar00rootroot00000000000000DependencyResolutionRequiredException.java000066400000000000000000000025171317160430700356530ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/artifactpackage org.apache.maven.artifact; /* * 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. */ /** * Exception that occurs when an artifact file is used, but has not been resolved. * * @author Brett Porter * TODO it may be better for artifact.getFile() to throw it - perhaps it is a runtime exception? */ public class DependencyResolutionRequiredException extends Exception { public DependencyResolutionRequiredException( Artifact artifact ) { super( "Attempted to access the artifact " + artifact + "; which has not yet been resolved" ); } } maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/artifact/InvalidRepositoryException.java000066400000000000000000000037001317160430700335500ustar00rootroot00000000000000package org.apache.maven.artifact; /* * 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.MalformedURLException; import org.codehaus.plexus.component.repository.exception.ComponentLookupException; /** * Error constructing an artifact repository. * * @author Brett Porter */ public class InvalidRepositoryException extends Exception { private final String repositoryId; public InvalidRepositoryException( String message, String repositoryId, MalformedURLException cause ) { super( message, cause ); this.repositoryId = repositoryId; } protected InvalidRepositoryException( String message, String repositoryId, ComponentLookupException cause ) { super( message, cause ); this.repositoryId = repositoryId; } @Deprecated public InvalidRepositoryException( String message, Throwable t ) { super( message, t ); this.repositoryId = null; } public InvalidRepositoryException( String message, String repositoryId ) { super( message ); this.repositoryId = repositoryId; } public String getRepositoryId() { return repositoryId; } } maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/artifact/factory/000077500000000000000000000000001317160430700270075ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/artifact/factory/ArtifactFactory.java000066400000000000000000000053361317160430700327460ustar00rootroot00000000000000package org.apache.maven.artifact.factory; /* * 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 org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.versioning.VersionRange; @Deprecated public interface ArtifactFactory { @Deprecated String ROLE = ArtifactFactory.class.getName(); Artifact createArtifact( String groupId, String artifactId, String version, String scope, String type ); Artifact createArtifactWithClassifier( String groupId, String artifactId, String version, String type, String classifier ); Artifact createDependencyArtifact( String groupId, String artifactId, VersionRange versionRange, String type, String classifier, String scope ); Artifact createDependencyArtifact( String groupId, String artifactId, VersionRange versionRange, String type, String classifier, String scope, boolean optional ); Artifact createDependencyArtifact( String groupId, String artifactId, VersionRange versionRange, String type, String classifier, String scope, String inheritedScope ); Artifact createDependencyArtifact( String groupId, String artifactId, VersionRange versionRange, String type, String classifier, String scope, String inheritedScope, boolean optional ); Artifact createBuildArtifact( String groupId, String artifactId, String version, String packaging ); Artifact createProjectArtifact( String groupId, String artifactId, String version ); Artifact createParentArtifact( String groupId, String artifactId, String version ); Artifact createPluginArtifact( String groupId, String artifactId, VersionRange versionRange ); Artifact createProjectArtifact( String groupId, String artifactId, String version, String scope ); Artifact createExtensionArtifact( String groupId, String artifactId, VersionRange versionRange ); } DefaultArtifactFactory.java000066400000000000000000000154311317160430700341710ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/artifact/factorypackage org.apache.maven.artifact.factory; /* * 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 org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.DefaultArtifact; import org.apache.maven.artifact.handler.ArtifactHandler; import org.apache.maven.artifact.handler.manager.ArtifactHandlerManager; import org.apache.maven.artifact.versioning.VersionRange; import org.codehaus.plexus.component.annotations.Component; import org.codehaus.plexus.component.annotations.Requirement; @Component( role = ArtifactFactory.class ) public class DefaultArtifactFactory implements ArtifactFactory { @Requirement private ArtifactHandlerManager artifactHandlerManager; public Artifact createArtifact( String groupId, String artifactId, String version, String scope, String type ) { return createArtifact( groupId, artifactId, version, scope, type, null, null ); } public Artifact createArtifactWithClassifier( String groupId, String artifactId, String version, String type, String classifier ) { return createArtifact( groupId, artifactId, version, null, type, classifier, null ); } public Artifact createDependencyArtifact( String groupId, String artifactId, VersionRange versionRange, String type, String classifier, String scope ) { return createArtifact( groupId, artifactId, versionRange, type, classifier, scope, null ); } public Artifact createDependencyArtifact( String groupId, String artifactId, VersionRange versionRange, String type, String classifier, String scope, boolean optional ) { return createArtifact( groupId, artifactId, versionRange, type, classifier, scope, null, optional ); } public Artifact createDependencyArtifact( String groupId, String artifactId, VersionRange versionRange, String type, String classifier, String scope, String inheritedScope ) { return createArtifact( groupId, artifactId, versionRange, type, classifier, scope, inheritedScope ); } public Artifact createDependencyArtifact( String groupId, String artifactId, VersionRange versionRange, String type, String classifier, String scope, String inheritedScope, boolean optional ) { return createArtifact( groupId, artifactId, versionRange, type, classifier, scope, inheritedScope, optional ); } public Artifact createBuildArtifact( String groupId, String artifactId, String version, String packaging ) { return createArtifact( groupId, artifactId, version, null, packaging, null, null ); } public Artifact createProjectArtifact( String groupId, String artifactId, String version ) { return createProjectArtifact( groupId, artifactId, version, null ); } public Artifact createParentArtifact( String groupId, String artifactId, String version ) { return createProjectArtifact( groupId, artifactId, version ); } public Artifact createPluginArtifact( String groupId, String artifactId, VersionRange versionRange ) { return createArtifact( groupId, artifactId, versionRange, "maven-plugin", null, Artifact.SCOPE_RUNTIME, null ); } public Artifact createProjectArtifact( String groupId, String artifactId, String version, String scope ) { return createArtifact( groupId, artifactId, version, scope, "pom" ); } public Artifact createExtensionArtifact( String groupId, String artifactId, VersionRange versionRange ) { return createArtifact( groupId, artifactId, versionRange, "jar", null, Artifact.SCOPE_RUNTIME, null ); } private Artifact createArtifact( String groupId, String artifactId, String version, String scope, String type, String classifier, String inheritedScope ) { VersionRange versionRange = null; if ( version != null ) { versionRange = VersionRange.createFromVersion( version ); } return createArtifact( groupId, artifactId, versionRange, type, classifier, scope, inheritedScope ); } private Artifact createArtifact( String groupId, String artifactId, VersionRange versionRange, String type, String classifier, String scope, String inheritedScope ) { return createArtifact( groupId, artifactId, versionRange, type, classifier, scope, inheritedScope, false ); } private Artifact createArtifact( String groupId, String artifactId, VersionRange versionRange, String type, String classifier, String scope, String inheritedScope, boolean optional ) { String desiredScope = Artifact.SCOPE_RUNTIME; if ( inheritedScope == null ) { desiredScope = scope; } else if ( Artifact.SCOPE_TEST.equals( scope ) || Artifact.SCOPE_PROVIDED.equals( scope ) ) { return null; } else if ( Artifact.SCOPE_COMPILE.equals( scope ) && Artifact.SCOPE_COMPILE.equals( inheritedScope ) ) { // added to retain compile artifactScope. Remove if you want compile inherited as runtime desiredScope = Artifact.SCOPE_COMPILE; } if ( Artifact.SCOPE_TEST.equals( inheritedScope ) ) { desiredScope = Artifact.SCOPE_TEST; } if ( Artifact.SCOPE_PROVIDED.equals( inheritedScope ) ) { desiredScope = Artifact.SCOPE_PROVIDED; } if ( Artifact.SCOPE_SYSTEM.equals( scope ) ) { // system scopes come through unchanged... desiredScope = Artifact.SCOPE_SYSTEM; } ArtifactHandler handler = artifactHandlerManager.getArtifactHandler( type ); return new DefaultArtifact( groupId, artifactId, versionRange, desiredScope, type, classifier, handler, optional ); } } maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/artifact/handler/000077500000000000000000000000001317160430700267555ustar00rootroot00000000000000DefaultArtifactHandler.java000066400000000000000000000055671317160430700341160ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/artifact/handlerpackage org.apache.maven.artifact.handler; /* * 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 org.codehaus.plexus.component.annotations.Component; /** * @author Brett Porter * @author Jason van Zyl */ @Component( role = ArtifactHandler.class ) public class DefaultArtifactHandler implements ArtifactHandler { private String extension; private String type; private String classifier; private String directory; private String packaging; private boolean includesDependencies; private String language; private boolean addedToClasspath; public DefaultArtifactHandler() { } public DefaultArtifactHandler( String type ) { this.type = type; } public String getExtension() { if ( extension == null ) { extension = type; } return extension; } public void setExtension( String extension ) { this.extension = extension; } public String getType() { return type; } public String getClassifier() { return classifier; } public String getDirectory() { if ( directory == null ) { directory = getPackaging() + "s"; } return directory; } public String getPackaging() { if ( packaging == null ) { packaging = type; } return packaging; } public boolean isIncludesDependencies() { return includesDependencies; } public void setIncludesDependencies( boolean includesDependencies ) { this.includesDependencies = includesDependencies; } public String getLanguage() { if ( language == null ) { language = "none"; } return language; } public void setLanguage( String language ) { this.language = language; } public boolean isAddedToClasspath() { return addedToClasspath; } public void setAddedToClasspath( boolean addedToClasspath ) { this.addedToClasspath = addedToClasspath; } } maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/artifact/handler/manager/000077500000000000000000000000001317160430700303675ustar00rootroot00000000000000ArtifactHandlerManager.java000066400000000000000000000022751317160430700355070ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/artifact/handler/managerpackage org.apache.maven.artifact.handler.manager; /* * 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.util.Map; import org.apache.maven.artifact.handler.ArtifactHandler; /** * @author Jason van Zyl */ public interface ArtifactHandlerManager { String ROLE = ArtifactHandlerManager.class.getName(); ArtifactHandler getArtifactHandler( String type ); @Deprecated void addHandlers( Map handlers ); } DefaultArtifactHandlerManager.java000066400000000000000000000043121317160430700370060ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/artifact/handler/managerpackage org.apache.maven.artifact.handler.manager; /* * 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.util.Map; import java.util.Set; import java.util.concurrent.ConcurrentHashMap; import org.apache.maven.artifact.handler.ArtifactHandler; import org.apache.maven.artifact.handler.DefaultArtifactHandler; import org.codehaus.plexus.component.annotations.Component; import org.codehaus.plexus.component.annotations.Requirement; /** * @author Jason van Zyl */ @Component( role = ArtifactHandlerManager.class ) public class DefaultArtifactHandlerManager implements ArtifactHandlerManager { @Requirement( role = ArtifactHandler.class ) private Map artifactHandlers; private Map unmanagedHandlers = new ConcurrentHashMap<>(); public ArtifactHandler getArtifactHandler( String type ) { ArtifactHandler handler = unmanagedHandlers.get( type ); if ( handler == null ) { handler = artifactHandlers.get( type ); if ( handler == null ) { handler = new DefaultArtifactHandler( type ); } } return handler; } public void addHandlers( Map handlers ) { // legacy support for maven-gpg-plugin:1.0 unmanagedHandlers.putAll( handlers ); } @Deprecated public Set getHandlerTypes() { return artifactHandlers.keySet(); } } maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/artifact/metadata/000077500000000000000000000000001317160430700271205ustar00rootroot00000000000000AbstractArtifactMetadata.java000066400000000000000000000022671317160430700345750ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/artifact/metadatapackage org.apache.maven.artifact.metadata; /* * 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 org.apache.maven.artifact.Artifact; @Deprecated public abstract class AbstractArtifactMetadata extends org.apache.maven.repository.legacy.metadata.AbstractArtifactMetadata implements org.apache.maven.artifact.metadata.ArtifactMetadata { protected AbstractArtifactMetadata( Artifact artifact ) { super( artifact ); } } ArtifactMetadataRetrievalException.java000066400000000000000000000036551317160430700366500ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/artifact/metadatapackage org.apache.maven.artifact.metadata; /* * 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 org.apache.maven.artifact.Artifact; @Deprecated public class ArtifactMetadataRetrievalException extends org.apache.maven.repository.legacy.metadata.ArtifactMetadataRetrievalException { /** @deprecated use {@link #ArtifactMetadataRetrievalException(String, Throwable, Artifact)} */ @Deprecated public ArtifactMetadataRetrievalException( String message ) { super( message, null, null ); } /** @deprecated use {@link #ArtifactMetadataRetrievalException(String, Throwable, Artifact)} */ @Deprecated public ArtifactMetadataRetrievalException( Throwable cause ) { super( null, cause, null ); } /** @deprecated use {@link #ArtifactMetadataRetrievalException(String, Throwable, Artifact)} */ @Deprecated public ArtifactMetadataRetrievalException( String message, Throwable cause ) { super( message, cause, null ); } public ArtifactMetadataRetrievalException( String message, Throwable cause, Artifact artifact ) { super( message, cause, artifact ); } } ArtifactMetadataSource.java000066400000000000000000000044751317160430700342750ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/artifact/metadatapackage org.apache.maven.artifact.metadata; /* * 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.util.List; import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.versioning.ArtifactVersion; import org.apache.maven.repository.legacy.metadata.MetadataResolutionRequest; @Deprecated public interface ArtifactMetadataSource extends org.apache.maven.repository.legacy.metadata.ArtifactMetadataSource { ResolutionGroup retrieve( MetadataResolutionRequest request ) throws ArtifactMetadataRetrievalException; ResolutionGroup retrieve( Artifact artifact, ArtifactRepository localRepository, List remoteRepositories ) throws ArtifactMetadataRetrievalException; List retrieveAvailableVersions( MetadataResolutionRequest request ) throws ArtifactMetadataRetrievalException; List retrieveAvailableVersions( Artifact artifact, ArtifactRepository localRepository, List remoteRepositories ) throws ArtifactMetadataRetrievalException; List retrieveAvailableVersionsFromDeploymentRepository( Artifact artifact, ArtifactRepository localRepository, ArtifactRepository remoteRepository ) throws ArtifactMetadataRetrievalException; }maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/artifact/metadata/ResolutionGroup.java000066400000000000000000000032601317160430700331440ustar00rootroot00000000000000package org.apache.maven.artifact.metadata; /* * 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.util.List; import java.util.Map; import java.util.Set; import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.repository.ArtifactRepository; @Deprecated public class ResolutionGroup extends org.apache.maven.repository.legacy.metadata.ResolutionGroup { public ResolutionGroup( Artifact pomArtifact, Set artifacts, List resolutionRepositories ) { super( pomArtifact, artifacts, resolutionRepositories ); } public ResolutionGroup( Artifact pomArtifact, Artifact relocatedArtifact, Set artifacts, Map managedVersions, List resolutionRepositories ) { super( pomArtifact, relocatedArtifact, artifacts, managedVersions, resolutionRepositories ); } } maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/artifact/repository/000077500000000000000000000000001317160430700275575ustar00rootroot00000000000000DefaultRepositoryRequest.java000066400000000000000000000071511317160430700354040ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/artifact/repositorypackage org.apache.maven.artifact.repository; /* * 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.util.ArrayList; import java.util.List; import org.apache.maven.execution.MavenSession; import org.apache.maven.project.MavenProject; /** * Collects basic settings to access the repository system. * * @author Benjamin Bentmann */ public class DefaultRepositoryRequest implements RepositoryRequest { private boolean offline; private boolean forceUpdate; private ArtifactRepository localRepository; private List remoteRepositories; /** * Creates an empty repository request. */ public DefaultRepositoryRequest() { // enables no-arg constructor } /** * Creates a shallow copy of the specified repository request. * * @param repositoryRequest The repository request to copy from, must not be {@code null}. */ public DefaultRepositoryRequest( RepositoryRequest repositoryRequest ) { setLocalRepository( repositoryRequest.getLocalRepository() ); setRemoteRepositories( repositoryRequest.getRemoteRepositories() ); setOffline( repositoryRequest.isOffline() ); setForceUpdate( repositoryRequest.isForceUpdate() ); } public static RepositoryRequest getRepositoryRequest( MavenSession session, MavenProject project ) { RepositoryRequest request = new DefaultRepositoryRequest(); request.setLocalRepository( session.getLocalRepository() ); if ( project != null ) { request.setRemoteRepositories( project.getPluginArtifactRepositories() ); } request.setOffline( session.isOffline() ); request.setForceUpdate( session.getRequest().isUpdateSnapshots() ); return request; } public boolean isOffline() { return offline; } public DefaultRepositoryRequest setOffline( boolean offline ) { this.offline = offline; return this; } public boolean isForceUpdate() { return forceUpdate; } public DefaultRepositoryRequest setForceUpdate( boolean forceUpdate ) { this.forceUpdate = forceUpdate; return this; } public ArtifactRepository getLocalRepository() { return localRepository; } public DefaultRepositoryRequest setLocalRepository( ArtifactRepository localRepository ) { this.localRepository = localRepository; return this; } public List getRemoteRepositories() { if ( remoteRepositories == null ) { remoteRepositories = new ArrayList<>(); } return remoteRepositories; } public DefaultRepositoryRequest setRemoteRepositories( List remoteRepositories ) { this.remoteRepositories = remoteRepositories; return this; } } LegacyLocalRepositoryManager.java000066400000000000000000000315331317160430700361220ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/artifact/repositorypackage org.apache.maven.artifact.repository; /* * 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.File; import java.util.Collections; import java.util.List; import org.apache.commons.lang3.Validate; import org.apache.maven.RepositoryUtils; import org.apache.maven.artifact.metadata.ArtifactMetadata; import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout; import org.apache.maven.artifact.repository.layout.DefaultRepositoryLayout; import org.apache.maven.artifact.repository.metadata.RepositoryMetadataStoreException; import org.apache.maven.repository.Proxy; import org.eclipse.aether.DefaultRepositorySystemSession; import org.eclipse.aether.RepositorySystem; import org.eclipse.aether.RepositorySystemSession; import org.eclipse.aether.artifact.Artifact; import org.eclipse.aether.metadata.Metadata; import org.eclipse.aether.repository.LocalArtifactRegistration; import org.eclipse.aether.repository.LocalArtifactRequest; import org.eclipse.aether.repository.LocalArtifactResult; import org.eclipse.aether.repository.LocalMetadataRegistration; import org.eclipse.aether.repository.LocalMetadataRequest; import org.eclipse.aether.repository.LocalMetadataResult; import org.eclipse.aether.repository.LocalRepository; import org.eclipse.aether.repository.LocalRepositoryManager; import org.eclipse.aether.repository.RemoteRepository; /** * Warning: This is an internal utility class that is only public for technical reasons, it is not part * of the public API. In particular, this class can be changed or deleted without prior notice. * * @author Benjamin Bentmann */ public class LegacyLocalRepositoryManager implements LocalRepositoryManager { private final ArtifactRepository delegate; private final LocalRepository repo; private final boolean realLocalRepo; public static RepositorySystemSession overlay( ArtifactRepository repository, RepositorySystemSession session, RepositorySystem system ) { if ( repository == null || repository.getBasedir() == null ) { return session; } if ( session != null ) { LocalRepositoryManager lrm = session.getLocalRepositoryManager(); if ( lrm != null && lrm.getRepository().getBasedir().equals( new File( repository.getBasedir() ) ) ) { return session; } } else { session = new DefaultRepositorySystemSession(); } final LocalRepositoryManager llrm = new LegacyLocalRepositoryManager( repository ); return new DefaultRepositorySystemSession( session ).setLocalRepositoryManager( llrm ); } private LegacyLocalRepositoryManager( ArtifactRepository delegate ) { this.delegate = Validate.notNull( delegate, "delegate cannot be null" ); ArtifactRepositoryLayout layout = delegate.getLayout(); repo = new LocalRepository( new File( delegate.getBasedir() ), ( layout != null ) ? layout.getClass().getSimpleName() : "legacy" ); /* * NOTE: "invoker:install" vs "appassembler:assemble": Both mojos use the artifact installer to put an artifact * into a repository. In the first case, the result needs to be a proper local repository that one can use for * local artifact resolution. In the second case, the result needs to precisely obey the path information of the * repository's layout to allow pointing at artifacts within the repository. Unfortunately, * DefaultRepositoryLayout does not correctly describe the layout of a local repository which unlike a remote * repository never uses timestamps in the filename of a snapshot artifact. The discrepancy gets notable when a * remotely resolved snapshot artifact gets passed into pathOf(). So producing a proper local artifact path * using DefaultRepositoryLayout requires us to enforce usage of the artifact's base version. This * transformation however contradicts the other use case of precisely obeying the repository's layout. The below * flag tries to detect which use case applies to make both plugins happy. */ realLocalRepo = ( layout instanceof DefaultRepositoryLayout ) && "local".equals( delegate.getId() ); } public LocalRepository getRepository() { return repo; } public String getPathForLocalArtifact( Artifact artifact ) { if ( realLocalRepo ) { return delegate.pathOf( RepositoryUtils.toArtifact( artifact.setVersion( artifact.getBaseVersion() ) ) ); } return delegate.pathOf( RepositoryUtils.toArtifact( artifact ) ); } public String getPathForRemoteArtifact( Artifact artifact, RemoteRepository repository, String context ) { return delegate.pathOf( RepositoryUtils.toArtifact( artifact ) ); } public String getPathForLocalMetadata( Metadata metadata ) { return delegate.pathOfLocalRepositoryMetadata( new ArtifactMetadataAdapter( metadata ), delegate ); } public String getPathForRemoteMetadata( Metadata metadata, RemoteRepository repository, String context ) { return delegate.pathOfLocalRepositoryMetadata( new ArtifactMetadataAdapter( metadata ), new ArtifactRepositoryAdapter( repository ) ); } public LocalArtifactResult find( RepositorySystemSession session, LocalArtifactRequest request ) { String path = getPathForLocalArtifact( request.getArtifact() ); File file = new File( getRepository().getBasedir(), path ); LocalArtifactResult result = new LocalArtifactResult( request ); if ( file.isFile() ) { result.setFile( file ); result.setAvailable( true ); } return result; } public LocalMetadataResult find( RepositorySystemSession session, LocalMetadataRequest request ) { Metadata metadata = request.getMetadata(); String path; if ( request.getRepository() == null ) { path = getPathForLocalMetadata( metadata ); } else { path = getPathForRemoteMetadata( metadata, request.getRepository(), request.getContext() ); } File file = new File( getRepository().getBasedir(), path ); LocalMetadataResult result = new LocalMetadataResult( request ); if ( file.isFile() ) { result.setFile( file ); } return result; } public void add( RepositorySystemSession session, LocalArtifactRegistration request ) { // noop } public void add( RepositorySystemSession session, LocalMetadataRegistration request ) { // noop } static class ArtifactMetadataAdapter implements ArtifactMetadata { private final Metadata metadata; public ArtifactMetadataAdapter( Metadata metadata ) { this.metadata = metadata; } public boolean storedInArtifactVersionDirectory() { return metadata.getVersion().length() > 0; } public boolean storedInGroupDirectory() { return metadata.getArtifactId().length() <= 0; } public String getGroupId() { return nullify( metadata.getGroupId() ); } public String getArtifactId() { return nullify( metadata.getArtifactId() ); } public String getBaseVersion() { return nullify( metadata.getVersion() ); } private String nullify( String str ) { return ( str == null || str.length() <= 0 ) ? null : str; } public Object getKey() { return metadata.toString(); } public String getRemoteFilename() { return metadata.getType(); } public String getLocalFilename( ArtifactRepository repository ) { return insertRepositoryKey( getRemoteFilename(), repository.getKey() ); } private String insertRepositoryKey( String filename, String repositoryKey ) { String result; int idx = filename.indexOf( '.' ); if ( idx < 0 ) { result = filename + '-' + repositoryKey; } else { result = filename.substring( 0, idx ) + '-' + repositoryKey + filename.substring( idx ); } return result; } public void merge( org.apache.maven.repository.legacy.metadata.ArtifactMetadata metadata ) { // not used } public void merge( ArtifactMetadata metadata ) { // not used } public void storeInLocalRepository( ArtifactRepository localRepository, ArtifactRepository remoteRepository ) throws RepositoryMetadataStoreException { // not used } public String extendedToString() { return metadata.toString(); } } static class ArtifactRepositoryAdapter implements ArtifactRepository { private final RemoteRepository repository; public ArtifactRepositoryAdapter( RemoteRepository repository ) { this.repository = repository; } public String pathOf( org.apache.maven.artifact.Artifact artifact ) { return null; } public String pathOfRemoteRepositoryMetadata( ArtifactMetadata artifactMetadata ) { return null; } public String pathOfLocalRepositoryMetadata( ArtifactMetadata metadata, ArtifactRepository repository ) { return null; } public String getUrl() { return repository.getUrl(); } public void setUrl( String url ) { } public String getBasedir() { return null; } public String getProtocol() { return repository.getProtocol(); } public String getId() { return repository.getId(); } public void setId( String id ) { } public ArtifactRepositoryPolicy getSnapshots() { return null; } public void setSnapshotUpdatePolicy( ArtifactRepositoryPolicy policy ) { } public ArtifactRepositoryPolicy getReleases() { return null; } public void setReleaseUpdatePolicy( ArtifactRepositoryPolicy policy ) { } public ArtifactRepositoryLayout getLayout() { return null; } public void setLayout( ArtifactRepositoryLayout layout ) { } public String getKey() { return getId(); } public boolean isUniqueVersion() { return true; } public boolean isBlacklisted() { return false; } public void setBlacklisted( boolean blackListed ) { } public org.apache.maven.artifact.Artifact find( org.apache.maven.artifact.Artifact artifact ) { return null; } public List findVersions( org.apache.maven.artifact.Artifact artifact ) { return Collections.emptyList(); } public boolean isProjectAware() { return false; } public void setAuthentication( Authentication authentication ) { } public Authentication getAuthentication() { return null; } public void setProxy( Proxy proxy ) { } public Proxy getProxy() { return null; } public List getMirroredRepositories() { return Collections.emptyList(); } public void setMirroredRepositories( List mirroredRepositories ) { } } } MavenArtifactRepository.java000066400000000000000000000260331317160430700351730ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/artifact/repositorypackage org.apache.maven.artifact.repository; /* * 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.File; import java.util.Collections; import java.util.List; import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.metadata.ArtifactMetadata; import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout; import org.apache.maven.repository.Proxy; //TODO completely separate local and remote artifact repositories public class MavenArtifactRepository implements ArtifactRepository { private String id; private String url; private String basedir; private String protocol; private ArtifactRepositoryLayout layout; private ArtifactRepositoryPolicy snapshots; private ArtifactRepositoryPolicy releases; private Authentication authentication; private Proxy proxy; private List mirroredRepositories = Collections.emptyList(); public MavenArtifactRepository() { } /** * Create a remote download repository. * * @param id the unique identifier of the repository * @param url the URL of the repository * @param layout the layout of the repository * @param snapshots the policies to use for snapshots * @param releases the policies to use for releases */ public MavenArtifactRepository( String id, String url, ArtifactRepositoryLayout layout, ArtifactRepositoryPolicy snapshots, ArtifactRepositoryPolicy releases ) { this.id = id; this.url = url; this.layout = layout; this.snapshots = snapshots; this.releases = releases; // // Derive these from the URL // this.protocol = protocol( url ); this.basedir = basedir( url ); } public String pathOf( Artifact artifact ) { return layout.pathOf( artifact ); } public String pathOfRemoteRepositoryMetadata( ArtifactMetadata artifactMetadata ) { return layout.pathOfRemoteRepositoryMetadata( artifactMetadata ); } public String pathOfLocalRepositoryMetadata( ArtifactMetadata metadata, ArtifactRepository repository ) { return layout.pathOfLocalRepositoryMetadata( metadata, repository ); } public void setLayout( ArtifactRepositoryLayout layout ) { this.layout = layout; } public ArtifactRepositoryLayout getLayout() { return layout; } public void setSnapshotUpdatePolicy( ArtifactRepositoryPolicy snapshots ) { this.snapshots = snapshots; } public ArtifactRepositoryPolicy getSnapshots() { return snapshots; } public void setReleaseUpdatePolicy( ArtifactRepositoryPolicy releases ) { this.releases = releases; } public ArtifactRepositoryPolicy getReleases() { return releases; } public String getKey() { return getId(); } public String toString() { StringBuilder sb = new StringBuilder( 256 ); sb.append( " id: " ).append( getId() ).append( '\n' ); sb.append( " url: " ).append( getUrl() ).append( '\n' ); sb.append( " layout: " ).append( layout != null ? layout : "none" ).append( '\n' ); if ( proxy != null ) { sb.append( " proxy: " ).append( proxy.getHost() ).append( ':' ).append( proxy.getPort() ).append( '\n' ); } if ( snapshots != null ) { sb.append( "snapshots: [enabled => " ).append( snapshots.isEnabled() ); sb.append( ", update => " ).append( snapshots.getUpdatePolicy() ).append( "]\n" ); } if ( releases != null ) { sb.append( " releases: [enabled => " ).append( releases.isEnabled() ); sb.append( ", update => " ).append( releases.getUpdatePolicy() ).append( "]\n" ); } return sb.toString(); } public Artifact find( Artifact artifact ) { File artifactFile = new File( getBasedir(), pathOf( artifact ) ); // We need to set the file here or the resolver will fail with an NPE, not fully equipped to deal // with multiple local repository implementations yet. artifact.setFile( artifactFile ); return artifact; } public List findVersions( Artifact artifact ) { return Collections.emptyList(); } public String getId() { return id; } public String getUrl() { return url; } public String getBasedir() { return basedir; } public String getProtocol() { return protocol; } public void setId( String id ) { this.id = id; } public void setUrl( String url ) { this.url = url; this.protocol = protocol( url ); this.basedir = basedir( url ); } // Path Utils /** * Return the protocol name. *
* E.g: for input * http://www.codehaus.org this method will return http * * @param url the url * @return the host name */ private static String protocol( final String url ) { final int pos = url.indexOf( ':' ); if ( pos == -1 ) { return ""; } return url.substring( 0, pos ).trim(); } /** * Derive the path portion of the given URL. * * @param url the repository URL * @return the basedir of the repository * TODO need to URL decode for spaces? */ private String basedir( String url ) { String retValue = null; if ( protocol.equalsIgnoreCase( "file" ) ) { retValue = url.substring( protocol.length() + 1 ); retValue = decode( retValue ); // special case: if omitted // on protocol, keep path as is if ( retValue.startsWith( "//" ) ) { retValue = retValue.substring( 2 ); if ( retValue.length() >= 2 && ( retValue.charAt( 1 ) == '|' || retValue.charAt( 1 ) == ':' ) ) { // special case: if there is a windows drive letter, then keep the original return value retValue = retValue.charAt( 0 ) + ":" + retValue.substring( 2 ); } else { // Now we expect the host int index = retValue.indexOf( '/' ); if ( index >= 0 ) { retValue = retValue.substring( index + 1 ); } // special case: if there is a windows drive letter, then keep the original return value if ( retValue.length() >= 2 && ( retValue.charAt( 1 ) == '|' || retValue.charAt( 1 ) == ':' ) ) { retValue = retValue.charAt( 0 ) + ":" + retValue.substring( 2 ); } else if ( index >= 0 ) { // leading / was previously stripped retValue = "/" + retValue; } } } // special case: if there is a windows drive letter using |, switch to : if ( retValue.length() >= 2 && retValue.charAt( 1 ) == '|' ) { retValue = retValue.charAt( 0 ) + ":" + retValue.substring( 2 ); } // normalize separators retValue = new File( retValue ).getPath(); } if ( retValue == null ) { retValue = "/"; } return retValue.trim(); } /** * Decodes the specified (portion of a) URL. Note: This decoder assumes that ISO-8859-1 is used to * convert URL-encoded bytes to characters. * * @param url The URL to decode, may be null. * @return The decoded URL or null if the input was null. */ private static String decode( String url ) { String decoded = url; if ( url != null ) { int pos = -1; while ( ( pos = decoded.indexOf( '%', pos + 1 ) ) >= 0 ) { if ( pos + 2 < decoded.length() ) { String hexStr = decoded.substring( pos + 1, pos + 3 ); char ch = (char) Integer.parseInt( hexStr, 16 ); decoded = decoded.substring( 0, pos ) + ch + decoded.substring( pos + 3 ); } } } return decoded; } public int hashCode() { final int prime = 31; int result = 1; result = prime * result + ( ( getId() == null ) ? 0 : getId().hashCode() ); return result; } public boolean equals( Object obj ) { if ( this == obj ) { return true; } if ( obj == null ) { return false; } if ( getClass() != obj.getClass() ) { return false; } ArtifactRepository other = (ArtifactRepository) obj; return eq( getId(), other.getId() ); } protected static boolean eq( T s1, T s2 ) { return s1 != null ? s1.equals( s2 ) : s2 == null; } public Authentication getAuthentication() { return authentication; } public void setAuthentication( Authentication authentication ) { this.authentication = authentication; } public Proxy getProxy() { return proxy; } public void setProxy( Proxy proxy ) { this.proxy = proxy; } public boolean isBlacklisted() { return false; } public void setBlacklisted( boolean blackListed ) { // no op } public boolean isUniqueVersion() { return true; } public boolean isProjectAware() { return false; } public List getMirroredRepositories() { return mirroredRepositories; } public void setMirroredRepositories( List mirroredRepositories ) { if ( mirroredRepositories != null ) { this.mirroredRepositories = mirroredRepositories; } else { this.mirroredRepositories = Collections.emptyList(); } } } maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/artifact/repository/RepositoryCache.java000066400000000000000000000051311317160430700335250ustar00rootroot00000000000000package org.apache.maven.artifact.repository; /* * 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. */ /** * Caches auxiliary data used during repository access like already processed metadata. The data in the cache is meant * for exclusive consumption by the repository system and is opaque to the cache implementation. * * @author Benjamin Bentmann */ @Deprecated // // Used by Tycho and will break users and force them to upgrade to Maven 3.1 so we should really leave // this here, possibly indefinitely. // public interface RepositoryCache { /** * Puts the specified data into the cache. Warning: The cache will directly save the provided * reference. If the cached data is mutable, i.e. could be modified after being put into the cache, the caller is * responsible for creating a copy of the original data and store the copy in the cache. * * @param request The repository request from which this cache was retrieved, must not be {@code null}. * @param key The key to use associate the data with, must not be {@code null}. * @param data The data to store in the cache, may be {@code null}. */ void put( RepositoryRequest request, Object key, Object data ); /** * Gets the specified data from the cache. Warning: The cache will directly return the saved * reference. If the cached data is to be modified after its retrieval, the caller is responsible to create a copy * of the returned data and use this instead of the cache record. * * @param request The repository request from which this cache was retrieved, must not be {@code null}. * @param key The key to use for lookup of the data, must not be {@code null}. * @return The requested data or {@code null} if none was present in the cache. */ Object get( RepositoryRequest request, Object key ); } RepositoryRequest.java000066400000000000000000000062011317160430700340720ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/artifact/repositorypackage org.apache.maven.artifact.repository; /* * 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.util.List; /** * Collects basic settings to access the repository system. * * @author Benjamin Bentmann */ public interface RepositoryRequest { /** * Indicates whether network access to remote repositories has been disabled. * * @return {@code true} if remote access has been disabled, {@code false} otherwise. */ boolean isOffline(); /** * Enables/disables network access to remote repositories. * * @param offline {@code true} to disable remote access, {@code false} to allow network access. * @return This request, never {@code null}. */ RepositoryRequest setOffline( boolean offline ); /** * Indicates whether remote repositories should be re-checked for updated artifacts/metadata regardless of their * configured update policy. * * @return {@code true} if remote repositories should be re-checked for updated artifacts/metadata, {@code false} * otherwise. */ boolean isForceUpdate(); /** * Enables/disabled forced checks for updated artifacts/metadata on remote repositories. * * @param forceUpdate {@code true} to forcibly check the remote repositories for updated artifacts/metadata, {@code * false} to use the update policy configured on each repository. * @return This request, never {@code null}. */ RepositoryRequest setForceUpdate( boolean forceUpdate ); /** * Gets the local repository to use. * * @return The local repository to use or {@code null} if not set. */ ArtifactRepository getLocalRepository(); /** * Sets the local repository to use. * * @param localRepository The local repository to use. * @return This request, never {@code null}. */ RepositoryRequest setLocalRepository( ArtifactRepository localRepository ); /** * Gets the remote repositories to use. * * @return The remote repositories to use, never {@code null}. */ List getRemoteRepositories(); /** * Sets the remote repositories to use. * * @param remoteRepositories The remote repositories to use. * @return This request, never {@code null}. */ RepositoryRequest setRemoteRepositories( List remoteRepositories ); } maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/artifact/repository/layout/000077500000000000000000000000001317160430700310745ustar00rootroot00000000000000DefaultRepositoryLayout.java000066400000000000000000000072741317160430700365540ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/artifact/repository/layoutpackage org.apache.maven.artifact.repository.layout; /* * 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 org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.handler.ArtifactHandler; import org.apache.maven.artifact.metadata.ArtifactMetadata; import org.apache.maven.artifact.repository.ArtifactRepository; import org.codehaus.plexus.component.annotations.Component; /** * @author jdcasey */ @Component( role = ArtifactRepositoryLayout.class, hint = "default" ) public class DefaultRepositoryLayout implements ArtifactRepositoryLayout { private static final char PATH_SEPARATOR = '/'; private static final char GROUP_SEPARATOR = '.'; private static final char ARTIFACT_SEPARATOR = '-'; public String getId() { return "default"; } public String pathOf( Artifact artifact ) { ArtifactHandler artifactHandler = artifact.getArtifactHandler(); StringBuilder path = new StringBuilder( 128 ); path.append( formatAsDirectory( artifact.getGroupId() ) ).append( PATH_SEPARATOR ); path.append( artifact.getArtifactId() ).append( PATH_SEPARATOR ); path.append( artifact.getBaseVersion() ).append( PATH_SEPARATOR ); path.append( artifact.getArtifactId() ).append( ARTIFACT_SEPARATOR ).append( artifact.getVersion() ); if ( artifact.hasClassifier() ) { path.append( ARTIFACT_SEPARATOR ).append( artifact.getClassifier() ); } if ( artifactHandler.getExtension() != null && artifactHandler.getExtension().length() > 0 ) { path.append( GROUP_SEPARATOR ).append( artifactHandler.getExtension() ); } return path.toString(); } public String pathOfLocalRepositoryMetadata( ArtifactMetadata metadata, ArtifactRepository repository ) { return pathOfRepositoryMetadata( metadata, metadata.getLocalFilename( repository ) ); } private String pathOfRepositoryMetadata( ArtifactMetadata metadata, String filename ) { StringBuilder path = new StringBuilder( 128 ); path.append( formatAsDirectory( metadata.getGroupId() ) ).append( PATH_SEPARATOR ); if ( !metadata.storedInGroupDirectory() ) { path.append( metadata.getArtifactId() ).append( PATH_SEPARATOR ); if ( metadata.storedInArtifactVersionDirectory() ) { path.append( metadata.getBaseVersion() ).append( PATH_SEPARATOR ); } } path.append( filename ); return path.toString(); } public String pathOfRemoteRepositoryMetadata( ArtifactMetadata metadata ) { return pathOfRepositoryMetadata( metadata, metadata.getRemoteFilename() ); } private String formatAsDirectory( String directory ) { return directory.replace( GROUP_SEPARATOR, PATH_SEPARATOR ); } @Override public String toString() { return getId(); } } maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/artifact/repository/metadata/000077500000000000000000000000001317160430700313375ustar00rootroot00000000000000AbstractRepositoryMetadata.java000066400000000000000000000171501317160430700374330ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/artifact/repository/metadatapackage org.apache.maven.artifact.repository.metadata; /* * 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 org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.metadata.ArtifactMetadata; import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.repository.ArtifactRepositoryPolicy; import org.apache.maven.artifact.repository.metadata.io.xpp3.MetadataXpp3Reader; import org.apache.maven.artifact.repository.metadata.io.xpp3.MetadataXpp3Writer; import org.codehaus.plexus.util.ReaderFactory; import org.codehaus.plexus.util.WriterFactory; import org.codehaus.plexus.util.xml.pull.XmlPullParserException; import java.io.File; import java.io.IOException; import java.io.Reader; import java.io.Writer; /** * Shared methods of the repository metadata handling. * * @author Brett Porter */ public abstract class AbstractRepositoryMetadata implements RepositoryMetadata { private Metadata metadata; protected AbstractRepositoryMetadata( Metadata metadata ) { this.metadata = metadata; } public String getRemoteFilename() { return "maven-metadata.xml"; } public String getLocalFilename( ArtifactRepository repository ) { return "maven-metadata-" + repository.getKey() + ".xml"; } public void storeInLocalRepository( ArtifactRepository localRepository, ArtifactRepository remoteRepository ) throws RepositoryMetadataStoreException { try { updateRepositoryMetadata( localRepository, remoteRepository ); } catch ( IOException | XmlPullParserException e ) { throw new RepositoryMetadataStoreException( "Error updating group repository metadata", e ); } } protected void updateRepositoryMetadata( ArtifactRepository localRepository, ArtifactRepository remoteRepository ) throws IOException, XmlPullParserException { MetadataXpp3Reader mappingReader = new MetadataXpp3Reader(); Metadata metadata = null; File metadataFile = new File( localRepository.getBasedir(), localRepository.pathOfLocalRepositoryMetadata( this, remoteRepository ) ); if ( metadataFile.length() == 0 ) { if ( !metadataFile.delete() ) { // sleep for 10ms just in case this is windows holding a file lock try { Thread.sleep( 10 ); } catch ( InterruptedException e ) { // ignore } metadataFile.delete(); // if this fails, forget about it, we'll try to overwrite it anyway so no need // to delete on exit } } else if ( metadataFile.exists() ) { try ( Reader reader = ReaderFactory.newXmlReader( metadataFile ) ) { metadata = mappingReader.read( reader, false ); } } boolean changed; // If file could not be found or was not valid, start from scratch if ( metadata == null ) { metadata = this.metadata; changed = true; } else { changed = metadata.merge( this.metadata ); } // beware meta-versions! String version = metadata.getVersion(); if ( version != null && ( Artifact.LATEST_VERSION.equals( version ) || Artifact.RELEASE_VERSION.equals( version ) ) ) { // meta-versions are not valid values...don't write them. metadata.setVersion( null ); } if ( changed || !metadataFile.exists() ) { metadataFile.getParentFile().mkdirs(); try ( Writer writer = WriterFactory.newXmlWriter( metadataFile ) ) { MetadataXpp3Writer mappingWriter = new MetadataXpp3Writer(); mappingWriter.write( writer, metadata ); } } else { metadataFile.setLastModified( System.currentTimeMillis() ); } } public String toString() { return "repository metadata for: \'" + getKey() + "\'"; } protected static Metadata createMetadata( Artifact artifact, Versioning versioning ) { Metadata metadata = new Metadata(); metadata.setGroupId( artifact.getGroupId() ); metadata.setArtifactId( artifact.getArtifactId() ); metadata.setVersion( artifact.getVersion() ); metadata.setVersioning( versioning ); return metadata; } protected static Versioning createVersioning( Snapshot snapshot ) { Versioning versioning = new Versioning(); versioning.setSnapshot( snapshot ); versioning.updateTimestamp(); return versioning; } public void setMetadata( Metadata metadata ) { this.metadata = metadata; } public Metadata getMetadata() { return metadata; } public void merge( org.apache.maven.repository.legacy.metadata.ArtifactMetadata metadata ) { // TODO not sure that it should assume this, maybe the calls to addMetadata should pre-merge, then artifact // replaces? AbstractRepositoryMetadata repoMetadata = (AbstractRepositoryMetadata) metadata; this.metadata.merge( repoMetadata.getMetadata() ); } public void merge( ArtifactMetadata metadata ) { // TODO not sure that it should assume this, maybe the calls to addMetadata should pre-merge, then artifact // replaces? AbstractRepositoryMetadata repoMetadata = (AbstractRepositoryMetadata) metadata; this.metadata.merge( repoMetadata.getMetadata() ); } public String extendedToString() { StringBuilder buffer = new StringBuilder( 256 ); buffer.append( "\nRepository Metadata\n--------------------------" ); buffer.append( "\nGroupId: " ).append( getGroupId() ); buffer.append( "\nArtifactId: " ).append( getArtifactId() ); buffer.append( "\nMetadata Type: " ).append( getClass().getName() ); return buffer.toString(); } public int getNature() { return RELEASE; } public ArtifactRepositoryPolicy getPolicy( ArtifactRepository repository ) { int nature = getNature(); if ( ( nature & RepositoryMetadata.RELEASE_OR_SNAPSHOT ) == RepositoryMetadata.RELEASE_OR_SNAPSHOT ) { ArtifactRepositoryPolicy policy = new ArtifactRepositoryPolicy( repository.getReleases() ); policy.merge( repository.getSnapshots() ); return policy; } else if ( ( nature & RepositoryMetadata.SNAPSHOT ) != 0 ) { return repository.getSnapshots(); } else { return repository.getReleases(); } } } ArtifactRepositoryMetadata.java000066400000000000000000000073311317160430700374250ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/artifact/repository/metadatapackage org.apache.maven.artifact.repository.metadata; /* * 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 org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.ArtifactUtils; import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.versioning.ArtifactVersion; import org.apache.maven.artifact.versioning.Restriction; import org.apache.maven.artifact.versioning.VersionRange; /** * Metadata for the artifact directory of the repository. * * @author Brett Porter */ public class ArtifactRepositoryMetadata extends AbstractRepositoryMetadata { private Artifact artifact; public ArtifactRepositoryMetadata( Artifact artifact ) { this( artifact, null ); } public ArtifactRepositoryMetadata( Artifact artifact, Versioning versioning ) { super( createMetadata( artifact, versioning ) ); this.artifact = artifact; } public boolean storedInGroupDirectory() { return false; } public boolean storedInArtifactVersionDirectory() { return false; } public String getGroupId() { return artifact.getGroupId(); } public String getArtifactId() { return artifact.getArtifactId(); } public String getBaseVersion() { // Don't want the artifact's version in here, as this is stored in the directory above that return null; } public Object getKey() { return "artifact " + artifact.getGroupId() + ":" + artifact.getArtifactId(); } public boolean isSnapshot() { // Don't consider the artifact's version in here, as this is stored in the directory above that return false; } public int getNature() { if ( artifact.getVersion() != null ) { return artifact.isSnapshot() ? SNAPSHOT : RELEASE; } VersionRange range = artifact.getVersionRange(); if ( range != null ) { for ( Restriction restriction : range.getRestrictions() ) { if ( isSnapshot( restriction.getLowerBound() ) || isSnapshot( restriction.getUpperBound() ) ) { return RELEASE_OR_SNAPSHOT; } } } return RELEASE; } private boolean isSnapshot( ArtifactVersion version ) { return version != null && ArtifactUtils.isSnapshot( version.getQualifier() ); } public ArtifactRepository getRepository() { return null; } public void setRepository( ArtifactRepository remoteRepository ) { /* * NOTE: Metadata at the g:a level contains a collection of available versions. After merging, we can't tell * which repository provides which version so the metadata manager must not restrict the artifact resolution to * the repository with the most recent updates. */ } } RepositoryMetadata.java000066400000000000000000000052641317160430700357520ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/artifact/repository/metadatapackage org.apache.maven.artifact.repository.metadata; /* * 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 org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.repository.ArtifactRepositoryPolicy; /** * Describes repository directory metadata. * * @author Brett Porter * TODO not happy about the store method - they use "this" */ public interface RepositoryMetadata extends org.apache.maven.artifact.metadata.ArtifactMetadata { int RELEASE = 1; int SNAPSHOT = 2; int RELEASE_OR_SNAPSHOT = RELEASE | SNAPSHOT; /** * Get the repository the metadata was located in. * * @return the repository */ ArtifactRepository getRepository(); /** * Set the repository the metadata was located in. * * @param remoteRepository the repository */ void setRepository( ArtifactRepository remoteRepository ); /** * Get the repository metadata associated with this marker. * * @return the metadata, or null if none loaded */ Metadata getMetadata(); /** * Set the metadata contents. * * @param metadata the metadata */ void setMetadata( Metadata metadata ); /** * Whether this represents a snapshot. * * @return if it is a snapshot */ boolean isSnapshot(); /** * Gets the artifact quality this metadata refers to. One of {@link #RELEASE}, {@link #SNAPSHOT} or * {@link #RELEASE_OR_SNAPSHOT}. * * @return The artifact quality this metadata refers to. */ int getNature(); /** * Gets the policy that applies to this metadata regarding the specified repository. * * @param repository The repository for which to determine the policy, must not be {@code null}. * @return The policy, never {@code null}. */ ArtifactRepositoryPolicy getPolicy( ArtifactRepository repository ); } RepositoryMetadataDeploymentException.java000066400000000000000000000024711317160430700416670ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/artifact/repository/metadatapackage org.apache.maven.artifact.repository.metadata; /* * 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. */ /** * Error while deploying repository metadata. * * @author Brett Porter */ public class RepositoryMetadataDeploymentException extends Throwable { public RepositoryMetadataDeploymentException( String message ) { super( message ); } public RepositoryMetadataDeploymentException( String message, Exception e ) { super( message, e ); } } RepositoryMetadataInstallationException.java000066400000000000000000000025021317160430700422030ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/artifact/repository/metadatapackage org.apache.maven.artifact.repository.metadata; /* * 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. */ /** * Error while installing repository metadata. * * @author Brett Porter */ public class RepositoryMetadataInstallationException extends Throwable { public RepositoryMetadataInstallationException( String message ) { super( message ); } public RepositoryMetadataInstallationException( String message, Exception e ) { super( message, e ); } } RepositoryMetadataManager.java000066400000000000000000000046401317160430700372420ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/artifact/repository/metadatapackage org.apache.maven.artifact.repository.metadata; /* * 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.util.List; import org.apache.maven.artifact.metadata.ArtifactMetadata; import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.repository.RepositoryRequest; public interface RepositoryMetadataManager { void resolve( RepositoryMetadata repositoryMetadata, RepositoryRequest repositoryRequest ) throws RepositoryMetadataResolutionException; void resolve( RepositoryMetadata repositoryMetadata, List repositories, ArtifactRepository localRepository ) throws RepositoryMetadataResolutionException; void resolveAlways( RepositoryMetadata metadata, ArtifactRepository localRepository, ArtifactRepository remoteRepository ) throws RepositoryMetadataResolutionException; /** * Deploy metadata to the remote repository. * * @param metadata the metadata to deploy * @param localRepository the local repository to install to first * @param deploymentRepository the remote repository to deploy to */ void deploy( ArtifactMetadata metadata, ArtifactRepository localRepository, ArtifactRepository deploymentRepository ) throws RepositoryMetadataDeploymentException; /** * Install the metadata in the local repository. * * @param metadata the metadata * @param localRepository the local repository */ void install( ArtifactMetadata metadata, ArtifactRepository localRepository ) throws RepositoryMetadataInstallationException; } RepositoryMetadataResolutionException.java000066400000000000000000000025161317160430700417120ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/artifact/repository/metadatapackage org.apache.maven.artifact.repository.metadata; /* * 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. */ /** * Error while retrieving repository metadata from the repository. * * @author Brett Porter */ public class RepositoryMetadataResolutionException extends Exception { public RepositoryMetadataResolutionException( String message ) { super( message ); } public RepositoryMetadataResolutionException( String message, Exception e ) { super( message, e ); } } maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/artifact/repository/metadata/io/000077500000000000000000000000001317160430700317465ustar00rootroot00000000000000DefaultMetadataReader.java000066400000000000000000000057251317160430700367130ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/artifact/repository/metadata/iopackage org.apache.maven.artifact.repository.metadata.io; /* * 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.File; import java.io.IOException; import java.io.InputStream; import java.io.Reader; import java.util.Map; import org.apache.commons.lang3.Validate; import org.apache.maven.artifact.repository.metadata.Metadata; import org.apache.maven.artifact.repository.metadata.io.xpp3.MetadataXpp3Reader; import org.codehaus.plexus.component.annotations.Component; import org.codehaus.plexus.util.ReaderFactory; import org.codehaus.plexus.util.xml.pull.XmlPullParserException; /** * Handles deserialization of metadata from some kind of textual format like XML. * * @author Benjamin Bentmann */ @Component( role = MetadataReader.class ) public class DefaultMetadataReader implements MetadataReader { public Metadata read( File input, Map options ) throws IOException { Validate.notNull( input, "input cannot be null" ); Metadata metadata = read( ReaderFactory.newXmlReader( input ), options ); return metadata; } public Metadata read( Reader input, Map options ) throws IOException { Validate.notNull( input, "input cannot be null" ); try ( final Reader in = input ) { return new MetadataXpp3Reader().read( in, isStrict( options ) ); } catch ( XmlPullParserException e ) { throw new MetadataParseException( e.getMessage(), e.getLineNumber(), e.getColumnNumber(), e ); } } public Metadata read( InputStream input, Map options ) throws IOException { Validate.notNull( input, "input cannot be null" ); try ( final InputStream in = input ) { return new MetadataXpp3Reader().read( in, isStrict( options ) ); } catch ( XmlPullParserException e ) { throw new MetadataParseException( e.getMessage(), e.getLineNumber(), e.getColumnNumber(), e ); } } private boolean isStrict( Map options ) { Object value = ( options != null ) ? options.get( IS_STRICT ) : null; return value == null || Boolean.parseBoolean( value.toString() ); } } MetadataParseException.java000066400000000000000000000060721317160430700371310ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/artifact/repository/metadata/iopackage org.apache.maven.artifact.repository.metadata.io; /* * 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; /** * Signals a failure to parse the metadata due to invalid syntax (e.g. non-wellformed XML or unknown elements). * * @author Benjamin Bentmann */ public class MetadataParseException extends IOException { /** * The one-based index of the line containing the error. */ private final int lineNumber; /** * The one-based index of the column containing the error. */ private final int columnNumber; /** * Creates a new parser exception with the specified details. * * @param message The error message, may be {@code null}. * @param lineNumber The one-based index of the line containing the error or {@code -1} if unknown. * @param columnNumber The one-based index of the column containing the error or {@code -1} if unknown. */ public MetadataParseException( String message, int lineNumber, int columnNumber ) { super( message ); this.lineNumber = lineNumber; this.columnNumber = columnNumber; } /** * Creates a new parser exception with the specified details. * * @param message The error message, may be {@code null}. * @param lineNumber The one-based index of the line containing the error or {@code -1} if unknown. * @param columnNumber The one-based index of the column containing the error or {@code -1} if unknown. * @param cause The nested cause of this error, may be {@code null}. */ public MetadataParseException( String message, int lineNumber, int columnNumber, Throwable cause ) { super( message ); initCause( cause ); this.lineNumber = lineNumber; this.columnNumber = columnNumber; } /** * Gets the one-based index of the line containing the error. * * @return The one-based index of the line containing the error or a non-positive value if unknown. */ public int getLineNumber() { return lineNumber; } /** * Gets the one-based index of the column containing the error. * * @return The one-based index of the column containing the error or non-positive value if unknown. */ public int getColumnNumber() { return columnNumber; } } MetadataReader.java000066400000000000000000000066341317160430700354060ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/artifact/repository/metadata/iopackage org.apache.maven.artifact.repository.metadata.io; /* * 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.File; import java.io.IOException; import java.io.InputStream; import java.io.Reader; import java.util.Map; import org.apache.maven.artifact.repository.metadata.Metadata; /** * Handles deserialization of metadata from some kind of textual format like XML. * * @author Benjamin Bentmann */ public interface MetadataReader { /** * The key for the option to enable strict parsing. This option is of type {@link Boolean} and defaults to {@code * true}. If {@code false}, unknown elements will be ignored instead of causing a failure. */ String IS_STRICT = "org.apache.maven.artifact.repository.metadata.io.isStrict"; /** * Reads the metadata from the specified file. * * @param input The file to deserialize the metadata from, must not be {@code null}. * @param options The options to use for deserialization, may be {@code null} to use the default values. * @return The deserialized metadata, never {@code null}. * @throws IOException If the metadata could not be deserialized. * @throws MetadataParseException If the input format could not be parsed. */ Metadata read( File input, Map options ) throws IOException, MetadataParseException; /** * Reads the metadata from the specified character reader. The reader will be automatically closed before the method * returns. * * @param input The reader to deserialize the metadata from, must not be {@code null}. * @param options The options to use for deserialization, may be {@code null} to use the default values. * @return The deserialized metadata, never {@code null}. * @throws IOException If the metadata could not be deserialized. * @throws MetadataParseException If the input format could not be parsed. */ Metadata read( Reader input, Map options ) throws IOException, MetadataParseException; /** * Reads the metadata from the specified byte stream. The stream will be automatically closed before the method * returns. * * @param input The stream to deserialize the metadata from, must not be {@code null}. * @param options The options to use for deserialization, may be {@code null} to use the default values. * @return The deserialized metadata, never {@code null}. * @throws IOException If the metadata could not be deserialized. * @throws MetadataParseException If the input format could not be parsed. */ Metadata read( InputStream input, Map options ) throws IOException, MetadataParseException; } maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/artifact/resolver/000077500000000000000000000000001317160430700272015ustar00rootroot00000000000000ArtifactResolutionRequest.java000066400000000000000000000204411317160430700351600ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/artifact/resolverpackage org.apache.maven.artifact.resolver; /* * 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.util.ArrayList; import java.util.List; import java.util.Map; import java.util.Set; import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.repository.RepositoryCache; import org.apache.maven.artifact.repository.RepositoryRequest; import org.apache.maven.artifact.resolver.filter.ArtifactFilter; import org.apache.maven.settings.Mirror; import org.apache.maven.settings.Proxy; import org.apache.maven.settings.Server; /** * A resolution request allows you to either use an existing MavenProject, or a coordinate (gid:aid:version) * to process a POMs dependencies. * * @author Jason van Zyl */ public class ArtifactResolutionRequest implements RepositoryRequest { private Artifact artifact; // Needs to go away // These are really overrides now, projects defining dependencies for a plugin that override what is // specified in the plugin itself. private Set artifactDependencies; private ArtifactRepository localRepository; private List remoteRepositories; private ArtifactFilter collectionFilter; private ArtifactFilter resolutionFilter; // Needs to go away private List listeners = new ArrayList<>(); // This is like a filter but overrides all transitive versions private Map managedVersionMap; private boolean resolveRoot = true; private boolean resolveTransitively = false; private boolean offline; private boolean forceUpdate; private List servers; private List mirrors; private List proxies; public ArtifactResolutionRequest() { // nothing here } public ArtifactResolutionRequest( RepositoryRequest request ) { setLocalRepository( request.getLocalRepository() ); setRemoteRepositories( request.getRemoteRepositories() ); setOffline( request.isOffline() ); setForceUpdate( request.isForceUpdate() ); } public Artifact getArtifact() { return artifact; } public ArtifactResolutionRequest setArtifact( Artifact artifact ) { this.artifact = artifact; return this; } public ArtifactResolutionRequest setArtifactDependencies( Set artifactDependencies ) { this.artifactDependencies = artifactDependencies; return this; } public Set getArtifactDependencies() { return artifactDependencies; } public ArtifactRepository getLocalRepository() { return localRepository; } public ArtifactResolutionRequest setLocalRepository( ArtifactRepository localRepository ) { this.localRepository = localRepository; return this; } public List getRemoteRepositories() { return remoteRepositories; } public ArtifactResolutionRequest setRemoteRepositories( List remoteRepositories ) { this.remoteRepositories = remoteRepositories; return this; } /** * Gets the artifact filter that controls traversal of the dependency graph. * * @return The filter used to determine which of the artifacts in the dependency graph should be traversed or * {@code null} to collect all transitive dependencies. */ public ArtifactFilter getCollectionFilter() { return collectionFilter; } public ArtifactResolutionRequest setCollectionFilter( ArtifactFilter filter ) { this.collectionFilter = filter; return this; } /** * Gets the artifact filter that controls downloading of artifact files. This filter operates on those artifacts * that have been included by the {@link #getCollectionFilter()}. * * @return The filter used to determine which of the artifacts should have their files resolved or {@code null} to * resolve the files for all collected artifacts. */ public ArtifactFilter getResolutionFilter() { return resolutionFilter; } public ArtifactResolutionRequest setResolutionFilter( ArtifactFilter filter ) { this.resolutionFilter = filter; return this; } public List getListeners() { return listeners; } public ArtifactResolutionRequest setListeners( List listeners ) { this.listeners = listeners; return this; } public ArtifactResolutionRequest addListener( ResolutionListener listener ) { listeners.add( listener ); return this; } public Map getManagedVersionMap() { return managedVersionMap; } public ArtifactResolutionRequest setManagedVersionMap( Map managedVersionMap ) { this.managedVersionMap = managedVersionMap; return this; } public ArtifactResolutionRequest setResolveRoot( boolean resolveRoot ) { this.resolveRoot = resolveRoot; return this; } public boolean isResolveRoot() { return resolveRoot; } public ArtifactResolutionRequest setResolveTransitively( boolean resolveDependencies ) { this.resolveTransitively = resolveDependencies; return this; } public boolean isResolveTransitively() { return resolveTransitively; } public String toString() { StringBuilder sb = new StringBuilder() .append( "REQUEST: " ).append( "\n" ) .append( "artifact: " ).append( artifact ).append( "\n" ) .append( artifactDependencies ).append( "\n" ) .append( "localRepository: " ).append( localRepository ).append( "\n" ) .append( "remoteRepositories: " ).append( remoteRepositories ).append( "\n" ); return sb.toString(); } public boolean isOffline() { return offline; } public ArtifactResolutionRequest setOffline( boolean offline ) { this.offline = offline; return this; } public boolean isForceUpdate() { return forceUpdate; } public ArtifactResolutionRequest setForceUpdate( boolean forceUpdate ) { this.forceUpdate = forceUpdate; return this; } public ArtifactResolutionRequest setServers( List servers ) { this.servers = servers; return this; } public List getServers() { if ( servers == null ) { servers = new ArrayList<>(); } return servers; } public ArtifactResolutionRequest setMirrors( List mirrors ) { this.mirrors = mirrors; return this; } public List getMirrors() { if ( mirrors == null ) { mirrors = new ArrayList<>(); } return mirrors; } public ArtifactResolutionRequest setProxies( List proxies ) { this.proxies = proxies; return this; } public List getProxies() { if ( proxies == null ) { proxies = new ArrayList<>(); } return proxies; } // // Used by Tycho and will break users and force them to upgrade to Maven 3.1 so we should really leave // this here, possibly indefinitely. // public ArtifactResolutionRequest setCache( RepositoryCache cache ) { return this; } } ArtifactResolutionResult.java000066400000000000000000000237301317160430700350120ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/artifact/resolverpackage org.apache.maven.artifact.resolver; /* * 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.util.ArrayList; import java.util.Collections; import java.util.LinkedHashSet; import java.util.List; import java.util.Set; import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.versioning.OverConstrainedVersionException; /** * Specific problems during resolution that we want to account for: *
    *
  • missing metadata
  • *
  • version range violations
  • *
  • version circular dependencies
  • *
  • missing artifacts
  • *
  • network/transfer errors
  • *
  • file system errors: permissions
  • *
* * @author Jason van Zyl * TODO carlos: all these possible has*Exceptions and get*Exceptions methods make the clients too * complex requiring a long list of checks, need to create a parent/interface/encapsulation * for the types of exceptions */ public class ArtifactResolutionResult { private Artifact originatingArtifact; private List missingArtifacts; // Exceptions private List exceptions; private List versionRangeViolations; private List metadataResolutionExceptions; private List circularDependencyExceptions; private List errorArtifactExceptions; // file system errors private List repositories; private Set artifacts; private Set resolutionNodes; public Artifact getOriginatingArtifact() { return originatingArtifact; } public ArtifactResolutionResult setOriginatingArtifact( final Artifact originatingArtifact ) { this.originatingArtifact = originatingArtifact; return this; } public void addArtifact( Artifact artifact ) { if ( artifacts == null ) { artifacts = new LinkedHashSet<>(); } artifacts.add( artifact ); } public Set getArtifacts() { if ( artifacts == null ) { artifacts = new LinkedHashSet<>(); } return artifacts; } public void setArtifacts( Set artifacts ) { this.artifacts = artifacts; } public Set getArtifactResolutionNodes() { if ( resolutionNodes == null ) { resolutionNodes = new LinkedHashSet<>(); } return resolutionNodes; } public void setArtifactResolutionNodes( Set resolutionNodes ) { this.resolutionNodes = resolutionNodes; } public boolean hasMissingArtifacts() { return missingArtifacts != null && !missingArtifacts.isEmpty(); } public List getMissingArtifacts() { return missingArtifacts == null ? Collections.emptyList() : missingArtifacts; } public ArtifactResolutionResult addMissingArtifact( Artifact artifact ) { missingArtifacts = initList( missingArtifacts ); missingArtifacts.add( artifact ); return this; } public ArtifactResolutionResult setUnresolvedArtifacts( final List unresolvedArtifacts ) { this.missingArtifacts = unresolvedArtifacts; return this; } public boolean isSuccess() { return !( hasMissingArtifacts() || hasExceptions() ); } // ------------------------------------------------------------------------ // Exceptions // ------------------------------------------------------------------------ public boolean hasExceptions() { return exceptions != null && !exceptions.isEmpty(); } public List getExceptions() { return exceptions == null ? Collections.emptyList() : exceptions; } // ------------------------------------------------------------------------ // Version Range Violations // ------------------------------------------------------------------------ public boolean hasVersionRangeViolations() { return versionRangeViolations != null; } /** * TODO this needs to accept a {@link OverConstrainedVersionException} as returned by * {@link #getVersionRangeViolation(int)} but it's not used like that in * DefaultLegacyArtifactCollector */ public ArtifactResolutionResult addVersionRangeViolation( Exception e ) { versionRangeViolations = initList( versionRangeViolations ); versionRangeViolations.add( e ); exceptions = initList( exceptions ); exceptions.add( e ); return this; } public OverConstrainedVersionException getVersionRangeViolation( int i ) { return (OverConstrainedVersionException) versionRangeViolations.get( i ); } public List getVersionRangeViolations() { return versionRangeViolations == null ? Collections.emptyList() : versionRangeViolations; } // ------------------------------------------------------------------------ // Metadata Resolution Exceptions: ArtifactResolutionExceptions // ------------------------------------------------------------------------ public boolean hasMetadataResolutionExceptions() { return metadataResolutionExceptions != null; } public ArtifactResolutionResult addMetadataResolutionException( ArtifactResolutionException e ) { metadataResolutionExceptions = initList( metadataResolutionExceptions ); metadataResolutionExceptions.add( e ); exceptions = initList( exceptions ); exceptions.add( e ); return this; } public ArtifactResolutionException getMetadataResolutionException( int i ) { return metadataResolutionExceptions.get( i ); } public List getMetadataResolutionExceptions() { return metadataResolutionExceptions == null ? Collections.emptyList() : metadataResolutionExceptions; } // ------------------------------------------------------------------------ // ErrorArtifactExceptions: ArtifactResolutionExceptions // ------------------------------------------------------------------------ public boolean hasErrorArtifactExceptions() { return errorArtifactExceptions != null; } public ArtifactResolutionResult addErrorArtifactException( ArtifactResolutionException e ) { errorArtifactExceptions = initList( errorArtifactExceptions ); errorArtifactExceptions.add( e ); exceptions = initList( exceptions ); exceptions.add( e ); return this; } public List getErrorArtifactExceptions() { if ( errorArtifactExceptions == null ) { return Collections.emptyList(); } return errorArtifactExceptions; } // ------------------------------------------------------------------------ // Circular Dependency Exceptions // ------------------------------------------------------------------------ public boolean hasCircularDependencyExceptions() { return circularDependencyExceptions != null; } public ArtifactResolutionResult addCircularDependencyException( CyclicDependencyException e ) { circularDependencyExceptions = initList( circularDependencyExceptions ); circularDependencyExceptions.add( e ); exceptions = initList( exceptions ); exceptions.add( e ); return this; } public CyclicDependencyException getCircularDependencyException( int i ) { return circularDependencyExceptions.get( i ); } public List getCircularDependencyExceptions() { if ( circularDependencyExceptions == null ) { return Collections.emptyList(); } return circularDependencyExceptions; } // ------------------------------------------------------------------------ // Repositories // ------------------------------------------------------------------------ public List getRepositories() { if ( repositories == null ) { return Collections.emptyList(); } return repositories; } public ArtifactResolutionResult setRepositories( final List repositories ) { this.repositories = repositories; return this; } // // Internal // private List initList( final List l ) { if ( l == null ) { return new ArrayList<>(); } return l; } public String toString() { StringBuilder sb = new StringBuilder(); if ( artifacts != null ) { int i = 1; sb.append( "---------\n" ); sb.append( artifacts.size() ).append( '\n' ); for ( Artifact a : artifacts ) { sb.append( i ).append( ' ' ).append( a ).append( '\n' ); i++; } sb.append( "---------\n" ); } return sb.toString(); } } DefaultResolutionErrorHandler.java000066400000000000000000000055501317160430700357520ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/artifact/resolverpackage org.apache.maven.artifact.resolver; /* * 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.util.ArrayList; import java.util.Collection; import java.util.List; import org.codehaus.plexus.component.annotations.Component; /** * @author Benjamin Bentmann */ @Component( role = ResolutionErrorHandler.class ) public class DefaultResolutionErrorHandler implements ResolutionErrorHandler { public void throwErrors( ArtifactResolutionRequest request, ArtifactResolutionResult result ) throws ArtifactResolutionException { // Metadata cannot be found if ( result.hasMetadataResolutionExceptions() ) { throw result.getMetadataResolutionException( 0 ); } // Metadata cannot be retrieved // Cyclic Dependency Error if ( result.hasCircularDependencyExceptions() ) { throw result.getCircularDependencyException( 0 ); } // Version Range Violation if ( result.hasVersionRangeViolations() ) { throw result.getVersionRangeViolation( 0 ); } // Transfer Error if ( result.hasErrorArtifactExceptions() ) { throw result.getErrorArtifactExceptions().get( 0 ); } if ( result.hasMissingArtifacts() ) { throw new MultipleArtifactsNotFoundException( request.getArtifact(), toList( result.getArtifacts() ), result.getMissingArtifacts(), request.getRemoteRepositories() ); } // this should never happen since we checked all possible error sources before but better be sure if ( result.hasExceptions() ) { throw new ArtifactResolutionException( "Unknown error during artifact resolution, " + request + ", " + result.getExceptions(), request.getArtifact(), request.getRemoteRepositories() ); } } private static List toList( Collection items ) { return ( items != null ) ? new ArrayList<>( items ) : null; } } ResolutionErrorHandler.java000066400000000000000000000020601317160430700344360ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/artifact/resolverpackage org.apache.maven.artifact.resolver; /* * 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 Benjamin Bentmann */ public interface ResolutionErrorHandler { void throwErrors( ArtifactResolutionRequest request, ArtifactResolutionResult result ) throws ArtifactResolutionException; } ResolutionListener.java000066400000000000000000000063131317160430700336410ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/artifact/resolverpackage org.apache.maven.artifact.resolver; /* * 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 org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.versioning.VersionRange; /** * Listens to the resolution process and handles events. * * @author Brett Porter */ public interface ResolutionListener { String ROLE = ResolutionListener.class.getName(); int TEST_ARTIFACT = 1; int PROCESS_CHILDREN = 2; int FINISH_PROCESSING_CHILDREN = 3; int INCLUDE_ARTIFACT = 4; int OMIT_FOR_NEARER = 5; int UPDATE_SCOPE = 6; @Deprecated int MANAGE_ARTIFACT = 7; int OMIT_FOR_CYCLE = 8; /** * this event means that the artifactScope has NOT been updated to a farther node artifactScope because current * node is in the first level pom */ int UPDATE_SCOPE_CURRENT_POM = 9; int SELECT_VERSION_FROM_RANGE = 10; int RESTRICT_RANGE = 11; int MANAGE_ARTIFACT_VERSION = 12; int MANAGE_ARTIFACT_SCOPE = 13; int MANAGE_ARTIFACT_SYSTEM_PATH = 14; void testArtifact( Artifact node ); void startProcessChildren( Artifact artifact ); void endProcessChildren( Artifact artifact ); void includeArtifact( Artifact artifact ); void omitForNearer( Artifact omitted, Artifact kept ); void updateScope( Artifact artifact, String scope ); @Deprecated void manageArtifact( Artifact artifact, Artifact replacement ); // TODO Use the following two instead of manageArtifact // TODO Remove ResolutionListenerDM interface //void manageArtifactVersion( Artifact artifact, Artifact replacement ); //void manageArtifactScope( Artifact artifact, Artifact replacement ); void omitForCycle( Artifact artifact ); /** * This event means that the artifactScope has NOT been updated to a farther node artifactScope because current * node is in the first level pom * * @param artifact current node artifact, the one in the first level pom * @param ignoredScope artifactScope that was ignored because artifact was in first level pom */ void updateScopeCurrentPom( Artifact artifact, String ignoredScope ); void selectVersionFromRange( Artifact artifact ); void restrictRange( Artifact artifact, Artifact replacement, VersionRange newRange ); } maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/artifact/resolver/ResolutionNode.java000066400000000000000000000155231317160430700330230ustar00rootroot00000000000000package org.apache.maven.artifact.resolver; /* * 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.util.ArrayList; import java.util.Collections; import java.util.Iterator; import java.util.LinkedList; import java.util.List; import java.util.Set; import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.resolver.filter.ArtifactFilter; import org.apache.maven.artifact.versioning.ArtifactVersion; import org.apache.maven.artifact.versioning.OverConstrainedVersionException; public class ResolutionNode { private Artifact artifact; private List children; private final List parents; private final int depth; private final ResolutionNode parent; private final List remoteRepositories; private boolean active = true; private List trail; public ResolutionNode( Artifact artifact, List remoteRepositories ) { this.artifact = artifact; this.remoteRepositories = remoteRepositories; depth = 0; parents = Collections.emptyList(); parent = null; } public ResolutionNode( Artifact artifact, List remoteRepositories, ResolutionNode parent ) { this.artifact = artifact; this.remoteRepositories = remoteRepositories; depth = parent.depth + 1; parents = new ArrayList<>(); parents.addAll( parent.parents ); parents.add( parent.getKey() ); this.parent = parent; } public Artifact getArtifact() { return artifact; } public Object getKey() { return artifact.getDependencyConflictId(); } public void addDependencies( Set artifacts, List remoteRepositories, ArtifactFilter filter ) throws CyclicDependencyException, OverConstrainedVersionException { if ( artifacts != null && !artifacts.isEmpty() ) { children = new ArrayList<>( artifacts.size() ); for ( Artifact a : artifacts ) { if ( parents.contains( a.getDependencyConflictId() ) ) { a.setDependencyTrail( getDependencyTrail() ); throw new CyclicDependencyException( "A dependency has introduced a cycle", a ); } children.add( new ResolutionNode( a, remoteRepositories, this ) ); } } else { children = Collections.emptyList(); } trail = null; } /** * @return {@link List} < {@link String} > with artifact ids * @throws OverConstrainedVersionException */ public List getDependencyTrail() throws OverConstrainedVersionException { List trial = getTrail(); List ret = new ArrayList<>( trial.size() ); for ( Artifact artifact : trial ) { ret.add( artifact.getId() ); } return ret; } private List getTrail() throws OverConstrainedVersionException { if ( trail == null ) { List ids = new LinkedList<>(); ResolutionNode node = this; while ( node != null ) { Artifact artifact = node.getArtifact(); if ( artifact.getVersion() == null ) { // set the recommended version ArtifactVersion selected = artifact.getSelectedVersion(); // MNG-2123: null is a valid response to getSelectedVersion, don't // assume it won't ever be. if ( selected != null ) { artifact.selectVersion( selected.toString() ); } else { throw new OverConstrainedVersionException( "Unable to get a selected Version for " + artifact.getArtifactId(), artifact ); } } ids.add( 0, artifact ); node = node.parent; } trail = ids; } return trail; } public boolean isResolved() { return children != null; } /** * Test whether the node is direct or transitive dependency. */ public boolean isChildOfRootNode() { return parent != null && parent.parent == null; } public Iterator getChildrenIterator() { return children.iterator(); } public int getDepth() { return depth; } public List getRemoteRepositories() { return remoteRepositories; } public boolean isActive() { return active; } public void enable() { active = true; // TODO if it was null, we really need to go find them now... or is this taken care of by the ordering? if ( children != null ) { for ( ResolutionNode node : children ) { node.enable(); } } } public void disable() { active = false; if ( children != null ) { for ( ResolutionNode node : children ) { node.disable(); } } } public boolean filterTrail( ArtifactFilter filter ) throws OverConstrainedVersionException { boolean success = true; if ( filter != null ) { for ( Artifact artifact : getTrail() ) { if ( !filter.include( artifact ) ) { success = false; } } } return success; } @Override public String toString() { return artifact.toString() + " (" + depth + "; " + ( active ? "enabled" : "disabled" ) + ")"; } public void setArtifact( Artifact artifact ) { this.artifact = artifact; } } maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/artifact/resolver/filter/000077500000000000000000000000001317160430700304665ustar00rootroot00000000000000AbstractScopeArtifactFilter.java000066400000000000000000000057641317160430700366470ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/artifact/resolver/filterpackage org.apache.maven.artifact.resolver.filter; /* * 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 org.apache.maven.artifact.Artifact; /** * Filter to only retain objects in the given artifactScope or better. * * @author Brett Porter */ abstract class AbstractScopeArtifactFilter implements ArtifactFilter { private boolean compileScope; private boolean runtimeScope; private boolean testScope; private boolean providedScope; private boolean systemScope; void addScopeInternal( String scope ) { if ( Artifact.SCOPE_COMPILE.equals( scope ) ) { systemScope = true; providedScope = true; compileScope = true; } else if ( Artifact.SCOPE_RUNTIME.equals( scope ) ) { compileScope = true; runtimeScope = true; } else if ( Artifact.SCOPE_COMPILE_PLUS_RUNTIME.equals( scope ) ) { systemScope = true; providedScope = true; compileScope = true; runtimeScope = true; } else if ( Artifact.SCOPE_RUNTIME_PLUS_SYSTEM.equals( scope ) ) { systemScope = true; compileScope = true; runtimeScope = true; } else if ( Artifact.SCOPE_TEST.equals( scope ) ) { systemScope = true; providedScope = true; compileScope = true; runtimeScope = true; testScope = true; } } public boolean include( Artifact artifact ) { if ( Artifact.SCOPE_COMPILE.equals( artifact.getScope() ) ) { return compileScope; } else if ( Artifact.SCOPE_RUNTIME.equals( artifact.getScope() ) ) { return runtimeScope; } else if ( Artifact.SCOPE_TEST.equals( artifact.getScope() ) ) { return testScope; } else if ( Artifact.SCOPE_PROVIDED.equals( artifact.getScope() ) ) { return providedScope; } else if ( Artifact.SCOPE_SYSTEM.equals( artifact.getScope() ) ) { return systemScope; } else { return true; } } } AndArtifactFilter.java000066400000000000000000000047541317160430700346120ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/artifact/resolver/filterpackage org.apache.maven.artifact.resolver.filter; /* * 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.util.ArrayList; import java.util.Iterator; import java.util.LinkedHashSet; import java.util.List; import java.util.Set; import org.apache.maven.artifact.Artifact; /** * Apply multiple filters. * * @author Brett Porter */ public class AndArtifactFilter implements ArtifactFilter { private Set filters; public AndArtifactFilter() { this.filters = new LinkedHashSet<>(); } public AndArtifactFilter( List filters ) { this.filters = new LinkedHashSet<>( filters ); } public boolean include( Artifact artifact ) { boolean include = true; for ( Iterator i = filters.iterator(); i.hasNext() && include; ) { ArtifactFilter filter = i.next(); if ( !filter.include( artifact ) ) { include = false; } } return include; } public void add( ArtifactFilter artifactFilter ) { filters.add( artifactFilter ); } public List getFilters() { return new ArrayList<>( filters ); } @Override public int hashCode() { int hash = 17; hash = hash * 31 + filters.hashCode(); return hash; } @Override public boolean equals( Object obj ) { if ( this == obj ) { return true; } if ( !( obj instanceof AndArtifactFilter ) ) { return false; } AndArtifactFilter other = (AndArtifactFilter) obj; return filters.equals( other.filters ); } } CumulativeScopeArtifactFilter.java000066400000000000000000000063641317160430700372170ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/artifact/resolver/filterpackage org.apache.maven.artifact.resolver.filter; /* * 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.util.Collection; import java.util.HashSet; import java.util.Set; /** * Filter to only retain objects in the given scope or better. This implementation allows the accumulation of multiple * scopes and their associated implied scopes, so that the user can filter apply a series of implication rules in a * single step. This should be a more efficient implementation of multiple standard {@link ScopeArtifactFilter} * instances ORed together. * * @author Brett Porter * @author jdcasey */ public class CumulativeScopeArtifactFilter extends AbstractScopeArtifactFilter { private Set scopes; /** * Create a new filter with the specified scopes and their implied scopes enabled. * * @param scopes The scopes to enable, along with all implied scopes, may be {@code null}. */ public CumulativeScopeArtifactFilter( Collection scopes ) { this.scopes = new HashSet<>(); addScopes( scopes ); } /** * Creates a new filter that combines the specified filters. * * @param filters The filters to combine, may be {@code null}. */ public CumulativeScopeArtifactFilter( CumulativeScopeArtifactFilter... filters ) { this.scopes = new HashSet<>(); if ( filters != null ) { for ( CumulativeScopeArtifactFilter filter : filters ) { addScopes( filter.getScopes() ); } } } private void addScopes( Collection scopes ) { if ( scopes != null ) { for ( String scope : scopes ) { addScope( scope ); } } } private void addScope( String scope ) { this.scopes.add( scope ); addScopeInternal( scope ); } public Set getScopes() { return scopes; } @Override public int hashCode() { int hash = 17; hash = hash * 31 + scopes.hashCode(); return hash; } @Override public boolean equals( Object obj ) { if ( this == obj ) { return true; } if ( !( obj instanceof CumulativeScopeArtifactFilter ) ) { return false; } CumulativeScopeArtifactFilter that = (CumulativeScopeArtifactFilter) obj; return scopes.equals( that.scopes ); } } ExcludesArtifactFilter.java000066400000000000000000000025721317160430700356600ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/artifact/resolver/filterpackage org.apache.maven.artifact.resolver.filter; /* * 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.util.List; import org.apache.maven.artifact.Artifact; /** * Filter to exclude from a list of artifact patterns. * * @author Brett Porter * TODO I think this is equiv. to exclusion set filter in maven-core */ public class ExcludesArtifactFilter extends IncludesArtifactFilter { public ExcludesArtifactFilter( List patterns ) { super( patterns ); } public boolean include( Artifact artifact ) { return !super.include( artifact ); } } ExclusionSetFilter.java000066400000000000000000000041771317160430700350560ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/artifact/resolver/filterpackage org.apache.maven.artifact.resolver.filter; /* * 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.util.Arrays; import java.util.LinkedHashSet; import java.util.Set; import org.apache.maven.artifact.Artifact; /** * @author Jason van Zyl */ public class ExclusionSetFilter implements ArtifactFilter { private Set excludes; public ExclusionSetFilter( String[] excludes ) { this.excludes = new LinkedHashSet<>( Arrays.asList( excludes ) ); } public ExclusionSetFilter( Set excludes ) { this.excludes = excludes; } public boolean include( Artifact artifact ) { String id = artifact.getArtifactId(); if ( excludes.contains( id ) ) { return false; } id = artifact.getGroupId() + ':' + id; return !excludes.contains( id ); } @Override public int hashCode() { int hash = 17; hash = hash * 31 + excludes.hashCode(); return hash; } @Override public boolean equals( Object obj ) { if ( this == obj ) { return true; } if ( !( obj instanceof ExclusionSetFilter ) ) { return false; } ExclusionSetFilter other = (ExclusionSetFilter) obj; return excludes.equals( other.excludes ); } } IncludesArtifactFilter.java000066400000000000000000000050061317160430700356450ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/artifact/resolver/filterpackage org.apache.maven.artifact.resolver.filter; /* * 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.util.ArrayList; import java.util.Iterator; import java.util.LinkedHashSet; import java.util.List; import java.util.Set; import org.apache.maven.artifact.Artifact; /** * Filter to include from a list of artifact patterns. * * @author Brett Porter */ public class IncludesArtifactFilter implements ArtifactFilter { private final Set patterns; public IncludesArtifactFilter( List patterns ) { this.patterns = new LinkedHashSet<>( patterns ); } public boolean include( Artifact artifact ) { String id = artifact.getGroupId() + ":" + artifact.getArtifactId(); boolean matched = false; for ( Iterator i = patterns.iterator(); i.hasNext() & !matched; ) { // TODO what about wildcards? Just specifying groups? versions? if ( id.equals( i.next() ) ) { matched = true; } } return matched; } public List getPatterns() { return new ArrayList<>( patterns ); } @Override public int hashCode() { int hash = 17; hash = hash * 31 + patterns.hashCode(); return hash; } @Override public boolean equals( Object obj ) { if ( this == obj ) { return true; } // make sure IncludesArtifactFilter is not equal ExcludesArtifactFilter! if ( obj == null || getClass() != obj.getClass() ) { return false; } IncludesArtifactFilter other = (IncludesArtifactFilter) obj; return patterns.equals( other.patterns ); } } ScopeArtifactFilter.java000066400000000000000000000036451317160430700351570ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/artifact/resolver/filterpackage org.apache.maven.artifact.resolver.filter; /* * 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. */ /** * Filter to only retain objects in the given artifactScope or better. * * @author Brett Porter */ public class ScopeArtifactFilter extends AbstractScopeArtifactFilter { private final String scope; public ScopeArtifactFilter( String scope ) { this.scope = scope; addScopeInternal( scope ); } public String getScope() { return scope; } @Override public int hashCode() { int hash = 17; hash = hash * 31 + ( scope != null ? scope.hashCode() : 0 ); return hash; } @Override public boolean equals( Object obj ) { if ( this == obj ) { return true; } if ( !( obj instanceof ScopeArtifactFilter ) ) { return false; } ScopeArtifactFilter other = (ScopeArtifactFilter) obj; return equals( scope, other.scope ); } private static boolean equals( T str1, T str2 ) { return str1 != null ? str1.equals( str2 ) : str2 == null; } } maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/bridge/000077500000000000000000000000001317160430700247775ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/bridge/MavenRepositorySystem.java000066400000000000000000000723701317160430700322260ustar00rootroot00000000000000package org.apache.maven.bridge; /* * 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.File; import java.net.MalformedURLException; import java.net.URL; import java.util.ArrayList; import java.util.Collections; import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Set; import org.apache.maven.RepositoryUtils; import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.DefaultArtifact; import org.apache.maven.artifact.InvalidRepositoryException; import org.apache.maven.artifact.handler.ArtifactHandler; import org.apache.maven.artifact.handler.manager.ArtifactHandlerManager; import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.repository.ArtifactRepositoryPolicy; import org.apache.maven.artifact.repository.Authentication; import org.apache.maven.artifact.repository.MavenArtifactRepository; import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout; import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout2; import org.apache.maven.artifact.repository.layout.DefaultRepositoryLayout; import org.apache.maven.artifact.resolver.filter.ExcludesArtifactFilter; import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException; import org.apache.maven.artifact.versioning.VersionRange; import org.apache.maven.execution.MavenExecutionRequest; import org.apache.maven.model.Dependency; import org.apache.maven.model.Exclusion; import org.apache.maven.model.Plugin; import org.apache.maven.repository.Proxy; import org.apache.maven.repository.RepositorySystem; import org.apache.maven.settings.Mirror; import org.codehaus.plexus.component.annotations.Component; import org.codehaus.plexus.component.annotations.Requirement; import org.codehaus.plexus.util.StringUtils; import org.eclipse.aether.RepositorySystemSession; import org.eclipse.aether.repository.AuthenticationContext; import org.eclipse.aether.repository.AuthenticationSelector; import org.eclipse.aether.repository.ProxySelector; import org.eclipse.aether.repository.RemoteRepository; /** * @author Jason van Zyl */ @Component( role = MavenRepositorySystem.class, hint = "default" ) public class MavenRepositorySystem { @Requirement private ArtifactHandlerManager artifactHandlerManager; @Requirement( role = ArtifactRepositoryLayout.class ) private Map layouts; // DefaultProjectBuilder public Artifact createArtifact( String groupId, String artifactId, String version, String scope, String type ) { return XcreateArtifact( groupId, artifactId, version, scope, type ); } // DefaultProjectBuilder public Artifact createProjectArtifact( String groupId, String artifactId, String metaVersionId ) { return XcreateProjectArtifact( groupId, artifactId, metaVersionId ); } // DefaultProjectBuilder public Artifact createDependencyArtifact( Dependency d ) { if ( d.getVersion() == null ) { return null; } VersionRange versionRange; try { versionRange = VersionRange.createFromVersionSpec( d.getVersion() ); } catch ( InvalidVersionSpecificationException e ) { return null; } Artifact artifact = XcreateDependencyArtifact( d.getGroupId(), d.getArtifactId(), versionRange, d.getType(), d.getClassifier(), d.getScope(), d.isOptional() ); if ( Artifact.SCOPE_SYSTEM.equals( d.getScope() ) && d.getSystemPath() != null ) { artifact.setFile( new File( d.getSystemPath() ) ); } if ( !d.getExclusions().isEmpty() ) { List exclusions = new ArrayList<>(); for ( Exclusion exclusion : d.getExclusions() ) { exclusions.add( exclusion.getGroupId() + ':' + exclusion.getArtifactId() ); } artifact.setDependencyFilter( new ExcludesArtifactFilter( exclusions ) ); } return artifact; } // DefaultProjectBuilder public Artifact createExtensionArtifact( String groupId, String artifactId, String version ) { VersionRange versionRange; try { versionRange = VersionRange.createFromVersionSpec( version ); } catch ( InvalidVersionSpecificationException e ) { return null; } return XcreateExtensionArtifact( groupId, artifactId, versionRange ); } // DefaultProjectBuilder public Artifact createParentArtifact( String groupId, String artifactId, String version ) { return XcreateParentArtifact( groupId, artifactId, version ); } // DefaultProjectBuilder public Artifact createPluginArtifact( Plugin plugin ) { VersionRange versionRange; try { String version = plugin.getVersion(); if ( StringUtils.isEmpty( version ) ) { version = "RELEASE"; } versionRange = VersionRange.createFromVersionSpec( version ); } catch ( InvalidVersionSpecificationException e ) { return null; } return XcreatePluginArtifact( plugin.getGroupId(), plugin.getArtifactId(), versionRange ); } public void injectMirror( List repositories, List mirrors ) { if ( repositories != null && mirrors != null ) { for ( ArtifactRepository repository : repositories ) { Mirror mirror = getMirror( repository, mirrors ); injectMirror( repository, mirror ); } } } private Mirror getMirror( RepositorySystemSession session, ArtifactRepository repository ) { if ( session != null ) { org.eclipse.aether.repository.MirrorSelector selector = session.getMirrorSelector(); if ( selector != null ) { RemoteRepository repo = selector.getMirror( RepositoryUtils.toRepo( repository ) ); if ( repo != null ) { Mirror mirror = new Mirror(); mirror.setId( repo.getId() ); mirror.setUrl( repo.getUrl() ); mirror.setLayout( repo.getContentType() ); return mirror; } } } return null; } public void injectMirror( RepositorySystemSession session, List repositories ) { if ( repositories != null && session != null ) { for ( ArtifactRepository repository : repositories ) { Mirror mirror = getMirror( session, repository ); injectMirror( repository, mirror ); } } } private void injectMirror( ArtifactRepository repository, Mirror mirror ) { if ( mirror != null ) { ArtifactRepository original = createArtifactRepository( repository.getId(), repository.getUrl(), repository.getLayout(), repository.getSnapshots(), repository.getReleases() ); repository.setMirroredRepositories( Collections.singletonList( original ) ); repository.setId( mirror.getId() ); repository.setUrl( mirror.getUrl() ); if ( StringUtils.isNotEmpty( mirror.getLayout() ) ) { repository.setLayout( getLayout( mirror.getLayout() ) ); } } } private Authentication getAuthentication( RepositorySystemSession session, ArtifactRepository repository ) { if ( session != null ) { AuthenticationSelector selector = session.getAuthenticationSelector(); if ( selector != null ) { RemoteRepository repo = RepositoryUtils.toRepo( repository ); org.eclipse.aether.repository.Authentication auth = selector.getAuthentication( repo ); if ( auth != null ) { repo = new RemoteRepository.Builder( repo ).setAuthentication( auth ).build(); AuthenticationContext authCtx = AuthenticationContext.forRepository( session, repo ); Authentication result = new Authentication( authCtx.get( AuthenticationContext.USERNAME ), authCtx.get( AuthenticationContext.PASSWORD ) ); result.setPrivateKey( authCtx.get( AuthenticationContext.PRIVATE_KEY_PATH ) ); result.setPassphrase( authCtx.get( AuthenticationContext.PRIVATE_KEY_PASSPHRASE ) ); authCtx.close(); return result; } } } return null; } public void injectAuthentication( RepositorySystemSession session, List repositories ) { if ( repositories != null && session != null ) { for ( ArtifactRepository repository : repositories ) { repository.setAuthentication( getAuthentication( session, repository ) ); } } } private Proxy getProxy( RepositorySystemSession session, ArtifactRepository repository ) { if ( session != null ) { ProxySelector selector = session.getProxySelector(); if ( selector != null ) { RemoteRepository repo = RepositoryUtils.toRepo( repository ); org.eclipse.aether.repository.Proxy proxy = selector.getProxy( repo ); if ( proxy != null ) { Proxy p = new Proxy(); p.setHost( proxy.getHost() ); p.setProtocol( proxy.getType() ); p.setPort( proxy.getPort() ); if ( proxy.getAuthentication() != null ) { repo = new RemoteRepository.Builder( repo ).setProxy( proxy ).build(); AuthenticationContext authCtx = AuthenticationContext.forProxy( session, repo ); p.setUserName( authCtx.get( AuthenticationContext.USERNAME ) ); p.setPassword( authCtx.get( AuthenticationContext.PASSWORD ) ); p.setNtlmDomain( authCtx.get( AuthenticationContext.NTLM_DOMAIN ) ); p.setNtlmHost( authCtx.get( AuthenticationContext.NTLM_WORKSTATION ) ); authCtx.close(); } return p; } } } return null; } public void injectProxy( RepositorySystemSession session, List repositories ) { if ( repositories != null && session != null ) { for ( ArtifactRepository repository : repositories ) { repository.setProxy( getProxy( session, repository ) ); } } } private ArtifactRepositoryLayout getLayout( String id ) { ArtifactRepositoryLayout layout = layouts.get( id ); return layout; } // // Taken from LegacyRepositorySystem // public static org.apache.maven.model.Repository fromSettingsRepository( org.apache.maven.settings.Repository settingsRepository ) { org.apache.maven.model.Repository modelRepository = new org.apache.maven.model.Repository(); modelRepository.setId( settingsRepository.getId() ); modelRepository.setLayout( settingsRepository.getLayout() ); modelRepository.setName( settingsRepository.getName() ); modelRepository.setUrl( settingsRepository.getUrl() ); modelRepository.setReleases( fromSettingsRepositoryPolicy( settingsRepository.getReleases() ) ); modelRepository.setSnapshots( fromSettingsRepositoryPolicy( settingsRepository.getSnapshots() ) ); return modelRepository; } public static org.apache.maven.model.RepositoryPolicy fromSettingsRepositoryPolicy( org.apache.maven.settings.RepositoryPolicy settingsRepositoryPolicy ) { org.apache.maven.model.RepositoryPolicy modelRepositoryPolicy = new org.apache.maven.model.RepositoryPolicy(); if ( settingsRepositoryPolicy != null ) { modelRepositoryPolicy.setEnabled( settingsRepositoryPolicy.isEnabled() ); modelRepositoryPolicy.setUpdatePolicy( settingsRepositoryPolicy.getUpdatePolicy() ); modelRepositoryPolicy.setChecksumPolicy( settingsRepositoryPolicy.getChecksumPolicy() ); } return modelRepositoryPolicy; } public static ArtifactRepository buildArtifactRepository( org.apache.maven.settings.Repository repo ) throws InvalidRepositoryException { return buildArtifactRepository( fromSettingsRepository( repo ) ); } public static ArtifactRepository buildArtifactRepository( org.apache.maven.model.Repository repo ) throws InvalidRepositoryException { if ( repo != null ) { String id = repo.getId(); if ( StringUtils.isEmpty( id ) ) { throw new InvalidRepositoryException( "Repository identifier missing", "" ); } String url = repo.getUrl(); if ( StringUtils.isEmpty( url ) ) { throw new InvalidRepositoryException( "URL missing for repository " + id, id ); } ArtifactRepositoryPolicy snapshots = buildArtifactRepositoryPolicy( repo.getSnapshots() ); ArtifactRepositoryPolicy releases = buildArtifactRepositoryPolicy( repo.getReleases() ); ArtifactRepositoryLayout layout = new DefaultRepositoryLayout(); return createArtifactRepository( id, url, layout, snapshots, releases ); } else { return null; } } public static ArtifactRepositoryPolicy buildArtifactRepositoryPolicy( org.apache.maven.model.RepositoryPolicy policy ) { boolean enabled = true; String updatePolicy = null; String checksumPolicy = null; if ( policy != null ) { enabled = policy.isEnabled(); if ( policy.getUpdatePolicy() != null ) { updatePolicy = policy.getUpdatePolicy(); } if ( policy.getChecksumPolicy() != null ) { checksumPolicy = policy.getChecksumPolicy(); } } return new ArtifactRepositoryPolicy( enabled, updatePolicy, checksumPolicy ); } public ArtifactRepository createArtifactRepository( String id, String url, String layoutId, ArtifactRepositoryPolicy snapshots, ArtifactRepositoryPolicy releases ) throws Exception { ArtifactRepositoryLayout layout = layouts.get( layoutId ); checkLayout( id, layoutId, layout ); return createArtifactRepository( id, url, layout, snapshots, releases ); } private void checkLayout( String repositoryId, String layoutId, ArtifactRepositoryLayout layout ) throws Exception { if ( layout == null ) { throw new Exception( String.format( "Cannot find ArtifactRepositoryLayout instance for: %s %s", layoutId, repositoryId ) ); } } public static ArtifactRepository createArtifactRepository( String id, String url, ArtifactRepositoryLayout repositoryLayout, ArtifactRepositoryPolicy snapshots, ArtifactRepositoryPolicy releases ) { if ( snapshots == null ) { snapshots = new ArtifactRepositoryPolicy(); } if ( releases == null ) { releases = new ArtifactRepositoryPolicy(); } ArtifactRepository repository; if ( repositoryLayout instanceof ArtifactRepositoryLayout2 ) { repository = ( (ArtifactRepositoryLayout2) repositoryLayout ).newMavenArtifactRepository( id, url, snapshots, releases ); } else { repository = new MavenArtifactRepository( id, url, repositoryLayout, snapshots, releases ); } return repository; } // ArtifactFactory private Artifact XcreateArtifact( String groupId, String artifactId, String version, String scope, String type ) { return XcreateArtifact( groupId, artifactId, version, scope, type, null, null ); } private Artifact XcreateDependencyArtifact( String groupId, String artifactId, VersionRange versionRange, String type, String classifier, String scope, boolean optional ) { return XcreateArtifact( groupId, artifactId, versionRange, type, classifier, scope, null, optional ); } private Artifact XcreateProjectArtifact( String groupId, String artifactId, String version ) { return XcreateProjectArtifact( groupId, artifactId, version, null ); } private Artifact XcreateParentArtifact( String groupId, String artifactId, String version ) { return XcreateProjectArtifact( groupId, artifactId, version ); } private Artifact XcreatePluginArtifact( String groupId, String artifactId, VersionRange versionRange ) { return XcreateArtifact( groupId, artifactId, versionRange, "maven-plugin", null, Artifact.SCOPE_RUNTIME, null ); } private Artifact XcreateProjectArtifact( String groupId, String artifactId, String version, String scope ) { return XcreateArtifact( groupId, artifactId, version, scope, "pom" ); } private Artifact XcreateExtensionArtifact( String groupId, String artifactId, VersionRange versionRange ) { return XcreateArtifact( groupId, artifactId, versionRange, "jar", null, Artifact.SCOPE_RUNTIME, null ); } private Artifact XcreateArtifact( String groupId, String artifactId, String version, String scope, String type, String classifier, String inheritedScope ) { VersionRange versionRange = null; if ( version != null ) { versionRange = VersionRange.createFromVersion( version ); } return XcreateArtifact( groupId, artifactId, versionRange, type, classifier, scope, inheritedScope ); } private Artifact XcreateArtifact( String groupId, String artifactId, VersionRange versionRange, String type, String classifier, String scope, String inheritedScope ) { return XcreateArtifact( groupId, artifactId, versionRange, type, classifier, scope, inheritedScope, false ); } private Artifact XcreateArtifact( String groupId, String artifactId, VersionRange versionRange, String type, String classifier, String scope, String inheritedScope, boolean optional ) { String desiredScope = Artifact.SCOPE_RUNTIME; if ( inheritedScope == null ) { desiredScope = scope; } else if ( Artifact.SCOPE_TEST.equals( scope ) || Artifact.SCOPE_PROVIDED.equals( scope ) ) { return null; } else if ( Artifact.SCOPE_COMPILE.equals( scope ) && Artifact.SCOPE_COMPILE.equals( inheritedScope ) ) { // added to retain compile artifactScope. Remove if you want compile inherited as runtime desiredScope = Artifact.SCOPE_COMPILE; } if ( Artifact.SCOPE_TEST.equals( inheritedScope ) ) { desiredScope = Artifact.SCOPE_TEST; } if ( Artifact.SCOPE_PROVIDED.equals( inheritedScope ) ) { desiredScope = Artifact.SCOPE_PROVIDED; } if ( Artifact.SCOPE_SYSTEM.equals( scope ) ) { // system scopes come through unchanged... desiredScope = Artifact.SCOPE_SYSTEM; } ArtifactHandler handler = artifactHandlerManager.getArtifactHandler( type ); return new DefaultArtifact( groupId, artifactId, versionRange, desiredScope, type, classifier, handler, optional ); } // // Code taken from LegacyRepositorySystem // public ArtifactRepository createDefaultRemoteRepository( MavenExecutionRequest request ) throws Exception { return createRepository( RepositorySystem.DEFAULT_REMOTE_REPO_URL, RepositorySystem.DEFAULT_REMOTE_REPO_ID, true, ArtifactRepositoryPolicy.UPDATE_POLICY_DAILY, false, ArtifactRepositoryPolicy.UPDATE_POLICY_DAILY, ArtifactRepositoryPolicy.CHECKSUM_POLICY_WARN ); } public ArtifactRepository createRepository( String url, String repositoryId, boolean releases, String releaseUpdates, boolean snapshots, String snapshotUpdates, String checksumPolicy ) throws Exception { ArtifactRepositoryPolicy snapshotsPolicy = new ArtifactRepositoryPolicy( snapshots, snapshotUpdates, checksumPolicy ); ArtifactRepositoryPolicy releasesPolicy = new ArtifactRepositoryPolicy( releases, releaseUpdates, checksumPolicy ); return createArtifactRepository( repositoryId, url, "default", snapshotsPolicy, releasesPolicy ); } public Set getRepoIds( List repositories ) { Set repoIds = new HashSet<>(); if ( repositories != null ) { for ( ArtifactRepository repository : repositories ) { repoIds.add( repository.getId() ); } } return repoIds; } public ArtifactRepository createLocalRepository( MavenExecutionRequest request, File localRepository ) throws Exception { return createRepository( "file://" + localRepository.toURI().getRawPath(), RepositorySystem.DEFAULT_LOCAL_REPO_ID, true, ArtifactRepositoryPolicy.UPDATE_POLICY_ALWAYS, true, ArtifactRepositoryPolicy.UPDATE_POLICY_ALWAYS, ArtifactRepositoryPolicy.CHECKSUM_POLICY_IGNORE ); } private static final String WILDCARD = "*"; private static final String EXTERNAL_WILDCARD = "external:*"; public static Mirror getMirror( ArtifactRepository repository, List mirrors ) { String repoId = repository.getId(); if ( repoId != null && mirrors != null ) { for ( Mirror mirror : mirrors ) { if ( repoId.equals( mirror.getMirrorOf() ) && matchesLayout( repository, mirror ) ) { return mirror; } } for ( Mirror mirror : mirrors ) { if ( matchPattern( repository, mirror.getMirrorOf() ) && matchesLayout( repository, mirror ) ) { return mirror; } } } return null; } /** * This method checks if the pattern matches the originalRepository. Valid patterns: * = everything external:* = * everything not on the localhost and not file based. repo,repo1 = repo or repo1 *,!repo1 = everything except repo1 * * @param originalRepository to compare for a match. * @param pattern used for match. Currently only '*' is supported. * @return true if the repository is a match to this pattern. */ static boolean matchPattern( ArtifactRepository originalRepository, String pattern ) { boolean result = false; String originalId = originalRepository.getId(); // simple checks first to short circuit processing below. if ( WILDCARD.equals( pattern ) || pattern.equals( originalId ) ) { result = true; } else { // process the list String[] repos = pattern.split( "," ); for ( String repo : repos ) { // see if this is a negative match if ( repo.length() > 1 && repo.startsWith( "!" ) ) { if ( repo.substring( 1 ).equals( originalId ) ) { // explicitly exclude. Set result and stop processing. result = false; break; } } // check for exact match else if ( repo.equals( originalId ) ) { result = true; break; } // check for external:* else if ( EXTERNAL_WILDCARD.equals( repo ) && isExternalRepo( originalRepository ) ) { result = true; // don't stop processing in case a future segment explicitly excludes this repo } else if ( WILDCARD.equals( repo ) ) { result = true; // don't stop processing in case a future segment explicitly excludes this repo } } } return result; } /** * Checks the URL to see if this repository refers to an external repository * * @param originalRepository * @return true if external. */ static boolean isExternalRepo( ArtifactRepository originalRepository ) { try { URL url = new URL( originalRepository.getUrl() ); return !( url.getHost().equals( "localhost" ) || url.getHost().equals( "127.0.0.1" ) || url.getProtocol().equals( "file" ) ); } catch ( MalformedURLException e ) { // bad url just skip it here. It should have been validated already, but the wagon lookup will deal with it return false; } } static boolean matchesLayout( ArtifactRepository repository, Mirror mirror ) { return matchesLayout( RepositoryUtils.getLayout( repository ), mirror.getMirrorOfLayouts() ); } /** * Checks whether the layouts configured for a mirror match with the layout of the repository. * * @param repoLayout The layout of the repository, may be {@code null}. * @param mirrorLayout The layouts supported by the mirror, may be {@code null}. * @return {@code true} if the layouts associated with the mirror match the layout of the original repository, * {@code false} otherwise. */ static boolean matchesLayout( String repoLayout, String mirrorLayout ) { boolean result = false; // simple checks first to short circuit processing below. if ( StringUtils.isEmpty( mirrorLayout ) || WILDCARD.equals( mirrorLayout ) ) { result = true; } else if ( mirrorLayout.equals( repoLayout ) ) { result = true; } else { // process the list String[] layouts = mirrorLayout.split( "," ); for ( String layout : layouts ) { // see if this is a negative match if ( layout.length() > 1 && layout.startsWith( "!" ) ) { if ( layout.substring( 1 ).equals( repoLayout ) ) { // explicitly exclude. Set result and stop processing. result = false; break; } } // check for exact match else if ( layout.equals( repoLayout ) ) { result = true; break; } else if ( WILDCARD.equals( layout ) ) { result = true; // don't stop processing in case a future segment explicitly excludes this repo } } } return result; } } maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/classrealm/000077500000000000000000000000001317160430700256715ustar00rootroot00000000000000ArtifactClassRealmConstituent.java000066400000000000000000000033501317160430700344220ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/classrealmpackage org.apache.maven.classrealm; /* * 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.File; import org.eclipse.aether.artifact.Artifact; /** * @author Benjamin Bentmann */ class ArtifactClassRealmConstituent implements ClassRealmConstituent { private final Artifact artifact; public ArtifactClassRealmConstituent( Artifact artifact ) { this.artifact = artifact; } public String getGroupId() { return artifact.getGroupId(); } public String getArtifactId() { return artifact.getArtifactId(); } public String getType() { return artifact.getExtension(); } public String getClassifier() { return artifact.getClassifier(); } public String getVersion() { return artifact.getBaseVersion(); } public File getFile() { return artifact.getFile(); } @Override public String toString() { return artifact.toString(); } } maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/classrealm/ClassRealmConstituent.java000066400000000000000000000036131317160430700330250ustar00rootroot00000000000000package org.apache.maven.classrealm; /* * 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.File; /** * Describes a constituent of a class realm. * * @author Benjamin Bentmann */ public interface ClassRealmConstituent { /** * Gets the group id of the constituent's artifact. * * @return The group id, never {@code null}. */ String getGroupId(); /** * Gets the artifact id of the constituent's artifact. * * @return The artifact id, never {@code null}. */ String getArtifactId(); /** * Gets the type of the constituent's artifact. * * @return The type, never {@code null}. */ String getType(); /** * Gets the classifier of the constituent's artifact. * * @return The classifier or an empty string, never {@code null}. */ String getClassifier(); /** * Gets the version of the constituent's artifact. * * @return The version, never {@code null}. */ String getVersion(); /** * Gets the file of the constituent's artifact. * * @return The file, never {@code null}. */ File getFile(); } maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/classrealm/ClassRealmManager.java000066400000000000000000000073651317160430700320700ustar00rootroot00000000000000package org.apache.maven.classrealm; /* * 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.util.List; import java.util.Map; import org.apache.maven.model.Model; import org.apache.maven.model.Plugin; import org.codehaus.plexus.classworlds.realm.ClassRealm; import org.eclipse.aether.artifact.Artifact; /** * Manages the class realms used by Maven. Warning: This is an internal utility interface that is only * public for technical reasons, it is not part of the public API. In particular, this interface can be changed or * deleted without prior notice. * * @author Benjamin Bentmann */ public interface ClassRealmManager { /** * Gets the class realm hosting the Maven core. * * @return The class realm hosting the Maven core, never {@code null}. */ ClassRealm getCoreRealm(); /** * Gets the class realm exposing the Maven API. This is basically a restricted view on the Maven core realm. * * @return The class realm exposing the Maven API, never {@code null}. */ ClassRealm getMavenApiRealm(); /** * Creates a new class realm for the specified project and its build extensions. * * @param model The model of the project for which to create a realm, must not be {@code null}. * @param artifacts The artifacts to add to the class realm, may be {@code null}. Unresolved artifacts (i.e. with a * missing file) will automatically be excluded from the realm. * @return The new project realm, never {@code null}. */ ClassRealm createProjectRealm( Model model, List artifacts ); /** * Creates a new class realm for the specified build extension. * * @param extension The extension plugin for which to create a realm, must not be {@code null}. * @param artifacts The artifacts to add to the class realm, may be {@code null}. Unresolved artifacts (i.e. with a * missing file) will automatically be excluded from the realm. * @return The new extension realm, never {@code null}. */ ClassRealm createExtensionRealm( Plugin extension, List artifacts ); /** * Creates a new class realm for the specified plugin. * * @param plugin The plugin for which to create a realm, must not be {@code null}. * @param parent The parent realm for the new realm, may be {@code null}. * @param parentImports The packages/types to import from the parent realm, may be {@code null}. * @param foreignImports The packages/types to import from foreign realms, may be {@code null}. * @param artifacts The artifacts to add to the class realm, may be {@code null}. Unresolved artifacts (i.e. with a * missing file) will automatically be excluded from the realm. * @return The new plugin realm, never {@code null}. */ ClassRealm createPluginRealm( Plugin plugin, ClassLoader parent, List parentImports, Map foreignImports, List artifacts ); } ClassRealmManagerDelegate.java000066400000000000000000000022271317160430700334340ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/classrealmpackage org.apache.maven.classrealm; /* * 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 org.codehaus.plexus.classworlds.realm.ClassRealm; /** * ClassRealmManagerDelegate is used to perform addition configuration of * class realms created by ClassRealmManager. * * @author igor */ public interface ClassRealmManagerDelegate { void setupRealm( ClassRealm classRealm, ClassRealmRequest request ); } maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/classrealm/ClassRealmRequest.java000066400000000000000000000051261317160430700321370ustar00rootroot00000000000000package org.apache.maven.classrealm; /* * 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.util.List; import java.util.Map; /** * Describes the requirements for a new class realm. * * @author Benjamin Bentmann */ public interface ClassRealmRequest { /** * The type of a class realm. */ enum RealmType { /** * The class realm for the public API of the Maven core. */ Core, /** * A class realm for a project to aggregates its build extensions. */ Project, /** * A class realm for a build extension. */ Extension, /** * A class realm for a plugin. */ Plugin, } /** * Gets the type of the class realm. * * @return The type of the class realm, never {@code null}. */ RealmType getType(); /** * Gets the parent class realm (if any). * * @return The parent class realm or {@code null} if using the default parent. */ ClassLoader getParent(); /** * @deprecated Use {@link #getParentImports()} instead. */ @Deprecated List getImports(); /** * Gets the packages/types to import from the parent realm. * * @return The modifiable list of packages/types to import from the parent realm, never {@code null}. */ List getParentImports(); /** * Gets the packages/types to import from foreign realms. * * @return The modifiable map of packages/types to import from foreign realms, never {@code null}. */ Map getForeignImports(); /** * Gets the constituents for the class realm. * * @return The modifiable list of constituents for the class realm, never {@code null}. */ List getConstituents(); } maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/classrealm/DefaultClassRealmManager.java000066400000000000000000000335201317160430700333650ustar00rootroot00000000000000package org.apache.maven.classrealm; /* * 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.File; import java.net.MalformedURLException; import java.util.ArrayList; import java.util.Collections; import java.util.LinkedHashSet; import java.util.List; import java.util.Map; import java.util.Random; import java.util.Set; import java.util.TreeMap; import javax.inject.Inject; import javax.inject.Named; import javax.inject.Singleton; import org.apache.commons.lang3.Validate; import org.apache.maven.artifact.ArtifactUtils; import org.apache.maven.classrealm.ClassRealmRequest.RealmType; import org.apache.maven.extension.internal.CoreExportsProvider; import org.apache.maven.model.Model; import org.apache.maven.model.Plugin; import org.codehaus.plexus.MutablePlexusContainer; import org.codehaus.plexus.PlexusContainer; import org.codehaus.plexus.classworlds.ClassWorld; import org.codehaus.plexus.classworlds.realm.ClassRealm; import org.codehaus.plexus.classworlds.realm.DuplicateRealmException; import org.codehaus.plexus.logging.Logger; import org.codehaus.plexus.util.StringUtils; import org.eclipse.aether.artifact.Artifact; /** * Manages the class realms used by Maven. Warning: This is an internal utility class that is only * public for technical reasons, it is not part of the public API. In particular, this class can be changed or deleted * without prior notice. * * @author Benjamin Bentmann */ @Named @Singleton public class DefaultClassRealmManager implements ClassRealmManager { public static final String API_REALMID = "maven.api"; /** * During normal command line build, ClassWorld is loaded by jvm system classloader, which only includes * plexus-classworlds jar and possibly javaagent classes, see https://issues.apache.org/jira/browse/MNG-4747. *

* Using ClassWorld to determine plugin/extensions realm parent classloaders gives m2e and integration test harness * flexibility to load multiple version of maven into dedicated classloaders without assuming state of jvm system * classloader. */ private static final ClassLoader PARENT_CLASSLOADER = ClassWorld.class.getClassLoader(); private final Logger logger; private final ClassWorld world; private final ClassRealm containerRealm; // this is a live injected collection private final List delegates; private final ClassRealm mavenApiRealm; /** * Patterns of artifacts provided by maven core and exported via maven api realm. These artifacts are filtered from * plugin and build extensions realms to avoid presence of duplicate and possibly conflicting classes on classpath. */ private final Set providedArtifacts; @Inject public DefaultClassRealmManager( Logger logger, PlexusContainer container, List delegates, CoreExportsProvider exports ) { this.logger = logger; this.world = ( (MutablePlexusContainer) container ).getClassWorld(); this.containerRealm = container.getContainerRealm(); this.delegates = delegates; Map foreignImports = exports.get().getExportedPackages(); this.mavenApiRealm = createRealm( API_REALMID, RealmType.Core, null /* parent */, null /* parentImports */, foreignImports, null /* artifacts */ ); this.providedArtifacts = exports.get().getExportedArtifacts(); } private ClassRealm newRealm( String id ) { synchronized ( world ) { String realmId = id; Random random = new Random(); while ( true ) { try { ClassRealm classRealm = world.newRealm( realmId, null ); if ( logger.isDebugEnabled() ) { logger.debug( "Created new class realm " + realmId ); } return classRealm; } catch ( DuplicateRealmException e ) { realmId = id + '-' + random.nextInt(); } } } } public ClassRealm getMavenApiRealm() { return mavenApiRealm; } /** * Creates a new class realm with the specified parent and imports. * * @param baseRealmId The base id to use for the new realm, must not be {@code null}. * @param type The type of the class realm, must not be {@code null}. * @param parent The parent realm for the new realm, may be {@code null}. * @param parentImports The packages/types to import from the parent realm, may be {@code null}. * @param foreignImports The packages/types to import from foreign realms, may be {@code null}. * @param artifacts The artifacts to add to the realm, may be {@code null}. Unresolved artifacts (i.e. with a * missing file) will automatically be excluded from the realm. * @return The created class realm, never {@code null}. */ private ClassRealm createRealm( String baseRealmId, RealmType type, ClassLoader parent, List parentImports, Map foreignImports, List artifacts ) { Set artifactIds = new LinkedHashSet<>(); List constituents = new ArrayList<>(); if ( artifacts != null ) { for ( Artifact artifact : artifacts ) { if ( !isProvidedArtifact( artifact ) ) { artifactIds.add( getId( artifact ) ); if ( artifact.getFile() != null ) { constituents.add( new ArtifactClassRealmConstituent( artifact ) ); } } } } if ( parentImports != null ) { parentImports = new ArrayList<>( parentImports ); } else { parentImports = new ArrayList<>(); } if ( foreignImports != null ) { foreignImports = new TreeMap<>( foreignImports ); } else { foreignImports = new TreeMap<>(); } ClassRealm classRealm = newRealm( baseRealmId ); if ( parent != null ) { classRealm.setParentClassLoader( parent ); } callDelegates( classRealm, type, parent, parentImports, foreignImports, constituents ); wireRealm( classRealm, parentImports, foreignImports ); Set includedIds = populateRealm( classRealm, constituents ); if ( logger.isDebugEnabled() ) { artifactIds.removeAll( includedIds ); for ( String id : artifactIds ) { logger.debug( " Excluded: " + id ); } } return classRealm; } public ClassRealm getCoreRealm() { return containerRealm; } public ClassRealm createProjectRealm( Model model, List artifacts ) { Validate.notNull( model, "model cannot be null" ); ClassLoader parent = getMavenApiRealm(); return createRealm( getKey( model ), RealmType.Project, parent, null, null, artifacts ); } private static String getKey( Model model ) { return "project>" + model.getGroupId() + ":" + model.getArtifactId() + ":" + model.getVersion(); } public ClassRealm createExtensionRealm( Plugin plugin, List artifacts ) { Validate.notNull( plugin, "plugin cannot be null" ); ClassLoader parent = PARENT_CLASSLOADER; Map foreignImports = Collections.singletonMap( "", getMavenApiRealm() ); return createRealm( getKey( plugin, true ), RealmType.Extension, parent, null, foreignImports, artifacts ); } private boolean isProvidedArtifact( Artifact artifact ) { return providedArtifacts.contains( artifact.getGroupId() + ":" + artifact.getArtifactId() ); } public ClassRealm createPluginRealm( Plugin plugin, ClassLoader parent, List parentImports, Map foreignImports, List artifacts ) { Validate.notNull( plugin, "plugin cannot be null" ); if ( parent == null ) { parent = PARENT_CLASSLOADER; } return createRealm( getKey( plugin, false ), RealmType.Plugin, parent, parentImports, foreignImports, artifacts ); } private static String getKey( Plugin plugin, boolean extension ) { String version = ArtifactUtils.toSnapshotVersion( plugin.getVersion() ); return ( extension ? "extension>" : "plugin>" ) + plugin.getGroupId() + ":" + plugin.getArtifactId() + ":" + version; } private static String getId( Artifact artifact ) { return getId( artifact.getGroupId(), artifact.getArtifactId(), artifact.getExtension(), artifact.getClassifier(), artifact.getBaseVersion() ); } private static String getId( ClassRealmConstituent constituent ) { return getId( constituent.getGroupId(), constituent.getArtifactId(), constituent.getType(), constituent.getClassifier(), constituent.getVersion() ); } private static String getId( String gid, String aid, String type, String cls, String ver ) { return gid + ':' + aid + ':' + type + ( StringUtils.isNotEmpty( cls ) ? ':' + cls : "" ) + ':' + ver; } private void callDelegates( ClassRealm classRealm, RealmType type, ClassLoader parent, List parentImports, Map foreignImports, List constituents ) { List delegates = new ArrayList<>( this.delegates ); if ( !delegates.isEmpty() ) { ClassRealmRequest request = new DefaultClassRealmRequest( type, parent, parentImports, foreignImports, constituents ); for ( ClassRealmManagerDelegate delegate : delegates ) { try { delegate.setupRealm( classRealm, request ); } catch ( Exception e ) { logger.error( delegate.getClass().getName() + " failed to setup class realm " + classRealm + ": " + e.getMessage(), e ); } } } } private Set populateRealm( ClassRealm classRealm, List constituents ) { Set includedIds = new LinkedHashSet<>(); if ( logger.isDebugEnabled() ) { logger.debug( "Populating class realm " + classRealm.getId() ); } for ( ClassRealmConstituent constituent : constituents ) { File file = constituent.getFile(); String id = getId( constituent ); includedIds.add( id ); if ( logger.isDebugEnabled() ) { logger.debug( " Included: " + id ); } try { classRealm.addURL( file.toURI().toURL() ); } catch ( MalformedURLException e ) { // Not going to happen logger.error( e.getMessage(), e ); } } return includedIds; } private void wireRealm( ClassRealm classRealm, List parentImports, Map foreignImports ) { if ( foreignImports != null && !foreignImports.isEmpty() ) { if ( logger.isDebugEnabled() ) { logger.debug( "Importing foreign packages into class realm " + classRealm.getId() ); } for ( Map.Entry entry : foreignImports.entrySet() ) { ClassLoader importedRealm = entry.getValue(); String imp = entry.getKey(); if ( logger.isDebugEnabled() ) { logger.debug( " Imported: " + imp + " < " + getId( importedRealm ) ); } classRealm.importFrom( importedRealm, imp ); } } if ( parentImports != null && !parentImports.isEmpty() ) { if ( logger.isDebugEnabled() ) { logger.debug( "Importing parent packages into class realm " + classRealm.getId() ); } for ( String imp : parentImports ) { if ( logger.isDebugEnabled() ) { logger.debug( " Imported: " + imp + " < " + getId( classRealm.getParentClassLoader() ) ); } classRealm.importFromParent( imp ); } } } private String getId( ClassLoader classLoader ) { if ( classLoader instanceof ClassRealm ) { return ( (ClassRealm) classLoader ).getId(); } return String.valueOf( classLoader ); } } maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/classrealm/DefaultClassRealmRequest.java000066400000000000000000000041721317160430700334440ustar00rootroot00000000000000package org.apache.maven.classrealm; /* * 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.util.List; import java.util.Map; /** * @author Benjamin Bentmann */ class DefaultClassRealmRequest implements ClassRealmRequest { private final RealmType type; private final ClassLoader parent; private final List parentImports; private final Map foreignImports; private final List constituents; public DefaultClassRealmRequest( RealmType type, ClassLoader parent, List parentImports, Map foreignImports, List constituents ) { this.type = type; this.parent = parent; this.parentImports = parentImports; this.foreignImports = foreignImports; this.constituents = constituents; } public RealmType getType() { return type; } public ClassLoader getParent() { return parent; } public List getImports() { return getParentImports(); } public List getParentImports() { return parentImports; } public Map getForeignImports() { return foreignImports; } public List getConstituents() { return constituents; } } maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/configuration/000077500000000000000000000000001317160430700264125ustar00rootroot00000000000000BasedirBeanConfigurationPathTranslator.java000066400000000000000000000043031317160430700367540ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/configurationpackage org.apache.maven.configuration; /* * 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.File; /** * A path translator that resolves relative paths against a specific base directory. * * @author Benjamin Bentmann */ public class BasedirBeanConfigurationPathTranslator implements BeanConfigurationPathTranslator { private final File basedir; /** * Creates a new path translator using the specified base directory. * * @param basedir The base directory to resolve relative paths against, may be {@code null} to disable path * translation. */ public BasedirBeanConfigurationPathTranslator( File basedir ) { this.basedir = basedir; } public File translatePath( File path ) { File result = path; if ( path != null && basedir != null ) { if ( path.isAbsolute() ) { // path is already absolute, we're done } else if ( path.getPath().startsWith( File.separator ) ) { // drive-relative Windows path, don't align with base dir but with drive root result = path.getAbsoluteFile(); } else { // an ordinary relative path, align with base dir result = new File( new File( basedir, path.getPath() ).toURI().normalize() ).getAbsoluteFile(); } } return result; } } BeanConfigurationException.java000066400000000000000000000023011317160430700344460ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/configurationpackage org.apache.maven.configuration; /* * 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. */ /** * Thrown when a bean couldn't be configured. * * @author Benjamin Bentmann */ public class BeanConfigurationException extends Exception { public BeanConfigurationException( String message ) { super( message ); } public BeanConfigurationException( String message, Throwable cause ) { super( message, cause ); } } BeanConfigurationPathTranslator.java000066400000000000000000000025141317160430700354640ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/configurationpackage org.apache.maven.configuration; /* * 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.File; /** * Postprocesses filesystem paths. For instance, a path translator might want to resolve relative paths given in the * bean configuration against some base directory. * * @author Benjamin Bentmann */ public interface BeanConfigurationPathTranslator { /** * Translates the specified path. * * @param path The path to translate, may be {@code null}. * @return The translated path or {@code null} if none. */ File translatePath( File path ); } BeanConfigurationRequest.java000066400000000000000000000116671317160430700341570ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/configurationpackage org.apache.maven.configuration; /* * 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. */ /** * A request to configure a bean from some configuration in the POM or similar. * * @author Benjamin Bentmann */ public interface BeanConfigurationRequest { /** * Gets the bean to configure. Eventually, a valid request must have a bean set. * * @return The bean to configure, or {@code null} if none. */ Object getBean(); /** * Sets the bean to configure. Eventually, a valid request must have a bean set. * * @param bean The bean to configure, may be {@code null}. * @return This request for chaining, never {@code null}. */ BeanConfigurationRequest setBean( Object bean ); /** * Gets the configuration to unmarshal into the bean. * * @return The configuration to unmarshal into the bean or {@code null} if none. */ Object getConfiguration(); /** * Sets the configuration to unmarshal into the bean. The configuration should be taken from * {@link org.apache.maven.model.ConfigurationContainer#getConfiguration()} or a similar source. * Fully equivalent to {@code setConfiguration(configuration, null)}. * * @param configuration The configuration to unmarshal, may be {@code null}. * @return This request for chaining, never {@code null}. */ BeanConfigurationRequest setConfiguration( Object configuration ); /** * Sets the configuration to unmarshal into the bean. The configuration should be taken from * {@link org.apache.maven.model.ConfigurationContainer#getConfiguration()} or a similar source. * If {@code element} is not {@code null}, child configuration element with the specified name will * be unmarshaled. * * @param configuration The configuration to unmarshal, may be {@code null}. * @param element Configuration element name to unmarshal or {@code null} to unmarshal entire configuration. * @return This request for chaining, never {@code null}. */ BeanConfigurationRequest setConfiguration( Object configuration, String element ); /** * Returns configuration element name or {@code null}. * * @see #setConfiguration(Object, String) * * @return Configuration element name or {@code null} */ String getConfigurationElement(); /** * Gets the class loader from which to load any types referenced by the configuration. If unset, the class loader of * the bean class will be used. * * @return The class loader to load referenced types from or {@code null} if unset. */ ClassLoader getClassLoader(); /** * Sets the class loader from which to load any types referenced by the configuration. If unset, the class loader of * the bean class will be used. * * @param classLoader The class loader to load referenced types from, may be {@code null}. * @return This request for chaining, never {@code null}. */ BeanConfigurationRequest setClassLoader( ClassLoader classLoader ); /** * Gets the optional preprocessor for configuration values. * * @return The preprocessor for configuration values or {@code null} if none. */ BeanConfigurationValuePreprocessor getValuePreprocessor(); /** * Sets the optional preprocessor for configuration values. * * @param valuePreprocessor The preprocessor for configuration values, may be {@code null} if unneeded. * @return This request for chaining, never {@code null}. */ BeanConfigurationRequest setValuePreprocessor( BeanConfigurationValuePreprocessor valuePreprocessor ); /** * Gets the optional path translator for configuration values unmarshalled to files. * * @return The path translator for files or {@code null} if none. */ BeanConfigurationPathTranslator getPathTranslator(); /** * Sets the optional path translator for configuration values unmarshalled to files. * * @param pathTranslator The path translator for files, may be {@code null} if unneeded. * @return This request for chaining, never {@code null}. */ BeanConfigurationRequest setPathTranslator( BeanConfigurationPathTranslator pathTranslator ); } BeanConfigurationValuePreprocessor.java000066400000000000000000000037511317160430700362050ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/configurationpackage org.apache.maven.configuration; /* * 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. */ /** * Preprocesses a value from a bean configuration before the bean configurator unmarshals it into a bean property. A * common use case for such preprocessing is the evaluation of variables within the configuration value. * * @author Benjamin Bentmann */ public interface BeanConfigurationValuePreprocessor { /** * Preprocesses the specified bean configuration value. The optional type provided to this method is a hint (not a * requirement) for the preprocessor to resolve the value to a compatible value or a (string) value than can be * unmarshalled into that type. The preprocessor is not required to perform any type conversion but should rather * filter out incompatible values from its result. * * @param value The configuration value to preprocess, must not be {@code null}. * @param type The target type of the value, may be {@code null}. * @return The processed configuration value or {@code null} if none. * @throws BeanConfigurationException If an error occurred while preprocessing the value. */ Object preprocessValue( String value, Class type ) throws BeanConfigurationException; } maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/configuration/BeanConfigurator.java000066400000000000000000000034251317160430700325110ustar00rootroot00000000000000package org.apache.maven.configuration; /* * 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. */ /** * Unmarshals some textual configuration from the POM or similar into the properties of a bean. This component works * similar to the way Maven configures plugins from the POM, i.e. some configuration like {@code value} * is mapped to an equally named property of the bean and converted. The properties of the bean are supposed to either * have a public setter or be backed by an equally named field (of any visibility). * * @since 3.0 * @author Benjamin Bentmann */ public interface BeanConfigurator { /** * Performs the specified bean configuration. * * @param request The configuration request that specifies the bean and the configuration to process, must not be * {@code null}. * @throws BeanConfigurationException If the bean configuration could not be successfully processed. */ void configureBean( BeanConfigurationRequest request ) throws BeanConfigurationException; } DefaultBeanConfigurationRequest.java000066400000000000000000000140371317160430700354560ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/configurationpackage org.apache.maven.configuration; /* * 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 org.apache.commons.lang3.Validate; import org.apache.maven.model.Build; import org.apache.maven.model.Model; import org.apache.maven.model.Plugin; import org.apache.maven.model.PluginExecution; import org.apache.maven.model.PluginManagement; import org.codehaus.plexus.util.StringUtils; /** * A basic bean configuration request. * * @author Benjamin Bentmann */ public class DefaultBeanConfigurationRequest implements BeanConfigurationRequest { private Object bean; private Object configuration; private String configurationElement; private ClassLoader classLoader; private BeanConfigurationValuePreprocessor valuePreprocessor; private BeanConfigurationPathTranslator pathTranslator; public Object getBean() { return bean; } public DefaultBeanConfigurationRequest setBean( Object bean ) { this.bean = bean; return this; } public Object getConfiguration() { return configuration; } public String getConfigurationElement() { return configurationElement; } public DefaultBeanConfigurationRequest setConfiguration( Object configuration ) { return setConfiguration( configuration, null ); } public DefaultBeanConfigurationRequest setConfiguration( Object configuration, String element ) { this.configuration = configuration; this.configurationElement = element; return this; } /** * Sets the configuration to the configuration taken from the specified build plugin in the POM. First, the build * plugins will be searched for the specified plugin, if that fails, the plugin management section will be searched. * * @param model The POM to extract the plugin configuration from, may be {@code null}. * @param pluginGroupId The group id of the plugin whose configuration should be used, must not be {@code null} or * empty. * @param pluginArtifactId The artifact id of the plugin whose configuration should be used, must not be * {@code null} or empty. * @param pluginExecutionId The id of a plugin execution whose configuration should be used, may be {@code null} or * empty to use the general plugin configuration. * @return This request for chaining, never {@code null}. */ public DefaultBeanConfigurationRequest setConfiguration( Model model, String pluginGroupId, String pluginArtifactId, String pluginExecutionId ) { Plugin plugin = findPlugin( model, pluginGroupId, pluginArtifactId ); if ( plugin != null ) { if ( StringUtils.isNotEmpty( pluginExecutionId ) ) { for ( PluginExecution execution : plugin.getExecutions() ) { if ( pluginExecutionId.equals( execution.getId() ) ) { setConfiguration( execution.getConfiguration() ); break; } } } else { setConfiguration( plugin.getConfiguration() ); } } return this; } private Plugin findPlugin( Model model, String groupId, String artifactId ) { Validate.notBlank( groupId, "groupId can neither be null, empty nor blank" ); Validate.notBlank( artifactId, "artifactId can neither be null, empty nor blank" ); if ( model != null ) { Build build = model.getBuild(); if ( build != null ) { for ( Plugin plugin : build.getPlugins() ) { if ( groupId.equals( plugin.getGroupId() ) && artifactId.equals( plugin.getArtifactId() ) ) { return plugin; } } PluginManagement mgmt = build.getPluginManagement(); if ( mgmt != null ) { for ( Plugin plugin : mgmt.getPlugins() ) { if ( groupId.equals( plugin.getGroupId() ) && artifactId.equals( plugin.getArtifactId() ) ) { return plugin; } } } } } return null; } public ClassLoader getClassLoader() { return classLoader; } public DefaultBeanConfigurationRequest setClassLoader( ClassLoader classLoader ) { this.classLoader = classLoader; return this; } public BeanConfigurationValuePreprocessor getValuePreprocessor() { return valuePreprocessor; } public DefaultBeanConfigurationRequest setValuePreprocessor( BeanConfigurationValuePreprocessor valuePreprocessor ) { this.valuePreprocessor = valuePreprocessor; return this; } public BeanConfigurationPathTranslator getPathTranslator() { return pathTranslator; } public DefaultBeanConfigurationRequest setPathTranslator( BeanConfigurationPathTranslator pathTranslator ) { this.pathTranslator = pathTranslator; return this; } } maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/configuration/internal/000077500000000000000000000000001317160430700302265ustar00rootroot00000000000000DefaultBeanConfigurator.java000066400000000000000000000127541317160430700355600ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/configuration/internalpackage org.apache.maven.configuration.internal; /* * 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.File; import org.apache.commons.lang3.Validate; import org.apache.maven.configuration.BeanConfigurationException; import org.apache.maven.configuration.BeanConfigurationPathTranslator; import org.apache.maven.configuration.BeanConfigurationRequest; import org.apache.maven.configuration.BeanConfigurationValuePreprocessor; import org.apache.maven.configuration.BeanConfigurator; import org.codehaus.plexus.component.annotations.Component; import org.codehaus.plexus.component.configurator.ComponentConfigurationException; import org.codehaus.plexus.component.configurator.converters.composite.ObjectWithFieldsConverter; import org.codehaus.plexus.component.configurator.converters.lookup.ConverterLookup; import org.codehaus.plexus.component.configurator.converters.lookup.DefaultConverterLookup; import org.codehaus.plexus.component.configurator.expression.ExpressionEvaluationException; import org.codehaus.plexus.component.configurator.expression.TypeAwareExpressionEvaluator; import org.codehaus.plexus.configuration.PlexusConfiguration; import org.codehaus.plexus.configuration.xml.XmlPlexusConfiguration; import org.codehaus.plexus.util.xml.Xpp3Dom; /** * Warning: This is an internal class that is only public for technical reasons, it is not part of the * public API. In particular, this class can be changed or deleted without prior notice. * * @author Benjamin Bentmann */ @Component( role = BeanConfigurator.class ) public class DefaultBeanConfigurator implements BeanConfigurator { private final ConverterLookup converterLookup = new DefaultConverterLookup(); public void configureBean( BeanConfigurationRequest request ) throws BeanConfigurationException { Validate.notNull( request, "request cannot be null" ); Validate.notNull( request.getBean(), "request.bean cannot be null" ); Object configuration = request.getConfiguration(); if ( configuration == null ) { return; } PlexusConfiguration plexusConfig; if ( configuration instanceof PlexusConfiguration ) { plexusConfig = (PlexusConfiguration) configuration; } else if ( configuration instanceof Xpp3Dom ) { plexusConfig = new XmlPlexusConfiguration( (Xpp3Dom) configuration ); } else { throw new BeanConfigurationException( "unsupported bean configuration source (" + configuration.getClass().getName() + ")" ); } if ( request.getConfigurationElement() != null ) { plexusConfig = plexusConfig.getChild( request.getConfigurationElement() ); } ClassLoader classLoader = request.getClassLoader(); if ( classLoader == null ) { classLoader = request.getBean().getClass().getClassLoader(); } BeanExpressionEvaluator evaluator = new BeanExpressionEvaluator( request ); ObjectWithFieldsConverter converter = new ObjectWithFieldsConverter(); try { converter.processConfiguration( converterLookup, request.getBean(), classLoader, plexusConfig, evaluator ); } catch ( ComponentConfigurationException e ) { throw new BeanConfigurationException( e.getMessage(), e ); } } static class BeanExpressionEvaluator implements TypeAwareExpressionEvaluator { private final BeanConfigurationValuePreprocessor preprocessor; private final BeanConfigurationPathTranslator translator; public BeanExpressionEvaluator( BeanConfigurationRequest request ) { preprocessor = request.getValuePreprocessor(); translator = request.getPathTranslator(); } public Object evaluate( String expression, Class type ) throws ExpressionEvaluationException { if ( preprocessor != null ) { try { return preprocessor.preprocessValue( expression, type ); } catch ( BeanConfigurationException e ) { throw new ExpressionEvaluationException( e.getMessage(), e ); } } return expression; } public Object evaluate( String expression ) throws ExpressionEvaluationException { return evaluate( expression, null ); } public File alignToBaseDirectory( File file ) { if ( translator != null ) { return translator.translatePath( file ); } return file; } } } maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/eventspy/000077500000000000000000000000001317160430700254205ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/eventspy/AbstractEventSpy.java000066400000000000000000000023151317160430700315250ustar00rootroot00000000000000package org.apache.maven.eventspy; /* * 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. */ /** * A skeleton eventspy that does nothing other than helping implementors. * @since 3.0.2 */ public abstract class AbstractEventSpy implements EventSpy { public void init( Context context ) throws Exception { } public void onEvent( Object event ) throws Exception { } public void close() throws Exception { } } maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/eventspy/EventSpy.java000066400000000000000000000051511317160430700300420ustar00rootroot00000000000000package org.apache.maven.eventspy; /* * 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.util.Map; /** * A core extension to monitor Maven's execution. Typically, such an extension gets loaded into Maven by specifying the * system property {@code maven.ext.class.path} on the command line. As soon as dependency injection is setup, Maven * looks up all implementers of this interface and calls their {@link #init(Context)} method. Note: * Implementors are strongly advised to inherit from {@link AbstractEventSpy} instead of directly implementing this * interface. * @since 3.0.2 */ public interface EventSpy { interface Context { /** * Gets key-value pairs providing information about the Maven runtime. * * @return The key-value pairs, never {@code null}. */ Map getData(); } /** * Initializes the spy. * * @param context The event spy context, never {@code null}. */ void init( Context context ) throws Exception; /** * Notifies the spy of some build event/operation. * * @param event The event, never {@code null}. * @see org.apache.maven.settings.building.SettingsBuildingRequest * @see org.apache.maven.settings.building.SettingsBuildingResult * @see org.apache.maven.execution.MavenExecutionRequest * @see org.apache.maven.execution.MavenExecutionResult * @see org.apache.maven.project.DependencyResolutionRequest * @see org.apache.maven.project.DependencyResolutionResult * @see org.apache.maven.execution.ExecutionEvent * @see org.eclipse.aether.RepositoryEvent */ void onEvent( Object event ) throws Exception; /** * Notifies the spy of Maven's termination, allowing it to free any resources allocated by it. */ void close() throws Exception; } maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/eventspy/internal/000077500000000000000000000000001317160430700272345ustar00rootroot00000000000000EventSpyDispatcher.java000066400000000000000000000073621317160430700336140ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/eventspy/internalpackage org.apache.maven.eventspy.internal; /* * 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.util.ArrayList; import java.util.List; import org.apache.maven.eventspy.EventSpy; import org.apache.maven.execution.ExecutionListener; import org.codehaus.plexus.component.annotations.Component; import org.codehaus.plexus.component.annotations.Requirement; import org.codehaus.plexus.logging.Logger; import org.eclipse.aether.RepositoryListener; /** * Dispatches callbacks to all registered eventspies. * @since 3.0.2 */ @Component( role = EventSpyDispatcher.class ) public class EventSpyDispatcher { @Requirement private Logger logger; @Requirement( role = EventSpy.class ) private List eventSpies; public void setEventSpies( List eventSpies ) { // make copy to get rid of needless overhead for dynamic lookups this.eventSpies = new ArrayList<>( eventSpies ); } public List getEventSpies() { return eventSpies; } public ExecutionListener chainListener( ExecutionListener listener ) { if ( eventSpies.isEmpty() ) { return listener; } return new EventSpyExecutionListener( this, listener ); } public RepositoryListener chainListener( RepositoryListener listener ) { if ( eventSpies.isEmpty() ) { return listener; } return new EventSpyRepositoryListener( this, listener ); } public void init( EventSpy.Context context ) { if ( eventSpies.isEmpty() ) { return; } for ( EventSpy eventSpy : eventSpies ) { try { eventSpy.init( context ); } catch ( Exception | LinkageError e ) { logError( "initialize", e, eventSpy ); } } } public void onEvent( Object event ) { if ( eventSpies.isEmpty() ) { return; } for ( EventSpy eventSpy : eventSpies ) { try { eventSpy.onEvent( event ); } catch ( Exception | LinkageError e ) { logError( "notify", e, eventSpy ); } } } public void close() { if ( eventSpies.isEmpty() ) { return; } for ( EventSpy eventSpy : eventSpies ) { try { eventSpy.close(); } catch ( Exception | LinkageError e ) { logError( "close", e, eventSpy ); } } } private void logError( String action, Throwable e, EventSpy spy ) { String msg = "Failed to " + action + " spy " + spy.getClass().getName() + ": " + e.getMessage(); if ( logger.isDebugEnabled() ) { logger.warn( msg, e ); } else { logger.warn( msg ); } } } EventSpyExecutionListener.java000066400000000000000000000101431317160430700351660ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/eventspy/internalpackage org.apache.maven.eventspy.internal; /* * 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 org.apache.maven.execution.AbstractExecutionListener; import org.apache.maven.execution.ExecutionEvent; import org.apache.maven.execution.ExecutionListener; /** * Forwards execution events to eventspies. * @since 3.0.2 */ class EventSpyExecutionListener extends AbstractExecutionListener { private final EventSpyDispatcher dispatcher; private final ExecutionListener delegate; public EventSpyExecutionListener( EventSpyDispatcher dispatcher, ExecutionListener delegate ) { this.dispatcher = dispatcher; this.delegate = delegate; } @Override public void projectDiscoveryStarted( ExecutionEvent event ) { dispatcher.onEvent( event ); delegate.projectDiscoveryStarted( event ); } @Override public void sessionStarted( ExecutionEvent event ) { dispatcher.onEvent( event ); delegate.sessionStarted( event ); } @Override public void sessionEnded( ExecutionEvent event ) { dispatcher.onEvent( event ); delegate.sessionEnded( event ); } @Override public void projectSkipped( ExecutionEvent event ) { dispatcher.onEvent( event ); delegate.projectSkipped( event ); } @Override public void projectStarted( ExecutionEvent event ) { dispatcher.onEvent( event ); delegate.projectStarted( event ); } @Override public void projectSucceeded( ExecutionEvent event ) { dispatcher.onEvent( event ); delegate.projectSucceeded( event ); } @Override public void projectFailed( ExecutionEvent event ) { dispatcher.onEvent( event ); delegate.projectFailed( event ); } @Override public void forkStarted( ExecutionEvent event ) { dispatcher.onEvent( event ); delegate.forkStarted( event ); } @Override public void forkSucceeded( ExecutionEvent event ) { dispatcher.onEvent( event ); delegate.forkSucceeded( event ); } @Override public void forkFailed( ExecutionEvent event ) { dispatcher.onEvent( event ); delegate.forkFailed( event ); } @Override public void mojoSkipped( ExecutionEvent event ) { dispatcher.onEvent( event ); delegate.mojoSkipped( event ); } @Override public void mojoStarted( ExecutionEvent event ) { dispatcher.onEvent( event ); delegate.mojoStarted( event ); } @Override public void mojoSucceeded( ExecutionEvent event ) { dispatcher.onEvent( event ); delegate.mojoSucceeded( event ); } @Override public void mojoFailed( ExecutionEvent event ) { dispatcher.onEvent( event ); delegate.mojoFailed( event ); } @Override public void forkedProjectStarted( ExecutionEvent event ) { dispatcher.onEvent( event ); delegate.forkedProjectStarted( event ); } @Override public void forkedProjectSucceeded( ExecutionEvent event ) { dispatcher.onEvent( event ); delegate.forkedProjectSucceeded( event ); } @Override public void forkedProjectFailed( ExecutionEvent event ) { dispatcher.onEvent( event ); delegate.forkedProjectFailed( event ); } } EventSpyRepositoryListener.java000066400000000000000000000110561317160430700354060ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/eventspy/internalpackage org.apache.maven.eventspy.internal; /* * 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 org.eclipse.aether.AbstractRepositoryListener; import org.eclipse.aether.RepositoryEvent; import org.eclipse.aether.RepositoryListener; /** * Forwards repository events to eventspies. * @since 3.0.2 */ class EventSpyRepositoryListener extends AbstractRepositoryListener { private final EventSpyDispatcher dispatcher; private final RepositoryListener delegate; public EventSpyRepositoryListener( EventSpyDispatcher dispatcher, RepositoryListener delegate ) { this.dispatcher = dispatcher; this.delegate = delegate; } @Override public void artifactDeployed( RepositoryEvent event ) { dispatcher.onEvent( event ); delegate.artifactDeployed( event ); } @Override public void artifactDeploying( RepositoryEvent event ) { dispatcher.onEvent( event ); delegate.artifactDeploying( event ); } @Override public void artifactDescriptorInvalid( RepositoryEvent event ) { dispatcher.onEvent( event ); delegate.artifactDescriptorInvalid( event ); } @Override public void artifactDescriptorMissing( RepositoryEvent event ) { dispatcher.onEvent( event ); delegate.artifactDescriptorMissing( event ); } @Override public void artifactInstalled( RepositoryEvent event ) { dispatcher.onEvent( event ); delegate.artifactInstalled( event ); } @Override public void artifactInstalling( RepositoryEvent event ) { dispatcher.onEvent( event ); delegate.artifactInstalling( event ); } @Override public void artifactResolved( RepositoryEvent event ) { dispatcher.onEvent( event ); delegate.artifactResolved( event ); } @Override public void artifactResolving( RepositoryEvent event ) { dispatcher.onEvent( event ); delegate.artifactResolving( event ); } @Override public void metadataDeployed( RepositoryEvent event ) { dispatcher.onEvent( event ); delegate.metadataDeployed( event ); } @Override public void metadataDeploying( RepositoryEvent event ) { dispatcher.onEvent( event ); delegate.metadataDeploying( event ); } @Override public void metadataInstalled( RepositoryEvent event ) { dispatcher.onEvent( event ); delegate.metadataInstalled( event ); } @Override public void metadataInstalling( RepositoryEvent event ) { dispatcher.onEvent( event ); delegate.metadataInstalling( event ); } @Override public void metadataInvalid( RepositoryEvent event ) { dispatcher.onEvent( event ); delegate.metadataInvalid( event ); } @Override public void metadataResolved( RepositoryEvent event ) { dispatcher.onEvent( event ); delegate.metadataResolved( event ); } @Override public void metadataResolving( RepositoryEvent event ) { dispatcher.onEvent( event ); delegate.metadataResolving( event ); } @Override public void artifactDownloaded( RepositoryEvent event ) { dispatcher.onEvent( event ); delegate.artifactDownloaded( event ); } @Override public void artifactDownloading( RepositoryEvent event ) { dispatcher.onEvent( event ); delegate.artifactDownloading( event ); } @Override public void metadataDownloaded( RepositoryEvent event ) { dispatcher.onEvent( event ); delegate.metadataDownloaded( event ); } @Override public void metadataDownloading( RepositoryEvent event ) { dispatcher.onEvent( event ); delegate.metadataDownloading( event ); } } maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/exception/000077500000000000000000000000001317160430700255415ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/exception/DefaultExceptionHandler.java000066400000000000000000000255321317160430700331540ustar00rootroot00000000000000package org.apache.maven.exception; /* * 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.net.ConnectException; import java.net.UnknownHostException; import java.util.ArrayList; import java.util.List; import org.apache.maven.lifecycle.LifecycleExecutionException; import org.apache.maven.model.building.ModelProblem; import org.apache.maven.model.building.ModelProblemUtils; import org.apache.maven.plugin.AbstractMojoExecutionException; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoFailureException; import org.apache.maven.plugin.PluginContainerException; import org.apache.maven.plugin.PluginExecutionException; import org.apache.maven.project.ProjectBuildingException; import org.apache.maven.project.ProjectBuildingResult; import org.codehaus.plexus.component.annotations.Component; import org.codehaus.plexus.util.StringUtils; /* - test projects for each of these - how to categorize the problems so that the id of the problem can be match to a page with descriptive help and the test project - nice little sample projects that could be run in the core as well as integration tests All Possible Errors - invalid lifecycle phase (maybe same as bad CLI param, though you were talking about embedder too) - specified is not found - malformed settings - malformed POM - local repository not writable - remote repositories not available - artifact metadata missing - extension metadata missing - extension artifact missing - artifact metadata retrieval problem - version range violation - circular dependency - artifact missing - artifact retrieval exception - md5 checksum doesn't match for local artifact, need to redownload this - POM doesn't exist for a goal that requires one - parent POM missing (in both the repository + relative path) - component not found Plugins: - plugin metadata missing - plugin metadata retrieval problem - plugin artifact missing - plugin artifact retrieval problem - plugin dependency metadata missing - plugin dependency metadata retrieval problem - plugin configuration problem - plugin execution failure due to something that is know to possibly go wrong (like compilation failure) - plugin execution error due to something that is not expected to go wrong (the compiler executable missing) - asking to use a plugin for which you do not have a version defined - tools to easily select versions - goal not found in a plugin (probably could list the ones that are) */ // PluginNotFoundException, PluginResolutionException, PluginDescriptorParsingException, // CycleDetectedInPluginGraphException; @Component( role = ExceptionHandler.class ) public class DefaultExceptionHandler implements ExceptionHandler { public ExceptionSummary handleException( Throwable exception ) { return handle( "", exception ); } private ExceptionSummary handle( String message, Throwable exception ) { String reference = getReference( exception ); List children = null; if ( exception instanceof ProjectBuildingException ) { List results = ( (ProjectBuildingException) exception ).getResults(); children = new ArrayList<>(); for ( ProjectBuildingResult result : results ) { ExceptionSummary child = handle( result ); if ( child != null ) { children.add( child ); } } message = "The build could not read " + children.size() + " project" + ( children.size() == 1 ? "" : "s" ); } else { message = getMessage( message, exception ); } return new ExceptionSummary( exception, message, reference, children ); } private ExceptionSummary handle( ProjectBuildingResult result ) { List children = new ArrayList<>(); for ( ModelProblem problem : result.getProblems() ) { ExceptionSummary child = handle( problem, result.getProjectId() ); if ( child != null ) { children.add( child ); } } if ( children.isEmpty() ) { return null; } String message = "\nThe project " + result.getProjectId() + " (" + result.getPomFile() + ") has " + children.size() + " error" + ( children.size() == 1 ? "" : "s" ); return new ExceptionSummary( null, message, null, children ); } private ExceptionSummary handle( ModelProblem problem, String projectId ) { if ( ModelProblem.Severity.ERROR.compareTo( problem.getSeverity() ) >= 0 ) { String message = problem.getMessage(); String location = ModelProblemUtils.formatLocation( problem, projectId ); if ( StringUtils.isNotEmpty( location ) ) { message += " @ " + location; } return handle( message, problem.getException() ); } else { return null; } } private String getReference( Throwable exception ) { String reference = ""; if ( exception != null ) { if ( exception instanceof MojoExecutionException ) { reference = MojoExecutionException.class.getSimpleName(); Throwable cause = exception.getCause(); if ( cause instanceof IOException ) { cause = cause.getCause(); if ( cause instanceof ConnectException ) { reference = ConnectException.class.getSimpleName(); } } } else if ( exception instanceof MojoFailureException ) { reference = MojoFailureException.class.getSimpleName(); } else if ( exception instanceof LinkageError ) { reference = LinkageError.class.getSimpleName(); } else if ( exception instanceof PluginExecutionException ) { Throwable cause = exception.getCause(); if ( cause instanceof PluginContainerException ) { Throwable cause2 = cause.getCause(); if ( cause2 instanceof NoClassDefFoundError && cause2.getMessage().contains( "org/sonatype/aether/" ) ) { reference = "AetherClassNotFound"; } } if ( StringUtils.isEmpty( reference ) ) { reference = getReference( cause ); } if ( StringUtils.isEmpty( reference ) ) { reference = exception.getClass().getSimpleName(); } } else if ( exception instanceof LifecycleExecutionException ) { reference = getReference( exception.getCause() ); } else if ( isNoteworthyException( exception ) ) { reference = exception.getClass().getSimpleName(); } } if ( StringUtils.isNotEmpty( reference ) && !reference.startsWith( "http:" ) ) { reference = "http://cwiki.apache.org/confluence/display/MAVEN/" + reference; } return reference; } private boolean isNoteworthyException( Throwable exception ) { if ( exception == null ) { return false; } else if ( exception instanceof Error ) { return true; } else if ( exception instanceof RuntimeException ) { return false; } else if ( exception.getClass().getName().startsWith( "java" ) ) { return false; } return true; } private String getMessage( String message, Throwable exception ) { String fullMessage = ( message != null ) ? message : ""; for ( Throwable t = exception; t != null; t = t.getCause() ) { String exceptionMessage = t.getMessage(); if ( t instanceof AbstractMojoExecutionException ) { String longMessage = ( (AbstractMojoExecutionException) t ).getLongMessage(); if ( StringUtils.isNotEmpty( longMessage ) ) { if ( StringUtils.isEmpty( exceptionMessage ) || longMessage.contains( exceptionMessage ) ) { exceptionMessage = longMessage; } else if ( !exceptionMessage.contains( longMessage ) ) { exceptionMessage = join( exceptionMessage, '\n' + longMessage ); } } } if ( StringUtils.isEmpty( exceptionMessage ) ) { exceptionMessage = t.getClass().getSimpleName(); } if ( t instanceof UnknownHostException && !fullMessage.contains( "host" ) ) { fullMessage = join( fullMessage, "Unknown host " + exceptionMessage ); } else if ( !fullMessage.contains( exceptionMessage ) ) { fullMessage = join( fullMessage, exceptionMessage ); } } return fullMessage.trim(); } private String join( String message1, String message2 ) { String message = ""; if ( StringUtils.isNotEmpty( message1 ) ) { message = message1.trim(); } if ( StringUtils.isNotEmpty( message2 ) ) { if ( StringUtils.isNotEmpty( message ) ) { if ( message.endsWith( "." ) || message.endsWith( "!" ) || message.endsWith( ":" ) ) { message += " "; } else { message += ": "; } } message += message2; } return message; } } maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/exception/ExceptionHandler.java000066400000000000000000000020011317160430700316310ustar00rootroot00000000000000package org.apache.maven.exception; /* * 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. */ /** * Transform an exception into useful end-user message. * * @since 3.0-alpha-3 */ public interface ExceptionHandler { ExceptionSummary handleException( Throwable e ); } maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/exception/ExceptionSummary.java000066400000000000000000000044221317160430700317220ustar00rootroot00000000000000package org.apache.maven.exception; /* * 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.util.Collections; import java.util.List; /** * Provide a summary of the exception, containing:

*/ public class ExceptionSummary { private Throwable exception; private String message; private String reference; private List children; public ExceptionSummary( Throwable exception, String message, String reference ) { this( exception, message, reference, null ); } public ExceptionSummary( Throwable exception, String message, String reference, List children ) { this.exception = exception; this.message = ( message != null ) ? message : ""; this.reference = ( reference != null ) ? reference : ""; this.children = ( children != null ) ? children : Collections.emptyList(); } public Throwable getException() { return exception; } public String getMessage() { return message; } public String getReference() { return reference; } public List getChildren() { return children; } } maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/execution/000077500000000000000000000000001317160430700255465ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/execution/AbstractExecutionListener.java000066400000000000000000000053231317160430700335510ustar00rootroot00000000000000package org.apache.maven.execution; /* * 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. */ /** * Provides a skeleton implementation for execution listeners. The methods of this class are empty. * * @author Benjamin Bentmann */ public class AbstractExecutionListener implements ExecutionListener { public void projectDiscoveryStarted( ExecutionEvent event ) { // default does nothing } public void sessionStarted( ExecutionEvent event ) { // default does nothing } public void sessionEnded( ExecutionEvent event ) { // default does nothing } public void projectSkipped( ExecutionEvent event ) { // default does nothing } public void projectStarted( ExecutionEvent event ) { // default does nothing } public void projectSucceeded( ExecutionEvent event ) { // default does nothing } public void projectFailed( ExecutionEvent event ) { // default does nothing } public void forkStarted( ExecutionEvent event ) { // default does nothing } public void forkSucceeded( ExecutionEvent event ) { // default does nothing } public void forkFailed( ExecutionEvent event ) { // default does nothing } public void mojoSkipped( ExecutionEvent event ) { // default does nothing } public void mojoStarted( ExecutionEvent event ) { // default does nothing } public void mojoSucceeded( ExecutionEvent event ) { // default does nothing } public void mojoFailed( ExecutionEvent event ) { // default does nothing } public void forkedProjectStarted( ExecutionEvent event ) { // default does nothing } public void forkedProjectSucceeded( ExecutionEvent event ) { // default does nothing } public void forkedProjectFailed( ExecutionEvent event ) { // default does nothing } } maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/execution/BuildFailure.java000066400000000000000000000034161317160430700307640ustar00rootroot00000000000000package org.apache.maven.execution; /* * 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 org.apache.maven.project.MavenProject; /** * Summarizes the result of a failed project build in the reactor. * * @author Benjamin Bentmann */ public class BuildFailure extends BuildSummary { /** * The cause of the build failure. */ private final Throwable cause; /** * Creates a new build summary for the specified project. * * @param project The project being summarized, must not be {@code null}. * @param time The build time of the project in milliseconds. * @param cause The cause of the build failure, may be {@code null}. */ public BuildFailure( MavenProject project, long time, Throwable cause ) { super( project, time ); this.cause = cause; } /** * Gets the cause of the build failure. * * @return The cause of the build failure or {@code null} if unknown. */ public Throwable getCause() { return cause; } } maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/execution/BuildSuccess.java000066400000000000000000000025611317160430700310050ustar00rootroot00000000000000package org.apache.maven.execution; /* * 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 org.apache.maven.project.MavenProject; /** * Summarizes the result of a successful project build in the reactor. * * @author Benjamin Bentmann */ public class BuildSuccess extends BuildSummary { /** * Creates a new build summary for the specified project. * * @param project The project being summarized, must not be {@code null}. * @param time The build time of the project in milliseconds. */ public BuildSuccess( MavenProject project, long time ) { super( project, time ); } } maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/execution/BuildSummary.java000066400000000000000000000041071317160430700310300ustar00rootroot00000000000000package org.apache.maven.execution; /* * 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 org.apache.commons.lang3.Validate; import org.apache.maven.project.MavenProject; /** * Summarizes the result of a project build in the reactor. * * @author Benjamin Bentmann */ public abstract class BuildSummary { /** * The project being summarized. */ private final MavenProject project; /** * The build time of the project in milliseconds. */ private final long time; /** * Creates a new build summary for the specified project. * * @param project The project being summarized, must not be {@code null}. * @param time The build time of the project in milliseconds. */ protected BuildSummary( MavenProject project, long time ) { this.project = Validate.notNull( project, "project cannot be null" ); // TODO Validate for < 0? this.time = time; } /** * Gets the project being summarized. * * @return The project being summarized, never {@code null}. */ public MavenProject getProject() { return project; } /** * Gets the build time of the project in milliseconds. * * @return The build time of the project in milliseconds. */ public long getTime() { return time; } } DefaultMavenExecutionRequest.java000066400000000000000000000741031317160430700341470ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/executionpackage org.apache.maven.execution; /* * 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.File; import java.util.ArrayList; import java.util.Date; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Properties; import org.apache.commons.lang3.Validate; import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.eventspy.internal.EventSpyDispatcher; import org.apache.maven.model.Profile; import org.apache.maven.project.DefaultProjectBuildingRequest; import org.apache.maven.project.ProjectBuildingRequest; import org.apache.maven.properties.internal.SystemProperties; import org.apache.maven.settings.Mirror; import org.apache.maven.settings.Proxy; import org.apache.maven.settings.Server; import org.apache.maven.toolchain.model.ToolchainModel; import org.eclipse.aether.DefaultRepositoryCache; import org.eclipse.aether.RepositoryCache; import org.eclipse.aether.repository.WorkspaceReader; import org.eclipse.aether.transfer.TransferListener; import com.google.common.collect.Maps; /** * @author Jason van Zyl */ public class DefaultMavenExecutionRequest implements MavenExecutionRequest { private RepositoryCache repositoryCache = new DefaultRepositoryCache(); private WorkspaceReader workspaceReader; private ArtifactRepository localRepository; private EventSpyDispatcher eventSpyDispatcher; private File localRepositoryPath; private boolean offline = false; private boolean interactiveMode = true; private boolean cacheTransferError; private boolean cacheNotFound; private List proxies; private List servers; private List mirrors; private List profiles; private List pluginGroups; private boolean isProjectPresent = true; // ---------------------------------------------------------------------------- // We need to allow per execution user and global settings as the embedder // might be running in a mode where its executing many threads with totally // different settings. // ---------------------------------------------------------------------------- private File userSettingsFile; private File globalSettingsFile; private File userToolchainsFile; private File globalToolchainsFile; // ---------------------------------------------------------------------------- // Request // ---------------------------------------------------------------------------- private File multiModuleProjectDirectory; private File basedir; private List goals; private boolean useReactor = false; private boolean recursive = true; private File pom; private String reactorFailureBehavior = REACTOR_FAIL_FAST; private List selectedProjects; private List excludedProjects; private String resumeFrom; private String makeBehavior; private Properties systemProperties; private Properties userProperties; private Date startTime; private boolean showErrors = false; private List activeProfiles; private List inactiveProfiles; private TransferListener transferListener; private int loggingLevel = LOGGING_LEVEL_INFO; private String globalChecksumPolicy; private boolean updateSnapshots = false; private List remoteRepositories; private List pluginArtifactRepositories; private ExecutionListener executionListener; private int degreeOfConcurrency = 1; private String builderId = "singlethreaded"; private Map> toolchains; /** * Suppress SNAPSHOT updates. * * @issue MNG-2681 */ private boolean noSnapshotUpdates; private boolean useLegacyLocalRepositoryManager = false; private Map data; public DefaultMavenExecutionRequest() { } public static MavenExecutionRequest copy( MavenExecutionRequest original ) { DefaultMavenExecutionRequest copy = new DefaultMavenExecutionRequest(); copy.setLocalRepository( original.getLocalRepository() ); copy.setLocalRepositoryPath( original.getLocalRepositoryPath() ); copy.setOffline( original.isOffline() ); copy.setInteractiveMode( original.isInteractiveMode() ); copy.setCacheNotFound( original.isCacheNotFound() ); copy.setCacheTransferError( original.isCacheTransferError() ); copy.setProxies( original.getProxies() ); copy.setServers( original.getServers() ); copy.setMirrors( original.getMirrors() ); copy.setProfiles( original.getProfiles() ); copy.setPluginGroups( original.getPluginGroups() ); copy.setProjectPresent( original.isProjectPresent() ); copy.setUserSettingsFile( original.getUserSettingsFile() ); copy.setGlobalSettingsFile( original.getGlobalSettingsFile() ); copy.setUserToolchainsFile( original.getUserToolchainsFile() ); copy.setGlobalToolchainsFile( original.getGlobalToolchainsFile() ); copy.setBaseDirectory( ( original.getBaseDirectory() != null ) ? new File( original.getBaseDirectory() ) : null ); copy.setGoals( original.getGoals() ); copy.setRecursive( original.isRecursive() ); copy.setPom( original.getPom() ); copy.setSystemProperties( original.getSystemProperties() ); copy.setUserProperties( original.getUserProperties() ); copy.setShowErrors( original.isShowErrors() ); copy.setActiveProfiles( original.getActiveProfiles() ); copy.setInactiveProfiles( original.getInactiveProfiles() ); copy.setTransferListener( original.getTransferListener() ); copy.setLoggingLevel( original.getLoggingLevel() ); copy.setGlobalChecksumPolicy( original.getGlobalChecksumPolicy() ); copy.setUpdateSnapshots( original.isUpdateSnapshots() ); copy.setRemoteRepositories( original.getRemoteRepositories() ); copy.setPluginArtifactRepositories( original.getPluginArtifactRepositories() ); copy.setRepositoryCache( original.getRepositoryCache() ); copy.setWorkspaceReader( original.getWorkspaceReader() ); copy.setNoSnapshotUpdates( original.isNoSnapshotUpdates() ); copy.setExecutionListener( original.getExecutionListener() ); copy.setUseLegacyLocalRepository( original.isUseLegacyLocalRepository() ); copy.setBuilderId( original.getBuilderId() ); return copy; } @Override public String getBaseDirectory() { if ( basedir == null ) { return null; } return basedir.getAbsolutePath(); } @Override public ArtifactRepository getLocalRepository() { return localRepository; } @Override public File getLocalRepositoryPath() { return localRepositoryPath; } @Override public List getGoals() { if ( goals == null ) { goals = new ArrayList<>(); } return goals; } @Override public Properties getSystemProperties() { if ( systemProperties == null ) { systemProperties = new Properties(); } return systemProperties; } @Override public Properties getUserProperties() { if ( userProperties == null ) { userProperties = new Properties(); } return userProperties; } @Override public File getPom() { return pom; } @Override public String getReactorFailureBehavior() { return reactorFailureBehavior; } @Override public List getSelectedProjects() { if ( selectedProjects == null ) { selectedProjects = new ArrayList<>(); } return selectedProjects; } @Override public List getExcludedProjects() { if ( excludedProjects == null ) { excludedProjects = new ArrayList<>(); } return excludedProjects; } @Override public String getResumeFrom() { return resumeFrom; } @Override public String getMakeBehavior() { return makeBehavior; } @Override public Date getStartTime() { return startTime; } @Override public boolean isShowErrors() { return showErrors; } @Override public boolean isInteractiveMode() { return interactiveMode; } @Override public MavenExecutionRequest setActiveProfiles( List activeProfiles ) { if ( activeProfiles != null ) { this.activeProfiles = new ArrayList<>( activeProfiles ); } else { this.activeProfiles = null; } return this; } @Override public MavenExecutionRequest setInactiveProfiles( List inactiveProfiles ) { if ( inactiveProfiles != null ) { this.inactiveProfiles = new ArrayList<>( inactiveProfiles ); } else { this.inactiveProfiles = null; } return this; } @Override public MavenExecutionRequest setRemoteRepositories( List remoteRepositories ) { if ( remoteRepositories != null ) { this.remoteRepositories = new ArrayList<>( remoteRepositories ); } else { this.remoteRepositories = null; } return this; } @Override public MavenExecutionRequest setPluginArtifactRepositories( List pluginArtifactRepositories ) { if ( pluginArtifactRepositories != null ) { this.pluginArtifactRepositories = new ArrayList<>( pluginArtifactRepositories ); } else { this.pluginArtifactRepositories = null; } return this; } public void setProjectBuildingConfiguration( ProjectBuildingRequest projectBuildingConfiguration ) { this.projectBuildingRequest = projectBuildingConfiguration; } @Override public List getActiveProfiles() { if ( activeProfiles == null ) { activeProfiles = new ArrayList<>(); } return activeProfiles; } @Override public List getInactiveProfiles() { if ( inactiveProfiles == null ) { inactiveProfiles = new ArrayList<>(); } return inactiveProfiles; } @Override public TransferListener getTransferListener() { return transferListener; } @Override public int getLoggingLevel() { return loggingLevel; } @Override public boolean isOffline() { return offline; } @Override public boolean isUpdateSnapshots() { return updateSnapshots; } @Override public boolean isNoSnapshotUpdates() { return noSnapshotUpdates; } @Override public String getGlobalChecksumPolicy() { return globalChecksumPolicy; } @Override public boolean isRecursive() { return recursive; } // ---------------------------------------------------------------------- // // ---------------------------------------------------------------------- @Override public MavenExecutionRequest setBaseDirectory( File basedir ) { this.basedir = basedir; return this; } @Override public MavenExecutionRequest setStartTime( Date startTime ) { this.startTime = startTime; return this; } @Override public MavenExecutionRequest setShowErrors( boolean showErrors ) { this.showErrors = showErrors; return this; } @Override public MavenExecutionRequest setGoals( List goals ) { if ( goals != null ) { this.goals = new ArrayList<>( goals ); } else { this.goals = null; } return this; } @Override public MavenExecutionRequest setLocalRepository( ArtifactRepository localRepository ) { this.localRepository = localRepository; if ( localRepository != null ) { setLocalRepositoryPath( new File( localRepository.getBasedir() ).getAbsoluteFile() ); } return this; } @Override public MavenExecutionRequest setLocalRepositoryPath( File localRepository ) { localRepositoryPath = localRepository; return this; } @Override public MavenExecutionRequest setLocalRepositoryPath( String localRepository ) { localRepositoryPath = ( localRepository != null ) ? new File( localRepository ) : null; return this; } @Override public MavenExecutionRequest setSystemProperties( Properties properties ) { if ( properties != null ) { this.systemProperties = SystemProperties.copyProperties( properties ); } else { this.systemProperties = null; } return this; } @Override public MavenExecutionRequest setUserProperties( Properties userProperties ) { if ( userProperties != null ) { this.userProperties = new Properties(); this.userProperties.putAll( userProperties ); } else { this.userProperties = null; } return this; } @Override public MavenExecutionRequest setReactorFailureBehavior( String failureBehavior ) { reactorFailureBehavior = failureBehavior; return this; } @Override public MavenExecutionRequest setSelectedProjects( List selectedProjects ) { if ( selectedProjects != null ) { this.selectedProjects = new ArrayList<>( selectedProjects ); } else { this.selectedProjects = null; } return this; } @Override public MavenExecutionRequest setExcludedProjects( List excludedProjects ) { if ( excludedProjects != null ) { this.excludedProjects = new ArrayList<>( excludedProjects ); } else { this.excludedProjects = null; } return this; } @Override public MavenExecutionRequest setResumeFrom( String project ) { this.resumeFrom = project; return this; } @Override public MavenExecutionRequest setMakeBehavior( String makeBehavior ) { this.makeBehavior = makeBehavior; return this; } @Override public MavenExecutionRequest addActiveProfile( String profile ) { if ( !getActiveProfiles().contains( profile ) ) { getActiveProfiles().add( profile ); } return this; } @Override public MavenExecutionRequest addInactiveProfile( String profile ) { if ( !getInactiveProfiles().contains( profile ) ) { getInactiveProfiles().add( profile ); } return this; } @Override public MavenExecutionRequest addActiveProfiles( List profiles ) { for ( String profile : profiles ) { addActiveProfile( profile ); } return this; } @Override public MavenExecutionRequest addInactiveProfiles( List profiles ) { for ( String profile : profiles ) { addInactiveProfile( profile ); } return this; } public MavenExecutionRequest setUseReactor( boolean reactorActive ) { useReactor = reactorActive; return this; } public boolean useReactor() { return useReactor; } /** @deprecated use {@link #setPom(File)} */ @Deprecated public MavenExecutionRequest setPomFile( String pomFilename ) { if ( pomFilename != null ) { pom = new File( pomFilename ); } return this; } @Override public MavenExecutionRequest setPom( File pom ) { this.pom = pom; return this; } @Override public MavenExecutionRequest setInteractiveMode( boolean interactive ) { interactiveMode = interactive; return this; } @Override public MavenExecutionRequest setTransferListener( TransferListener transferListener ) { this.transferListener = transferListener; return this; } @Override public MavenExecutionRequest setLoggingLevel( int loggingLevel ) { this.loggingLevel = loggingLevel; return this; } @Override public MavenExecutionRequest setOffline( boolean offline ) { this.offline = offline; return this; } @Override public MavenExecutionRequest setUpdateSnapshots( boolean updateSnapshots ) { this.updateSnapshots = updateSnapshots; return this; } @Override public MavenExecutionRequest setNoSnapshotUpdates( boolean noSnapshotUpdates ) { this.noSnapshotUpdates = noSnapshotUpdates; return this; } @Override public MavenExecutionRequest setGlobalChecksumPolicy( String globalChecksumPolicy ) { this.globalChecksumPolicy = globalChecksumPolicy; return this; } // ---------------------------------------------------------------------------- // Settings equivalents // ---------------------------------------------------------------------------- @Override public List getProxies() { if ( proxies == null ) { proxies = new ArrayList<>(); } return proxies; } @Override public MavenExecutionRequest setProxies( List proxies ) { if ( proxies != null ) { this.proxies = new ArrayList<>( proxies ); } else { this.proxies = null; } return this; } @Override public MavenExecutionRequest addProxy( Proxy proxy ) { Validate.notNull( proxy, "proxy cannot be null" ); for ( Proxy p : getProxies() ) { if ( p.getId() != null && p.getId().equals( proxy.getId() ) ) { return this; } } getProxies().add( proxy ); return this; } @Override public List getServers() { if ( servers == null ) { servers = new ArrayList<>(); } return servers; } @Override public MavenExecutionRequest setServers( List servers ) { if ( servers != null ) { this.servers = new ArrayList<>( servers ); } else { this.servers = null; } return this; } @Override public MavenExecutionRequest addServer( Server server ) { Validate.notNull( server, "server cannot be null" ); for ( Server p : getServers() ) { if ( p.getId() != null && p.getId().equals( server.getId() ) ) { return this; } } getServers().add( server ); return this; } @Override public List getMirrors() { if ( mirrors == null ) { mirrors = new ArrayList<>(); } return mirrors; } @Override public MavenExecutionRequest setMirrors( List mirrors ) { if ( mirrors != null ) { this.mirrors = new ArrayList<>( mirrors ); } else { this.mirrors = null; } return this; } @Override public MavenExecutionRequest addMirror( Mirror mirror ) { Validate.notNull( mirror, "mirror cannot be null" ); for ( Mirror p : getMirrors() ) { if ( p.getId() != null && p.getId().equals( mirror.getId() ) ) { return this; } } getMirrors().add( mirror ); return this; } @Override public List getProfiles() { if ( profiles == null ) { profiles = new ArrayList<>(); } return profiles; } @Override public MavenExecutionRequest setProfiles( List profiles ) { if ( profiles != null ) { this.profiles = new ArrayList<>( profiles ); } else { this.profiles = null; } return this; } @Override public List getPluginGroups() { if ( pluginGroups == null ) { pluginGroups = new ArrayList<>(); } return pluginGroups; } @Override public MavenExecutionRequest setPluginGroups( List pluginGroups ) { if ( pluginGroups != null ) { this.pluginGroups = new ArrayList<>( pluginGroups ); } else { this.pluginGroups = null; } return this; } @Override public MavenExecutionRequest addPluginGroup( String pluginGroup ) { if ( !getPluginGroups().contains( pluginGroup ) ) { getPluginGroups().add( pluginGroup ); } return this; } @Override public MavenExecutionRequest addPluginGroups( List pluginGroups ) { for ( String pluginGroup : pluginGroups ) { addPluginGroup( pluginGroup ); } return this; } @Override public MavenExecutionRequest setRecursive( boolean recursive ) { this.recursive = recursive; return this; } // calculated from request attributes. private ProjectBuildingRequest projectBuildingRequest; @Override public boolean isProjectPresent() { return isProjectPresent; } @Override public MavenExecutionRequest setProjectPresent( boolean projectPresent ) { isProjectPresent = projectPresent; return this; } // Settings files @Override public File getUserSettingsFile() { return userSettingsFile; } @Override public MavenExecutionRequest setUserSettingsFile( File userSettingsFile ) { this.userSettingsFile = userSettingsFile; return this; } @Override public File getGlobalSettingsFile() { return globalSettingsFile; } @Override public MavenExecutionRequest setGlobalSettingsFile( File globalSettingsFile ) { this.globalSettingsFile = globalSettingsFile; return this; } @Override public File getUserToolchainsFile() { return userToolchainsFile; } @Override public MavenExecutionRequest setUserToolchainsFile( File userToolchainsFile ) { this.userToolchainsFile = userToolchainsFile; return this; } @Override public File getGlobalToolchainsFile() { return globalToolchainsFile; } @Override public MavenExecutionRequest setGlobalToolchainsFile( File globalToolchainsFile ) { this.globalToolchainsFile = globalToolchainsFile; return this; } @Override public MavenExecutionRequest addRemoteRepository( ArtifactRepository repository ) { for ( ArtifactRepository repo : getRemoteRepositories() ) { if ( repo.getId() != null && repo.getId().equals( repository.getId() ) ) { return this; } } getRemoteRepositories().add( repository ); return this; } @Override public List getRemoteRepositories() { if ( remoteRepositories == null ) { remoteRepositories = new ArrayList<>(); } return remoteRepositories; } @Override public MavenExecutionRequest addPluginArtifactRepository( ArtifactRepository repository ) { for ( ArtifactRepository repo : getPluginArtifactRepositories() ) { if ( repo.getId() != null && repo.getId().equals( repository.getId() ) ) { return this; } } getPluginArtifactRepositories().add( repository ); return this; } @Override public List getPluginArtifactRepositories() { if ( pluginArtifactRepositories == null ) { pluginArtifactRepositories = new ArrayList<>(); } return pluginArtifactRepositories; } // TODO this does not belong here. @Override public ProjectBuildingRequest getProjectBuildingRequest() { if ( projectBuildingRequest == null ) { projectBuildingRequest = new DefaultProjectBuildingRequest(); projectBuildingRequest.setLocalRepository( getLocalRepository() ); projectBuildingRequest.setSystemProperties( getSystemProperties() ); projectBuildingRequest.setUserProperties( getUserProperties() ); projectBuildingRequest.setRemoteRepositories( getRemoteRepositories() ); projectBuildingRequest.setPluginArtifactRepositories( getPluginArtifactRepositories() ); projectBuildingRequest.setActiveProfileIds( getActiveProfiles() ); projectBuildingRequest.setInactiveProfileIds( getInactiveProfiles() ); projectBuildingRequest.setProfiles( getProfiles() ); projectBuildingRequest.setProcessPlugins( true ); projectBuildingRequest.setBuildStartTime( getStartTime() ); } return projectBuildingRequest; } @Override public MavenExecutionRequest addProfile( Profile profile ) { Validate.notNull( profile, "profile cannot be null" ); for ( Profile p : getProfiles() ) { if ( p.getId() != null && p.getId().equals( profile.getId() ) ) { return this; } } getProfiles().add( profile ); return this; } @Override public RepositoryCache getRepositoryCache() { return repositoryCache; } @Override public MavenExecutionRequest setRepositoryCache( RepositoryCache repositoryCache ) { this.repositoryCache = repositoryCache; return this; } @Override public ExecutionListener getExecutionListener() { return executionListener; } @Override public MavenExecutionRequest setExecutionListener( ExecutionListener executionListener ) { this.executionListener = executionListener; return this; } @Override public void setDegreeOfConcurrency( final int degreeOfConcurrency ) { this.degreeOfConcurrency = degreeOfConcurrency; } @Override public int getDegreeOfConcurrency() { return degreeOfConcurrency; } @Override public WorkspaceReader getWorkspaceReader() { return workspaceReader; } @Override public MavenExecutionRequest setWorkspaceReader( WorkspaceReader workspaceReader ) { this.workspaceReader = workspaceReader; return this; } @Override public boolean isCacheTransferError() { return cacheTransferError; } @Override public MavenExecutionRequest setCacheTransferError( boolean cacheTransferError ) { this.cacheTransferError = cacheTransferError; return this; } @Override public boolean isCacheNotFound() { return cacheNotFound; } @Override public MavenExecutionRequest setCacheNotFound( boolean cacheNotFound ) { this.cacheNotFound = cacheNotFound; return this; } @Override public boolean isUseLegacyLocalRepository() { return this.useLegacyLocalRepositoryManager; } @Override public MavenExecutionRequest setUseLegacyLocalRepository( boolean useLegacyLocalRepositoryManager ) { this.useLegacyLocalRepositoryManager = useLegacyLocalRepositoryManager; return this; } @Override public MavenExecutionRequest setBuilderId( String builderId ) { this.builderId = builderId; return this; } @Override public String getBuilderId() { return builderId; } @Override public Map> getToolchains() { if ( toolchains == null ) { toolchains = new HashMap<>(); } return toolchains; } @Override public MavenExecutionRequest setToolchains( Map> toolchains ) { this.toolchains = toolchains; return this; } @Override public void setMultiModuleProjectDirectory( File directory ) { this.multiModuleProjectDirectory = directory; } @Override public File getMultiModuleProjectDirectory() { return multiModuleProjectDirectory; } @Override public MavenExecutionRequest setEventSpyDispatcher( EventSpyDispatcher eventSpyDispatcher ) { this.eventSpyDispatcher = eventSpyDispatcher; return this; } @Override public EventSpyDispatcher getEventSpyDispatcher() { return eventSpyDispatcher; } @Override public Map getData() { if ( data == null ) { data = Maps.newHashMap(); } return data; } } DefaultMavenExecutionRequestPopulator.java000066400000000000000000000242611317160430700360550ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/executionpackage org.apache.maven.execution; /* * 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.File; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Set; import javax.inject.Inject; import javax.inject.Named; import org.apache.maven.artifact.InvalidRepositoryException; import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.bridge.MavenRepositorySystem; import org.apache.maven.repository.RepositorySystem; // // All of this needs to go away and be couched in terms of the execution request // import org.apache.maven.settings.Mirror; import org.apache.maven.settings.Proxy; import org.apache.maven.settings.Repository; import org.apache.maven.settings.Server; import org.apache.maven.settings.Settings; import org.apache.maven.settings.SettingsUtils; // // Settings in core // import org.apache.maven.toolchain.model.PersistedToolchains; import org.apache.maven.toolchain.model.ToolchainModel; import org.codehaus.plexus.util.StringUtils; @Named public class DefaultMavenExecutionRequestPopulator implements MavenExecutionRequestPopulator { private final MavenRepositorySystem repositorySystem; @Inject public DefaultMavenExecutionRequestPopulator( MavenRepositorySystem repositorySystem ) { this.repositorySystem = repositorySystem; } @Override public MavenExecutionRequest populateFromToolchains( MavenExecutionRequest request, PersistedToolchains toolchains ) throws MavenExecutionRequestPopulationException { if ( toolchains != null ) { Map> groupedToolchains = new HashMap<>( 2 ); for ( ToolchainModel model : toolchains.getToolchains() ) { if ( !groupedToolchains.containsKey( model.getType() ) ) { groupedToolchains.put( model.getType(), new ArrayList() ); } groupedToolchains.get( model.getType() ).add( model ); } request.setToolchains( groupedToolchains ); } return request; } @Override public MavenExecutionRequest populateDefaults( MavenExecutionRequest request ) throws MavenExecutionRequestPopulationException { baseDirectory( request ); localRepository( request ); populateDefaultPluginGroups( request ); injectDefaultRepositories( request ); injectDefaultPluginRepositories( request ); return request; } // // // private void populateDefaultPluginGroups( MavenExecutionRequest request ) { request.addPluginGroup( "org.apache.maven.plugins" ); request.addPluginGroup( "org.codehaus.mojo" ); } private void injectDefaultRepositories( MavenExecutionRequest request ) throws MavenExecutionRequestPopulationException { Set definedRepositories = repositorySystem.getRepoIds( request.getRemoteRepositories() ); if ( !definedRepositories.contains( RepositorySystem.DEFAULT_REMOTE_REPO_ID ) ) { try { request.addRemoteRepository( repositorySystem.createDefaultRemoteRepository( request ) ); } catch ( Exception e ) { throw new MavenExecutionRequestPopulationException( "Cannot create default remote repository.", e ); } } } private void injectDefaultPluginRepositories( MavenExecutionRequest request ) throws MavenExecutionRequestPopulationException { Set definedRepositories = repositorySystem.getRepoIds( request.getPluginArtifactRepositories() ); if ( !definedRepositories.contains( RepositorySystem.DEFAULT_REMOTE_REPO_ID ) ) { try { request.addPluginArtifactRepository( repositorySystem.createDefaultRemoteRepository( request ) ); } catch ( Exception e ) { throw new MavenExecutionRequestPopulationException( "Cannot create default remote repository.", e ); } } } private void localRepository( MavenExecutionRequest request ) throws MavenExecutionRequestPopulationException { // ------------------------------------------------------------------------ // Local Repository // // 1. Use a value has been passed in via the configuration // 2. Use value in the resultant settings // 3. Use default value // ------------------------------------------------------------------------ if ( request.getLocalRepository() == null ) { request.setLocalRepository( createLocalRepository( request ) ); } if ( request.getLocalRepositoryPath() == null ) { request.setLocalRepositoryPath( new File( request.getLocalRepository().getBasedir() ).getAbsoluteFile() ); } } // ------------------------------------------------------------------------ // Artifact Transfer Mechanism // ------------------------------------------------------------------------ private ArtifactRepository createLocalRepository( MavenExecutionRequest request ) throws MavenExecutionRequestPopulationException { String localRepositoryPath = null; if ( request.getLocalRepositoryPath() != null ) { localRepositoryPath = request.getLocalRepositoryPath().getAbsolutePath(); } if ( StringUtils.isEmpty( localRepositoryPath ) ) { localRepositoryPath = RepositorySystem.defaultUserLocalRepository.getAbsolutePath(); } try { return repositorySystem.createLocalRepository( request, new File( localRepositoryPath ) ); } catch ( Exception e ) { throw new MavenExecutionRequestPopulationException( "Cannot create local repository.", e ); } } private void baseDirectory( MavenExecutionRequest request ) { if ( request.getBaseDirectory() == null && request.getPom() != null ) { request.setBaseDirectory( request.getPom().getAbsoluteFile().getParentFile() ); } } /*if_not[MAVEN4]*/ @Override @Deprecated public MavenExecutionRequest populateFromSettings( MavenExecutionRequest request, Settings settings ) throws MavenExecutionRequestPopulationException { if ( settings == null ) { return request; } request.setOffline( settings.isOffline() ); request.setInteractiveMode( settings.isInteractiveMode() ); request.setPluginGroups( settings.getPluginGroups() ); request.setLocalRepositoryPath( settings.getLocalRepository() ); for ( Server server : settings.getServers() ) { server = server.clone(); request.addServer( server ); } // // // true // http // proxy.somewhere.com // 8080 // proxyuser // somepassword // www.google.com|*.somewhere.com // // for ( Proxy proxy : settings.getProxies() ) { if ( !proxy.isActive() ) { continue; } proxy = proxy.clone(); request.addProxy( proxy ); } // // // nexus // * // http://repository.sonatype.org/content/groups/public // // for ( Mirror mirror : settings.getMirrors() ) { mirror = mirror.clone(); request.addMirror( mirror ); } request.setActiveProfiles( settings.getActiveProfiles() ); for ( org.apache.maven.settings.Profile rawProfile : settings.getProfiles() ) { request.addProfile( SettingsUtils.convertFromSettingsProfile( rawProfile ) ); if ( settings.getActiveProfiles().contains( rawProfile.getId() ) ) { List remoteRepositories = rawProfile.getRepositories(); for ( Repository remoteRepository : remoteRepositories ) { try { request.addRemoteRepository( repositorySystem.buildArtifactRepository( remoteRepository ) ); } catch ( InvalidRepositoryException e ) { // do nothing for now } } List pluginRepositories = rawProfile.getPluginRepositories(); for ( Repository pluginRepo : pluginRepositories ) { try { request.addPluginArtifactRepository( repositorySystem.buildArtifactRepository( pluginRepo ) ); } catch ( InvalidRepositoryException e ) { // do nothing for now } } } } return request; } /*end[MAVEN4]*/ } DefaultMavenExecutionResult.java000066400000000000000000000061761317160430700340020ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/executionpackage org.apache.maven.execution; /* * 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.util.Collections; import java.util.IdentityHashMap; import java.util.List; import java.util.Map; import java.util.concurrent.CopyOnWriteArrayList; import org.apache.maven.project.DependencyResolutionResult; import org.apache.maven.project.MavenProject; /** @author Jason van Zyl */ public class DefaultMavenExecutionResult implements MavenExecutionResult { private MavenProject project; private List topologicallySortedProjects = Collections.emptyList(); private DependencyResolutionResult dependencyResolutionResult; private final List exceptions = new CopyOnWriteArrayList<>(); private final Map buildSummaries = Collections.synchronizedMap( new IdentityHashMap() ); public MavenExecutionResult setProject( MavenProject project ) { this.project = project; return this; } public MavenProject getProject() { return project; } public MavenExecutionResult setTopologicallySortedProjects( List topologicallySortedProjects ) { this.topologicallySortedProjects = topologicallySortedProjects; return this; } public List getTopologicallySortedProjects() { return null == topologicallySortedProjects ? Collections.emptyList() : topologicallySortedProjects; } public DependencyResolutionResult getDependencyResolutionResult() { return dependencyResolutionResult; } public MavenExecutionResult setDependencyResolutionResult( DependencyResolutionResult dependencyResolutionResult ) { this.dependencyResolutionResult = dependencyResolutionResult; return this; } public List getExceptions() { return exceptions; } public MavenExecutionResult addException( Throwable t ) { exceptions.add( t ); return this; } public boolean hasExceptions() { return !getExceptions().isEmpty(); } public BuildSummary getBuildSummary( MavenProject project ) { return buildSummaries.get( project ); } public void addBuildSummary( BuildSummary summary ) { buildSummaries.put( summary.getProject(), summary ); } } maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/execution/ExecutionEvent.java000066400000000000000000000045341317160430700313640ustar00rootroot00000000000000package org.apache.maven.execution; /* * 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 org.apache.maven.plugin.MojoExecution; import org.apache.maven.project.MavenProject; /** * Holds data relevant for an execution event. * * @author Benjamin Bentmann */ public interface ExecutionEvent { /** * The possible types of execution events. */ enum Type { ProjectDiscoveryStarted, SessionStarted, SessionEnded, ProjectSkipped, ProjectStarted, ProjectSucceeded, ProjectFailed, MojoSkipped, MojoStarted, MojoSucceeded, MojoFailed, ForkStarted, ForkSucceeded, ForkFailed, ForkedProjectStarted, ForkedProjectSucceeded, ForkedProjectFailed, } /** * Gets the type of the event. * * @return The type of the event, never {@code null}. */ Type getType(); /** * Gets the session from which this event originates. * * @return The current session, never {@code null}. */ MavenSession getSession(); /** * Gets the current project (if any). * * @return The current project or {@code null} if not applicable. */ MavenProject getProject(); /** * Gets the current mojo execution (if any). * * @return The current mojo execution or {@code null} if not applicable. */ MojoExecution getMojoExecution(); /** * Gets the exception that caused the event (if any). * * @return The exception or {@code null} if none. */ Exception getException(); } maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/execution/ExecutionListener.java000066400000000000000000000040601317160430700320620ustar00rootroot00000000000000package org.apache.maven.execution; /* * 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. */ /** * Defines events that Maven fires during a build. Warning: This interface might be extended in future * Maven versions to support further events. Hence it is strongly recommended to derive custom listeners from * {@link AbstractExecutionListener} in order to avoid interoperability problems. * * @author Benjamin Bentmann */ public interface ExecutionListener { void projectDiscoveryStarted( ExecutionEvent event ); void sessionStarted( ExecutionEvent event ); void sessionEnded( ExecutionEvent event ); void projectSkipped( ExecutionEvent event ); void projectStarted( ExecutionEvent event ); void projectSucceeded( ExecutionEvent event ); void projectFailed( ExecutionEvent event ); void mojoSkipped( ExecutionEvent event ); void mojoStarted( ExecutionEvent event ); void mojoSucceeded( ExecutionEvent event ); void mojoFailed( ExecutionEvent event ); void forkStarted( ExecutionEvent event ); void forkSucceeded( ExecutionEvent event ); void forkFailed( ExecutionEvent event ); void forkedProjectStarted( ExecutionEvent event ); void forkedProjectSucceeded( ExecutionEvent event ); void forkedProjectFailed( ExecutionEvent event ); } maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/execution/MavenExecutionRequest.java000066400000000000000000000317471317160430700327300ustar00rootroot00000000000000package org.apache.maven.execution; /* * 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.File; import java.util.Date; import java.util.List; import java.util.Map; import java.util.Properties; import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.repository.ArtifactRepositoryPolicy; import org.apache.maven.eventspy.internal.EventSpyDispatcher; import org.apache.maven.model.Profile; import org.apache.maven.project.ProjectBuildingRequest; // // These settings values need to be removed and pushed down into a provider of configuration information // import org.apache.maven.settings.Mirror; import org.apache.maven.settings.Proxy; import org.apache.maven.settings.Server; // import org.apache.maven.toolchain.model.ToolchainModel; import org.codehaus.plexus.logging.Logger; import org.eclipse.aether.RepositoryCache; import org.eclipse.aether.repository.WorkspaceReader; import org.eclipse.aether.transfer.TransferListener; /** * @author Jason van Zyl */ public interface MavenExecutionRequest { // ---------------------------------------------------------------------- // Logging // ---------------------------------------------------------------------- int LOGGING_LEVEL_DEBUG = Logger.LEVEL_DEBUG; int LOGGING_LEVEL_INFO = Logger.LEVEL_INFO; int LOGGING_LEVEL_WARN = Logger.LEVEL_WARN; int LOGGING_LEVEL_ERROR = Logger.LEVEL_ERROR; int LOGGING_LEVEL_FATAL = Logger.LEVEL_FATAL; int LOGGING_LEVEL_DISABLED = Logger.LEVEL_DISABLED; // ---------------------------------------------------------------------- // Reactor Failure Mode // ---------------------------------------------------------------------- String REACTOR_FAIL_FAST = "FAIL_FAST"; String REACTOR_FAIL_AT_END = "FAIL_AT_END"; String REACTOR_FAIL_NEVER = "FAIL_NEVER"; // ---------------------------------------------------------------------- // Reactor Make Mode // ---------------------------------------------------------------------- String REACTOR_MAKE_UPSTREAM = "make-upstream"; String REACTOR_MAKE_DOWNSTREAM = "make-downstream"; String REACTOR_MAKE_BOTH = "make-both"; // ---------------------------------------------------------------------- // Artifact repository policies // ---------------------------------------------------------------------- String CHECKSUM_POLICY_FAIL = ArtifactRepositoryPolicy.CHECKSUM_POLICY_FAIL; String CHECKSUM_POLICY_WARN = ArtifactRepositoryPolicy.CHECKSUM_POLICY_WARN; // ---------------------------------------------------------------------- // // ---------------------------------------------------------------------- // Base directory MavenExecutionRequest setBaseDirectory( File basedir ); String getBaseDirectory(); // Timing (remove this) MavenExecutionRequest setStartTime( Date start ); Date getStartTime(); // Goals MavenExecutionRequest setGoals( List goals ); List getGoals(); // Properties /** * Sets the system properties to use for interpolation and profile activation. The system properties are collected * from the runtime environment like {@link System#getProperties()} and environment variables. * * @param systemProperties The system properties, may be {@code null}. * @return This request, never {@code null}. */ MavenExecutionRequest setSystemProperties( Properties systemProperties ); /** * Gets the system properties to use for interpolation and profile activation. The system properties are collected * from the runtime environment like {@link System#getProperties()} and environment variables. * * @return The system properties, never {@code null}. */ Properties getSystemProperties(); /** * Sets the user properties to use for interpolation and profile activation. The user properties have been * configured directly by the user on his discretion, e.g. via the {@code -Dkey=value} parameter on the command * line. * * @param userProperties The user properties, may be {@code null}. * @return This request, never {@code null}. */ MavenExecutionRequest setUserProperties( Properties userProperties ); /** * Gets the user properties to use for interpolation and profile activation. The user properties have been * configured directly by the user on his discretion, e.g. via the {@code -Dkey=value} parameter on the command * line. * * @return The user properties, never {@code null}. */ Properties getUserProperties(); // Reactor MavenExecutionRequest setReactorFailureBehavior( String failureBehavior ); String getReactorFailureBehavior(); MavenExecutionRequest setSelectedProjects( List projects ); List getSelectedProjects(); /** * @param projects the projects to exclude * @return this MavenExecutionRequest * @since 3.2 */ MavenExecutionRequest setExcludedProjects( List projects ); /** * @return the excluded projects, never {@code null} * @since 3.2 */ List getExcludedProjects(); MavenExecutionRequest setResumeFrom( String project ); String getResumeFrom(); MavenExecutionRequest setMakeBehavior( String makeBehavior ); String getMakeBehavior(); /** * Set's the parallel degree of concurrency used by the build. * * @param degreeOfConcurrency */ void setDegreeOfConcurrency( int degreeOfConcurrency ); /** * @return the degree of concurrency for the build. */ int getDegreeOfConcurrency(); // Recursive (really to just process the top-level POM) MavenExecutionRequest setRecursive( boolean recursive ); boolean isRecursive(); MavenExecutionRequest setPom( File pom ); File getPom(); // Errors MavenExecutionRequest setShowErrors( boolean showErrors ); boolean isShowErrors(); // Transfer listeners MavenExecutionRequest setTransferListener( TransferListener transferListener ); TransferListener getTransferListener(); // Logging MavenExecutionRequest setLoggingLevel( int loggingLevel ); int getLoggingLevel(); // Update snapshots MavenExecutionRequest setUpdateSnapshots( boolean updateSnapshots ); boolean isUpdateSnapshots(); MavenExecutionRequest setNoSnapshotUpdates( boolean noSnapshotUpdates ); boolean isNoSnapshotUpdates(); // Checksum policy MavenExecutionRequest setGlobalChecksumPolicy( String globalChecksumPolicy ); String getGlobalChecksumPolicy(); // Local repository MavenExecutionRequest setLocalRepositoryPath( String localRepository ); MavenExecutionRequest setLocalRepositoryPath( File localRepository ); File getLocalRepositoryPath(); MavenExecutionRequest setLocalRepository( ArtifactRepository repository ); ArtifactRepository getLocalRepository(); // Interactive MavenExecutionRequest setInteractiveMode( boolean interactive ); boolean isInteractiveMode(); // Offline MavenExecutionRequest setOffline( boolean offline ); boolean isOffline(); boolean isCacheTransferError(); MavenExecutionRequest setCacheTransferError( boolean cacheTransferError ); boolean isCacheNotFound(); MavenExecutionRequest setCacheNotFound( boolean cacheNotFound ); // Profiles List getProfiles(); MavenExecutionRequest addProfile( Profile profile ); MavenExecutionRequest setProfiles( List profiles ); MavenExecutionRequest addActiveProfile( String profile ); MavenExecutionRequest addActiveProfiles( List profiles ); MavenExecutionRequest setActiveProfiles( List profiles ); List getActiveProfiles(); MavenExecutionRequest addInactiveProfile( String profile ); MavenExecutionRequest addInactiveProfiles( List profiles ); MavenExecutionRequest setInactiveProfiles( List profiles ); List getInactiveProfiles(); // Proxies List getProxies(); MavenExecutionRequest setProxies( List proxies ); MavenExecutionRequest addProxy( Proxy proxy ); // Servers List getServers(); MavenExecutionRequest setServers( List servers ); MavenExecutionRequest addServer( Server server ); // Mirrors List getMirrors(); MavenExecutionRequest setMirrors( List mirrors ); MavenExecutionRequest addMirror( Mirror mirror ); // Plugin groups List getPluginGroups(); MavenExecutionRequest setPluginGroups( List pluginGroups ); MavenExecutionRequest addPluginGroup( String pluginGroup ); MavenExecutionRequest addPluginGroups( List pluginGroups ); boolean isProjectPresent(); MavenExecutionRequest setProjectPresent( boolean isProjectPresent ); File getUserSettingsFile(); MavenExecutionRequest setUserSettingsFile( File userSettingsFile ); File getGlobalSettingsFile(); MavenExecutionRequest setGlobalSettingsFile( File globalSettingsFile ); MavenExecutionRequest addRemoteRepository( ArtifactRepository repository ); MavenExecutionRequest addPluginArtifactRepository( ArtifactRepository repository ); /** * Set a new list of remote repositories to use the execution request. This is necessary if you perform * transformations on the remote repositories being used. For example if you replace existing repositories with * mirrors then it's easier to just replace the whole list with a new list of transformed repositories. * * @param repositories * @return This request, never {@code null}. */ MavenExecutionRequest setRemoteRepositories( List repositories ); List getRemoteRepositories(); MavenExecutionRequest setPluginArtifactRepositories( List repositories ); List getPluginArtifactRepositories(); MavenExecutionRequest setRepositoryCache( RepositoryCache repositoryCache ); RepositoryCache getRepositoryCache(); WorkspaceReader getWorkspaceReader(); MavenExecutionRequest setWorkspaceReader( WorkspaceReader workspaceReader ); File getUserToolchainsFile(); MavenExecutionRequest setUserToolchainsFile( File userToolchainsFile ); /** * * * @return the global toolchains file * @since 3.3.0 */ File getGlobalToolchainsFile(); /** * * @param globalToolchainsFile the global toolchains file * @return this request * @since 3.3.0 */ MavenExecutionRequest setGlobalToolchainsFile( File globalToolchainsFile ); ExecutionListener getExecutionListener(); MavenExecutionRequest setExecutionListener( ExecutionListener executionListener ); ProjectBuildingRequest getProjectBuildingRequest(); /** * @since 3.1 */ boolean isUseLegacyLocalRepository(); /** * @since 3.1 */ MavenExecutionRequest setUseLegacyLocalRepository( boolean useLegacyLocalRepository ); /** * Controls the {@link org.apache.maven.lifecycle.internal.builder.Builder} used by Maven by specification * of the builder's id. * * @since 3.2.0 */ MavenExecutionRequest setBuilderId( String builderId ); /** * Controls the {@link org.apache.maven.lifecycle.internal.builder.Builder} used by Maven by specification * of the builders id. * * @since 3.2.0 */ String getBuilderId(); /** * * @param toolchains all toolchains grouped by type * @return this request * @since 3.3.0 */ MavenExecutionRequest setToolchains( Map> toolchains ); /** * * @return all toolchains grouped by type, never {@code null} * @since 3.3.0 */ Map> getToolchains(); /** * @since 3.3.0 */ void setMultiModuleProjectDirectory( File file ); /** * @since 3.3.0 */ File getMultiModuleProjectDirectory(); /** * @since 3.3.0 */ MavenExecutionRequest setEventSpyDispatcher( EventSpyDispatcher eventSpyDispatcher ); /** * @since 3.3.0 */ EventSpyDispatcher getEventSpyDispatcher(); /** * @since 3.3.0 */ Map getData(); } MavenExecutionRequestPopulationException.java000066400000000000000000000024761317160430700366000ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/executionpackage org.apache.maven.execution; /* * 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 Jason van Zyl */ public class MavenExecutionRequestPopulationException extends Exception { public MavenExecutionRequestPopulationException( String message ) { super( message ); } public MavenExecutionRequestPopulationException( Throwable cause ) { super( cause ); } public MavenExecutionRequestPopulationException( String message, Throwable cause ) { super( message, cause ); } } MavenExecutionRequestPopulator.java000066400000000000000000000066151317160430700345530ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/executionpackage org.apache.maven.execution; /* * 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 org.apache.maven.settings.Settings; import org.apache.maven.toolchain.model.PersistedToolchains; /** * Assists in populating an execution request for invocation of Maven. * * @author Benjamin Bentmann */ public interface MavenExecutionRequestPopulator { /** * Copies the values from the given toolchains into the specified execution request. This method will replace any * existing values in the execution request that are controlled by the toolchains. Hence, it is expected that this * method is called on a new/empty execution request before the caller mutates it to fit its needs. * * @param request The execution request to populate, must not be {@code null}. * @param toolchains The toolchains to copy into the execution request, may be {@code null}. * @return The populated execution request, never {@code null}. * @throws MavenExecutionRequestPopulationException If the execution request could not be populated. * @since 3.3.0 */ MavenExecutionRequest populateFromToolchains( MavenExecutionRequest request, PersistedToolchains toolchains ) throws MavenExecutionRequestPopulationException; /** * Injects default values like plugin groups or repositories into the specified execution request. * * @param request The execution request to populate, must not be {@code null}. * @return The populated execution request, never {@code null}. * @throws MavenExecutionRequestPopulationException If the execution request could not be populated. */ MavenExecutionRequest populateDefaults( MavenExecutionRequest request ) throws MavenExecutionRequestPopulationException; /*if_not[MAVEN4]*/ /** * Copies the values from the given settings into the specified execution request. This method will replace any * existing values in the execution request that are controlled by the settings. Hence, it is expected that this * method is called on a new/empty execution request before the caller mutates it to fit its needs. * * @param request The execution request to populate, must not be {@code null}. * @param settings The settings to copy into the execution request, may be {@code null}. * @return The populated execution request, never {@code null}. * @throws MavenExecutionRequestPopulationException If the execution request could not be populated. */ @Deprecated MavenExecutionRequest populateFromSettings( MavenExecutionRequest request, Settings settings ) throws MavenExecutionRequestPopulationException; /*end[MAVEN4]*/ } maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/execution/MavenExecutionResult.java000066400000000000000000000045171317160430700325510ustar00rootroot00000000000000package org.apache.maven.execution; /* * 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.util.List; import org.apache.maven.project.DependencyResolutionResult; import org.apache.maven.project.MavenProject; /** * @author Jason van Zyl */ public interface MavenExecutionResult { MavenExecutionResult setProject( MavenProject project ); MavenProject getProject(); MavenExecutionResult setTopologicallySortedProjects( List projects ); /** * @return the sorted list, or an empty list if there are no projects. */ List getTopologicallySortedProjects(); MavenExecutionResult setDependencyResolutionResult( DependencyResolutionResult result ); DependencyResolutionResult getDependencyResolutionResult(); // for each exception // - knowing what artifacts are missing // - project building exception // - invalid project model exception: list of markers // - xmlpull parser exception List getExceptions(); MavenExecutionResult addException( Throwable e ); boolean hasExceptions(); /** * Gets the build summary for the specified project. * * @param project The project to get the build summary for, must not be {@code null}. * @return The build summary for the project or {@code null} if the project has not been built (yet). */ BuildSummary getBuildSummary( MavenProject project ); /** * Add the specified build summary. * * @param summary The build summary to add, must not be {@code null}. */ void addBuildSummary( BuildSummary summary ); } maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/execution/MavenSession.java000066400000000000000000000304701317160430700310270ustar00rootroot00000000000000package org.apache.maven.execution; /* * 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.File; import java.util.Arrays; import java.util.Date; import java.util.List; import java.util.Map; import java.util.Properties; import java.util.concurrent.ConcurrentHashMap; import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.repository.RepositoryCache; import org.apache.maven.monitor.event.EventDispatcher; import org.apache.maven.plugin.descriptor.PluginDescriptor; import org.apache.maven.project.MavenProject; import org.apache.maven.project.ProjectBuildingRequest; import org.apache.maven.settings.Settings; import org.codehaus.plexus.PlexusContainer; import org.codehaus.plexus.component.repository.exception.ComponentLookupException; import org.eclipse.aether.RepositorySystemSession; /** * A Maven execution session. * * @author Jason van Zyl */ public class MavenSession implements Cloneable { private MavenExecutionRequest request; private MavenExecutionResult result; private RepositorySystemSession repositorySession; private Properties executionProperties; private MavenProject currentProject; /** * These projects have already been topologically sorted in the {@link org.apache.maven.Maven} component before * being passed into the session. This is also the potentially constrained set of projects by using --projects * on the command line. */ private List projects; /** * The full set of projects before any potential constraining by --projects. Useful in the case where you want to * build a smaller set of projects but perform other operations in the context of your reactor. */ private List allProjects; private MavenProject topLevelProject; private ProjectDependencyGraph projectDependencyGraph; private boolean parallel; private final Map>> pluginContextsByProjectAndPluginKey = new ConcurrentHashMap<>(); public void setProjects( List projects ) { if ( !projects.isEmpty() ) { this.currentProject = projects.get( 0 ); this.topLevelProject = currentProject; for ( MavenProject project : projects ) { if ( project.isExecutionRoot() ) { topLevelProject = project; break; } } } else { this.currentProject = null; this.topLevelProject = null; } this.projects = projects; } public ArtifactRepository getLocalRepository() { return request.getLocalRepository(); } public List getGoals() { return request.getGoals(); } /** * Gets the user properties to use for interpolation and profile activation. The user properties have been * configured directly by the user on his discretion, e.g. via the {@code -Dkey=value} parameter on the command * line. * * @return The user properties, never {@code null}. */ public Properties getUserProperties() { return request.getUserProperties(); } /** * Gets the system properties to use for interpolation and profile activation. The system properties are collected * from the runtime environment like {@link System#getProperties()} and environment variables. * * @return The system properties, never {@code null}. */ public Properties getSystemProperties() { return request.getSystemProperties(); } public Settings getSettings() { return settings; } public List getProjects() { return projects; } public String getExecutionRootDirectory() { return request.getBaseDirectory(); } public MavenExecutionRequest getRequest() { return request; } public void setCurrentProject( MavenProject currentProject ) { this.currentProject = currentProject; } public MavenProject getCurrentProject() { return currentProject; } public ProjectBuildingRequest getProjectBuildingRequest() { return request.getProjectBuildingRequest().setRepositorySession( getRepositorySession() ); } public List getPluginGroups() { return request.getPluginGroups(); } public boolean isOffline() { return request.isOffline(); } public MavenProject getTopLevelProject() { return topLevelProject; } public MavenExecutionResult getResult() { return result; } // Backward compat public Map getPluginContext( PluginDescriptor plugin, MavenProject project ) { String projectKey = project.getId(); Map> pluginContextsByKey = pluginContextsByProjectAndPluginKey.get( projectKey ); if ( pluginContextsByKey == null ) { pluginContextsByKey = new ConcurrentHashMap<>(); pluginContextsByProjectAndPluginKey.put( projectKey, pluginContextsByKey ); } String pluginKey = plugin.getPluginLookupKey(); Map pluginContext = pluginContextsByKey.get( pluginKey ); if ( pluginContext == null ) { pluginContext = new ConcurrentHashMap<>(); pluginContextsByKey.put( pluginKey, pluginContext ); } return pluginContext; } public ProjectDependencyGraph getProjectDependencyGraph() { return projectDependencyGraph; } public void setProjectDependencyGraph( ProjectDependencyGraph projectDependencyGraph ) { this.projectDependencyGraph = projectDependencyGraph; } public String getReactorFailureBehavior() { return request.getReactorFailureBehavior(); } @Override public MavenSession clone() { try { return (MavenSession) super.clone(); } catch ( CloneNotSupportedException e ) { throw new RuntimeException( "Bug", e ); } } public Date getStartTime() { return request.getStartTime(); } public boolean isParallel() { return parallel; } public void setParallel( boolean parallel ) { this.parallel = parallel; } public RepositorySystemSession getRepositorySession() { return repositorySession; } private Map projectMap; public void setProjectMap( Map projectMap ) { this.projectMap = projectMap; } /** This is a provisional method and may be removed */ public List getAllProjects() { return allProjects; } /** This is a provisional method and may be removed */ public void setAllProjects( List allProjects ) { this.allProjects = allProjects; } /*if_not[MAVEN4]*/ // // Deprecated // private PlexusContainer container; private final Settings settings; @Deprecated /** @deprecated This appears to only be used in the ReactorReader and we can do any processing required there */ public Map getProjectMap() { return projectMap; } @Deprecated public MavenSession( PlexusContainer container, RepositorySystemSession repositorySession, MavenExecutionRequest request, MavenExecutionResult result ) { this.container = container; this.request = request; this.result = result; this.settings = new SettingsAdapter( request ); this.repositorySession = repositorySession; } @Deprecated public MavenSession( PlexusContainer container, MavenExecutionRequest request, MavenExecutionResult result, MavenProject project ) { this( container, request, result, Arrays.asList( new MavenProject[]{project} ) ); } @Deprecated public MavenSession( PlexusContainer container, Settings settings, ArtifactRepository localRepository, EventDispatcher eventDispatcher, ReactorManager unused, List goals, String executionRootDir, Properties executionProperties, Date startTime ) { this( container, settings, localRepository, eventDispatcher, unused, goals, executionRootDir, executionProperties, null, startTime ); } @Deprecated public MavenSession( PlexusContainer container, Settings settings, ArtifactRepository localRepository, EventDispatcher eventDispatcher, ReactorManager unused, List goals, String executionRootDir, Properties executionProperties, Properties userProperties, Date startTime ) { this.container = container; this.settings = settings; this.executionProperties = executionProperties; this.request = new DefaultMavenExecutionRequest(); this.request.setUserProperties( userProperties ); this.request.setLocalRepository( localRepository ); this.request.setGoals( goals ); this.request.setBaseDirectory( ( executionRootDir != null ) ? new File( executionRootDir ) : null ); this.request.setStartTime( startTime ); } @Deprecated public MavenSession( PlexusContainer container, MavenExecutionRequest request, MavenExecutionResult result, List projects ) { this.container = container; this.request = request; this.result = result; this.settings = new SettingsAdapter( request ); setProjects( projects ); } @Deprecated public List getSortedProjects() { return getProjects(); } @Deprecated // // Used by Tycho and will break users and force them to upgrade to Maven 3.1 so we should really leave // this here, possibly indefinitely. // public RepositoryCache getRepositoryCache() { return null; } @Deprecated public EventDispatcher getEventDispatcher() { return null; } @Deprecated public boolean isUsingPOMsFromFilesystem() { return request.isProjectPresent(); } /** * @deprecated Use either {@link #getUserProperties()} or {@link #getSystemProperties()}. */ @Deprecated public Properties getExecutionProperties() { if ( executionProperties == null ) { executionProperties = new Properties(); executionProperties.putAll( request.getSystemProperties() ); executionProperties.putAll( request.getUserProperties() ); } return executionProperties; } @Deprecated public PlexusContainer getContainer() { return container; } @Deprecated public Object lookup( String role ) throws ComponentLookupException { return container.lookup( role ); } @Deprecated public Object lookup( String role, String roleHint ) throws ComponentLookupException { return container.lookup( role, roleHint ); } @Deprecated public List lookupList( String role ) throws ComponentLookupException { return container.lookupList( role ); } @Deprecated public Map lookupMap( String role ) throws ComponentLookupException { return container.lookupMap( role ); } /*end[MAVEN4]*/ } maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/execution/MojoExecutionEvent.java000066400000000000000000000047731317160430700322160ustar00rootroot00000000000000package org.apache.maven.execution; /* * 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 org.apache.maven.plugin.Mojo; import org.apache.maven.plugin.MojoExecution; import org.apache.maven.project.MavenProject; /** *

* Encapsulates parameters of MojoExecutionListener callback methods and is meant to provide API evolution path should * it become necessary to introduce new parameters in the existing callbacks in the future. *

* Note: This class is part of work in progress and can be changed or removed without notice. * * @see MojoExecutionListener * @see org.apache.maven.execution.scope.WeakMojoExecutionListener * @since 3.1.2 */ public class MojoExecutionEvent { private final MavenSession session; private final MavenProject project; private final MojoExecution mojoExecution; private final Mojo mojo; private final Throwable cause; public MojoExecutionEvent( MavenSession session, MavenProject project, MojoExecution mojoExecution, Mojo mojo ) { this( session, project, mojoExecution, mojo, null ); } public MojoExecutionEvent( MavenSession session, MavenProject project, MojoExecution mojoExecution, Mojo mojo, Throwable cause ) { this.session = session; this.project = project; this.mojoExecution = mojoExecution; this.mojo = mojo; this.cause = cause; } public MavenSession getSession() { return session; } public MavenProject getProject() { return project; } public MojoExecution getExecution() { return mojoExecution; } public Mojo getMojo() { return mojo; } public Throwable getCause() { return cause; } } maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/execution/MojoExecutionListener.java000066400000000000000000000027601317160430700327140ustar00rootroot00000000000000package org.apache.maven.execution; /* * 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 org.apache.maven.plugin.MojoExecutionException; /** *

* Extension point that allows build extensions observe and possibly veto mojo executions. *

* Note: This interface is part of work in progress and can be changed or removed without notice. * * @see org.apache.maven.execution.scope.WeakMojoExecutionListener * @since 3.1.2 */ public interface MojoExecutionListener { void beforeMojoExecution( MojoExecutionEvent event ) throws MojoExecutionException; void afterMojoExecutionSuccess( MojoExecutionEvent event ) throws MojoExecutionException; void afterExecutionFailure( MojoExecutionEvent event ); } maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/execution/ProjectDependencyGraph.java000066400000000000000000000053271317160430700330070ustar00rootroot00000000000000package org.apache.maven.execution; /* * 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.util.List; import org.apache.maven.project.MavenProject; /** * Describes the inter-dependencies between projects in the reactor. * * @author Benjamin Bentmann * @since 3.0-alpha */ public interface ProjectDependencyGraph { /** * Gets all collected projects. * * @return All collected projects. * * @since 3.5.0 */ List getAllProjects(); /** * Gets all projects in their intended build order, i.e. after topologically sorting the projects according to their * inter-dependencies. * * @return The projects in the build order, never {@code null}. */ List getSortedProjects(); /** * Gets the downstream projects of the specified project. A downstream project is a project that directly or * indirectly depends on the given project. * * @param project The project whose downstream projects should be retrieved, must not be {@code null}. * @param transitive A flag whether to retrieve all direct and indirect downstream projects or just the immediate * downstream projects. * @return The downstream projects in the build order, never {@code null}. */ List getDownstreamProjects( MavenProject project, boolean transitive ); /** * Gets the upstream projects of the specified project. An upstream project is a project that directly or indirectly * is a prerequisite of the given project. * * @param project The project whose upstream projects should be retrieved, must not be {@code null}. * @param transitive A flag whether to retrieve all direct and indirect upstream projects or just the immediate * upstream projects. * @return The upstream projects in the build order, never {@code null}. */ List getUpstreamProjects( MavenProject project, boolean transitive ); } maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/execution/ProjectExecutionEvent.java000066400000000000000000000051611317160430700327100ustar00rootroot00000000000000package org.apache.maven.execution; /* * 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.util.List; import org.apache.maven.plugin.MojoExecution; import org.apache.maven.project.MavenProject; /** *

* Encapsulates parameters of ProjectExecutionListener callback methods and is meant to provide API evolution path * should it become necessary to introduce new parameters in the existing callbacks in the future. *

* Note: This class is part of work in progress and can be changed or removed without notice. * * @see ProjectExecutionListener * @since 3.1.2 */ public class ProjectExecutionEvent { private final MavenSession session; private final MavenProject project; private final List executionPlan; private final Throwable cause; public ProjectExecutionEvent( MavenSession session, MavenProject project ) { this( session, project, null, null ); } public ProjectExecutionEvent( MavenSession session, MavenProject project, List executionPlan ) { this( session, project, executionPlan, null ); } public ProjectExecutionEvent( MavenSession session, MavenProject project, Throwable cause ) { this( session, project, null, cause ); } public ProjectExecutionEvent( MavenSession session, MavenProject project, List executionPlan, Throwable cause ) { this.session = session; this.project = project; this.executionPlan = executionPlan; this.cause = cause; } public MavenSession getSession() { return session; } public MavenProject getProject() { return project; } public List getExecutionPlan() { return executionPlan; } public Throwable getCause() { return cause; } } maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/execution/ProjectExecutionListener.java000066400000000000000000000032151317160430700334120ustar00rootroot00000000000000package org.apache.maven.execution; /* * 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 org.apache.maven.lifecycle.LifecycleExecutionException; /** *

* Extension point that allows build extensions observe and possibly veto project build execution. *

* Note: This interface is part of work in progress and can be changed or removed without notice. * * @see ExecutionListener * @see MojoExecutionListener * @since 3.1.2 */ public interface ProjectExecutionListener { void beforeProjectExecution( ProjectExecutionEvent event ) throws LifecycleExecutionException; void beforeProjectLifecycleExecution( ProjectExecutionEvent event ) throws LifecycleExecutionException; void afterProjectExecutionSuccess( ProjectExecutionEvent event ) throws LifecycleExecutionException; void afterProjectExecutionFailure( ProjectExecutionEvent event ); } maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/execution/ReactorManager.java000066400000000000000000000142531317160430700313100ustar00rootroot00000000000000package org.apache.maven.execution; /* * 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 org.apache.maven.artifact.ArtifactUtils; import org.apache.maven.plugin.descriptor.PluginDescriptor; import org.apache.maven.project.DuplicateProjectException; import org.apache.maven.project.MavenProject; import org.apache.maven.project.ProjectSorter; import org.codehaus.plexus.util.dag.CycleDetectedException; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; @Deprecated public class ReactorManager { public static final String FAIL_FAST = "fail-fast"; public static final String FAIL_AT_END = "fail-at-end"; public static final String FAIL_NEVER = "fail-never"; public static final String MAKE_MODE = "make"; public static final String MAKE_DEPENDENTS_MODE = "make-dependents"; // make projects that depend on me, and projects that I depend on public static final String MAKE_BOTH_MODE = "make-both"; private List blackList = new ArrayList<>(); private Map buildFailuresByProject = new HashMap<>(); private Map> pluginContextsByProjectAndPluginKey = new HashMap<>(); private String failureBehavior = FAIL_FAST; private final ProjectSorter sorter; private Map buildSuccessesByProject = new HashMap<>(); public ReactorManager( List projects ) throws CycleDetectedException, DuplicateProjectException { this.sorter = new ProjectSorter( projects ); } public Map getPluginContext( PluginDescriptor plugin, MavenProject project ) { Map pluginContextsByKey = pluginContextsByProjectAndPluginKey.get( project.getId() ); if ( pluginContextsByKey == null ) { pluginContextsByKey = new HashMap<>(); pluginContextsByProjectAndPluginKey.put( project.getId(), pluginContextsByKey ); } Map pluginContext = pluginContextsByKey.get( plugin.getPluginLookupKey() ); if ( pluginContext == null ) { pluginContext = new HashMap<>(); pluginContextsByKey.put( plugin.getPluginLookupKey(), pluginContext ); } return pluginContext; } public void setFailureBehavior( String failureBehavior ) { if ( failureBehavior == null ) { this.failureBehavior = FAIL_FAST; // default return; } if ( FAIL_FAST.equals( failureBehavior ) || FAIL_AT_END.equals( failureBehavior ) || FAIL_NEVER.equals( failureBehavior ) ) { this.failureBehavior = failureBehavior; } else { throw new IllegalArgumentException( "Invalid failure behavior (must be one of: \'" + FAIL_FAST + "\', \'" + FAIL_AT_END + "\', \'" + FAIL_NEVER + "\')." ); } } public String getFailureBehavior() { return failureBehavior; } public void blackList( MavenProject project ) { blackList( getProjectKey( project ) ); } private void blackList( String id ) { if ( !blackList.contains( id ) ) { blackList.add( id ); List dependents = sorter.getDependents( id ); if ( dependents != null && !dependents.isEmpty() ) { for ( String dependentId : dependents ) { if ( !buildSuccessesByProject.containsKey( dependentId ) && !buildFailuresByProject.containsKey( dependentId ) ) { blackList( dependentId ); } } } } } public boolean isBlackListed( MavenProject project ) { return blackList.contains( getProjectKey( project ) ); } private static String getProjectKey( MavenProject project ) { return ArtifactUtils.versionlessKey( project.getGroupId(), project.getArtifactId() ); } public void registerBuildFailure( MavenProject project, Exception error, String task, long time ) { buildFailuresByProject.put( getProjectKey( project ), new BuildFailure( project, time, error ) ); } public boolean hasBuildFailures() { return !buildFailuresByProject.isEmpty(); } public boolean hasBuildFailure( MavenProject project ) { return buildFailuresByProject.containsKey( getProjectKey( project ) ); } public boolean hasMultipleProjects() { return sorter.hasMultipleProjects(); } public List getSortedProjects() { return sorter.getSortedProjects(); } public boolean hasBuildSuccess( MavenProject project ) { return buildSuccessesByProject.containsKey( getProjectKey( project ) ); } public void registerBuildSuccess( MavenProject project, long time ) { buildSuccessesByProject.put( getProjectKey( project ), new BuildSuccess( project, time ) ); } public BuildFailure getBuildFailure( MavenProject project ) { return buildFailuresByProject.get( getProjectKey( project ) ); } public BuildSuccess getBuildSuccess( MavenProject project ) { return buildSuccessesByProject.get( getProjectKey( project ) ); } public boolean executedMultipleProjects() { return buildFailuresByProject.size() + buildSuccessesByProject.size() > 1; } } maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/execution/SettingsAdapter.java000066400000000000000000000071461317160430700315220ustar00rootroot00000000000000package org.apache.maven.execution; /* * 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.File; import java.util.ArrayList; import java.util.List; import org.apache.maven.settings.Mirror; import org.apache.maven.settings.Profile; import org.apache.maven.settings.Proxy; import org.apache.maven.settings.RuntimeInfo; import org.apache.maven.settings.Server; import org.apache.maven.settings.Settings; import org.apache.maven.settings.SettingsUtils; /** * Adapt a {@link MavenExecutionRequest} to a {@link Settings} object for use in the Maven core. * We want to make sure that what is ask for in the execution request overrides what is in the settings. * The CLI feeds into an execution request so if a particular value is present in the execution request * then we will take that over the value coming from the user settings. * * @author Jason van Zyl */ class SettingsAdapter extends Settings { private MavenExecutionRequest request; private RuntimeInfo runtimeInfo; public SettingsAdapter( MavenExecutionRequest request ) { this.request = request; /* * NOTE: Plugins like maven-release-plugin query the path to the settings.xml to pass it into a forked Maven and * the CLI will fail when called with a non-existing settings, so be sure to only point at actual files. Having * a null file should be harmless as this case matches general Maven 2.x behavior... */ File userSettings = request.getUserSettingsFile(); this.runtimeInfo = new RuntimeInfo( ( userSettings != null && userSettings.isFile() ) ? userSettings : null ); } @Override public String getLocalRepository() { if ( request.getLocalRepositoryPath() != null ) { return request.getLocalRepositoryPath().getAbsolutePath(); } return null; } @Override public boolean isInteractiveMode() { return request.isInteractiveMode(); } @Override public boolean isOffline() { return request.isOffline(); } @Override public List getProxies() { return request.getProxies(); } @Override public List getServers() { return request.getServers(); } @Override public List getMirrors() { return request.getMirrors(); } @Override public List getProfiles() { List result = new ArrayList<>(); for ( org.apache.maven.model.Profile profile : request.getProfiles() ) { result.add( SettingsUtils.convertToSettingsProfile( profile ) ); } return result; } @Override public List getActiveProfiles() { return request.getActiveProfiles(); } @Override public List getPluginGroups() { return request.getPluginGroups(); } } maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/execution/scope/000077500000000000000000000000001317160430700266575ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/execution/scope/MojoExecutionScoped.java000066400000000000000000000025301317160430700334500ustar00rootroot00000000000000package org.apache.maven.execution.scope; /* * 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 java.lang.annotation.ElementType.TYPE; import static java.lang.annotation.RetentionPolicy.RUNTIME; import java.lang.annotation.Retention; import java.lang.annotation.Target; import com.google.inject.ScopeAnnotation; /** * Indicates that annotated component should be instantiated before mojo execution starts and discarded after mojo * execution completes. * * @author igor * @since 3.1.2 */ @Target( { TYPE } ) @Retention( RUNTIME ) @ScopeAnnotation public @interface MojoExecutionScoped { } WeakMojoExecutionListener.java000066400000000000000000000034101317160430700345470ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/execution/scopepackage org.apache.maven.execution.scope; /* * 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 org.apache.maven.execution.MojoExecutionEvent; import org.apache.maven.plugin.MojoExecutionException; /** * Extension point that allows build extensions observe and possibly veto mojo executions. *

* Unlike {@link org.apache.maven.execution.MojoExecutionListener}, this extension point does not * trigger instantiation of the component, hence "weak" class name prefix. Only applies to mojo execution * scoped components. *

* Note: This interface is part of work in progress and can be changed or removed without notice. * * @see org.apache.maven.execution.MojoExecutionListener * @since 3.1.2 */ public interface WeakMojoExecutionListener { void beforeMojoExecution( MojoExecutionEvent event ) throws MojoExecutionException; void afterMojoExecutionSuccess( MojoExecutionEvent event ) throws MojoExecutionException; void afterExecutionFailure( MojoExecutionEvent event ); } maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/execution/scope/internal/000077500000000000000000000000001317160430700304735ustar00rootroot00000000000000MojoExecutionScope.java000066400000000000000000000132601317160430700350430ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/execution/scope/internalpackage org.apache.maven.execution.scope.internal; /* * 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.util.Collection; import java.util.IdentityHashMap; import java.util.LinkedList; import java.util.Map; import org.apache.maven.execution.MojoExecutionEvent; import org.apache.maven.execution.MojoExecutionListener; import org.apache.maven.execution.scope.WeakMojoExecutionListener; import org.apache.maven.plugin.MojoExecutionException; import com.google.common.collect.Maps; import com.google.inject.Key; import com.google.inject.OutOfScopeException; import com.google.inject.Provider; import com.google.inject.Scope; import com.google.inject.util.Providers; public class MojoExecutionScope implements Scope, MojoExecutionListener { private static final Provider SEEDED_KEY_PROVIDER = new Provider() { public Object get() { throw new IllegalStateException(); } }; private static final class ScopeState { public final Map, Provider> seeded = Maps.newHashMap(); public final Map, Object> provided = Maps.newHashMap(); } private final ThreadLocal> values = new ThreadLocal<>(); public MojoExecutionScope() { } public void enter() { LinkedList stack = values.get(); if ( stack == null ) { stack = new LinkedList<>(); values.set( stack ); } stack.addFirst( new ScopeState() ); } private ScopeState getScopeState() { LinkedList stack = values.get(); if ( stack == null || stack.isEmpty() ) { throw new IllegalStateException(); } return stack.getFirst(); } public void exit() throws MojoExecutionException { final LinkedList stack = values.get(); if ( stack == null || stack.isEmpty() ) { throw new IllegalStateException(); } stack.removeFirst(); if ( stack.isEmpty() ) { values.remove(); } } public void seed( Class clazz, Provider value ) { getScopeState().seeded.put( Key.get( clazz ), value ); } public void seed( Class clazz, final T value ) { getScopeState().seeded.put( Key.get( clazz ), Providers.of( value ) ); } public Provider scope( final Key key, final Provider unscoped ) { return new Provider() { @SuppressWarnings( "unchecked" ) public T get() { LinkedList stack = values.get(); if ( stack == null || stack.isEmpty() ) { throw new OutOfScopeException( "Cannot access " + key + " outside of a scoping block" ); } ScopeState state = stack.getFirst(); Provider seeded = state.seeded.get( key ); if ( seeded != null ) { return (T) seeded.get(); } T provided = (T) state.provided.get( key ); if ( provided == null && unscoped != null ) { provided = unscoped.get(); state.provided.put( key, provided ); } return provided; } }; } @SuppressWarnings( { "unchecked" } ) public static Provider seededKeyProvider() { return (Provider) SEEDED_KEY_PROVIDER; } public void beforeMojoExecution( MojoExecutionEvent event ) throws MojoExecutionException { for ( WeakMojoExecutionListener provided : getProvidedListeners() ) { provided.beforeMojoExecution( event ); } } public void afterMojoExecutionSuccess( MojoExecutionEvent event ) throws MojoExecutionException { for ( WeakMojoExecutionListener provided : getProvidedListeners() ) { provided.afterMojoExecutionSuccess( event ); } } public void afterExecutionFailure( MojoExecutionEvent event ) { for ( WeakMojoExecutionListener provided : getProvidedListeners() ) { provided.afterExecutionFailure( event ); } } private Collection getProvidedListeners() { // the same instance can be provided multiple times under different Key's // deduplicate instances to avoid redundant beforeXXX/afterXXX callbacks IdentityHashMap listeners = new IdentityHashMap<>(); for ( Object provided : getScopeState().provided.values() ) { if ( provided instanceof WeakMojoExecutionListener ) { listeners.put( (WeakMojoExecutionListener) provided, null ); } } return listeners.keySet(); } } MojoExecutionScopeCoreModule.java000066400000000000000000000024551317160430700370260ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/execution/scope/internalpackage org.apache.maven.execution.scope.internal; /* * 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 javax.inject.Inject; import javax.inject.Named; import org.apache.maven.execution.MojoExecutionListener; @Named public class MojoExecutionScopeCoreModule extends MojoExecutionScopeModule { @Inject public MojoExecutionScopeCoreModule() { super( new MojoExecutionScope() ); } @Override protected void configure() { super.configure(); bind( MojoExecutionListener.class ).toInstance( scope ); } } MojoExecutionScopeModule.java000066400000000000000000000037141317160430700362140ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/execution/scope/internalpackage org.apache.maven.execution.scope.internal; /* * 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 org.apache.maven.execution.scope.MojoExecutionScoped; import org.apache.maven.plugin.MojoExecution; import org.apache.maven.project.MavenProject; import org.codehaus.plexus.PlexusContainer; import org.codehaus.plexus.component.repository.exception.ComponentLookupException; import com.google.inject.AbstractModule; public class MojoExecutionScopeModule extends AbstractModule { protected final MojoExecutionScope scope; public MojoExecutionScopeModule( PlexusContainer container ) throws ComponentLookupException { this( container.lookup( MojoExecutionScope.class ) ); } protected MojoExecutionScopeModule( MojoExecutionScope scope ) { this.scope = scope; } @Override protected void configure() { bindScope( MojoExecutionScoped.class, scope ); bind( MojoExecutionScope.class ).toInstance( scope ); bind( MavenProject.class ).toProvider( MojoExecutionScope.seededKeyProvider() ).in( scope ); bind( MojoExecution.class ).toProvider( MojoExecutionScope.seededKeyProvider() ).in( scope ); } } maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/extension/000077500000000000000000000000001317160430700255575ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/extension/internal/000077500000000000000000000000001317160430700273735ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/extension/internal/CoreExports.java000066400000000000000000000045531317160430700325220ustar00rootroot00000000000000package org.apache.maven.extension.internal; /* * 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.util.LinkedHashMap; import java.util.Map; import java.util.Set; import org.codehaus.plexus.classworlds.realm.ClassRealm; import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableSet; /** * Provides information about artifacts (identified by groupId:artifactId string key) and classpath elements exported by * Maven core itself and loaded Maven core extensions. * * @since 3.3.0 */ public class CoreExports { private final Set artifacts; private final Map packages; public CoreExports( CoreExtensionEntry entry ) { this( entry.getClassRealm(), entry.getExportedArtifacts(), entry.getExportedPackages() ); } public CoreExports( ClassRealm realm, Set exportedArtifacts, Set exportedPackages ) { Map packages = new LinkedHashMap<>(); for ( String pkg : exportedPackages ) { packages.put( pkg, realm ); } this.artifacts = ImmutableSet.copyOf( exportedArtifacts ); this.packages = ImmutableMap.copyOf( packages ); } /** * Returns artifacts exported by Maven core and core extensions. Artifacts are identified by their * groupId:artifactId string key. */ public Set getExportedArtifacts() { return artifacts; } /** * Returns packages exported by Maven core and core extensions. */ public Map getExportedPackages() { return packages; } } CoreExportsProvider.java000066400000000000000000000027721317160430700341570ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/extension/internalpackage org.apache.maven.extension.internal; /* * 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 javax.inject.Inject; import javax.inject.Named; import javax.inject.Singleton; import org.codehaus.plexus.PlexusContainer; import org.eclipse.sisu.Nullable; @Named @Singleton public class CoreExportsProvider { private final CoreExports exports; @Inject public CoreExportsProvider( PlexusContainer container, @Nullable CoreExports exports ) { if ( exports == null ) { this.exports = new CoreExports( CoreExtensionEntry.discoverFrom( container.getContainerRealm() ) ); } else { this.exports = exports; } } public CoreExports get() { return exports; } } CoreExtensionEntry.java000066400000000000000000000102121317160430700337620ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/extension/internalpackage org.apache.maven.extension.internal; /* * 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 com.google.common.collect.ImmutableSet; import org.apache.maven.project.ExtensionDescriptor; import org.apache.maven.project.ExtensionDescriptorBuilder; import org.codehaus.plexus.classworlds.realm.ClassRealm; import java.io.File; import java.io.IOException; import java.io.InputStream; import java.net.URL; import java.util.Collection; import java.util.Enumeration; import java.util.LinkedHashSet; import java.util.Set; /** * Provides information about artifacts (identified by groupId:artifactId string key) and classpath elements exported by * Maven core itself or a Maven core extension. * * @since 3.3.0 */ public class CoreExtensionEntry { private final ClassRealm realm; private final Set artifacts; private final Set packages; public CoreExtensionEntry( ClassRealm realm, Collection artifacts, Collection packages ) { this.realm = realm; this.artifacts = ImmutableSet.copyOf( artifacts ); this.packages = ImmutableSet.copyOf( packages ); } /** * Returns ClassLoader used to load extension classes. */ public ClassRealm getClassRealm() { return realm; } /** * Returns artifacts exported by the extension, identified by groupId:artifactId string key. */ public Set getExportedArtifacts() { return artifacts; } /** * Returns classpath elements exported by the extension. */ public Set getExportedPackages() { return packages; } private static final ExtensionDescriptorBuilder builder = new ExtensionDescriptorBuilder(); public static CoreExtensionEntry discoverFrom( ClassRealm loader ) { Set artifacts = new LinkedHashSet<>(); Set packages = new LinkedHashSet<>(); try { Enumeration urls = loader.getResources( builder.getExtensionDescriptorLocation() ); while ( urls.hasMoreElements() ) { try ( InputStream is = urls.nextElement().openStream() ) { ExtensionDescriptor descriptor = builder.build( is ); artifacts.addAll( descriptor.getExportedArtifacts() ); packages.addAll( descriptor.getExportedPackages() ); } } } catch ( IOException ignored ) { // exports descriptors are entirely optional } return new CoreExtensionEntry( loader, artifacts, packages ); } public static CoreExtensionEntry discoverFrom( ClassRealm loader, Collection classpath ) { Set artifacts = new LinkedHashSet<>(); Set packages = new LinkedHashSet<>(); try { for ( File entry : classpath ) { ExtensionDescriptor descriptor = builder.build( entry ); if ( descriptor != null ) { artifacts.addAll( descriptor.getExportedArtifacts() ); packages.addAll( descriptor.getExportedPackages() ); } } } catch ( IOException ignored ) { // exports descriptors are entirely optional } return new CoreExtensionEntry( loader, artifacts, packages ); } } maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/graph/000077500000000000000000000000001317160430700246445ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/graph/DefaultGraphBuilder.java000066400000000000000000000415161317160430700313730ustar00rootroot00000000000000package org.apache.maven.graph; /* * 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.File; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; import java.util.HashMap; import java.util.LinkedHashSet; import java.util.List; import java.util.Map; import com.google.common.collect.Lists; import org.apache.maven.DefaultMaven; import org.apache.maven.MavenExecutionException; import org.apache.maven.ProjectCycleException; import org.apache.maven.artifact.ArtifactUtils; import org.apache.maven.execution.MavenExecutionRequest; import org.apache.maven.execution.MavenSession; import org.apache.maven.execution.ProjectDependencyGraph; import org.apache.maven.model.Plugin; import org.apache.maven.model.building.DefaultModelProblem; import org.apache.maven.model.building.ModelProblem; import org.apache.maven.model.building.ModelProblemUtils; import org.apache.maven.model.building.ModelSource; import org.apache.maven.model.building.Result; import org.apache.maven.model.building.UrlModelSource; import org.apache.maven.project.DuplicateProjectException; import org.apache.maven.project.MavenProject; import org.apache.maven.project.ProjectBuilder; import org.apache.maven.project.ProjectBuildingException; import org.apache.maven.project.ProjectBuildingRequest; import org.apache.maven.project.ProjectBuildingResult; import org.codehaus.plexus.component.annotations.Component; import org.codehaus.plexus.component.annotations.Requirement; import org.codehaus.plexus.logging.Logger; import org.codehaus.plexus.util.StringUtils; import org.codehaus.plexus.util.dag.CycleDetectedException; @Component( role = GraphBuilder.class, hint = GraphBuilder.HINT ) public class DefaultGraphBuilder implements GraphBuilder { @Requirement private Logger logger; @Requirement protected ProjectBuilder projectBuilder; @Override public Result build( MavenSession session ) { try { Result result = sessionDependencyGraph( session ); if ( result == null ) { final List projects = getProjectsForMavenReactor( session ); validateProjects( projects ); result = reactorDependencyGraph( session, projects ); } return result; } catch ( final ProjectBuildingException e ) { return Result.error( Lists.newArrayList( new DefaultModelProblem( null, null, null, null, 0, 0, e ) ) ); } catch ( final CycleDetectedException e ) { String message = "The projects in the reactor contain a cyclic reference: " + e.getMessage(); ProjectCycleException error = new ProjectCycleException( message, e ); return Result.error( Lists.newArrayList( new DefaultModelProblem( null, null, null, null, 0, 0, error ) ) ); } catch ( final DuplicateProjectException e ) { return Result.error( Lists.newArrayList( new DefaultModelProblem( null, null, null, null, 0, 0, e ) ) ); } catch ( final MavenExecutionException e ) { return Result.error( Lists.newArrayList( new DefaultModelProblem( null, null, null, null, 0, 0, e ) ) ); } } private Result sessionDependencyGraph( final MavenSession session ) throws CycleDetectedException, DuplicateProjectException { Result result = null; if ( session.getProjectDependencyGraph() != null || session.getProjects() != null ) { final ProjectDependencyGraph graph = new DefaultProjectDependencyGraph( session.getAllProjects(), session.getProjects() ); result = Result.success( graph ); } return result; } private Result reactorDependencyGraph( MavenSession session, List projects ) throws CycleDetectedException, DuplicateProjectException, MavenExecutionException { ProjectDependencyGraph projectDependencyGraph = new DefaultProjectDependencyGraph( projects ); List activeProjects = projectDependencyGraph.getSortedProjects(); activeProjects = trimSelectedProjects( activeProjects, projectDependencyGraph, session.getRequest() ); activeProjects = trimExcludedProjects( activeProjects, session.getRequest() ); activeProjects = trimResumedProjects( activeProjects, session.getRequest() ); if ( activeProjects.size() != projectDependencyGraph.getSortedProjects().size() ) { projectDependencyGraph = new FilteredProjectDependencyGraph( projectDependencyGraph, activeProjects ); } return Result.success( projectDependencyGraph ); } private List trimSelectedProjects( List projects, ProjectDependencyGraph graph, MavenExecutionRequest request ) throws MavenExecutionException { List result = projects; if ( !request.getSelectedProjects().isEmpty() ) { File reactorDirectory = null; if ( request.getBaseDirectory() != null ) { reactorDirectory = new File( request.getBaseDirectory() ); } Collection selectedProjects = new LinkedHashSet<>( projects.size() ); for ( String selector : request.getSelectedProjects() ) { MavenProject selectedProject = null; for ( MavenProject project : projects ) { if ( isMatchingProject( project, selector, reactorDirectory ) ) { selectedProject = project; break; } } if ( selectedProject != null ) { selectedProjects.add( selectedProject ); } else { throw new MavenExecutionException( "Could not find the selected project in the reactor: " + selector, request.getPom() ); } } boolean makeUpstream = false; boolean makeDownstream = false; if ( MavenExecutionRequest.REACTOR_MAKE_UPSTREAM.equals( request.getMakeBehavior() ) ) { makeUpstream = true; } else if ( MavenExecutionRequest.REACTOR_MAKE_DOWNSTREAM.equals( request.getMakeBehavior() ) ) { makeDownstream = true; } else if ( MavenExecutionRequest.REACTOR_MAKE_BOTH.equals( request.getMakeBehavior() ) ) { makeUpstream = true; makeDownstream = true; } else if ( StringUtils.isNotEmpty( request.getMakeBehavior() ) ) { throw new MavenExecutionException( "Invalid reactor make behavior: " + request.getMakeBehavior(), request.getPom() ); } if ( makeUpstream || makeDownstream ) { for ( MavenProject selectedProject : new ArrayList<>( selectedProjects ) ) { if ( makeUpstream ) { selectedProjects.addAll( graph.getUpstreamProjects( selectedProject, true ) ); } if ( makeDownstream ) { selectedProjects.addAll( graph.getDownstreamProjects( selectedProject, true ) ); } } } result = new ArrayList<>( selectedProjects.size() ); for ( MavenProject project : projects ) { if ( selectedProjects.contains( project ) ) { result.add( project ); } } } return result; } private List trimExcludedProjects( List projects, MavenExecutionRequest request ) throws MavenExecutionException { List result = projects; if ( !request.getExcludedProjects().isEmpty() ) { File reactorDirectory = null; if ( request.getBaseDirectory() != null ) { reactorDirectory = new File( request.getBaseDirectory() ); } Collection excludedProjects = new LinkedHashSet<>( projects.size() ); for ( String selector : request.getExcludedProjects() ) { MavenProject excludedProject = null; for ( MavenProject project : projects ) { if ( isMatchingProject( project, selector, reactorDirectory ) ) { excludedProject = project; break; } } if ( excludedProject != null ) { excludedProjects.add( excludedProject ); } else { throw new MavenExecutionException( "Could not find the selected project in the reactor: " + selector, request.getPom() ); } } result = new ArrayList<>( projects.size() ); for ( MavenProject project : projects ) { if ( !excludedProjects.contains( project ) ) { result.add( project ); } } } return result; } private List trimResumedProjects( List projects, MavenExecutionRequest request ) throws MavenExecutionException { List result = projects; if ( StringUtils.isNotEmpty( request.getResumeFrom() ) ) { File reactorDirectory = null; if ( request.getBaseDirectory() != null ) { reactorDirectory = new File( request.getBaseDirectory() ); } String selector = request.getResumeFrom(); result = new ArrayList<>( projects.size() ); boolean resumed = false; for ( MavenProject project : projects ) { if ( !resumed && isMatchingProject( project, selector, reactorDirectory ) ) { resumed = true; } if ( resumed ) { result.add( project ); } } if ( !resumed ) { throw new MavenExecutionException( "Could not find project to resume reactor build from: " + selector + " vs " + projects, request.getPom() ); } } return result; } private boolean isMatchingProject( MavenProject project, String selector, File reactorDirectory ) { // [groupId]:artifactId if ( selector.indexOf( ':' ) >= 0 ) { String id = ':' + project.getArtifactId(); if ( id.equals( selector ) ) { return true; } id = project.getGroupId() + id; if ( id.equals( selector ) ) { return true; } } // relative path, e.g. "sub", "../sub" or "." else if ( reactorDirectory != null ) { File selectedProject = new File( new File( reactorDirectory, selector ).toURI().normalize() ); if ( selectedProject.isFile() ) { return selectedProject.equals( project.getFile() ); } else if ( selectedProject.isDirectory() ) { return selectedProject.equals( project.getBasedir() ); } } return false; } // //////////////////////////////////////////////////////////////////////////////////////////////////////////////// // // Project collection // // //////////////////////////////////////////////////////////////////////////////////////////////////////////////// private List getProjectsForMavenReactor( MavenSession session ) throws ProjectBuildingException { MavenExecutionRequest request = session.getRequest(); request.getProjectBuildingRequest().setRepositorySession( session.getRepositorySession() ); List projects = new ArrayList<>(); // We have no POM file. // if ( request.getPom() == null ) { ModelSource modelSource = new UrlModelSource( DefaultMaven.class.getResource( "project/standalone.xml" ) ); MavenProject project = projectBuilder.build( modelSource, request.getProjectBuildingRequest() ) .getProject(); project.setExecutionRoot( true ); projects.add( project ); request.setProjectPresent( false ); return projects; } List files = Arrays.asList( request.getPom().getAbsoluteFile() ); collectProjects( projects, files, request ); return projects; } private void collectProjects( List projects, List files, MavenExecutionRequest request ) throws ProjectBuildingException { ProjectBuildingRequest projectBuildingRequest = request.getProjectBuildingRequest(); List results = projectBuilder.build( files, request.isRecursive(), projectBuildingRequest ); boolean problems = false; for ( ProjectBuildingResult result : results ) { projects.add( result.getProject() ); if ( !result.getProblems().isEmpty() && logger.isWarnEnabled() ) { logger.warn( "" ); logger.warn( "Some problems were encountered while building the effective model for " + result.getProject().getId() ); for ( ModelProblem problem : result.getProblems() ) { String loc = ModelProblemUtils.formatLocation( problem, result.getProjectId() ); logger.warn( problem.getMessage() + ( StringUtils.isNotEmpty( loc ) ? " @ " + loc : "" ) ); } problems = true; } } if ( problems ) { logger.warn( "" ); logger.warn( "It is highly recommended to fix these problems" + " because they threaten the stability of your build." ); logger.warn( "" ); logger.warn( "For this reason, future Maven versions might no" + " longer support building such malformed projects." ); logger.warn( "" ); } } private void validateProjects( List projects ) { Map projectsMap = new HashMap<>(); for ( MavenProject p : projects ) { String projectKey = ArtifactUtils.key( p.getGroupId(), p.getArtifactId(), p.getVersion() ); projectsMap.put( projectKey, p ); } for ( MavenProject project : projects ) { // MNG-1911 / MNG-5572: Building plugins with extensions cannot be part of reactor for ( Plugin plugin : project.getBuildPlugins() ) { if ( plugin.isExtensions() ) { String pluginKey = ArtifactUtils.key( plugin.getGroupId(), plugin.getArtifactId(), plugin.getVersion() ); if ( projectsMap.containsKey( pluginKey ) ) { logger.warn( project.getName() + " uses " + plugin.getKey() + " as extensions, which is not possible within the same reactor build. " + "This plugin was pulled from the local repository!" ); } } } } } } maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/graph/DefaultProjectDependencyGraph.java000066400000000000000000000117611317160430700334110ustar00rootroot00000000000000package org.apache.maven.graph; /* * 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.util.ArrayList; import java.util.Collection; import java.util.Collections; import java.util.HashSet; import java.util.List; import java.util.Set; import org.apache.commons.lang3.Validate; import org.apache.maven.execution.ProjectDependencyGraph; import org.apache.maven.project.DuplicateProjectException; import org.apache.maven.project.MavenProject; import org.apache.maven.project.ProjectSorter; import org.codehaus.plexus.util.dag.CycleDetectedException; /** * Describes the inter-dependencies between projects in the reactor. * * @author Benjamin Bentmann */ public class DefaultProjectDependencyGraph implements ProjectDependencyGraph { private ProjectSorter sorter; private List allProjects; /** * Creates a new project dependency graph based on the specified projects. * * @param projects The projects to create the dependency graph with * @throws DuplicateProjectException * @throws CycleDetectedException */ public DefaultProjectDependencyGraph( Collection projects ) throws CycleDetectedException, DuplicateProjectException { super(); this.allProjects = Collections.unmodifiableList( new ArrayList<>( projects ) ); this.sorter = new ProjectSorter( projects ); } /** * Creates a new project dependency graph based on the specified projects. * * @param allProjects All collected projects. * @param projects The projects to create the dependency graph with. * * @throws DuplicateProjectException * @throws CycleDetectedException * @since 3.5.0 */ public DefaultProjectDependencyGraph( final List allProjects, final Collection projects ) throws CycleDetectedException, DuplicateProjectException { super(); this.allProjects = Collections.unmodifiableList( new ArrayList<>( allProjects ) ); this.sorter = new ProjectSorter( projects ); } /** * @since 3.5.0 */ public List getAllProjects() { return this.allProjects; } public List getSortedProjects() { return new ArrayList<>( sorter.getSortedProjects() ); } public List getDownstreamProjects( MavenProject project, boolean transitive ) { Validate.notNull( project, "project cannot be null" ); Set projectIds = new HashSet<>(); getDownstreamProjects( ProjectSorter.getId( project ), projectIds, transitive ); return getSortedProjects( projectIds ); } private void getDownstreamProjects( String projectId, Set projectIds, boolean transitive ) { for ( String id : sorter.getDependents( projectId ) ) { if ( projectIds.add( id ) && transitive ) { getDownstreamProjects( id, projectIds, transitive ); } } } public List getUpstreamProjects( MavenProject project, boolean transitive ) { Validate.notNull( project, "project cannot be null" ); Set projectIds = new HashSet<>(); getUpstreamProjects( ProjectSorter.getId( project ), projectIds, transitive ); return getSortedProjects( projectIds ); } private void getUpstreamProjects( String projectId, Collection projectIds, boolean transitive ) { for ( String id : sorter.getDependencies( projectId ) ) { if ( projectIds.add( id ) && transitive ) { getUpstreamProjects( id, projectIds, transitive ); } } } private List getSortedProjects( Set projectIds ) { List result = new ArrayList<>( projectIds.size() ); for ( MavenProject mavenProject : sorter.getSortedProjects() ) { if ( projectIds.contains( ProjectSorter.getId( mavenProject ) ) ) { result.add( mavenProject ); } } return result; } @Override public String toString() { return sorter.getSortedProjects().toString(); } } FilteredProjectDependencyGraph.java000066400000000000000000000070361317160430700335040ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/graphpackage org.apache.maven.graph; /* * 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.util.ArrayList; import java.util.Collection; import java.util.IdentityHashMap; import java.util.List; import java.util.Map; import org.apache.commons.lang3.Validate; import org.apache.maven.execution.ProjectDependencyGraph; import org.apache.maven.project.MavenProject; /** * Provides a sub view of another dependency graph. * * @author Benjamin Bentmann */ class FilteredProjectDependencyGraph implements ProjectDependencyGraph { private ProjectDependencyGraph projectDependencyGraph; private Map whiteList; private List sortedProjects; /** * Creates a new project dependency graph from the specified graph. * * @param projectDependencyGraph The project dependency graph to create a sub view from, must not be {@code null}. * @param whiteList The projects on which the dependency view should focus, must not be {@code null}. */ public FilteredProjectDependencyGraph( ProjectDependencyGraph projectDependencyGraph, Collection whiteList ) { this.projectDependencyGraph = Validate.notNull( projectDependencyGraph, "projectDependencyGraph cannot be null" ); this.whiteList = new IdentityHashMap(); for ( MavenProject project : whiteList ) { this.whiteList.put( project, null ); } } /** * @since 3.5.0 */ public List getAllProjects() { return this.projectDependencyGraph.getAllProjects(); } public List getSortedProjects() { if ( sortedProjects == null ) { sortedProjects = applyFilter( projectDependencyGraph.getSortedProjects() ); } return new ArrayList<>( sortedProjects ); } public List getDownstreamProjects( MavenProject project, boolean transitive ) { return applyFilter( projectDependencyGraph.getDownstreamProjects( project, transitive ) ); } public List getUpstreamProjects( MavenProject project, boolean transitive ) { return applyFilter( projectDependencyGraph.getUpstreamProjects( project, transitive ) ); } private List applyFilter( Collection projects ) { List filtered = new ArrayList<>( projects.size() ); for ( MavenProject project : projects ) { if ( whiteList.containsKey( project ) ) { filtered.add( project ); } } return filtered; } @Override public String toString() { return getSortedProjects().toString(); } } maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/graph/GraphBuilder.java000066400000000000000000000023721317160430700300630ustar00rootroot00000000000000package org.apache.maven.graph; /* * 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 org.apache.maven.execution.MavenSession; import org.apache.maven.execution.ProjectDependencyGraph; import org.apache.maven.model.building.Result; /** * Builds the {@link ProjectDependencyGraph inter-dependencies graph} between projects in the reactor. * * @since 3.0-alpha */ public interface GraphBuilder { String HINT = "graphBuilder"; Result build( MavenSession session ); } maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/internal/000077500000000000000000000000001317160430700253575ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/internal/aether/000077500000000000000000000000001317160430700266275ustar00rootroot00000000000000DefaultRepositorySystemSessionFactory.java000066400000000000000000000255541317160430700372130ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/internal/aetherpackage org.apache.maven.internal.aether; /* * 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 org.apache.maven.RepositoryUtils; import org.apache.maven.artifact.handler.manager.ArtifactHandlerManager; import org.apache.maven.bridge.MavenRepositorySystem; import org.apache.maven.eventspy.internal.EventSpyDispatcher; import org.apache.maven.execution.MavenExecutionRequest; import org.apache.maven.repository.internal.MavenRepositorySystemUtils; import org.apache.maven.settings.Mirror; import org.apache.maven.settings.Proxy; import org.apache.maven.settings.Server; import org.apache.maven.settings.building.SettingsProblem; import org.apache.maven.settings.crypto.DefaultSettingsDecryptionRequest; import org.apache.maven.settings.crypto.SettingsDecrypter; import org.apache.maven.settings.crypto.SettingsDecryptionResult; import org.codehaus.plexus.configuration.xml.XmlPlexusConfiguration; import org.codehaus.plexus.logging.Logger; import org.codehaus.plexus.util.xml.Xpp3Dom; import org.eclipse.aether.ConfigurationProperties; import org.eclipse.aether.DefaultRepositorySystemSession; import org.eclipse.aether.RepositorySystem; import org.eclipse.aether.repository.LocalRepository; import org.eclipse.aether.repository.NoLocalRepositoryManagerException; import org.eclipse.aether.repository.RepositoryPolicy; import org.eclipse.aether.repository.WorkspaceReader; import org.eclipse.aether.resolution.ResolutionErrorPolicy; import org.eclipse.aether.spi.localrepo.LocalRepositoryManagerFactory; import org.eclipse.aether.util.repository.AuthenticationBuilder; import org.eclipse.aether.util.repository.DefaultAuthenticationSelector; import org.eclipse.aether.util.repository.DefaultMirrorSelector; import org.eclipse.aether.util.repository.DefaultProxySelector; import org.eclipse.aether.util.repository.SimpleResolutionErrorPolicy; import org.eclipse.sisu.Nullable; import javax.inject.Inject; import javax.inject.Named; import java.io.IOException; import java.io.InputStream; import java.util.LinkedHashMap; import java.util.Map; import java.util.Properties; /** * @since 3.3.0 */ @Named public class DefaultRepositorySystemSessionFactory { @Inject private Logger logger; @Inject private ArtifactHandlerManager artifactHandlerManager; @Inject private RepositorySystem repoSystem; @Inject @Nullable @Named( "simple" ) private LocalRepositoryManagerFactory simpleLocalRepoMgrFactory; @Inject @Nullable @Named( "ide" ) private WorkspaceReader workspaceRepository; @Inject private SettingsDecrypter settingsDecrypter; @Inject private EventSpyDispatcher eventSpyDispatcher; @Inject MavenRepositorySystem mavenRepositorySystem; public DefaultRepositorySystemSession newRepositorySession( MavenExecutionRequest request ) { DefaultRepositorySystemSession session = MavenRepositorySystemUtils.newSession(); session.setCache( request.getRepositoryCache() ); Map configProps = new LinkedHashMap<>(); configProps.put( ConfigurationProperties.USER_AGENT, getUserAgent() ); configProps.put( ConfigurationProperties.INTERACTIVE, request.isInteractiveMode() ); configProps.putAll( request.getSystemProperties() ); configProps.putAll( request.getUserProperties() ); session.setOffline( request.isOffline() ); session.setChecksumPolicy( request.getGlobalChecksumPolicy() ); if ( request.isNoSnapshotUpdates() ) { session.setUpdatePolicy( RepositoryPolicy.UPDATE_POLICY_NEVER ); } else if ( request.isUpdateSnapshots() ) { session.setUpdatePolicy( RepositoryPolicy.UPDATE_POLICY_ALWAYS ); } else { session.setUpdatePolicy( null ); } int errorPolicy = 0; errorPolicy |= request.isCacheNotFound() ? ResolutionErrorPolicy.CACHE_NOT_FOUND : ResolutionErrorPolicy.CACHE_DISABLED; errorPolicy |= request.isCacheTransferError() ? ResolutionErrorPolicy.CACHE_TRANSFER_ERROR : ResolutionErrorPolicy.CACHE_DISABLED; session.setResolutionErrorPolicy( new SimpleResolutionErrorPolicy( errorPolicy, errorPolicy | ResolutionErrorPolicy.CACHE_NOT_FOUND ) ); session.setArtifactTypeRegistry( RepositoryUtils.newArtifactTypeRegistry( artifactHandlerManager ) ); LocalRepository localRepo = new LocalRepository( request.getLocalRepository().getBasedir() ); if ( request.isUseLegacyLocalRepository() ) { try { session.setLocalRepositoryManager( simpleLocalRepoMgrFactory.newInstance( session, localRepo ) ); logger.info( "Disabling enhanced local repository: using legacy is strongly discouraged to ensure" + " build reproducibility." ); } catch ( NoLocalRepositoryManagerException e ) { logger.error( "Failed to configure legacy local repository: falling back to default" ); session.setLocalRepositoryManager( repoSystem.newLocalRepositoryManager( session, localRepo ) ); } } else { session.setLocalRepositoryManager( repoSystem.newLocalRepositoryManager( session, localRepo ) ); } if ( request.getWorkspaceReader() != null ) { session.setWorkspaceReader( request.getWorkspaceReader() ); } else { session.setWorkspaceReader( workspaceRepository ); } DefaultSettingsDecryptionRequest decrypt = new DefaultSettingsDecryptionRequest(); decrypt.setProxies( request.getProxies() ); decrypt.setServers( request.getServers() ); SettingsDecryptionResult decrypted = settingsDecrypter.decrypt( decrypt ); if ( logger.isDebugEnabled() ) { for ( SettingsProblem problem : decrypted.getProblems() ) { logger.debug( problem.getMessage(), problem.getException() ); } } DefaultMirrorSelector mirrorSelector = new DefaultMirrorSelector(); for ( Mirror mirror : request.getMirrors() ) { mirrorSelector.add( mirror.getId(), mirror.getUrl(), mirror.getLayout(), false, mirror.getMirrorOf(), mirror.getMirrorOfLayouts() ); } session.setMirrorSelector( mirrorSelector ); DefaultProxySelector proxySelector = new DefaultProxySelector(); for ( Proxy proxy : decrypted.getProxies() ) { AuthenticationBuilder authBuilder = new AuthenticationBuilder(); authBuilder.addUsername( proxy.getUsername() ).addPassword( proxy.getPassword() ); proxySelector.add( new org.eclipse.aether.repository.Proxy( proxy.getProtocol(), proxy.getHost(), proxy.getPort(), authBuilder.build() ), proxy.getNonProxyHosts() ); } session.setProxySelector( proxySelector ); DefaultAuthenticationSelector authSelector = new DefaultAuthenticationSelector(); for ( Server server : decrypted.getServers() ) { AuthenticationBuilder authBuilder = new AuthenticationBuilder(); authBuilder.addUsername( server.getUsername() ).addPassword( server.getPassword() ); authBuilder.addPrivateKey( server.getPrivateKey(), server.getPassphrase() ); authSelector.add( server.getId(), authBuilder.build() ); if ( server.getConfiguration() != null ) { Xpp3Dom dom = (Xpp3Dom) server.getConfiguration(); for ( int i = dom.getChildCount() - 1; i >= 0; i-- ) { Xpp3Dom child = dom.getChild( i ); if ( "wagonProvider".equals( child.getName() ) ) { dom.removeChild( i ); } } XmlPlexusConfiguration config = new XmlPlexusConfiguration( dom ); configProps.put( "aether.connector.wagon.config." + server.getId(), config ); } configProps.put( "aether.connector.perms.fileMode." + server.getId(), server.getFilePermissions() ); configProps.put( "aether.connector.perms.dirMode." + server.getId(), server.getDirectoryPermissions() ); } session.setAuthenticationSelector( authSelector ); session.setTransferListener( request.getTransferListener() ); session.setRepositoryListener( eventSpyDispatcher.chainListener( new LoggingRepositoryListener( logger ) ) ); session.setUserProperties( request.getUserProperties() ); session.setSystemProperties( request.getSystemProperties() ); session.setConfigProperties( configProps ); mavenRepositorySystem.injectMirror( request.getRemoteRepositories(), request.getMirrors() ); mavenRepositorySystem.injectProxy( session, request.getRemoteRepositories() ); mavenRepositorySystem.injectAuthentication( session, request.getRemoteRepositories() ); mavenRepositorySystem.injectMirror( request.getPluginArtifactRepositories(), request.getMirrors() ); mavenRepositorySystem.injectProxy( session, request.getPluginArtifactRepositories() ); mavenRepositorySystem.injectAuthentication( session, request.getPluginArtifactRepositories() ); return session; } private String getUserAgent() { return "Apache-Maven/" + getMavenVersion() + " (Java " + System.getProperty( "java.version" ) + "; " + System.getProperty( "os.name" ) + " " + System.getProperty( "os.version" ) + ")"; } private String getMavenVersion() { Properties props = new Properties(); try ( InputStream is = getClass().getResourceAsStream( "/META-INF/maven/org.apache.maven/maven-core/pom.properties" ) ) { if ( is != null ) { props.load( is ); } } catch ( IOException e ) { logger.debug( "Failed to read Maven version", e ); } return props.getProperty( "version", "unknown-version" ); } } LoggingRepositoryListener.java000066400000000000000000000076521317160430700346210ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/internal/aetherpackage org.apache.maven.internal.aether; /* * 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.FileNotFoundException; import org.codehaus.plexus.logging.Logger; import org.eclipse.aether.AbstractRepositoryListener; import org.eclipse.aether.RepositoryEvent; import org.eclipse.aether.transfer.MetadataNotFoundException; /** * @author Benjamin Bentmann */ class LoggingRepositoryListener extends AbstractRepositoryListener { private final Logger logger; public LoggingRepositoryListener( Logger logger ) { this.logger = logger; } @Override public void artifactInstalling( RepositoryEvent event ) { logger.info( "Installing " + event.getArtifact().getFile() + " to " + event.getFile() ); } @Override public void metadataInstalling( RepositoryEvent event ) { logger.debug( "Installing " + event.getMetadata() + " to " + event.getFile() ); } @Override public void metadataResolved( RepositoryEvent event ) { Exception e = event.getException(); if ( e != null ) { if ( e instanceof MetadataNotFoundException ) { logger.debug( e.getMessage() ); } else if ( logger.isDebugEnabled() ) { logger.warn( e.getMessage(), e ); } else { logger.warn( e.getMessage() ); } } } @Override public void metadataInvalid( RepositoryEvent event ) { Exception exception = event.getException(); StringBuilder buffer = new StringBuilder( 256 ); buffer.append( "The metadata " ); if ( event.getMetadata().getFile() != null ) { buffer.append( event.getMetadata().getFile() ); } else { buffer.append( event.getMetadata() ); } if ( exception instanceof FileNotFoundException ) { buffer.append( " is inaccessible" ); } else { buffer.append( " is invalid" ); } if ( exception != null ) { buffer.append( ": " ); buffer.append( exception.getMessage() ); } if ( logger.isDebugEnabled() ) { logger.warn( buffer.toString(), exception ); } else { logger.warn( buffer.toString() ); } } @Override public void artifactDescriptorInvalid( RepositoryEvent event ) { StringBuilder buffer = new StringBuilder( 256 ); buffer.append( "The POM for " ); buffer.append( event.getArtifact() ); buffer.append( " is invalid, transitive dependencies (if any) will not be available" ); if ( logger.isDebugEnabled() ) { logger.warn( buffer + ": " + event.getException().getMessage() ); } else { logger.warn( buffer + ", enable debug logging for more details" ); } } @Override public void artifactDescriptorMissing( RepositoryEvent event ) { logger.warn( "The POM for " + event.getArtifact() + " is missing, no dependency information available" ); } } maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/lifecycle/000077500000000000000000000000001317160430700255025ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/lifecycle/DefaultLifecycleExecutor.java000066400000000000000000000166641317160430700333050ustar00rootroot00000000000000package org.apache.maven.lifecycle; /* * 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 org.apache.maven.execution.MavenSession; import org.apache.maven.lifecycle.internal.LifecycleExecutionPlanCalculator; import org.apache.maven.lifecycle.internal.LifecycleStarter; import org.apache.maven.lifecycle.internal.LifecycleTaskSegmentCalculator; import org.apache.maven.lifecycle.internal.MojoDescriptorCreator; import org.apache.maven.lifecycle.internal.MojoExecutor; import org.apache.maven.lifecycle.internal.ProjectIndex; import org.apache.maven.lifecycle.internal.TaskSegment; import org.apache.maven.model.Plugin; import org.apache.maven.plugin.InvalidPluginDescriptorException; import org.apache.maven.plugin.MojoExecution; import org.apache.maven.plugin.MojoNotFoundException; import org.apache.maven.plugin.PluginDescriptorParsingException; import org.apache.maven.plugin.PluginManagerException; import org.apache.maven.plugin.PluginNotFoundException; import org.apache.maven.plugin.PluginResolutionException; import org.apache.maven.plugin.descriptor.MojoDescriptor; import org.apache.maven.plugin.prefix.NoPluginFoundForPrefixException; import org.apache.maven.plugin.version.PluginVersionResolutionException; import org.apache.maven.project.MavenProject; import org.codehaus.plexus.component.annotations.Component; import org.codehaus.plexus.component.annotations.Requirement; import java.util.Arrays; import java.util.List; import java.util.Map; import java.util.Set; /** * A facade that provides lifecycle services to components outside maven core. * * Note that this component is not normally used from within core itself. * * @author Jason van Zyl * @author Benjamin Bentmann * @author Kristian Rosenvold */ @Component( role = LifecycleExecutor.class ) public class DefaultLifecycleExecutor implements LifecycleExecutor { @Requirement private LifeCyclePluginAnalyzer lifeCyclePluginAnalyzer; @Requirement private DefaultLifecycles defaultLifeCycles; @Requirement private LifecycleTaskSegmentCalculator lifecycleTaskSegmentCalculator; @Requirement private LifecycleExecutionPlanCalculator lifecycleExecutionPlanCalculator; @Requirement private MojoExecutor mojoExecutor; @Requirement private LifecycleStarter lifecycleStarter; public void execute( MavenSession session ) { lifecycleStarter.execute( session ); } @Requirement private MojoDescriptorCreator mojoDescriptorCreator; // These methods deal with construction intact Plugin object that look like they come from a standard // block in a Maven POM. We have to do some wiggling to pull the sources of information // together and this really shows the problem of constructing a sensible default configuration but // it's all encapsulated here so it appears normalized to the POM builder. // We are going to take the project packaging and find all plugin in the default lifecycle and create // fully populated Plugin objects, including executions with goals and default configuration taken // from the plugin.xml inside a plugin. // // TODO This whole method could probably removed by injecting lifeCyclePluginAnalyzer straight into client site. // TODO But for some reason the whole plexus appcontext refuses to start when I try this. public Set getPluginsBoundByDefaultToAllLifecycles( String packaging ) { return lifeCyclePluginAnalyzer.getPluginsBoundByDefaultToAllLifecycles( packaging ); } // USED BY MAVEN HELP PLUGIN @Deprecated public Map getPhaseToLifecycleMap() { return defaultLifeCycles.getPhaseToLifecycleMap(); } // NOTE: Backward-compat with maven-help-plugin:2.1 @SuppressWarnings( { "UnusedDeclaration" } ) MojoDescriptor getMojoDescriptor( String task, MavenSession session, MavenProject project, String invokedVia, boolean canUsePrefix, boolean isOptionalMojo ) throws PluginNotFoundException, PluginResolutionException, PluginDescriptorParsingException, MojoNotFoundException, NoPluginFoundForPrefixException, InvalidPluginDescriptorException, PluginVersionResolutionException { return mojoDescriptorCreator.getMojoDescriptor( task, session, project ); } // Used by m2eclipse @SuppressWarnings( { "UnusedDeclaration" } ) public MavenExecutionPlan calculateExecutionPlan( MavenSession session, boolean setup, String... tasks ) throws PluginNotFoundException, PluginResolutionException, PluginDescriptorParsingException, MojoNotFoundException, NoPluginFoundForPrefixException, InvalidPluginDescriptorException, PluginManagerException, LifecyclePhaseNotFoundException, LifecycleNotFoundException, PluginVersionResolutionException { List taskSegments = lifecycleTaskSegmentCalculator.calculateTaskSegments( session, Arrays.asList( tasks ) ); TaskSegment mergedSegment = new TaskSegment( false ); for ( TaskSegment taskSegment : taskSegments ) { mergedSegment.getTasks().addAll( taskSegment.getTasks() ); } return lifecycleExecutionPlanCalculator.calculateExecutionPlan( session, session.getCurrentProject(), mergedSegment.getTasks(), setup ); } public MavenExecutionPlan calculateExecutionPlan( MavenSession session, String... tasks ) throws PluginNotFoundException, PluginResolutionException, PluginDescriptorParsingException, MojoNotFoundException, NoPluginFoundForPrefixException, InvalidPluginDescriptorException, PluginManagerException, LifecyclePhaseNotFoundException, LifecycleNotFoundException, PluginVersionResolutionException { return calculateExecutionPlan( session, true, tasks ); } // Site 3.x public void calculateForkedExecutions( MojoExecution mojoExecution, MavenSession session ) throws MojoNotFoundException, PluginNotFoundException, PluginResolutionException, PluginDescriptorParsingException, NoPluginFoundForPrefixException, InvalidPluginDescriptorException, LifecyclePhaseNotFoundException, LifecycleNotFoundException, PluginVersionResolutionException { lifecycleExecutionPlanCalculator.calculateForkedExecutions( mojoExecution, session ); } // Site 3.x public List executeForkedExecutions( MojoExecution mojoExecution, MavenSession session ) throws LifecycleExecutionException { return mojoExecutor.executeForkedExecutions( mojoExecution, session, new ProjectIndex( session.getProjects() ) ); } } maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/lifecycle/DefaultLifecycles.java000066400000000000000000000112601317160430700317340ustar00rootroot00000000000000package org.apache.maven.lifecycle; /* * 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 org.codehaus.plexus.component.annotations.Component; import org.codehaus.plexus.component.annotations.Requirement; import org.codehaus.plexus.logging.Logger; import org.codehaus.plexus.util.StringUtils; import com.google.common.base.Preconditions; import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; import java.util.LinkedHashMap; import java.util.LinkedHashSet; import java.util.List; import java.util.Map; import java.util.Set; /** * @since 3.0 * @author Jason van Zyl * @author Kristian Rosenvold */ // TODO The configuration for the lifecycle needs to be externalized so that I can use the annotations properly for the // wiring and reference and external source for the lifecycle configuration. @Component( role = DefaultLifecycles.class ) public class DefaultLifecycles { public static final String[] STANDARD_LIFECYCLES = { "default", "clean", "site" }; // @Configuration(source="org/apache/maven/lifecycle/lifecycles.xml") @Requirement( role = Lifecycle.class ) private Map lifecycles; @Requirement private Logger logger; public DefaultLifecycles() { } public DefaultLifecycles( Map lifecycles, Logger logger ) { this.lifecycles = new LinkedHashMap<>(); this.logger = logger; this.lifecycles = lifecycles; } public Lifecycle get( String key ) { return getPhaseToLifecycleMap().get( key ); } /** * We use this to map all phases to the lifecycle that contains it. This is used so that a user can specify the * phase they want to execute and we can easily determine what lifecycle we need to run. * * @return A map of lifecycles, indexed on id */ public Map getPhaseToLifecycleMap() { // If people are going to make their own lifecycles then we need to tell people how to namespace them correctly // so that they don't interfere with internally defined lifecycles. HashMap phaseToLifecycleMap = new HashMap<>(); for ( Lifecycle lifecycle : getLifeCycles() ) { if ( logger.isDebugEnabled() ) { logger.debug( "Lifecycle " + lifecycle ); } for ( String phase : lifecycle.getPhases() ) { // The first definition wins. if ( !phaseToLifecycleMap.containsKey( phase ) ) { phaseToLifecycleMap.put( phase, lifecycle ); } else { Lifecycle original = phaseToLifecycleMap.get( phase ); logger.warn( "Duplicated lifecycle phase " + phase + ". Defined in " + original.getId() + " but also in " + lifecycle.getId() ); } } } return phaseToLifecycleMap; } public List getLifeCycles() { // ensure canonical order of standard lifecycles Map lifecycles = new LinkedHashMap<>( this.lifecycles ); LinkedHashSet lifecycleNames = new LinkedHashSet<>( Arrays.asList( STANDARD_LIFECYCLES ) ); lifecycleNames.addAll( lifecycles.keySet() ); ArrayList result = new ArrayList<>(); for ( String name : lifecycleNames ) { Lifecycle lifecycle = lifecycles.get( name ); Preconditions.checkNotNull( "A lifecycle must have an id.", lifecycle.getId() ); result.add( lifecycle ); } return result; } public String getLifecyclePhaseList() { Set phases = new LinkedHashSet<>(); for ( Lifecycle lifecycle : getLifeCycles() ) { phases.addAll( lifecycle.getPhases() ); } return StringUtils.join( phases.iterator(), ", " ); } } maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/lifecycle/LifeCyclePluginAnalyzer.java000066400000000000000000000020701317160430700330700ustar00rootroot00000000000000package org.apache.maven.lifecycle; /* * 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.util.Set; import org.apache.maven.model.Plugin; /** * @since 3.0 * @author Kristian Rosenvold */ public interface LifeCyclePluginAnalyzer { Set getPluginsBoundByDefaultToAllLifecycles( String packaging ); } maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/lifecycle/Lifecycle.java000066400000000000000000000042251317160430700302470ustar00rootroot00000000000000package org.apache.maven.lifecycle; /* * 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.util.List; import java.util.Map; import org.apache.maven.lifecycle.mapping.LifecyclePhase; /** * Class Lifecycle. */ public class Lifecycle { public Lifecycle() { } public Lifecycle( String id, List phases, Map defaultPhases ) { this.id = id; this.phases = phases; this.defaultPhases = defaultPhases; } // // clean // // pre-clean // clean // post-clean // // // org.apache.maven.plugins:maven-clean-plugin:clean // // private String id; private List phases; private Map defaultPhases; public String getId() { return this.id; } public List getPhases() { return this.phases; } public Map getDefaultLifecyclePhases() { return defaultPhases; } @Deprecated public Map getDefaultPhases() { return LifecyclePhase.toLegacyMap( getDefaultLifecyclePhases() ); } @Override public String toString() { return id + " -> " + phases; } } LifecycleExecutionException.java000066400000000000000000000061611317160430700337340ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/lifecyclepackage org.apache.maven.lifecycle; /* * 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.shared.utils.logging.MessageUtils.buffer; import org.apache.maven.plugin.MojoExecution; import org.apache.maven.project.MavenProject; import org.apache.maven.shared.utils.logging.MessageBuilder; /** * @author Jason van Zyl */ public class LifecycleExecutionException extends Exception { private MavenProject project; public LifecycleExecutionException( String message ) { super( message ); } public LifecycleExecutionException( Throwable cause ) { super( cause ); } public LifecycleExecutionException( String message, Throwable cause ) { super( message, cause ); } public LifecycleExecutionException( String message, MavenProject project ) { super( message ); this.project = project; } public LifecycleExecutionException( String message, MojoExecution execution, MavenProject project ) { super( message ); this.project = project; } public LifecycleExecutionException( String message, MojoExecution execution, MavenProject project, Throwable cause ) { super( message, cause ); this.project = project; } public LifecycleExecutionException( MojoExecution execution, MavenProject project, Throwable cause ) { this( createMessage( execution, project, cause ), execution, project, cause ); } public MavenProject getProject() { return project; } private static String createMessage( MojoExecution execution, MavenProject project, Throwable cause ) { MessageBuilder buffer = buffer( 256 ); buffer.a( "Failed to execute goal" ); if ( execution != null ) { buffer.a( ' ' ); buffer.mojo( execution.getGroupId() + ':' + execution.getArtifactId() + ':' + execution.getVersion() + ':' + execution.getGoal() ); buffer.a( ' ' ).strong( '(' + execution.getExecutionId() + ')' ); } if ( project != null ) { buffer.a( " on project " ); buffer.project( project.getArtifactId() ); } if ( cause != null ) { buffer.a( ": " ).failure( cause.getMessage() ); } return buffer.toString(); } } maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/lifecycle/LifecycleExecutor.java000066400000000000000000000102341317160430700317630ustar00rootroot00000000000000package org.apache.maven.lifecycle; /* * 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 org.apache.maven.execution.MavenSession; import org.apache.maven.model.Plugin; import org.apache.maven.plugin.InvalidPluginDescriptorException; import org.apache.maven.plugin.MojoExecution; import org.apache.maven.plugin.MojoNotFoundException; import org.apache.maven.plugin.PluginDescriptorParsingException; import org.apache.maven.plugin.PluginManagerException; import org.apache.maven.plugin.PluginNotFoundException; import org.apache.maven.plugin.PluginResolutionException; import org.apache.maven.plugin.prefix.NoPluginFoundForPrefixException; import org.apache.maven.plugin.version.PluginVersionResolutionException; import org.apache.maven.project.MavenProject; import java.util.List; import java.util.Set; /** * A facade that provides lifecycle services to components outside Maven core. * * @author Jason van Zyl */ public interface LifecycleExecutor { // USED BY MAVEN HELP PLUGIN @Deprecated String ROLE = LifecycleExecutor.class.getName(); // For a given project packaging find all the plugins that are bound to any registered // lifecycles. The project builder needs to now what default plugin information needs to be // merged into POM being built. Once the POM builder has this plugin information, versions can be assigned // by the POM builder because they will have to be defined in plugin management. Once this is setComplete then it // can be passed back so that the default configuration information can be populated. // // We need to know the specific version so that we can lookup the right version of the plugin descriptor // which tells us what the default configuration is. // /** * @return The plugins bound to the lifecycles of the specified packaging or {@code null} if the packaging is * unknown. */ Set getPluginsBoundByDefaultToAllLifecycles( String packaging ); MavenExecutionPlan calculateExecutionPlan( MavenSession session, String... tasks ) throws PluginNotFoundException, PluginResolutionException, PluginDescriptorParsingException, MojoNotFoundException, NoPluginFoundForPrefixException, InvalidPluginDescriptorException, PluginManagerException, LifecyclePhaseNotFoundException, LifecycleNotFoundException, PluginVersionResolutionException; MavenExecutionPlan calculateExecutionPlan( MavenSession session, boolean setup, String... tasks ) throws PluginNotFoundException, PluginResolutionException, PluginDescriptorParsingException, MojoNotFoundException, NoPluginFoundForPrefixException, InvalidPluginDescriptorException, PluginManagerException, LifecyclePhaseNotFoundException, LifecycleNotFoundException, PluginVersionResolutionException; void execute( MavenSession session ); // used by the site plugin 3.x void calculateForkedExecutions( MojoExecution mojoExecution, MavenSession session ) throws MojoNotFoundException, PluginNotFoundException, PluginResolutionException, PluginDescriptorParsingException, NoPluginFoundForPrefixException, InvalidPluginDescriptorException, LifecyclePhaseNotFoundException, LifecycleNotFoundException, PluginVersionResolutionException; // used by the site plugin 3.x List executeForkedExecutions( MojoExecution mojoExecution, MavenSession session ) throws LifecycleExecutionException; } maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/lifecycle/LifecycleMappingDelegate.java000066400000000000000000000045051317160430700332170ustar00rootroot00000000000000package org.apache.maven.lifecycle; /* * 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.util.List; import java.util.Map; import org.apache.maven.execution.MavenSession; import org.apache.maven.plugin.InvalidPluginDescriptorException; import org.apache.maven.plugin.MojoExecution; import org.apache.maven.plugin.MojoNotFoundException; import org.apache.maven.plugin.PluginDescriptorParsingException; import org.apache.maven.plugin.PluginNotFoundException; import org.apache.maven.plugin.PluginResolutionException; import org.apache.maven.project.MavenProject; /** * Lifecycle mapping delegate component interface. Calculates project build execution plan given {@link Lifecycle} and * lifecycle phase. Standard lifecycles use plugin execution {@code } or mojo default lifecycle phase to * calculate the execution plan, but custom lifecycles can use alternative mapping strategies. *

* Implementations of this interface must be annotated with either {@code @Named("lifecycle-id")} or equivalent plexus * {@code @Component} annotations. * * @since 3.2.0 * @see org.apache.maven.lifecycle.internal.DefaultLifecycleMappingDelegate * @author ifedorenko */ public interface LifecycleMappingDelegate { Map> calculateLifecycleMappings( MavenSession session, MavenProject project, Lifecycle lifecycle, String lifecyclePhase ) throws PluginNotFoundException, PluginResolutionException, PluginDescriptorParsingException, MojoNotFoundException, InvalidPluginDescriptorException; } LifecycleNotFoundException.java000066400000000000000000000032401317160430700335200ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/lifecyclepackage org.apache.maven.lifecycle; /* * 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. */ /** * Signals a failure to locate a lifecycle. * * @author Benjamin Bentmann */ public class LifecycleNotFoundException extends Exception { private final String lifecycleId; /** * Creates a new exception to indicate that the specified lifecycle is unknown. * * @param lifecycleId The identifier of the lifecycle that could not be located, may be {@code null}. */ public LifecycleNotFoundException( String lifecycleId ) { super( "Unknown lifecycle " + lifecycleId ); this.lifecycleId = ( lifecycleId != null ) ? lifecycleId : ""; } /** * Gets the identifier of the lifecycle that was not found. * * @return The identifier of the lifecycle that was not found, never {@code null}. */ public String getLifecycleId() { return lifecycleId; } } LifecyclePhaseNotFoundException.java000066400000000000000000000034201317160430700345010ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/lifecyclepackage org.apache.maven.lifecycle; /* * 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. */ /** * Signals a failure to locate the lifecycle for some phase. * * @author Benjamin Bentmann */ public class LifecyclePhaseNotFoundException extends Exception { private final String lifecyclePhase; /** * Creates a new exception to indicate that the specified lifecycle phase is not defined by any known lifecycle. * * @param message The detail message, may be {@code null}. * @param lifecyclePhase The name of the lifecycle phase that could not be located, may be {@code null}. */ public LifecyclePhaseNotFoundException( String message, String lifecyclePhase ) { super( message ); this.lifecyclePhase = ( lifecyclePhase != null ) ? lifecyclePhase : ""; } /** * Gets the lifecycle phase that was not found. * * @return The lifecycle phase that was not found, never {@code null}. */ public String getLifecyclePhase() { return lifecyclePhase; } } maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/lifecycle/MavenExecutionPlan.java000066400000000000000000000150461317160430700321200ustar00rootroot00000000000000package org.apache.maven.lifecycle; /* * 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.util.ArrayList; import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; import java.util.LinkedHashMap; import java.util.LinkedHashSet; import java.util.List; import java.util.Map; import java.util.Set; import org.apache.maven.lifecycle.internal.ExecutionPlanItem; import org.apache.maven.model.Plugin; import org.apache.maven.plugin.MojoExecution; import org.apache.maven.plugin.descriptor.MojoDescriptor; //TODO lifecycles being executed //TODO what runs in each phase //TODO plugins that need downloading //TODO project dependencies that need downloading //TODO unfortunately the plugins need to be downloaded in order to get the plugin.xml file. need to externalize this // from the plugin archive. //TODO this will be the class that people get in IDEs to modify public class MavenExecutionPlan implements Iterable { /* At the moment, this class is totally immutable, and this is in line with thoughts about the pre-calculated execution plan that stays the same during the execution. If deciding to add mutable state to this class, it should be at least considered to separate this into a separate mutable structure. */ private final List planItem; private final Map lastMojoExecutionForAllPhases; final List phasesInExecutionPlan; public MavenExecutionPlan( List planItem, DefaultLifecycles defaultLifecycles ) { this.planItem = planItem; lastMojoExecutionForAllPhases = new LinkedHashMap<>(); LinkedHashSet totalPhaseSet = new LinkedHashSet<>(); if ( defaultLifecycles != null ) { for ( String phase : getDistinctPhasesInOrderOfExecutionPlanAppearance( planItem ) ) { final Lifecycle lifecycle = defaultLifecycles.get( phase ); if ( lifecycle != null ) { totalPhaseSet.addAll( lifecycle.getPhases() ); } } } this.phasesInExecutionPlan = new ArrayList<>( totalPhaseSet ); Map lastInExistingPhases = new HashMap<>(); for ( ExecutionPlanItem executionPlanItem : getExecutionPlanItems() ) { lastInExistingPhases.put( executionPlanItem.getLifecyclePhase(), executionPlanItem ); } ExecutionPlanItem lastSeenExecutionPlanItem = null; for ( String phase : totalPhaseSet ) { ExecutionPlanItem forThisPhase = lastInExistingPhases.get( phase ); if ( forThisPhase != null ) { lastSeenExecutionPlanItem = forThisPhase; } lastMojoExecutionForAllPhases.put( phase, lastSeenExecutionPlanItem ); } } public Iterator iterator() { return getExecutionPlanItems().iterator(); } /** * Returns the last ExecutionPlanItem in the supplied phase. If no items are in the specified phase, * the closest executionPlanItem from an earlier phase item will be returned. * * @param requestedPhase the requested phase * The execution plan item * @return The ExecutionPlanItem or null if none can be found */ public ExecutionPlanItem findLastInPhase( String requestedPhase ) { return lastMojoExecutionForAllPhases.get( requestedPhase ); } private List getExecutionPlanItems() { return planItem; } private static Iterable getDistinctPhasesInOrderOfExecutionPlanAppearance( List planItems ) { LinkedHashSet result = new LinkedHashSet<>(); for ( ExecutionPlanItem executionPlanItem : planItems ) { final String phase = executionPlanItem.getLifecyclePhase(); if ( !result.contains( phase ) ) { result.add( phase ); } } return result; } public List getMojoExecutions() { List result = new ArrayList<>(); for ( ExecutionPlanItem executionPlanItem : planItem ) { result.add( executionPlanItem.getMojoExecution() ); } return result; } /** * Get set of plugins having a goal/mojo used but not marked @threadSafe * * @return the set of plugins (without info on which goal is concerned) */ public Set getNonThreadSafePlugins() { Set plugins = new HashSet<>(); for ( ExecutionPlanItem executionPlanItem : planItem ) { final MojoExecution mojoExecution = executionPlanItem.getMojoExecution(); if ( !mojoExecution.getMojoDescriptor().isThreadSafe() ) { plugins.add( mojoExecution.getPlugin() ); } } return plugins; } /** * Get set of mojos used but not marked @threadSafe * * @return the set of mojo descriptors */ public Set getNonThreadSafeMojos() { Set mojos = new HashSet<>(); for ( ExecutionPlanItem executionPlanItem : planItem ) { final MojoExecution mojoExecution = executionPlanItem.getMojoExecution(); if ( !mojoExecution.getMojoDescriptor().isThreadSafe() ) { mojos.add( mojoExecution.getMojoDescriptor() ); } } return mojos; } // Used by m2e but will be removed, really. @Deprecated public List getExecutions() { return getMojoExecutions(); } public int size() { return planItem.size(); } } maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/lifecycle/MissingProjectException.java000066400000000000000000000023611317160430700331660ustar00rootroot00000000000000package org.apache.maven.lifecycle; /* * 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. */ /** * Signals a failure to execute a lifecycle phase or mojo because a project is required but not present. * * @author Benjamin Bentmann */ public class MissingProjectException extends Exception { /** * Creates a new exception. * * @param message The detail message, may be {@code null}. */ public MissingProjectException( String message ) { super( message ); } } maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/lifecycle/MojoExecutionConfigurator.java000066400000000000000000000034471317160430700335300ustar00rootroot00000000000000package org.apache.maven.lifecycle; /* * 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 org.apache.maven.plugin.MojoExecution; import org.apache.maven.project.MavenProject; /** *

* A MojoExecutionConfigurator is responsible for creating the configuration for Mojo based on configuration for a Mojo * in the MavenProject and the default configuration for the Mojo from the containing plugin's plugin.xml descriptor. *

* Note: This interface is part of work in progress and can be changed or removed without notice. * @author Jason van Zyl * @since 3.3.1, MNG-5753 */ public interface MojoExecutionConfigurator { /** * Create the MojoExecution configuration based on configuration for a Mojo in the MavenProject and the * default configuration for the Mojo from the containing plugin's plugin.xml descriptor. * * @param project * @param mojoExecution * @param allowPluginLevelConfig */ void configure( MavenProject project, MojoExecution mojoExecution, boolean allowPluginLevelConfig ); } maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/lifecycle/NoGoalSpecifiedException.java000066400000000000000000000023071317160430700332210ustar00rootroot00000000000000package org.apache.maven.lifecycle; /* * 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. */ /** * Signals a failure to build because no goal was specified. * * @author Benjamin Bentmann */ public class NoGoalSpecifiedException extends Exception { /** * Creates a new exception. * * @param message The detail message, may be {@code null}. */ public NoGoalSpecifiedException( String message ) { super( message ); } } maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/lifecycle/internal/000077500000000000000000000000001317160430700273165ustar00rootroot00000000000000BuildListCalculator.java000066400000000000000000000046621317160430700340170ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/lifecycle/internalpackage org.apache.maven.lifecycle.internal; /* * 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 org.apache.maven.execution.MavenSession; import org.apache.maven.lifecycle.internal.builder.BuilderCommon; import org.apache.maven.project.MavenProject; import org.codehaus.plexus.component.annotations.Component; import java.util.ArrayList; import java.util.Collections; import java.util.List; /** * NOTE: This class is not part of any public api and can be changed or deleted without prior notice. * * @since 3.0 * @author Kristian Rosenvold */ @Component( role = BuildListCalculator.class ) public class BuildListCalculator { public ProjectBuildList calculateProjectBuilds( MavenSession session, List taskSegments ) { List projectBuilds = new ArrayList<>(); MavenProject rootProject = session.getTopLevelProject(); for ( TaskSegment taskSegment : taskSegments ) { List projects; if ( taskSegment.isAggregating() ) { projects = Collections.singletonList( rootProject ); } else { projects = session.getProjects(); } for ( MavenProject project : projects ) { BuilderCommon.attachToThread( project ); // Not totally sure if this is needed for anything MavenSession copiedSession = session.clone(); copiedSession.setCurrentProject( project ); projectBuilds.add( new ProjectSegment( project, taskSegment, copiedSession ) ); } } return new ProjectBuildList( projectBuilds ); } } BuildThreadFactory.java000066400000000000000000000025571317160430700336320ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/lifecycle/internalpackage org.apache.maven.lifecycle.internal; /* * 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.util.concurrent.ThreadFactory; import java.util.concurrent.atomic.AtomicInteger; /** * Simple {@link ThreadFactory} implementation that ensures the corresponding threads have a meaningful name. */ public class BuildThreadFactory implements ThreadFactory { private final AtomicInteger id = new AtomicInteger(); private static final String PREFIX = "BuilderThread"; public Thread newThread( Runnable r ) { return new Thread( r, String.format( "%s %d", PREFIX, id.getAndIncrement() ) ); } }CompoundProjectExecutionListener.java000066400000000000000000000046131317160430700366130ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/lifecycle/internalpackage org.apache.maven.lifecycle.internal; /* * 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.util.Collection; import org.apache.maven.execution.ProjectExecutionEvent; import org.apache.maven.execution.ProjectExecutionListener; import org.apache.maven.lifecycle.LifecycleExecutionException; class CompoundProjectExecutionListener implements ProjectExecutionListener { private final Collection listeners; public CompoundProjectExecutionListener( Collection listeners ) { this.listeners = listeners; // NB this is live injected collection } public void beforeProjectExecution( ProjectExecutionEvent event ) throws LifecycleExecutionException { for ( ProjectExecutionListener listener : listeners ) { listener.beforeProjectExecution( event ); } } public void beforeProjectLifecycleExecution( ProjectExecutionEvent event ) throws LifecycleExecutionException { for ( ProjectExecutionListener listener : listeners ) { listener.beforeProjectLifecycleExecution( event ); } } public void afterProjectExecutionSuccess( ProjectExecutionEvent event ) throws LifecycleExecutionException { for ( ProjectExecutionListener listener : listeners ) { listener.afterProjectExecutionSuccess( event ); } } public void afterProjectExecutionFailure( ProjectExecutionEvent event ) { for ( ProjectExecutionListener listener : listeners ) { listener.afterProjectExecutionFailure( event ); } } } DefaultExecutionEvent.java000066400000000000000000000037361317160430700343650ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/lifecycle/internalpackage org.apache.maven.lifecycle.internal; /* * 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 org.apache.maven.execution.ExecutionEvent; import org.apache.maven.execution.MavenSession; import org.apache.maven.plugin.MojoExecution; import org.apache.maven.project.MavenProject; /** * Holds data relevant for an execution event. * * @author Benjamin Bentmann */ class DefaultExecutionEvent implements ExecutionEvent { private final Type type; private final MavenSession session; private final MojoExecution mojoExecution; private final Exception exception; public DefaultExecutionEvent( Type type, MavenSession session, MojoExecution mojoExecution, Exception exception ) { this.type = type; this.session = session; this.mojoExecution = mojoExecution; this.exception = exception; } public Type getType() { return type; } public MavenSession getSession() { return session; } public MavenProject getProject() { return session.getCurrentProject(); } public MojoExecution getMojoExecution() { return mojoExecution; } public Exception getException() { return exception; } } DefaultExecutionEventCatapult.java000066400000000000000000000103651317160430700360570ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/lifecycle/internalpackage org.apache.maven.lifecycle.internal; /* * 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 org.apache.maven.execution.ExecutionEvent; import org.apache.maven.execution.ExecutionListener; import org.apache.maven.execution.MavenSession; import org.apache.maven.plugin.MojoExecution; import org.codehaus.plexus.component.annotations.Component; /** * Assists in firing execution events. Warning: This is an internal utility class that is only public * for technical reasons, it is not part of the public API. In particular, this class can be changed or deleted without * prior notice. * * @author Benjamin Bentmann */ @Component( role = ExecutionEventCatapult.class ) public class DefaultExecutionEventCatapult implements ExecutionEventCatapult { public void fire( ExecutionEvent.Type eventType, MavenSession session, MojoExecution mojoExecution ) { fire( eventType, session, mojoExecution, null ); } public void fire( ExecutionEvent.Type eventType, MavenSession session, MojoExecution mojoExecution, Exception exception ) { ExecutionListener listener = session.getRequest().getExecutionListener(); if ( listener != null ) { ExecutionEvent event = new DefaultExecutionEvent( eventType, session, mojoExecution, exception ); switch ( eventType ) { case ProjectDiscoveryStarted: listener.projectDiscoveryStarted( event ); break; case SessionStarted: listener.sessionStarted( event ); break; case SessionEnded: listener.sessionEnded( event ); break; case ProjectSkipped: listener.projectSkipped( event ); break; case ProjectStarted: listener.projectStarted( event ); break; case ProjectSucceeded: listener.projectSucceeded( event ); break; case ProjectFailed: listener.projectFailed( event ); break; case MojoSkipped: listener.mojoSkipped( event ); break; case MojoStarted: listener.mojoStarted( event ); break; case MojoSucceeded: listener.mojoSucceeded( event ); break; case MojoFailed: listener.mojoFailed( event ); break; case ForkStarted: listener.forkStarted( event ); break; case ForkSucceeded: listener.forkSucceeded( event ); break; case ForkFailed: listener.forkFailed( event ); break; case ForkedProjectStarted: listener.forkedProjectStarted( event ); break; case ForkedProjectSucceeded: listener.forkedProjectSucceeded( event ); break; case ForkedProjectFailed: listener.forkedProjectFailed( event ); break; default: throw new IllegalStateException( "Unknown execution event type " + eventType ); } } } } DefaultLifecycleExecutionPlanCalculator.java000066400000000000000000000617451317160430700400340ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/lifecycle/internalpackage org.apache.maven.lifecycle.internal; /* * 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.util.ArrayList; import java.util.Arrays; import java.util.Collection; import java.util.Collections; import java.util.HashSet; import java.util.List; import java.util.Map; import org.apache.maven.execution.MavenSession; import org.apache.maven.lifecycle.DefaultLifecycles; import org.apache.maven.lifecycle.Lifecycle; import org.apache.maven.lifecycle.LifecycleMappingDelegate; import org.apache.maven.lifecycle.LifecycleNotFoundException; import org.apache.maven.lifecycle.LifecyclePhaseNotFoundException; import org.apache.maven.lifecycle.MavenExecutionPlan; import org.apache.maven.lifecycle.MojoExecutionConfigurator; import org.apache.maven.lifecycle.internal.builder.BuilderCommon; import org.apache.maven.plugin.BuildPluginManager; import org.apache.maven.plugin.InvalidPluginDescriptorException; import org.apache.maven.plugin.MojoExecution; import org.apache.maven.plugin.MojoNotFoundException; import org.apache.maven.plugin.PluginDescriptorParsingException; import org.apache.maven.plugin.PluginNotFoundException; import org.apache.maven.plugin.PluginResolutionException; import org.apache.maven.plugin.descriptor.MojoDescriptor; import org.apache.maven.plugin.descriptor.Parameter; import org.apache.maven.plugin.descriptor.PluginDescriptor; import org.apache.maven.plugin.lifecycle.Execution; import org.apache.maven.plugin.lifecycle.Phase; import org.apache.maven.plugin.prefix.NoPluginFoundForPrefixException; import org.apache.maven.plugin.version.PluginVersionResolutionException; import org.apache.maven.plugin.version.PluginVersionResolver; import org.apache.maven.project.MavenProject; import org.codehaus.plexus.component.annotations.Component; import org.codehaus.plexus.component.annotations.Requirement; import org.codehaus.plexus.util.StringUtils; import org.codehaus.plexus.util.xml.Xpp3Dom; import org.codehaus.plexus.util.xml.pull.XmlPullParserException; import com.google.common.collect.ImmutableMap; /** * NOTE: This class is not part of any public api and can be changed or deleted without prior notice. * * @since 3.0 * @author Benjamin Bentmann * @author Kristian Rosenvold (Extract class) */ @Component( role = LifecycleExecutionPlanCalculator.class ) public class DefaultLifecycleExecutionPlanCalculator implements LifecycleExecutionPlanCalculator { @Requirement private PluginVersionResolver pluginVersionResolver; @Requirement private BuildPluginManager pluginManager; @Requirement private DefaultLifecycles defaultLifeCycles; @Requirement private MojoDescriptorCreator mojoDescriptorCreator; @Requirement private LifecyclePluginResolver lifecyclePluginResolver; @Requirement( hint = DefaultLifecycleMappingDelegate.HINT ) private LifecycleMappingDelegate standardDelegate; @Requirement private Map delegates; @Requirement private Map mojoExecutionConfigurators; @SuppressWarnings( { "UnusedDeclaration" } ) public DefaultLifecycleExecutionPlanCalculator() { } // Only used for testing public DefaultLifecycleExecutionPlanCalculator( BuildPluginManager pluginManager, DefaultLifecycles defaultLifeCycles, MojoDescriptorCreator mojoDescriptorCreator, LifecyclePluginResolver lifecyclePluginResolver ) { this.pluginManager = pluginManager; this.defaultLifeCycles = defaultLifeCycles; this.mojoDescriptorCreator = mojoDescriptorCreator; this.lifecyclePluginResolver = lifecyclePluginResolver; this.mojoExecutionConfigurators = ImmutableMap.of( "default", (MojoExecutionConfigurator) new DefaultMojoExecutionConfigurator() ); } @Override public MavenExecutionPlan calculateExecutionPlan( MavenSession session, MavenProject project, List tasks, boolean setup ) throws PluginNotFoundException, PluginResolutionException, LifecyclePhaseNotFoundException, PluginDescriptorParsingException, MojoNotFoundException, InvalidPluginDescriptorException, NoPluginFoundForPrefixException, LifecycleNotFoundException, PluginVersionResolutionException { lifecyclePluginResolver.resolveMissingPluginVersions( project, session ); final List executions = calculateMojoExecutions( session, project, tasks ); if ( setup ) { setupMojoExecutions( session, project, executions ); } final List planItem = ExecutionPlanItem.createExecutionPlanItems( project, executions ); return new MavenExecutionPlan( planItem, defaultLifeCycles ); } @Override public MavenExecutionPlan calculateExecutionPlan( MavenSession session, MavenProject project, List tasks ) throws PluginNotFoundException, PluginResolutionException, LifecyclePhaseNotFoundException, PluginDescriptorParsingException, MojoNotFoundException, InvalidPluginDescriptorException, NoPluginFoundForPrefixException, LifecycleNotFoundException, PluginVersionResolutionException { return calculateExecutionPlan( session, project, tasks, true ); } private void setupMojoExecutions( MavenSession session, MavenProject project, List mojoExecutions ) throws PluginNotFoundException, PluginResolutionException, PluginDescriptorParsingException, MojoNotFoundException, InvalidPluginDescriptorException, NoPluginFoundForPrefixException, LifecyclePhaseNotFoundException, LifecycleNotFoundException, PluginVersionResolutionException { for ( MojoExecution mojoExecution : mojoExecutions ) { setupMojoExecution( session, project, mojoExecution ); } } @Override public void setupMojoExecution( MavenSession session, MavenProject project, MojoExecution mojoExecution ) throws PluginNotFoundException, PluginResolutionException, PluginDescriptorParsingException, MojoNotFoundException, InvalidPluginDescriptorException, NoPluginFoundForPrefixException, LifecyclePhaseNotFoundException, LifecycleNotFoundException, PluginVersionResolutionException { MojoDescriptor mojoDescriptor = mojoExecution.getMojoDescriptor(); if ( mojoDescriptor == null ) { mojoDescriptor = pluginManager.getMojoDescriptor( mojoExecution.getPlugin(), mojoExecution.getGoal(), project.getRemotePluginRepositories(), session.getRepositorySession() ); mojoExecution.setMojoDescriptor( mojoDescriptor ); } mojoExecutionConfigurator( mojoExecution ).configure( project, mojoExecution, MojoExecution.Source.CLI.equals( mojoExecution.getSource() ) ); finalizeMojoConfiguration( mojoExecution ); calculateForkedExecutions( mojoExecution, session, project, new HashSet() ); } public List calculateMojoExecutions( MavenSession session, MavenProject project, List tasks ) throws PluginNotFoundException, PluginResolutionException, PluginDescriptorParsingException, MojoNotFoundException, NoPluginFoundForPrefixException, InvalidPluginDescriptorException, PluginVersionResolutionException, LifecyclePhaseNotFoundException { final List mojoExecutions = new ArrayList<>(); for ( Object task : tasks ) { if ( task instanceof GoalTask ) { String pluginGoal = ( (GoalTask) task ).pluginGoal; String executionId = "default-cli"; int executionIdx = pluginGoal.indexOf( '@' ); if ( executionIdx > 0 ) { executionId = pluginGoal.substring( executionIdx + 1 ); } MojoDescriptor mojoDescriptor = mojoDescriptorCreator.getMojoDescriptor( pluginGoal, session, project ); MojoExecution mojoExecution = new MojoExecution( mojoDescriptor, executionId, MojoExecution.Source.CLI ); mojoExecutions.add( mojoExecution ); } else if ( task instanceof LifecycleTask ) { String lifecyclePhase = ( (LifecycleTask) task ).getLifecyclePhase(); Map> phaseToMojoMapping = calculateLifecycleMappings( session, project, lifecyclePhase ); for ( List mojoExecutionsFromLifecycle : phaseToMojoMapping.values() ) { mojoExecutions.addAll( mojoExecutionsFromLifecycle ); } } else { throw new IllegalStateException( "unexpected task " + task ); } } return mojoExecutions; } private Map> calculateLifecycleMappings( MavenSession session, MavenProject project, String lifecyclePhase ) throws LifecyclePhaseNotFoundException, PluginNotFoundException, PluginResolutionException, PluginDescriptorParsingException, MojoNotFoundException, InvalidPluginDescriptorException { /* * Determine the lifecycle that corresponds to the given phase. */ Lifecycle lifecycle = defaultLifeCycles.get( lifecyclePhase ); if ( lifecycle == null ) { throw new LifecyclePhaseNotFoundException( "Unknown lifecycle phase \"" + lifecyclePhase + "\". You must specify a valid lifecycle phase" + " or a goal in the format : or" + " :[:]:. Available lifecycle phases are: " + defaultLifeCycles.getLifecyclePhaseList() + ".", lifecyclePhase ); } LifecycleMappingDelegate delegate; if ( Arrays.binarySearch( DefaultLifecycles.STANDARD_LIFECYCLES, lifecycle.getId() ) >= 0 ) { delegate = standardDelegate; } else { delegate = delegates.get( lifecycle.getId() ); if ( delegate == null ) { delegate = standardDelegate; } } return delegate.calculateLifecycleMappings( session, project, lifecycle, lifecyclePhase ); } /** * Post-processes the effective configuration for the specified mojo execution. This step discards all parameters * from the configuration that are not applicable to the mojo and injects the default values for any missing * parameters. * * @param mojoExecution The mojo execution whose configuration should be finalized, must not be {@code null}. */ private void finalizeMojoConfiguration( MojoExecution mojoExecution ) { MojoDescriptor mojoDescriptor = mojoExecution.getMojoDescriptor(); Xpp3Dom executionConfiguration = mojoExecution.getConfiguration(); if ( executionConfiguration == null ) { executionConfiguration = new Xpp3Dom( "configuration" ); } Xpp3Dom defaultConfiguration = getMojoConfiguration( mojoDescriptor ); Xpp3Dom finalConfiguration = new Xpp3Dom( "configuration" ); if ( mojoDescriptor.getParameters() != null ) { for ( Parameter parameter : mojoDescriptor.getParameters() ) { Xpp3Dom parameterConfiguration = executionConfiguration.getChild( parameter.getName() ); if ( parameterConfiguration == null ) { parameterConfiguration = executionConfiguration.getChild( parameter.getAlias() ); } Xpp3Dom parameterDefaults = defaultConfiguration.getChild( parameter.getName() ); parameterConfiguration = Xpp3Dom.mergeXpp3Dom( parameterConfiguration, parameterDefaults, Boolean.TRUE ); if ( parameterConfiguration != null ) { parameterConfiguration = new Xpp3Dom( parameterConfiguration, parameter.getName() ); if ( StringUtils.isEmpty( parameterConfiguration.getAttribute( "implementation" ) ) && StringUtils.isNotEmpty( parameter.getImplementation() ) ) { parameterConfiguration.setAttribute( "implementation", parameter.getImplementation() ); } finalConfiguration.addChild( parameterConfiguration ); } } } mojoExecution.setConfiguration( finalConfiguration ); } private Xpp3Dom getMojoConfiguration( MojoDescriptor mojoDescriptor ) { return MojoDescriptorCreator.convert( mojoDescriptor ); } @Override public void calculateForkedExecutions( MojoExecution mojoExecution, MavenSession session ) throws MojoNotFoundException, PluginNotFoundException, PluginResolutionException, PluginDescriptorParsingException, NoPluginFoundForPrefixException, InvalidPluginDescriptorException, LifecyclePhaseNotFoundException, LifecycleNotFoundException, PluginVersionResolutionException { calculateForkedExecutions( mojoExecution, session, session.getCurrentProject(), new HashSet() ); } private void calculateForkedExecutions( MojoExecution mojoExecution, MavenSession session, MavenProject project, Collection alreadyForkedExecutions ) throws MojoNotFoundException, PluginNotFoundException, PluginResolutionException, PluginDescriptorParsingException, NoPluginFoundForPrefixException, InvalidPluginDescriptorException, LifecyclePhaseNotFoundException, LifecycleNotFoundException, PluginVersionResolutionException { MojoDescriptor mojoDescriptor = mojoExecution.getMojoDescriptor(); if ( !mojoDescriptor.isForking() ) { return; } if ( !alreadyForkedExecutions.add( mojoDescriptor ) ) { return; } List forkedProjects = LifecycleDependencyResolver.getProjects( project, session, mojoDescriptor.isAggregator() ); for ( MavenProject forkedProject : forkedProjects ) { if ( forkedProject != project ) { lifecyclePluginResolver.resolveMissingPluginVersions( forkedProject, session ); } List forkedExecutions; if ( StringUtils.isNotEmpty( mojoDescriptor.getExecutePhase() ) ) { forkedExecutions = calculateForkedLifecycle( mojoExecution, session, forkedProject, alreadyForkedExecutions ); } else { forkedExecutions = calculateForkedGoal( mojoExecution, session, forkedProject, alreadyForkedExecutions ); } mojoExecution.setForkedExecutions( BuilderCommon.getKey( forkedProject ), forkedExecutions ); } alreadyForkedExecutions.remove( mojoDescriptor ); } private List calculateForkedLifecycle( MojoExecution mojoExecution, MavenSession session, MavenProject project, Collection alreadyForkedExecutions ) throws MojoNotFoundException, PluginNotFoundException, PluginResolutionException, PluginDescriptorParsingException, NoPluginFoundForPrefixException, InvalidPluginDescriptorException, LifecyclePhaseNotFoundException, LifecycleNotFoundException, PluginVersionResolutionException { MojoDescriptor mojoDescriptor = mojoExecution.getMojoDescriptor(); String forkedPhase = mojoDescriptor.getExecutePhase(); Map> lifecycleMappings = calculateLifecycleMappings( session, project, forkedPhase ); for ( List forkedExecutions : lifecycleMappings.values() ) { for ( MojoExecution forkedExecution : forkedExecutions ) { if ( forkedExecution.getMojoDescriptor() == null ) { MojoDescriptor forkedMojoDescriptor = pluginManager.getMojoDescriptor( forkedExecution.getPlugin(), forkedExecution.getGoal(), project.getRemotePluginRepositories(), session.getRepositorySession() ); forkedExecution.setMojoDescriptor( forkedMojoDescriptor ); } mojoExecutionConfigurator( forkedExecution ).configure( project, forkedExecution, false ); } } injectLifecycleOverlay( lifecycleMappings, mojoExecution, session, project ); List mojoExecutions = new ArrayList<>(); for ( List forkedExecutions : lifecycleMappings.values() ) { for ( MojoExecution forkedExecution : forkedExecutions ) { if ( !alreadyForkedExecutions.contains( forkedExecution.getMojoDescriptor() ) ) { finalizeMojoConfiguration( forkedExecution ); calculateForkedExecutions( forkedExecution, session, project, alreadyForkedExecutions ); mojoExecutions.add( forkedExecution ); } } } return mojoExecutions; } private void injectLifecycleOverlay( Map> lifecycleMappings, MojoExecution mojoExecution, MavenSession session, MavenProject project ) throws PluginDescriptorParsingException, LifecycleNotFoundException, MojoNotFoundException, PluginNotFoundException, PluginResolutionException, NoPluginFoundForPrefixException, InvalidPluginDescriptorException, PluginVersionResolutionException { MojoDescriptor mojoDescriptor = mojoExecution.getMojoDescriptor(); PluginDescriptor pluginDescriptor = mojoDescriptor.getPluginDescriptor(); String forkedLifecycle = mojoDescriptor.getExecuteLifecycle(); if ( StringUtils.isEmpty( forkedLifecycle ) ) { return; } org.apache.maven.plugin.lifecycle.Lifecycle lifecycleOverlay; try { lifecycleOverlay = pluginDescriptor.getLifecycleMapping( forkedLifecycle ); } catch ( IOException | XmlPullParserException e ) { throw new PluginDescriptorParsingException( pluginDescriptor.getPlugin(), pluginDescriptor.getSource(), e ); } if ( lifecycleOverlay == null ) { throw new LifecycleNotFoundException( forkedLifecycle ); } for ( Phase phase : lifecycleOverlay.getPhases() ) { List forkedExecutions = lifecycleMappings.get( phase.getId() ); if ( forkedExecutions != null ) { for ( Execution execution : phase.getExecutions() ) { for ( String goal : execution.getGoals() ) { MojoDescriptor forkedMojoDescriptor; if ( goal.indexOf( ':' ) < 0 ) { forkedMojoDescriptor = pluginDescriptor.getMojo( goal ); if ( forkedMojoDescriptor == null ) { throw new MojoNotFoundException( goal, pluginDescriptor ); } } else { forkedMojoDescriptor = mojoDescriptorCreator.getMojoDescriptor( goal, session, project ); } MojoExecution forkedExecution = new MojoExecution( forkedMojoDescriptor, mojoExecution.getExecutionId() ); Xpp3Dom forkedConfiguration = (Xpp3Dom) execution.getConfiguration(); forkedExecution.setConfiguration( forkedConfiguration ); mojoExecutionConfigurator( forkedExecution ).configure( project, forkedExecution, true ); forkedExecutions.add( forkedExecution ); } } Xpp3Dom phaseConfiguration = (Xpp3Dom) phase.getConfiguration(); if ( phaseConfiguration != null ) { for ( MojoExecution forkedExecution : forkedExecutions ) { Xpp3Dom forkedConfiguration = forkedExecution.getConfiguration(); forkedConfiguration = Xpp3Dom.mergeXpp3Dom( phaseConfiguration, forkedConfiguration ); forkedExecution.setConfiguration( forkedConfiguration ); } } } } } // org.apache.maven.plugins:maven-remote-resources-plugin:1.0:process // TODO take repo mans into account as one may be aggregating prefixes of many // TODO collect at the root of the repository, read the one at the root, and fetch remote if something is missing // or the user forces the issue private List calculateForkedGoal( MojoExecution mojoExecution, MavenSession session, MavenProject project, Collection alreadyForkedExecutions ) throws MojoNotFoundException, PluginNotFoundException, PluginResolutionException, PluginDescriptorParsingException, NoPluginFoundForPrefixException, InvalidPluginDescriptorException, LifecyclePhaseNotFoundException, LifecycleNotFoundException, PluginVersionResolutionException { MojoDescriptor mojoDescriptor = mojoExecution.getMojoDescriptor(); PluginDescriptor pluginDescriptor = mojoDescriptor.getPluginDescriptor(); String forkedGoal = mojoDescriptor.getExecuteGoal(); MojoDescriptor forkedMojoDescriptor = pluginDescriptor.getMojo( forkedGoal ); if ( forkedMojoDescriptor == null ) { throw new MojoNotFoundException( forkedGoal, pluginDescriptor ); } if ( alreadyForkedExecutions.contains( forkedMojoDescriptor ) ) { return Collections.emptyList(); } MojoExecution forkedExecution = new MojoExecution( forkedMojoDescriptor, forkedGoal ); mojoExecutionConfigurator( forkedExecution ).configure( project, forkedExecution, true ); finalizeMojoConfiguration( forkedExecution ); calculateForkedExecutions( forkedExecution, session, project, alreadyForkedExecutions ); return Collections.singletonList( forkedExecution ); } private MojoExecutionConfigurator mojoExecutionConfigurator( MojoExecution mojoExecution ) { String configuratorId = mojoExecution.getMojoDescriptor().getComponentConfigurator(); if ( configuratorId == null ) { configuratorId = "default"; } MojoExecutionConfigurator mojoExecutionConfigurator = mojoExecutionConfigurators.get( configuratorId ); if ( mojoExecutionConfigurator == null ) { // // The plugin has a custom component configurator but does not have a custom mojo execution configurator // so fall back to the default mojo execution configurator. // mojoExecutionConfigurator = mojoExecutionConfigurators.get( "default" ); } return mojoExecutionConfigurator; } } DefaultLifecycleMappingDelegate.java000066400000000000000000000151541317160430700362630ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/lifecycle/internalpackage org.apache.maven.lifecycle.internal; /* * 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.util.ArrayList; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import java.util.TreeMap; import org.apache.maven.execution.MavenSession; import org.apache.maven.lifecycle.Lifecycle; import org.apache.maven.lifecycle.LifecycleMappingDelegate; import org.apache.maven.model.Plugin; import org.apache.maven.model.PluginExecution; import org.apache.maven.plugin.BuildPluginManager; import org.apache.maven.plugin.InvalidPluginDescriptorException; import org.apache.maven.plugin.MojoExecution; import org.apache.maven.plugin.MojoNotFoundException; import org.apache.maven.plugin.PluginDescriptorParsingException; import org.apache.maven.plugin.PluginNotFoundException; import org.apache.maven.plugin.PluginResolutionException; import org.apache.maven.plugin.descriptor.MojoDescriptor; import org.apache.maven.project.MavenProject; import org.codehaus.plexus.component.annotations.Component; import org.codehaus.plexus.component.annotations.Requirement; @Component( role = LifecycleMappingDelegate.class, hint = DefaultLifecycleMappingDelegate.HINT ) public class DefaultLifecycleMappingDelegate implements LifecycleMappingDelegate { public static final String HINT = "default"; @Requirement private BuildPluginManager pluginManager; public Map> calculateLifecycleMappings( MavenSession session, MavenProject project, Lifecycle lifecycle, String lifecyclePhase ) throws PluginNotFoundException, PluginResolutionException, PluginDescriptorParsingException, MojoNotFoundException, InvalidPluginDescriptorException { /* * Initialize mapping from lifecycle phase to bound mojos. The key set of this map denotes the phases the caller * is interested in, i.e. all phases up to and including the specified phase. */ Map>> mappings = new LinkedHashMap<>(); for ( String phase : lifecycle.getPhases() ) { Map> phaseBindings = new TreeMap<>(); mappings.put( phase, phaseBindings ); if ( phase.equals( lifecyclePhase ) ) { break; } } /* * Grab plugin executions that are bound to the selected lifecycle phases from project. The effective model of * the project already contains the plugin executions induced by the project's packaging type. Remember, all * phases of interest and only those are in the lifecycle mapping, if a phase has no value in the map, we are * not interested in any of the executions bound to it. */ for ( Plugin plugin : project.getBuild().getPlugins() ) { for ( PluginExecution execution : plugin.getExecutions() ) { // if the phase is specified then I don't have to go fetch the plugin yet and pull it down // to examine the phase it is associated to. if ( execution.getPhase() != null ) { Map> phaseBindings = mappings.get( execution.getPhase() ); if ( phaseBindings != null ) { for ( String goal : execution.getGoals() ) { MojoExecution mojoExecution = new MojoExecution( plugin, goal, execution.getId() ); mojoExecution.setLifecyclePhase( execution.getPhase() ); addMojoExecution( phaseBindings, mojoExecution, execution.getPriority() ); } } } // if not then i need to grab the mojo descriptor and look at the phase that is specified else { for ( String goal : execution.getGoals() ) { MojoDescriptor mojoDescriptor = pluginManager.getMojoDescriptor( plugin, goal, project.getRemotePluginRepositories(), session.getRepositorySession() ); Map> phaseBindings = mappings.get( mojoDescriptor.getPhase() ); if ( phaseBindings != null ) { MojoExecution mojoExecution = new MojoExecution( mojoDescriptor, execution.getId() ); mojoExecution.setLifecyclePhase( mojoDescriptor.getPhase() ); addMojoExecution( phaseBindings, mojoExecution, execution.getPriority() ); } } } } } Map> lifecycleMappings = new LinkedHashMap<>(); for ( Map.Entry>> entry : mappings.entrySet() ) { List mojoExecutions = new ArrayList<>(); for ( List executions : entry.getValue().values() ) { mojoExecutions.addAll( executions ); } lifecycleMappings.put( entry.getKey(), mojoExecutions ); } return lifecycleMappings; } private void addMojoExecution( Map> phaseBindings, MojoExecution mojoExecution, int priority ) { List mojoExecutions = phaseBindings.get( priority ); if ( mojoExecutions == null ) { mojoExecutions = new ArrayList<>(); phaseBindings.put( priority, mojoExecutions ); } mojoExecutions.add( mojoExecution ); } } DefaultLifecyclePluginAnalyzer.java000066400000000000000000000211131317160430700361710ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/lifecycle/internalpackage org.apache.maven.lifecycle.internal; /* * 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 org.apache.maven.lifecycle.DefaultLifecycles; import org.apache.maven.lifecycle.LifeCyclePluginAnalyzer; import org.apache.maven.lifecycle.Lifecycle; import org.apache.maven.lifecycle.mapping.LifecycleMapping; import org.apache.maven.lifecycle.mapping.LifecycleMojo; import org.apache.maven.lifecycle.mapping.LifecyclePhase; import org.apache.maven.model.Plugin; import org.apache.maven.model.PluginExecution; import org.codehaus.plexus.component.annotations.Component; import org.codehaus.plexus.component.annotations.Requirement; import org.codehaus.plexus.logging.Logger; import org.codehaus.plexus.util.StringUtils; import org.codehaus.plexus.util.xml.Xpp3Dom; import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; import java.util.HashSet; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import java.util.Set; /** * NOTE: This class is not part of any public api and can be changed or deleted without prior notice. * * @since 3.0 * @author Benjamin Bentmann * @author Jason van Zyl * @author jdcasey * @author Kristian Rosenvold (extracted class only) */ @Component( role = LifeCyclePluginAnalyzer.class ) public class DefaultLifecyclePluginAnalyzer implements LifeCyclePluginAnalyzer { @Requirement( role = LifecycleMapping.class ) private Map lifecycleMappings; @Requirement private DefaultLifecycles defaultLifeCycles; @Requirement private Logger logger; public DefaultLifecyclePluginAnalyzer() { } // These methods deal with construction intact Plugin object that look like they come from a standard // block in a Maven POM. We have to do some wiggling to pull the sources of information // together and this really shows the problem of constructing a sensible default configuration but // it's all encapsulated here so it appears normalized to the POM builder. // We are going to take the project packaging and find all plugins in the default lifecycle and create // fully populated Plugin objects, including executions with goals and default configuration taken // from the plugin.xml inside a plugin. // public Set getPluginsBoundByDefaultToAllLifecycles( String packaging ) { if ( logger.isDebugEnabled() ) { logger.debug( "Looking up lifecycle mappings for packaging " + packaging + " from " + Thread.currentThread().getContextClassLoader() ); } LifecycleMapping lifecycleMappingForPackaging = lifecycleMappings.get( packaging ); if ( lifecycleMappingForPackaging == null ) { return null; } Map plugins = new LinkedHashMap<>(); for ( Lifecycle lifecycle : getOrderedLifecycles() ) { org.apache.maven.lifecycle.mapping.Lifecycle lifecycleConfiguration = lifecycleMappingForPackaging.getLifecycles().get( lifecycle.getId() ); Map phaseToGoalMapping = null; if ( lifecycleConfiguration != null ) { phaseToGoalMapping = lifecycleConfiguration.getLifecyclePhases(); } else if ( lifecycle.getDefaultLifecyclePhases() != null ) { phaseToGoalMapping = lifecycle.getDefaultLifecyclePhases(); } if ( phaseToGoalMapping != null ) { for ( Map.Entry goalsForLifecyclePhase : phaseToGoalMapping.entrySet() ) { String phase = goalsForLifecyclePhase.getKey(); LifecyclePhase goals = goalsForLifecyclePhase.getValue(); if ( goals != null ) { parseLifecyclePhaseDefinitions( plugins, phase, goals ); } } } } return plugins.keySet(); } private List getOrderedLifecycles() { // NOTE: The lifecycle order can affect implied execution ids so we better be deterministic. List lifecycles = new ArrayList<>( defaultLifeCycles.getLifeCycles() ); Collections.sort( lifecycles, new Comparator() { public int compare( Lifecycle l1, Lifecycle l2 ) { return l1.getId().compareTo( l2.getId() ); } } ); return lifecycles; } private void parseLifecyclePhaseDefinitions( Map plugins, String phase, LifecyclePhase goals ) { List mojos = goals.getMojos(); if ( mojos != null ) { for ( int i = 0; i < mojos.size(); i++ ) { LifecycleMojo mojo = mojos.get( i ); GoalSpec gs = parseGoalSpec( mojo.getGoal() ); if ( gs == null ) { logger.warn( "Ignored invalid goal specification '" + mojo.getGoal() + "' from lifecycle mapping for phase " + phase ); continue; } Plugin plugin = new Plugin(); plugin.setGroupId( gs.groupId ); plugin.setArtifactId( gs.artifactId ); plugin.setVersion( gs.version ); Plugin existing = plugins.get( plugin ); if ( existing != null ) { if ( existing.getVersion() == null ) { existing.setVersion( plugin.getVersion() ); } plugin = existing; } else { plugins.put( plugin, plugin ); } PluginExecution execution = new PluginExecution(); execution.setId( getExecutionId( plugin, gs.goal ) ); execution.setPhase( phase ); execution.setPriority( i - mojos.size() ); execution.getGoals().add( gs.goal ); Xpp3Dom lifecycleConfiguration = mojo.getConfiguration(); if ( lifecycleConfiguration != null ) { execution.setConfiguration( new Xpp3Dom( lifecycleConfiguration ) ); } plugin.setDependencies( mojo.getDependencies() ); plugin.getExecutions().add( execution ); } } } private GoalSpec parseGoalSpec( String goalSpec ) { GoalSpec gs = new GoalSpec(); String[] p = StringUtils.split( goalSpec.trim(), ":" ); if ( p.length == 3 ) { // :: gs.groupId = p[0]; gs.artifactId = p[1]; gs.goal = p[2]; } else if ( p.length == 4 ) { // ::: gs.groupId = p[0]; gs.artifactId = p[1]; gs.version = p[2]; gs.goal = p[3]; } else { // invalid gs = null; } return gs; } private String getExecutionId( Plugin plugin, String goal ) { Set existingIds = new HashSet<>(); for ( PluginExecution execution : plugin.getExecutions() ) { existingIds.add( execution.getId() ); } String base = "default-" + goal; String id = base; for ( int index = 1; existingIds.contains( id ); index++ ) { id = base + '-' + index; } return id; } static class GoalSpec { String groupId; String artifactId; String version; String goal; } } DefaultLifecycleTaskSegmentCalculator.java000066400000000000000000000127371317160430700375000ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/lifecycle/internalpackage org.apache.maven.lifecycle.internal; /* * 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 org.apache.maven.execution.MavenSession; import org.apache.maven.lifecycle.LifecycleNotFoundException; import org.apache.maven.lifecycle.LifecyclePhaseNotFoundException; import org.apache.maven.plugin.InvalidPluginDescriptorException; import org.apache.maven.plugin.MojoNotFoundException; import org.apache.maven.plugin.PluginDescriptorParsingException; import org.apache.maven.plugin.PluginNotFoundException; import org.apache.maven.plugin.PluginResolutionException; import org.apache.maven.plugin.descriptor.MojoDescriptor; import org.apache.maven.plugin.prefix.NoPluginFoundForPrefixException; import org.apache.maven.plugin.version.PluginVersionResolutionException; import org.apache.maven.project.MavenProject; import org.codehaus.plexus.component.annotations.Component; import org.codehaus.plexus.component.annotations.Requirement; import org.codehaus.plexus.util.StringUtils; import java.util.ArrayList; import java.util.Arrays; import java.util.List; /** *

* Calculates the task segments in the build *

* NOTE: This class is not part of any public api and can be changed or deleted without prior notice. * * @since 3.0 * @author Benjamin Bentmann * @author Jason van Zyl * @author jdcasey * @author Kristian Rosenvold (extracted class) */ @Component( role = LifecycleTaskSegmentCalculator.class ) public class DefaultLifecycleTaskSegmentCalculator implements LifecycleTaskSegmentCalculator { @Requirement private MojoDescriptorCreator mojoDescriptorCreator; @Requirement private LifecyclePluginResolver lifecyclePluginResolver; public DefaultLifecycleTaskSegmentCalculator() { } public List calculateTaskSegments( MavenSession session ) throws PluginNotFoundException, PluginResolutionException, PluginDescriptorParsingException, MojoNotFoundException, NoPluginFoundForPrefixException, InvalidPluginDescriptorException, PluginVersionResolutionException, LifecyclePhaseNotFoundException, LifecycleNotFoundException { MavenProject rootProject = session.getTopLevelProject(); List tasks = session.getGoals(); if ( ( tasks == null || tasks.isEmpty() ) && !StringUtils.isEmpty( rootProject.getDefaultGoal() ) ) { tasks = Arrays.asList( StringUtils.split( rootProject.getDefaultGoal() ) ); } return calculateTaskSegments( session, tasks ); } public List calculateTaskSegments( MavenSession session, List tasks ) throws PluginNotFoundException, PluginResolutionException, PluginDescriptorParsingException, MojoNotFoundException, NoPluginFoundForPrefixException, InvalidPluginDescriptorException, PluginVersionResolutionException { List taskSegments = new ArrayList<>( tasks.size() ); TaskSegment currentSegment = null; for ( String task : tasks ) { if ( isGoalSpecification( task ) ) { // "pluginPrefix:goal" or "groupId:artifactId[:version]:goal" lifecyclePluginResolver.resolveMissingPluginVersions( session.getTopLevelProject(), session ); MojoDescriptor mojoDescriptor = mojoDescriptorCreator.getMojoDescriptor( task, session, session.getTopLevelProject() ); boolean aggregating = mojoDescriptor.isAggregator() || !mojoDescriptor.isProjectRequired(); if ( currentSegment == null || currentSegment.isAggregating() != aggregating ) { currentSegment = new TaskSegment( aggregating ); taskSegments.add( currentSegment ); } currentSegment.getTasks().add( new GoalTask( task ) ); } else { // lifecycle phase if ( currentSegment == null || currentSegment.isAggregating() ) { currentSegment = new TaskSegment( false ); taskSegments.add( currentSegment ); } currentSegment.getTasks().add( new LifecycleTask( task ) ); } } return taskSegments; } public boolean requiresProject( MavenSession session ) { List goals = session.getGoals(); if ( goals != null ) { for ( String goal : goals ) { if ( !isGoalSpecification( goal ) ) { return true; } } } return false; } private boolean isGoalSpecification( String task ) { return task.indexOf( ':' ) >= 0; } }DefaultMojoExecutionConfigurator.java000066400000000000000000000067471317160430700366000ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/lifecycle/internalpackage org.apache.maven.lifecycle.internal; /* * 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.util.Collection; import org.apache.maven.lifecycle.MojoExecutionConfigurator; import org.apache.maven.model.Plugin; import org.apache.maven.model.PluginExecution; import org.apache.maven.plugin.MojoExecution; import org.apache.maven.project.MavenProject; import org.codehaus.plexus.component.annotations.Component; import org.codehaus.plexus.util.StringUtils; import org.codehaus.plexus.util.xml.Xpp3Dom; /** * @since 3.3.1, MNG-5753 */ @Component( role = MojoExecutionConfigurator.class ) public class DefaultMojoExecutionConfigurator implements MojoExecutionConfigurator { @Override public void configure( MavenProject project, MojoExecution mojoExecution, boolean allowPluginLevelConfig ) { String g = mojoExecution.getGroupId(); String a = mojoExecution.getArtifactId(); Plugin plugin = findPlugin( g, a, project.getBuildPlugins() ); if ( plugin == null && project.getPluginManagement() != null ) { plugin = findPlugin( g, a, project.getPluginManagement().getPlugins() ); } if ( plugin != null ) { PluginExecution pluginExecution = findPluginExecution( mojoExecution.getExecutionId(), plugin.getExecutions() ); Xpp3Dom pomConfiguration = null; if ( pluginExecution != null ) { pomConfiguration = (Xpp3Dom) pluginExecution.getConfiguration(); } else if ( allowPluginLevelConfig ) { pomConfiguration = (Xpp3Dom) plugin.getConfiguration(); } Xpp3Dom mojoConfiguration = ( pomConfiguration != null ) ? new Xpp3Dom( pomConfiguration ) : null; mojoConfiguration = Xpp3Dom.mergeXpp3Dom( mojoExecution.getConfiguration(), mojoConfiguration ); mojoExecution.setConfiguration( mojoConfiguration ); } } private Plugin findPlugin( String groupId, String artifactId, Collection plugins ) { for ( Plugin plugin : plugins ) { if ( artifactId.equals( plugin.getArtifactId() ) && groupId.equals( plugin.getGroupId() ) ) { return plugin; } } return null; } private PluginExecution findPluginExecution( String executionId, Collection executions ) { if ( StringUtils.isNotEmpty( executionId ) ) { for ( PluginExecution execution : executions ) { if ( executionId.equals( execution.getId() ) ) { return execution; } } } return null; } } DefaultProjectArtifactFactory.java000066400000000000000000000034171317160430700360300ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/lifecycle/internalpackage org.apache.maven.lifecycle.internal; /* * 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.util.Set; import javax.inject.Inject; import javax.inject.Named; import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.factory.ArtifactFactory; import org.apache.maven.project.MavenProject; import org.apache.maven.project.artifact.InvalidDependencyVersionException; import org.apache.maven.project.artifact.MavenMetadataSource; @SuppressWarnings( "deprecation" ) @Named public class DefaultProjectArtifactFactory implements ProjectArtifactFactory { private final ArtifactFactory artifactFactory; @Inject public DefaultProjectArtifactFactory( ArtifactFactory artifactFactory ) { this.artifactFactory = artifactFactory; } @Override public Set createArtifacts( MavenProject project ) throws InvalidDependencyVersionException { return MavenMetadataSource.createArtifacts( artifactFactory, project.getDependencies(), null, null, project ); } } DependencyContext.java000066400000000000000000000077401317160430700335350ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/lifecycle/internalpackage org.apache.maven.lifecycle.internal; /* * 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 org.apache.maven.project.MavenProject; import java.util.Arrays; import java.util.Collection; import java.util.Collections; import java.util.TreeSet; /** *

* Context of dependency artifacts for a particular project. *

* NOTE: This class is not part of any public api and can be changed or deleted without prior notice. * * @since 3.0 * @author Benjamin Bentmann * @author Kristian Rosenvold (class extract only) */ // TODO From a concurrency perspective, this class is not good. The combination of mutable/immutable state is not nice public class DependencyContext { private static final Collection UNRESOLVED = Arrays.asList(); private final MavenProject project; private final Collection scopesToCollectForCurrentProject; private final Collection scopesToResolveForCurrentProject; private final Collection scopesToCollectForAggregatedProjects; private final Collection scopesToResolveForAggregatedProjects; private volatile Collection lastDependencyArtifacts = UNRESOLVED; private volatile int lastDependencyArtifactCount = -1; public DependencyContext( MavenProject project, Collection scopesToCollect, Collection scopesToResolve ) { this.project = project; scopesToCollectForCurrentProject = scopesToCollect; scopesToResolveForCurrentProject = scopesToResolve; scopesToCollectForAggregatedProjects = Collections.synchronizedSet( new TreeSet() ); scopesToResolveForAggregatedProjects = Collections.synchronizedSet( new TreeSet() ); } public MavenProject getProject() { return project; } public Collection getScopesToCollectForCurrentProject() { return scopesToCollectForCurrentProject; } public Collection getScopesToResolveForCurrentProject() { return scopesToResolveForCurrentProject; } public Collection getScopesToCollectForAggregatedProjects() { return scopesToCollectForAggregatedProjects; } public Collection getScopesToResolveForAggregatedProjects() { return scopesToResolveForAggregatedProjects; } public boolean isResolutionRequiredForCurrentProject() { return lastDependencyArtifacts != project.getDependencyArtifacts() || ( lastDependencyArtifacts != null && lastDependencyArtifactCount != lastDependencyArtifacts.size() ); } public boolean isResolutionRequiredForAggregatedProjects( Collection scopesToCollect, Collection scopesToResolve ) { boolean required = scopesToCollectForAggregatedProjects.addAll( scopesToCollect ) || scopesToResolveForAggregatedProjects.addAll( scopesToResolve ); return required; } public void synchronizeWithProjectState() { lastDependencyArtifacts = project.getDependencyArtifacts(); lastDependencyArtifactCount = ( lastDependencyArtifacts != null ) ? lastDependencyArtifacts.size() : 0; } } ExecutionEventCatapult.java000066400000000000000000000030421317160430700345440ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/lifecycle/internalpackage org.apache.maven.lifecycle.internal; /* * 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 org.apache.maven.execution.ExecutionEvent; import org.apache.maven.execution.MavenSession; import org.apache.maven.plugin.MojoExecution; /** * Assists in firing execution events. Warning: This is an internal utility interface that is only * public for technical reasons, it is not part of the public API. In particular, this interface can be changed or * deleted without prior notice. * * @author Benjamin Bentmann */ public interface ExecutionEventCatapult { void fire( ExecutionEvent.Type eventType, MavenSession session, MojoExecution mojoExecution ); void fire( ExecutionEvent.Type eventType, MavenSession session, MojoExecution mojoExecution, Exception exception ); } ExecutionPlanItem.java000066400000000000000000000052001317160430700334740ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/lifecycle/internalpackage org.apache.maven.lifecycle.internal; /* * 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 org.apache.maven.lifecycle.internal.builder.BuilderCommon; import org.apache.maven.model.Plugin; import org.apache.maven.plugin.MojoExecution; import org.apache.maven.plugin.descriptor.MojoDescriptor; import org.apache.maven.project.MavenProject; import java.util.ArrayList; import java.util.List; /** *

* Wraps individual MojoExecutions, containing information about completion status and scheduling. *

* NOTE: This class is not part of any public api and can be changed or deleted without prior notice. * * @since 3.0 * @author Kristian Rosenvold */ public class ExecutionPlanItem { private final MojoExecution mojoExecution; public ExecutionPlanItem( MojoExecution mojoExecution ) { this.mojoExecution = mojoExecution; } public static List createExecutionPlanItems( MavenProject mavenProject, List executions ) { BuilderCommon.attachToThread( mavenProject ); List result = new ArrayList<>(); for ( MojoExecution mojoExecution : executions ) { result.add( new ExecutionPlanItem( mojoExecution ) ); } return result; } public MojoExecution getMojoExecution() { return mojoExecution; } public String getLifecyclePhase() { return mojoExecution.getLifecyclePhase(); } public Plugin getPlugin() { final MojoDescriptor mojoDescriptor = getMojoExecution().getMojoDescriptor(); return mojoDescriptor.getPluginDescriptor().getPlugin(); } @Override public String toString() { return "ExecutionPlanItem{" + ", mojoExecution=" + mojoExecution + '}' + super.toString(); } } maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/lifecycle/internal/GoalTask.java000066400000000000000000000024301317160430700316650ustar00rootroot00000000000000package org.apache.maven.lifecycle.internal; /* * 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. */ /** *

* A task that is a goal *

* NOTE: This class is not part of any public api and can be changed or deleted without prior notice. * * @since 3.0 * @author Benjamin Bentmann */ public final class GoalTask { final String pluginGoal; public GoalTask( String pluginGoal ) { this.pluginGoal = pluginGoal; } @Override public String toString() { return pluginGoal; } } LifecycleDebugLogger.java000066400000000000000000000144661317160430700341230ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/lifecycle/internalpackage org.apache.maven.lifecycle.internal; /* * 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 org.apache.maven.lifecycle.MavenExecutionPlan; import org.apache.maven.lifecycle.internal.builder.BuilderCommon; import org.apache.maven.plugin.MojoExecution; import org.apache.maven.plugin.descriptor.MojoDescriptor; import org.apache.maven.project.MavenProject; import org.codehaus.plexus.component.annotations.Component; import org.codehaus.plexus.component.annotations.Requirement; import org.codehaus.plexus.logging.Logger; import org.codehaus.plexus.util.StringUtils; import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Set; import java.util.TreeSet; /** *

* Logs debug output from the various lifecycle phases. *

* NOTE: This class is not part of any public api and can be changed or deleted without prior notice. * * @since 3.0 * @author Benjamin Bentmann * @author Jason van Zyl * @author Kristian Rosenvold (extracted class only) */ @Component( role = LifecycleDebugLogger.class ) public class LifecycleDebugLogger { @Requirement private Logger logger; public LifecycleDebugLogger() { } public LifecycleDebugLogger( Logger logger ) { this.logger = logger; } public void debug( String s ) { logger.debug( s ); } public void info( String s ) { logger.info( s ); } public void debugReactorPlan( ProjectBuildList projectBuilds ) { if ( !logger.isDebugEnabled() ) { return; } logger.debug( "=== REACTOR BUILD PLAN ================================================" ); for ( Iterator it = projectBuilds.iterator(); it.hasNext(); ) { ProjectSegment projectBuild = it.next(); logger.debug( "Project: " + projectBuild.getProject().getId() ); logger.debug( "Tasks: " + projectBuild.getTaskSegment().getTasks() ); logger.debug( "Style: " + ( projectBuild.getTaskSegment().isAggregating() ? "Aggregating" : "Regular" ) ); if ( it.hasNext() ) { logger.debug( "-----------------------------------------------------------------------" ); } } logger.debug( "=======================================================================" ); } public void debugProjectPlan( MavenProject currentProject, MavenExecutionPlan executionPlan ) { if ( !logger.isDebugEnabled() ) { return; } logger.debug( "=== PROJECT BUILD PLAN ================================================" ); logger.debug( "Project: " + BuilderCommon.getKey( currentProject ) ); debugDependencyRequirements( executionPlan.getMojoExecutions() ); logger.debug( "Repositories (dependencies): " + currentProject.getRemoteProjectRepositories() ); logger.debug( "Repositories (plugins) : " + currentProject.getRemotePluginRepositories() ); for ( ExecutionPlanItem mojoExecution : executionPlan ) { debugMojoExecution( mojoExecution.getMojoExecution() ); } logger.debug( "=======================================================================" ); } private void debugMojoExecution( MojoExecution mojoExecution ) { String mojoExecId = mojoExecution.getGroupId() + ':' + mojoExecution.getArtifactId() + ':' + mojoExecution.getVersion() + ':' + mojoExecution.getGoal() + " (" + mojoExecution.getExecutionId() + ')'; Map> forkedExecutions = mojoExecution.getForkedExecutions(); if ( !forkedExecutions.isEmpty() ) { for ( Map.Entry> fork : forkedExecutions.entrySet() ) { logger.debug( "--- init fork of " + fork.getKey() + " for " + mojoExecId + " ---" ); debugDependencyRequirements( fork.getValue() ); for ( MojoExecution forkedExecution : fork.getValue() ) { debugMojoExecution( forkedExecution ); } logger.debug( "--- exit fork of " + fork.getKey() + " for " + mojoExecId + " ---" ); } } logger.debug( "-----------------------------------------------------------------------" ); logger.debug( "Goal: " + mojoExecId ); logger.debug( "Style: " + ( mojoExecution.getMojoDescriptor().isAggregator() ? "Aggregating" : "Regular" ) ); logger.debug( "Configuration: " + mojoExecution.getConfiguration() ); } private void debugDependencyRequirements( List mojoExecutions ) { Set scopesToCollect = new TreeSet<>(); Set scopesToResolve = new TreeSet<>(); for ( MojoExecution mojoExecution : mojoExecutions ) { MojoDescriptor mojoDescriptor = mojoExecution.getMojoDescriptor(); String scopeToCollect = mojoDescriptor.getDependencyCollectionRequired(); if ( StringUtils.isNotEmpty( scopeToCollect ) ) { scopesToCollect.add( scopeToCollect ); } String scopeToResolve = mojoDescriptor.getDependencyResolutionRequired(); if ( StringUtils.isNotEmpty( scopeToResolve ) ) { scopesToResolve.add( scopeToResolve ); } } logger.debug( "Dependencies (collect): " + scopesToCollect ); logger.debug( "Dependencies (resolve): " + scopesToResolve ); } }LifecycleDependencyResolver.java000066400000000000000000000321171317160430700355260ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/lifecycle/internalpackage org.apache.maven.lifecycle.internal; /* * 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.util.Collection; import java.util.Collections; import java.util.HashMap; import java.util.HashSet; import java.util.LinkedHashSet; import java.util.List; import java.util.Map; import java.util.Set; import javax.inject.Inject; import javax.inject.Named; import org.apache.maven.RepositoryUtils; import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.ArtifactUtils; import org.apache.maven.eventspy.internal.EventSpyDispatcher; import org.apache.maven.execution.MavenSession; import org.apache.maven.lifecycle.LifecycleExecutionException; import org.apache.maven.plugin.ProjectArtifactsCache; import org.apache.maven.project.DefaultDependencyResolutionRequest; import org.apache.maven.project.DependencyResolutionException; import org.apache.maven.project.DependencyResolutionResult; import org.apache.maven.project.MavenProject; import org.apache.maven.project.ProjectDependenciesResolver; import org.apache.maven.project.artifact.InvalidDependencyVersionException; import org.codehaus.plexus.logging.Logger; import org.eclipse.aether.graph.Dependency; import org.eclipse.aether.graph.DependencyFilter; import org.eclipse.aether.graph.DependencyNode; import org.eclipse.aether.util.filter.AndDependencyFilter; import org.eclipse.aether.util.filter.ScopeDependencyFilter; /** *

* Resolves dependencies for the artifacts in context of the lifecycle build *

* NOTE: This class is not part of any public api and can be changed or deleted without prior notice. * @since 3.0 * @author Benjamin Bentmann * @author Jason van Zyl * @author Kristian Rosenvold (extracted class) */ @Named public class LifecycleDependencyResolver { @Inject private ProjectDependenciesResolver dependenciesResolver; @Inject private Logger logger; @Inject private ProjectArtifactFactory artifactFactory; @Inject private EventSpyDispatcher eventSpyDispatcher; @Inject private ProjectArtifactsCache projectArtifactsCache; public LifecycleDependencyResolver() { } public LifecycleDependencyResolver( ProjectDependenciesResolver projectDependenciesResolver, Logger logger ) { this.dependenciesResolver = projectDependenciesResolver; this.logger = logger; } public static List getProjects( MavenProject project, MavenSession session, boolean aggregator ) { if ( aggregator ) { return session.getProjects(); } else { return Collections.singletonList( project ); } } public void resolveProjectDependencies( MavenProject project, Collection scopesToCollect, Collection scopesToResolve, MavenSession session, boolean aggregating, Set projectArtifacts ) throws LifecycleExecutionException { ClassLoader tccl = Thread.currentThread().getContextClassLoader(); try { ClassLoader projectRealm = project.getClassRealm(); if ( projectRealm != null && projectRealm != tccl ) { Thread.currentThread().setContextClassLoader( projectRealm ); } if ( project.getDependencyArtifacts() == null ) { try { project.setDependencyArtifacts( artifactFactory.createArtifacts( project ) ); } catch ( InvalidDependencyVersionException e ) { throw new LifecycleExecutionException( e ); } } Set artifacts; ProjectArtifactsCache.Key cacheKey = projectArtifactsCache.createKey( project, scopesToCollect, scopesToResolve, aggregating, session.getRepositorySession() ); ProjectArtifactsCache.CacheRecord recordArtifacts; recordArtifacts = projectArtifactsCache.get( cacheKey ); if ( recordArtifacts != null ) { artifacts = recordArtifacts.artifacts; } else { try { artifacts = getDependencies( project, scopesToCollect, scopesToResolve, session, aggregating, projectArtifacts ); recordArtifacts = projectArtifactsCache.put( cacheKey, artifacts ); } catch ( LifecycleExecutionException e ) { projectArtifactsCache.put( cacheKey, e ); projectArtifactsCache.register( project, cacheKey, recordArtifacts ); throw e; } } projectArtifactsCache.register( project, cacheKey, recordArtifacts ); project.setResolvedArtifacts( artifacts ); Map map = new HashMap<>(); for ( Artifact artifact : artifacts ) { map.put( artifact.getDependencyConflictId(), artifact ); } for ( Artifact artifact : project.getDependencyArtifacts() ) { if ( artifact.getFile() == null ) { Artifact resolved = map.get( artifact.getDependencyConflictId() ); if ( resolved != null ) { artifact.setFile( resolved.getFile() ); artifact.setDependencyTrail( resolved.getDependencyTrail() ); artifact.setResolvedVersion( resolved.getVersion() ); artifact.setResolved( true ); } } } } finally { Thread.currentThread().setContextClassLoader( tccl ); } } private Set getDependencies( MavenProject project, Collection scopesToCollect, Collection scopesToResolve, MavenSession session, boolean aggregating, Set projectArtifacts ) throws LifecycleExecutionException { if ( scopesToCollect == null ) { scopesToCollect = Collections.emptySet(); } if ( scopesToResolve == null ) { scopesToResolve = Collections.emptySet(); } if ( scopesToCollect.isEmpty() && scopesToResolve.isEmpty() ) { return new LinkedHashSet<>(); } scopesToCollect = new HashSet<>( scopesToCollect ); scopesToCollect.addAll( scopesToResolve ); DependencyFilter collectionFilter = new ScopeDependencyFilter( null, negate( scopesToCollect ) ); DependencyFilter resolutionFilter = new ScopeDependencyFilter( null, negate( scopesToResolve ) ); resolutionFilter = AndDependencyFilter.newInstance( collectionFilter, resolutionFilter ); resolutionFilter = AndDependencyFilter.newInstance( resolutionFilter, new ReactorDependencyFilter( projectArtifacts ) ); DependencyResolutionResult result; try { DefaultDependencyResolutionRequest request = new DefaultDependencyResolutionRequest( project, session.getRepositorySession() ); request.setResolutionFilter( resolutionFilter ); eventSpyDispatcher.onEvent( request ); result = dependenciesResolver.resolve( request ); } catch ( DependencyResolutionException e ) { result = e.getResult(); /* * MNG-2277, the check below compensates for our bad plugin support where we ended up with aggregator * plugins that require dependency resolution although they usually run in phases of the build where project * artifacts haven't been assembled yet. The prime example of this is "mvn release:prepare". */ if ( aggregating && areAllDependenciesInReactor( session.getProjects(), result.getUnresolvedDependencies() ) ) { logger.warn( "The following dependencies could not be resolved at this point of the build" + " but seem to be part of the reactor:" ); for ( Dependency dependency : result.getUnresolvedDependencies() ) { logger.warn( "o " + dependency ); } logger.warn( "Try running the build up to the lifecycle phase \"package\"" ); } else { throw new LifecycleExecutionException( null, project, e ); } } eventSpyDispatcher.onEvent( result ); Set artifacts = new LinkedHashSet<>(); if ( result.getDependencyGraph() != null && !result.getDependencyGraph().getChildren().isEmpty() ) { RepositoryUtils.toArtifacts( artifacts, result.getDependencyGraph().getChildren(), Collections.singletonList( project.getArtifact().getId() ), collectionFilter ); } return artifacts; } private boolean areAllDependenciesInReactor( Collection projects, Collection dependencies ) { Set projectKeys = getReactorProjectKeys( projects ); for ( Dependency dependency : dependencies ) { org.eclipse.aether.artifact.Artifact a = dependency.getArtifact(); String key = ArtifactUtils.key( a.getGroupId(), a.getArtifactId(), a.getVersion() ); if ( !projectKeys.contains( key ) ) { return false; } } return true; } private Set getReactorProjectKeys( Collection projects ) { Set projectKeys = new HashSet<>( projects.size() * 2 ); for ( MavenProject project : projects ) { String key = ArtifactUtils.key( project.getGroupId(), project.getArtifactId(), project.getVersion() ); projectKeys.add( key ); } return projectKeys; } private Collection negate( Collection scopes ) { Collection result = new HashSet<>(); Collections.addAll( result, "system", "compile", "provided", "runtime", "test" ); for ( String scope : scopes ) { if ( "compile".equals( scope ) ) { result.remove( "compile" ); result.remove( "system" ); result.remove( "provided" ); } else if ( "runtime".equals( scope ) ) { result.remove( "compile" ); result.remove( "runtime" ); } else if ( "compile+runtime".equals( scope ) ) { result.remove( "compile" ); result.remove( "system" ); result.remove( "provided" ); result.remove( "runtime" ); } else if ( "runtime+system".equals( scope ) ) { result.remove( "compile" ); result.remove( "system" ); result.remove( "runtime" ); } else if ( "test".equals( scope ) ) { result.clear(); } } return result; } private static class ReactorDependencyFilter implements DependencyFilter { private Set keys = new HashSet<>(); public ReactorDependencyFilter( Collection artifacts ) { for ( Artifact artifact : artifacts ) { String key = ArtifactUtils.key( artifact ); keys.add( key ); } } public boolean accept( DependencyNode node, List parents ) { Dependency dependency = node.getDependency(); if ( dependency != null ) { org.eclipse.aether.artifact.Artifact a = dependency.getArtifact(); String key = ArtifactUtils.key( a.getGroupId(), a.getArtifactId(), a.getVersion() ); return !keys.contains( key ); } return false; } } } LifecycleExecutionPlanCalculator.java000066400000000000000000000066461317160430700365260ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/lifecycle/internalpackage org.apache.maven.lifecycle.internal; /* * 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 org.apache.maven.execution.MavenSession; import org.apache.maven.lifecycle.LifecycleNotFoundException; import org.apache.maven.lifecycle.LifecyclePhaseNotFoundException; import org.apache.maven.lifecycle.MavenExecutionPlan; import org.apache.maven.plugin.InvalidPluginDescriptorException; import org.apache.maven.plugin.MojoExecution; import org.apache.maven.plugin.MojoNotFoundException; import org.apache.maven.plugin.PluginDescriptorParsingException; import org.apache.maven.plugin.PluginNotFoundException; import org.apache.maven.plugin.PluginResolutionException; import org.apache.maven.plugin.prefix.NoPluginFoundForPrefixException; import org.apache.maven.plugin.version.PluginVersionResolutionException; import org.apache.maven.project.MavenProject; import java.util.List; /** * @since 3.0 * @author Benjamin Bentmann * @author Kristian Rosenvold (extract interface only) */ public interface LifecycleExecutionPlanCalculator { MavenExecutionPlan calculateExecutionPlan( MavenSession session, MavenProject project, List tasks ) throws PluginNotFoundException, PluginResolutionException, LifecyclePhaseNotFoundException, PluginDescriptorParsingException, MojoNotFoundException, InvalidPluginDescriptorException, NoPluginFoundForPrefixException, LifecycleNotFoundException, PluginVersionResolutionException; MavenExecutionPlan calculateExecutionPlan( MavenSession session, MavenProject project, List tasks, boolean setup ) throws PluginNotFoundException, PluginResolutionException, LifecyclePhaseNotFoundException, PluginDescriptorParsingException, MojoNotFoundException, InvalidPluginDescriptorException, NoPluginFoundForPrefixException, LifecycleNotFoundException, PluginVersionResolutionException; void calculateForkedExecutions( MojoExecution mojoExecution, MavenSession session ) throws MojoNotFoundException, PluginNotFoundException, PluginResolutionException, PluginDescriptorParsingException, NoPluginFoundForPrefixException, InvalidPluginDescriptorException, LifecyclePhaseNotFoundException, LifecycleNotFoundException, PluginVersionResolutionException; void setupMojoExecution( MavenSession session, MavenProject project, MojoExecution mojoExecution ) throws PluginNotFoundException, PluginResolutionException, PluginDescriptorParsingException, MojoNotFoundException, InvalidPluginDescriptorException, NoPluginFoundForPrefixException, LifecyclePhaseNotFoundException, LifecycleNotFoundException, PluginVersionResolutionException; } LifecycleModuleBuilder.java000066400000000000000000000142311317160430700344570ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/lifecycle/internalpackage org.apache.maven.lifecycle.internal; /* * 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.util.HashSet; import java.util.List; import org.apache.maven.artifact.Artifact; import org.apache.maven.execution.BuildSuccess; import org.apache.maven.execution.ExecutionEvent; import org.apache.maven.execution.MavenSession; import org.apache.maven.execution.ProjectExecutionEvent; import org.apache.maven.execution.ProjectExecutionListener; import org.apache.maven.lifecycle.MavenExecutionPlan; import org.apache.maven.lifecycle.internal.builder.BuilderCommon; import org.apache.maven.plugin.MojoExecution; import org.apache.maven.project.MavenProject; import org.apache.maven.session.scope.internal.SessionScope; import org.codehaus.plexus.component.annotations.Component; import org.codehaus.plexus.component.annotations.Requirement; /** *

* Builds one or more lifecycles for a full module *

* NOTE: This class is not part of any public api and can be changed or deleted without prior notice. * * @since 3.0 * @author Benjamin Bentmann * @author Jason van Zyl * @author Kristian Rosenvold (extracted class) */ @Component( role = LifecycleModuleBuilder.class ) public class LifecycleModuleBuilder { @Requirement private MojoExecutor mojoExecutor; @Requirement private BuilderCommon builderCommon; @Requirement private ExecutionEventCatapult eventCatapult; private ProjectExecutionListener projectExecutionListener; // this tricks plexus-component-metadata generate required metadata @Requirement private List projectExecutionListeners; @Requirement private SessionScope sessionScope; public void setProjectExecutionListeners( final List listeners ) { this.projectExecutionListeners = listeners; this.projectExecutionListener = new CompoundProjectExecutionListener( listeners ); } public void buildProject( MavenSession session, ReactorContext reactorContext, MavenProject currentProject, TaskSegment taskSegment ) { buildProject( session, session, reactorContext, currentProject, taskSegment ); } public void buildProject( MavenSession session, MavenSession rootSession, ReactorContext reactorContext, MavenProject currentProject, TaskSegment taskSegment ) { session.setCurrentProject( currentProject ); long buildStartTime = System.currentTimeMillis(); // session may be different from rootSession seeded in DefaultMaven // explicitly seed the right session here to make sure it is used by Guice sessionScope.enter( reactorContext.getSessionScopeMemento() ); sessionScope.seed( MavenSession.class, session ); try { if ( reactorContext.getReactorBuildStatus().isHaltedOrBlacklisted( currentProject ) ) { eventCatapult.fire( ExecutionEvent.Type.ProjectSkipped, session, null ); return; } BuilderCommon.attachToThread( currentProject ); projectExecutionListener.beforeProjectExecution( new ProjectExecutionEvent( session, currentProject ) ); eventCatapult.fire( ExecutionEvent.Type.ProjectStarted, session, null ); MavenExecutionPlan executionPlan = builderCommon.resolveBuildPlan( session, currentProject, taskSegment, new HashSet() ); List mojoExecutions = executionPlan.getMojoExecutions(); projectExecutionListener.beforeProjectLifecycleExecution( new ProjectExecutionEvent( session, currentProject, mojoExecutions ) ); mojoExecutor.execute( session, mojoExecutions, reactorContext.getProjectIndex() ); long buildEndTime = System.currentTimeMillis(); projectExecutionListener.afterProjectExecutionSuccess( new ProjectExecutionEvent( session, currentProject, mojoExecutions ) ); reactorContext.getResult().addBuildSummary( new BuildSuccess( currentProject, buildEndTime - buildStartTime ) ); eventCatapult.fire( ExecutionEvent.Type.ProjectSucceeded, session, null ); } catch ( Throwable t ) { builderCommon.handleBuildError( reactorContext, rootSession, session, currentProject, t, buildStartTime ); projectExecutionListener.afterProjectExecutionFailure( new ProjectExecutionEvent( session, currentProject, t ) ); // rethrow original errors and runtime exceptions if ( t instanceof RuntimeException ) { throw (RuntimeException) t; } if ( t instanceof Error ) { throw (Error) t; } } finally { sessionScope.exit(); session.setCurrentProject( null ); Thread.currentThread().setContextClassLoader( reactorContext.getOriginalContextClassLoader() ); } } } LifecyclePluginResolver.java000066400000000000000000000071251317160430700347070ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/lifecycle/internalpackage org.apache.maven.lifecycle.internal; /* * 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.util.HashMap; import java.util.Map; import org.apache.maven.execution.MavenSession; import org.apache.maven.model.Plugin; import org.apache.maven.model.PluginManagement; import org.apache.maven.plugin.version.DefaultPluginVersionRequest; import org.apache.maven.plugin.version.PluginVersionRequest; import org.apache.maven.plugin.version.PluginVersionResolutionException; import org.apache.maven.plugin.version.PluginVersionResolver; import org.apache.maven.project.MavenProject; import org.codehaus.plexus.component.annotations.Component; import org.codehaus.plexus.component.annotations.Requirement; /** * NOTE: This class is not part of any public api and can be changed or deleted without prior notice. * @since 3.0 * @author Benjamin Bentmann * @author Kristian Rosenvold (Extract class) */ @Component( role = LifecyclePluginResolver.class ) public class LifecyclePluginResolver { @Requirement private PluginVersionResolver pluginVersionResolver; public LifecyclePluginResolver( PluginVersionResolver pluginVersionResolver ) { this.pluginVersionResolver = pluginVersionResolver; } public LifecyclePluginResolver() { } public void resolveMissingPluginVersions( MavenProject project, MavenSession session ) throws PluginVersionResolutionException { Map versions = new HashMap<>( 64 ); for ( Plugin plugin : project.getBuildPlugins() ) { if ( plugin.getVersion() == null ) { PluginVersionRequest request = new DefaultPluginVersionRequest( plugin, session.getRepositorySession(), project.getRemotePluginRepositories() ); plugin.setVersion( pluginVersionResolver.resolve( request ).getVersion() ); } versions.put( plugin.getKey(), plugin.getVersion() ); } PluginManagement pluginManagement = project.getPluginManagement(); if ( pluginManagement != null ) { for ( Plugin plugin : pluginManagement.getPlugins() ) { if ( plugin.getVersion() == null ) { plugin.setVersion( versions.get( plugin.getKey() ) ); if ( plugin.getVersion() == null ) { PluginVersionRequest request = new DefaultPluginVersionRequest( plugin, session.getRepositorySession(), project.getRemotePluginRepositories() ); plugin.setVersion( pluginVersionResolver.resolve( request ).getVersion() ); } } } } } }maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/lifecycle/internal/LifecycleStarter.java000066400000000000000000000132131317160430700334250ustar00rootroot00000000000000package org.apache.maven.lifecycle.internal; /* * 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.util.List; import java.util.Map; import org.apache.maven.execution.ExecutionEvent; import org.apache.maven.execution.MavenExecutionResult; import org.apache.maven.execution.MavenSession; import org.apache.maven.lifecycle.DefaultLifecycles; import org.apache.maven.lifecycle.MissingProjectException; import org.apache.maven.lifecycle.NoGoalSpecifiedException; import org.apache.maven.lifecycle.internal.builder.Builder; import org.apache.maven.lifecycle.internal.builder.BuilderNotFoundException; import org.apache.maven.session.scope.internal.SessionScope; import org.codehaus.plexus.component.annotations.Component; import org.codehaus.plexus.component.annotations.Requirement; import org.codehaus.plexus.logging.Logger; /** * Starts the build life cycle * * @author Jason van Zyl * @author Benjamin Bentmann * @author Kristian Rosenvold */ @Component( role = LifecycleStarter.class ) public class LifecycleStarter { @Requirement private ExecutionEventCatapult eventCatapult; @Requirement private DefaultLifecycles defaultLifeCycles; @Requirement private Logger logger; @Requirement private BuildListCalculator buildListCalculator; @Requirement private LifecycleDebugLogger lifecycleDebugLogger; @Requirement private LifecycleTaskSegmentCalculator lifecycleTaskSegmentCalculator; @Requirement private Map builders; @Requirement private SessionScope sessionScope; public void execute( MavenSession session ) { eventCatapult.fire( ExecutionEvent.Type.SessionStarted, session, null ); ReactorContext reactorContext = null; ProjectBuildList projectBuilds = null; MavenExecutionResult result = session.getResult(); try { if ( buildExecutionRequiresProject( session ) && projectIsNotPresent( session ) ) { throw new MissingProjectException( "The goal you specified requires a project to execute" + " but there is no POM in this directory (" + session.getExecutionRootDirectory() + ")." + " Please verify you invoked Maven from the correct directory." ); } List taskSegments = lifecycleTaskSegmentCalculator.calculateTaskSegments( session ); projectBuilds = buildListCalculator.calculateProjectBuilds( session, taskSegments ); if ( projectBuilds.isEmpty() ) { throw new NoGoalSpecifiedException( "No goals have been specified for this build." + " You must specify a valid lifecycle phase or a goal in the format : or" + " :[:]:." + " Available lifecycle phases are: " + defaultLifeCycles.getLifecyclePhaseList() + "." ); } ProjectIndex projectIndex = new ProjectIndex( session.getProjects() ); if ( logger.isDebugEnabled() ) { lifecycleDebugLogger.debugReactorPlan( projectBuilds ); } ClassLoader oldContextClassLoader = Thread.currentThread().getContextClassLoader(); ReactorBuildStatus reactorBuildStatus = new ReactorBuildStatus( session.getProjectDependencyGraph() ); reactorContext = new ReactorContext( result, projectIndex, oldContextClassLoader, reactorBuildStatus, sessionScope.memento() ); String builderId = session.getRequest().getBuilderId(); Builder builder = builders.get( builderId ); if ( builder == null ) { throw new BuilderNotFoundException( String.format( "The builder requested using id = %s cannot be" + " found", builderId ) ); } int degreeOfConcurrency = session.getRequest().getDegreeOfConcurrency(); if ( degreeOfConcurrency >= 2 ) { logger.info( "" ); logger.info( String.format( "Using the %s implementation with a thread count of %d", builder.getClass().getSimpleName(), degreeOfConcurrency ) ); } builder.build( session, reactorContext, projectBuilds, taskSegments, reactorBuildStatus ); } catch ( Exception e ) { result.addException( e ); } finally { eventCatapult.fire( ExecutionEvent.Type.SessionEnded, session, null ); } } private boolean buildExecutionRequiresProject( MavenSession session ) { return lifecycleTaskSegmentCalculator.requiresProject( session ); } private boolean projectIsNotPresent( MavenSession session ) { return !session.getRequest().isProjectPresent(); } } maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/lifecycle/internal/LifecycleTask.java000066400000000000000000000026321317160430700327060ustar00rootroot00000000000000package org.apache.maven.lifecycle.internal; /* * 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. */ /** *

* A task that is a lifecycle *

* NOTE: This class is not part of any public api and can be changed or deleted without prior notice. * * @since 3.0 * @author Benjamin Bentmann */ public final class LifecycleTask { private final String lifecyclePhase; public LifecycleTask( String lifecyclePhase ) { this.lifecyclePhase = lifecyclePhase; } @Override public String toString() { return getLifecyclePhase(); } public String getLifecyclePhase() { return lifecyclePhase; } } LifecycleTaskSegmentCalculator.java000066400000000000000000000051121317160430700361600ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/lifecycle/internalpackage org.apache.maven.lifecycle.internal; /* * 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 org.apache.maven.execution.MavenSession; import org.apache.maven.lifecycle.LifecycleNotFoundException; import org.apache.maven.lifecycle.LifecyclePhaseNotFoundException; import org.apache.maven.plugin.InvalidPluginDescriptorException; import org.apache.maven.plugin.MojoNotFoundException; import org.apache.maven.plugin.PluginDescriptorParsingException; import org.apache.maven.plugin.PluginNotFoundException; import org.apache.maven.plugin.PluginResolutionException; import org.apache.maven.plugin.prefix.NoPluginFoundForPrefixException; import org.apache.maven.plugin.version.PluginVersionResolutionException; import java.util.List; /** *

* Calculates the task segments in the build *

* NOTE: This class is not part of any public api and can be changed or deleted without prior notice. * * @since 3.0 * @author Benjamin Bentmann * @author Jason van Zyl * @author jdcasey * @author Kristian Rosenvold (extracted interface) */ public interface LifecycleTaskSegmentCalculator { List calculateTaskSegments( MavenSession session ) throws PluginNotFoundException, PluginResolutionException, PluginDescriptorParsingException, MojoNotFoundException, NoPluginFoundForPrefixException, InvalidPluginDescriptorException, PluginVersionResolutionException, LifecyclePhaseNotFoundException, LifecycleNotFoundException; List calculateTaskSegments( MavenSession session, List tasks ) throws PluginNotFoundException, PluginResolutionException, PluginDescriptorParsingException, MojoNotFoundException, NoPluginFoundForPrefixException, InvalidPluginDescriptorException, PluginVersionResolutionException; boolean requiresProject( MavenSession session ); } MojoDescriptorCreator.java000066400000000000000000000253111317160430700343670ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/lifecycle/internalpackage org.apache.maven.lifecycle.internal; /* * 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 org.apache.maven.execution.MavenSession; import org.apache.maven.model.Plugin; import org.apache.maven.plugin.BuildPluginManager; import org.apache.maven.plugin.InvalidPluginDescriptorException; import org.apache.maven.plugin.MojoNotFoundException; import org.apache.maven.plugin.PluginDescriptorParsingException; import org.apache.maven.plugin.PluginNotFoundException; import org.apache.maven.plugin.PluginResolutionException; import org.apache.maven.plugin.descriptor.MojoDescriptor; import org.apache.maven.plugin.prefix.DefaultPluginPrefixRequest; import org.apache.maven.plugin.prefix.NoPluginFoundForPrefixException; import org.apache.maven.plugin.prefix.PluginPrefixRequest; import org.apache.maven.plugin.prefix.PluginPrefixResolver; import org.apache.maven.plugin.prefix.PluginPrefixResult; import org.apache.maven.plugin.version.DefaultPluginVersionRequest; import org.apache.maven.plugin.version.PluginVersionRequest; import org.apache.maven.plugin.version.PluginVersionResolutionException; import org.apache.maven.plugin.version.PluginVersionResolver; import org.apache.maven.project.MavenProject; import org.codehaus.plexus.component.annotations.Component; import org.codehaus.plexus.component.annotations.Requirement; import org.codehaus.plexus.configuration.PlexusConfiguration; import org.codehaus.plexus.logging.Logger; import org.codehaus.plexus.util.xml.Xpp3Dom; import java.util.ArrayList; import java.util.Collection; import java.util.StringTokenizer; /** *

* Resolves dependencies for the artifacts in context of the lifecycle build *

* NOTE: This class is not part of any public api and can be changed or deleted without prior notice. * * @since 3.0 * @author Benjamin Bentmann * @author Jason van Zyl * @author jdcasey * @author Kristian Rosenvold (extracted class only) */ @Component( role = MojoDescriptorCreator.class ) public class MojoDescriptorCreator { @Requirement private Logger logger; @Requirement private PluginVersionResolver pluginVersionResolver; @Requirement private BuildPluginManager pluginManager; @Requirement private PluginPrefixResolver pluginPrefixResolver; @Requirement private LifecyclePluginResolver lifecyclePluginResolver; public MojoDescriptorCreator() { } public MojoDescriptorCreator( PluginVersionResolver pluginVersionResolver, BuildPluginManager pluginManager, PluginPrefixResolver pluginPrefixResolver, LifecyclePluginResolver lifecyclePluginResolver ) { this.pluginVersionResolver = pluginVersionResolver; this.pluginManager = pluginManager; this.pluginPrefixResolver = pluginPrefixResolver; this.lifecyclePluginResolver = lifecyclePluginResolver; } private Plugin findPlugin( String groupId, String artifactId, Collection plugins ) { for ( Plugin plugin : plugins ) { if ( artifactId.equals( plugin.getArtifactId() ) && groupId.equals( plugin.getGroupId() ) ) { return plugin; } } return null; } public static Xpp3Dom convert( MojoDescriptor mojoDescriptor ) { Xpp3Dom dom = new Xpp3Dom( "configuration" ); PlexusConfiguration c = mojoDescriptor.getMojoConfiguration(); PlexusConfiguration[] ces = c.getChildren(); if ( ces != null ) { for ( PlexusConfiguration ce : ces ) { String value = ce.getValue( null ); String defaultValue = ce.getAttribute( "default-value", null ); if ( value != null || defaultValue != null ) { Xpp3Dom e = new Xpp3Dom( ce.getName() ); e.setValue( value ); if ( defaultValue != null ) { e.setAttribute( "default-value", defaultValue ); } dom.addChild( e ); } } } return dom; } // org.apache.maven.plugins:maven-remote-resources-plugin:1.0:process@executionId public MojoDescriptor getMojoDescriptor( String task, MavenSession session, MavenProject project ) throws PluginNotFoundException, PluginResolutionException, PluginDescriptorParsingException, MojoNotFoundException, NoPluginFoundForPrefixException, InvalidPluginDescriptorException, PluginVersionResolutionException { String goal = null; Plugin plugin = null; StringTokenizer tok = new StringTokenizer( task, ":" ); int numTokens = tok.countTokens(); if ( numTokens >= 4 ) { // We have everything that we need // // org.apache.maven.plugins:maven-remote-resources-plugin:1.0:process // // groupId // artifactId // version // goal // plugin = new Plugin(); plugin.setGroupId( tok.nextToken() ); plugin.setArtifactId( tok.nextToken() ); plugin.setVersion( tok.nextToken() ); goal = tok.nextToken(); // This won't be valid, but it constructs something easy to read in the error message while ( tok.hasMoreTokens() ) { goal += ":" + tok.nextToken(); } } else if ( numTokens == 3 ) { // We have everything that we need except the version // // org.apache.maven.plugins:maven-remote-resources-plugin:???:process // // groupId // artifactId // ??? // goal // plugin = new Plugin(); plugin.setGroupId( tok.nextToken() ); plugin.setArtifactId( tok.nextToken() ); goal = tok.nextToken(); } else if ( numTokens <= 2 ) { // We have a prefix and goal // // idea:idea // String prefix = tok.nextToken(); if ( numTokens == 2 ) { goal = tok.nextToken(); } else { // goal was missing - pass through to MojoNotFoundException goal = ""; } // This is the case where someone has executed a single goal from the command line // of the form: // // mvn remote-resources:process // // From the metadata stored on the server which has been created as part of a standard // Maven plugin deployment we will find the right PluginDescriptor from the remote // repository. plugin = findPluginForPrefix( prefix, session ); } int executionIdx = goal.indexOf( '@' ); if ( executionIdx > 0 ) { goal = goal.substring( 0, executionIdx ); } injectPluginDeclarationFromProject( plugin, project ); // If there is no version to be found then we need to look in the repository metadata for // this plugin and see what's specified as the latest release. // if ( plugin.getVersion() == null ) { resolvePluginVersion( plugin, session, project ); } return pluginManager.getMojoDescriptor( plugin, goal, project.getRemotePluginRepositories(), session.getRepositorySession() ); } // TODO take repo mans into account as one may be aggregating prefixes of many // TODO collect at the root of the repository, read the one at the root, and fetch remote if something is missing // or the user forces the issue public Plugin findPluginForPrefix( String prefix, MavenSession session ) throws NoPluginFoundForPrefixException { // [prefix]:[goal] if ( session.getCurrentProject() != null ) { try { lifecyclePluginResolver.resolveMissingPluginVersions( session.getCurrentProject(), session ); } catch ( PluginVersionResolutionException e ) { // not critical here logger.debug( e.getMessage(), e ); } } PluginPrefixRequest prefixRequest = new DefaultPluginPrefixRequest( prefix, session ); PluginPrefixResult prefixResult = pluginPrefixResolver.resolve( prefixRequest ); Plugin plugin = new Plugin(); plugin.setGroupId( prefixResult.getGroupId() ); plugin.setArtifactId( prefixResult.getArtifactId() ); return plugin; } private void resolvePluginVersion( Plugin plugin, MavenSession session, MavenProject project ) throws PluginVersionResolutionException { PluginVersionRequest versionRequest = new DefaultPluginVersionRequest( plugin, session.getRepositorySession(), project.getRemotePluginRepositories() ); plugin.setVersion( pluginVersionResolver.resolve( versionRequest ).getVersion() ); } private void injectPluginDeclarationFromProject( Plugin plugin, MavenProject project ) { Plugin pluginInPom = findPlugin( plugin, project.getBuildPlugins() ); if ( pluginInPom == null && project.getPluginManagement() != null ) { pluginInPom = findPlugin( plugin, project.getPluginManagement().getPlugins() ); } if ( pluginInPom != null ) { if ( plugin.getVersion() == null ) { plugin.setVersion( pluginInPom.getVersion() ); } plugin.setDependencies( new ArrayList<>( pluginInPom.getDependencies() ) ); } } private Plugin findPlugin( Plugin plugin, Collection plugins ) { return findPlugin( plugin.getGroupId(), plugin.getArtifactId(), plugins ); } } maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/lifecycle/internal/MojoExecutor.java000066400000000000000000000354631317160430700326170ustar00rootroot00000000000000package org.apache.maven.lifecycle.internal; /* * 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 org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.resolver.filter.ArtifactFilter; import org.apache.maven.artifact.resolver.filter.CumulativeScopeArtifactFilter; import org.apache.maven.execution.ExecutionEvent; import org.apache.maven.execution.MavenSession; import org.apache.maven.lifecycle.LifecycleExecutionException; import org.apache.maven.lifecycle.MissingProjectException; import org.apache.maven.plugin.BuildPluginManager; import org.apache.maven.plugin.MavenPluginManager; import org.apache.maven.plugin.MojoExecution; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoFailureException; import org.apache.maven.plugin.PluginConfigurationException; import org.apache.maven.plugin.PluginIncompatibleException; import org.apache.maven.plugin.PluginManagerException; import org.apache.maven.plugin.descriptor.MojoDescriptor; import org.apache.maven.project.MavenProject; import org.codehaus.plexus.component.annotations.Component; import org.codehaus.plexus.component.annotations.Requirement; import org.codehaus.plexus.util.StringUtils; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; import java.util.Collections; import java.util.List; import java.util.Map; import java.util.Set; import java.util.TreeSet; /** *

* Executes an individual mojo *

* NOTE: This class is not part of any public api and can be changed or deleted without prior notice. * * @author Jason van Zyl * @author Benjamin Bentmann * @author Kristian Rosenvold * @since 3.0 */ @Component( role = MojoExecutor.class ) public class MojoExecutor { @Requirement private BuildPluginManager pluginManager; @Requirement private MavenPluginManager mavenPluginManager; @Requirement private LifecycleDependencyResolver lifeCycleDependencyResolver; @Requirement private ExecutionEventCatapult eventCatapult; public MojoExecutor() { } public DependencyContext newDependencyContext( MavenSession session, List mojoExecutions ) { Set scopesToCollect = new TreeSet<>(); Set scopesToResolve = new TreeSet<>(); collectDependencyRequirements( scopesToResolve, scopesToCollect, mojoExecutions ); return new DependencyContext( session.getCurrentProject(), scopesToCollect, scopesToResolve ); } private void collectDependencyRequirements( Set scopesToResolve, Set scopesToCollect, Collection mojoExecutions ) { for ( MojoExecution mojoExecution : mojoExecutions ) { MojoDescriptor mojoDescriptor = mojoExecution.getMojoDescriptor(); scopesToResolve.addAll( toScopes( mojoDescriptor.getDependencyResolutionRequired() ) ); scopesToCollect.addAll( toScopes( mojoDescriptor.getDependencyCollectionRequired() ) ); } } private Collection toScopes( String classpath ) { if ( StringUtils.isNotEmpty( classpath ) ) { if ( Artifact.SCOPE_COMPILE.equals( classpath ) ) { return Arrays.asList( Artifact.SCOPE_COMPILE, Artifact.SCOPE_SYSTEM, Artifact.SCOPE_PROVIDED ); } else if ( Artifact.SCOPE_RUNTIME.equals( classpath ) ) { return Arrays.asList( Artifact.SCOPE_COMPILE, Artifact.SCOPE_RUNTIME ); } else if ( Artifact.SCOPE_COMPILE_PLUS_RUNTIME.equals( classpath ) ) { return Arrays.asList( Artifact.SCOPE_COMPILE, Artifact.SCOPE_SYSTEM, Artifact.SCOPE_PROVIDED, Artifact.SCOPE_RUNTIME ); } else if ( Artifact.SCOPE_RUNTIME_PLUS_SYSTEM.equals( classpath ) ) { return Arrays.asList( Artifact.SCOPE_COMPILE, Artifact.SCOPE_SYSTEM, Artifact.SCOPE_RUNTIME ); } else if ( Artifact.SCOPE_TEST.equals( classpath ) ) { return Arrays.asList( Artifact.SCOPE_COMPILE, Artifact.SCOPE_SYSTEM, Artifact.SCOPE_PROVIDED, Artifact.SCOPE_RUNTIME, Artifact.SCOPE_TEST ); } } return Collections.emptyList(); } public void execute( MavenSession session, List mojoExecutions, ProjectIndex projectIndex ) throws LifecycleExecutionException { DependencyContext dependencyContext = newDependencyContext( session, mojoExecutions ); PhaseRecorder phaseRecorder = new PhaseRecorder( session.getCurrentProject() ); for ( MojoExecution mojoExecution : mojoExecutions ) { execute( session, mojoExecution, projectIndex, dependencyContext, phaseRecorder ); } } public void execute( MavenSession session, MojoExecution mojoExecution, ProjectIndex projectIndex, DependencyContext dependencyContext, PhaseRecorder phaseRecorder ) throws LifecycleExecutionException { execute( session, mojoExecution, projectIndex, dependencyContext ); phaseRecorder.observeExecution( mojoExecution ); } private void execute( MavenSession session, MojoExecution mojoExecution, ProjectIndex projectIndex, DependencyContext dependencyContext ) throws LifecycleExecutionException { MojoDescriptor mojoDescriptor = mojoExecution.getMojoDescriptor(); try { mavenPluginManager.checkRequiredMavenVersion( mojoDescriptor.getPluginDescriptor() ); } catch ( PluginIncompatibleException e ) { throw new LifecycleExecutionException( mojoExecution, session.getCurrentProject(), e ); } if ( mojoDescriptor.isProjectRequired() && !session.getRequest().isProjectPresent() ) { Throwable cause = new MissingProjectException( "Goal requires a project to execute" + " but there is no POM in this directory (" + session.getExecutionRootDirectory() + ")." + " Please verify you invoked Maven from the correct directory." ); throw new LifecycleExecutionException( mojoExecution, null, cause ); } if ( mojoDescriptor.isOnlineRequired() && session.isOffline() ) { if ( MojoExecution.Source.CLI.equals( mojoExecution.getSource() ) ) { Throwable cause = new IllegalStateException( "Goal requires online mode for execution" + " but Maven is currently offline." ); throw new LifecycleExecutionException( mojoExecution, session.getCurrentProject(), cause ); } else { eventCatapult.fire( ExecutionEvent.Type.MojoSkipped, session, mojoExecution ); return; } } List forkedProjects = executeForkedExecutions( mojoExecution, session, projectIndex ); ensureDependenciesAreResolved( mojoDescriptor, session, dependencyContext ); eventCatapult.fire( ExecutionEvent.Type.MojoStarted, session, mojoExecution ); try { try { pluginManager.executeMojo( session, mojoExecution ); } catch ( MojoFailureException | PluginManagerException | PluginConfigurationException | MojoExecutionException e ) { throw new LifecycleExecutionException( mojoExecution, session.getCurrentProject(), e ); } eventCatapult.fire( ExecutionEvent.Type.MojoSucceeded, session, mojoExecution ); } catch ( LifecycleExecutionException e ) { eventCatapult.fire( ExecutionEvent.Type.MojoFailed, session, mojoExecution, e ); throw e; } finally { for ( MavenProject forkedProject : forkedProjects ) { forkedProject.setExecutionProject( null ); } } } public void ensureDependenciesAreResolved( MojoDescriptor mojoDescriptor, MavenSession session, DependencyContext dependencyContext ) throws LifecycleExecutionException { MavenProject project = dependencyContext.getProject(); boolean aggregating = mojoDescriptor.isAggregator(); if ( dependencyContext.isResolutionRequiredForCurrentProject() ) { Collection scopesToCollect = dependencyContext.getScopesToCollectForCurrentProject(); Collection scopesToResolve = dependencyContext.getScopesToResolveForCurrentProject(); lifeCycleDependencyResolver.resolveProjectDependencies( project, scopesToCollect, scopesToResolve, session, aggregating, Collections.emptySet() ); dependencyContext.synchronizeWithProjectState(); } if ( aggregating ) { Collection scopesToCollect = toScopes( mojoDescriptor.getDependencyCollectionRequired() ); Collection scopesToResolve = toScopes( mojoDescriptor.getDependencyResolutionRequired() ); if ( dependencyContext.isResolutionRequiredForAggregatedProjects( scopesToCollect, scopesToResolve ) ) { for ( MavenProject aggregatedProject : session.getProjects() ) { if ( aggregatedProject != project ) { lifeCycleDependencyResolver.resolveProjectDependencies( aggregatedProject, scopesToCollect, scopesToResolve, session, aggregating, Collections.emptySet() ); } } } } ArtifactFilter artifactFilter = getArtifactFilter( mojoDescriptor ); List projectsToResolve = LifecycleDependencyResolver.getProjects( session.getCurrentProject(), session, mojoDescriptor.isAggregator() ); for ( MavenProject projectToResolve : projectsToResolve ) { projectToResolve.setArtifactFilter( artifactFilter ); } } private ArtifactFilter getArtifactFilter( MojoDescriptor mojoDescriptor ) { String scopeToResolve = mojoDescriptor.getDependencyResolutionRequired(); String scopeToCollect = mojoDescriptor.getDependencyCollectionRequired(); List scopes = new ArrayList<>( 2 ); if ( StringUtils.isNotEmpty( scopeToCollect ) ) { scopes.add( scopeToCollect ); } if ( StringUtils.isNotEmpty( scopeToResolve ) ) { scopes.add( scopeToResolve ); } if ( scopes.isEmpty() ) { return null; } else { return new CumulativeScopeArtifactFilter( scopes ); } } public List executeForkedExecutions( MojoExecution mojoExecution, MavenSession session, ProjectIndex projectIndex ) throws LifecycleExecutionException { List forkedProjects = Collections.emptyList(); Map> forkedExecutions = mojoExecution.getForkedExecutions(); if ( !forkedExecutions.isEmpty() ) { eventCatapult.fire( ExecutionEvent.Type.ForkStarted, session, mojoExecution ); MavenProject project = session.getCurrentProject(); forkedProjects = new ArrayList<>( forkedExecutions.size() ); try { for ( Map.Entry> fork : forkedExecutions.entrySet() ) { String projectId = fork.getKey(); int index = projectIndex.getIndices().get( projectId ); MavenProject forkedProject = projectIndex.getProjects().get( projectId ); forkedProjects.add( forkedProject ); MavenProject executedProject = forkedProject.clone(); forkedProject.setExecutionProject( executedProject ); List mojoExecutions = fork.getValue(); if ( mojoExecutions.isEmpty() ) { continue; } try { session.setCurrentProject( executedProject ); session.getProjects().set( index, executedProject ); projectIndex.getProjects().put( projectId, executedProject ); eventCatapult.fire( ExecutionEvent.Type.ForkedProjectStarted, session, mojoExecution ); execute( session, mojoExecutions, projectIndex ); eventCatapult.fire( ExecutionEvent.Type.ForkedProjectSucceeded, session, mojoExecution ); } catch ( LifecycleExecutionException e ) { eventCatapult.fire( ExecutionEvent.Type.ForkedProjectFailed, session, mojoExecution, e ); throw e; } finally { projectIndex.getProjects().put( projectId, forkedProject ); session.getProjects().set( index, forkedProject ); session.setCurrentProject( project ); } } eventCatapult.fire( ExecutionEvent.Type.ForkSucceeded, session, mojoExecution ); } catch ( LifecycleExecutionException e ) { eventCatapult.fire( ExecutionEvent.Type.ForkFailed, session, mojoExecution, e ); throw e; } } return forkedProjects; } } maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/lifecycle/internal/PhaseRecorder.java000066400000000000000000000044511317160430700327130ustar00rootroot00000000000000package org.apache.maven.lifecycle.internal; /* * 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 org.apache.maven.plugin.MojoExecution; import org.apache.maven.project.MavenProject; /** * NOTE: This class is not part of any public api and can be changed or deleted without prior notice. * @since 3.0 * @author Benjamin Bentmann * @author Kristian Rosenvold */ public class PhaseRecorder { private String lastLifecyclePhase; private final MavenProject project; public PhaseRecorder( MavenProject project ) { this.project = project; } public void observeExecution( MojoExecution mojoExecution ) { String lifecyclePhase = mojoExecution.getLifecyclePhase(); if ( lifecyclePhase != null ) { if ( lastLifecyclePhase == null ) { lastLifecyclePhase = lifecyclePhase; } else if ( !lifecyclePhase.equals( lastLifecyclePhase ) ) { project.addLifecyclePhase( lastLifecyclePhase ); lastLifecyclePhase = lifecyclePhase; } } if ( lastLifecyclePhase != null ) { project.addLifecyclePhase( lastLifecyclePhase ); } } public boolean isDifferentPhase( MojoExecution nextMojoExecution ) { String lifecyclePhase = nextMojoExecution.getLifecyclePhase(); if ( lifecyclePhase == null ) { return lastLifecyclePhase != null; } return !lifecyclePhase.equals( lastLifecyclePhase ); } } ProjectArtifactFactory.java000066400000000000000000000026541317160430700345250ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/lifecycle/internalpackage org.apache.maven.lifecycle.internal; /* * 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.util.Set; import org.apache.maven.artifact.Artifact; import org.apache.maven.project.MavenProject; import org.apache.maven.project.artifact.InvalidDependencyVersionException; /** *

* Component interface responsible for creation of MavenProject#dependencyArtifacts instances. *

* NOTE: This class is not part of any public api and can be changed or deleted without prior notice. * * @since 3.2.4 */ public interface ProjectArtifactFactory { Set createArtifacts( MavenProject project ) throws InvalidDependencyVersionException; } maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/lifecycle/internal/ProjectBuildList.java000066400000000000000000000113471317160430700334110ustar00rootroot00000000000000package org.apache.maven.lifecycle.internal; /* * 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.util.ArrayList; import java.util.Collections; import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Set; import org.apache.maven.artifact.ArtifactUtils; import org.apache.maven.execution.MavenSession; import org.apache.maven.project.MavenProject; /** *

* A list of project segments, ordered so that all ProjectSegments from first TaskSegment come before any * subsequent TaskSegments. *

* Note: This interface is part of work in progress and can be changed or removed without notice. * * @since 3.0 * @author Kristian Rosenvold */ public class ProjectBuildList implements Iterable { private final List items; public ProjectBuildList( List items ) { this.items = Collections.unmodifiableList( items ); } // TODO Optimize; or maybe just rewrite the whole way aggregating mojos are being run. /** * Returns aProjectBuildList that contains only items for the specified taskSegment * @param taskSegment the requested tasksegment * @return a project build list for the supplied task segment */ public ProjectBuildList getByTaskSegment( TaskSegment taskSegment ) { List currentSegment = new ArrayList<>(); for ( ProjectSegment projectBuild : items ) { if ( taskSegment == projectBuild.getTaskSegment() ) { // NOTE: There's no notion of taskSegment equality. currentSegment.add( projectBuild ); } } return new ProjectBuildList( currentSegment ); } public Map selectSegment( TaskSegment taskSegment ) { Map result = new HashMap<>(); for ( ProjectSegment projectBuild : items ) { if ( taskSegment == projectBuild.getTaskSegment() ) { // NOTE: There's no notion of taskSegment equality. result.put( projectBuild.getProject(), projectBuild ); } } return result; } /** * Finds the first ProjectSegment matching the supplied project * @param mavenProject the requested project * @return The projectSegment or null. */ public ProjectSegment findByMavenProject( MavenProject mavenProject ) { for ( ProjectSegment projectBuild : items ) { if ( mavenProject.equals( projectBuild.getProject() ) ) { return projectBuild; } } return null; } public Iterator iterator() { return items.iterator(); } public void closeAll() { for ( ProjectSegment item : items ) { MavenSession sessionForThisModule = item.getSession(); sessionForThisModule.setCurrentProject( null ); } } public int size() { return items.size(); } public ProjectSegment get( int index ) { return items.get( index ); } public Set getReactorProjectKeys() { Set projectKeys = new HashSet<>( items.size() * 2 ); for ( ProjectSegment projectBuild : items ) { MavenProject project = projectBuild.getProject(); String key = ArtifactUtils.key( project.getGroupId(), project.getArtifactId(), project.getVersion() ); projectKeys.add( key ); } return projectKeys; } public boolean isEmpty() { return items.isEmpty(); } /** * @return a set of all the projects managed by the build */ public Set getProjects() { Set projects = new HashSet<>(); for ( ProjectSegment s : items ) { projects.add( s.getProject() ); } return projects; } } maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/lifecycle/internal/ProjectIndex.java000066400000000000000000000042371317160430700325650ustar00rootroot00000000000000package org.apache.maven.lifecycle.internal; /* * 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 org.apache.maven.lifecycle.internal.builder.BuilderCommon; import org.apache.maven.project.MavenProject; import java.util.HashMap; import java.util.List; import java.util.Map; /** *

* Provides the positional index of the project *

* NOTE: This class is not part of any public api and can be changed or deleted without prior notice. * * @since 3.0 * @author Benjamin Bentmann * @author Kristian Rosenvold (extracted class only) */ // TODO Kristian wonders if this class really is necessary and if it overlaps other concepts. public final class ProjectIndex { private final Map projects; private final Map indices; public ProjectIndex( List projects ) { this.projects = new HashMap<>( projects.size() * 2 ); this.indices = new HashMap<>( projects.size() * 2 ); for ( int i = 0; i < projects.size(); i++ ) { MavenProject project = projects.get( i ); String key = BuilderCommon.getKey( project ); this.getProjects().put( key, project ); this.getIndices().put( key, i ); } } public Map getProjects() { return projects; } public Map getIndices() { return indices; } } maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/lifecycle/internal/ProjectSegment.java000066400000000000000000000071571317160430700331240ustar00rootroot00000000000000package org.apache.maven.lifecycle.internal; /* * 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 org.apache.maven.execution.MavenSession; import org.apache.maven.execution.ProjectDependencyGraph; import org.apache.maven.project.MavenProject; import java.util.List; /** * A build context that matches a mavenproject to a given tasksegment, and the session to be used. *

* A note to the reader; *

*

* There are several issues/discussions regarding how "aggregator" plugins should be handled. * Read for instance http://docs.codehaus.org/display/MAVEN/Deterministic+Lifecycle+Planning *

*

* In their current implementation they are "bolted" onto the lifecycle by separating them * into TaskSegments. This class represents the execution context of one such task segment. *

*

* Wise voices have suggested that maybe aggregators shouldn't be bound to the ordinary * lifecycle at all, in which case we wouldn't be needing this class at all ( and * ProjectBuildList.getByTaskSegments). Or maybe they should be introduced in the calculation * of the execution plan instead, which seems much nicer. *

*

* Additionally this class contains a clone of the MavenSession, which is *only* needed * because it has as notion of a "current" project. *

* NOTE: This class is not part of any public api and can be changed or deleted without prior notice. * * @since 3.0 * @author Jason van Zyl * @author Benjamin Bentmann * @author Kristian Rosenvold */ public final class ProjectSegment { private final MavenProject project; private final TaskSegment taskSegment; private final MavenSession session; private final List nonTransitiveUpstreamProjects; private final List transitiveUpstreamProjects; public ProjectSegment( MavenProject project, TaskSegment taskSegment, MavenSession copiedSession ) { this.project = project; this.taskSegment = taskSegment; this.session = copiedSession; final ProjectDependencyGraph dependencyGraph = getSession().getProjectDependencyGraph(); nonTransitiveUpstreamProjects = dependencyGraph.getUpstreamProjects( getProject(), false ); transitiveUpstreamProjects = dependencyGraph.getUpstreamProjects( getProject(), true ); } public MavenSession getSession() { return session; } public MavenProject getProject() { return project; } public TaskSegment getTaskSegment() { return taskSegment; } public List getImmediateUpstreamProjects() { return nonTransitiveUpstreamProjects; } public List getTransitiveUpstreamProjects() { return transitiveUpstreamProjects; } @Override public String toString() { return getProject().getId() + " -> " + getTaskSegment(); } } ReactorBuildStatus.java000066400000000000000000000047601317160430700336740ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/lifecycle/internalpackage org.apache.maven.lifecycle.internal; /* * 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 org.apache.maven.execution.ProjectDependencyGraph; import org.apache.maven.lifecycle.internal.builder.BuilderCommon; import org.apache.maven.project.MavenProject; import java.util.Collection; import java.util.Collections; import java.util.HashSet; /** * Contains status information that is global to an entire reactor build. * * @since 3.0 * @author Kristian Rosenvold */ public class ReactorBuildStatus { private final ProjectDependencyGraph projectDependencyGraph; private final Collection blackListedProjects = Collections.synchronizedSet( new HashSet() ); private volatile boolean halted = false; public ReactorBuildStatus( ProjectDependencyGraph projectDependencyGraph ) { this.projectDependencyGraph = projectDependencyGraph; } public boolean isBlackListed( MavenProject project ) { return blackListedProjects.contains( BuilderCommon.getKey( project ) ); } public void blackList( MavenProject project ) { if ( blackListedProjects.add( BuilderCommon.getKey( project ) ) && projectDependencyGraph != null ) { for ( MavenProject downstreamProject : projectDependencyGraph.getDownstreamProjects( project, true ) ) { blackListedProjects.add( BuilderCommon.getKey( downstreamProject ) ); } } } public void halt() { halted = true; } public boolean isHalted() { return halted; } public boolean isHaltedOrBlacklisted( MavenProject mavenProject ) { return isBlackListed( mavenProject ) || isHalted(); } } maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/lifecycle/internal/ReactorContext.java000066400000000000000000000047401317160430700331320ustar00rootroot00000000000000package org.apache.maven.lifecycle.internal; /* * 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 org.apache.maven.execution.MavenExecutionResult; import org.apache.maven.session.scope.internal.SessionScope; /** * Context that is fixed for the entire reactor build. * * @since 3.0 * @author Jason van Zyl * @author Kristian Rosenvold * NOTE: This class is not part of any public api and can be changed or deleted without prior notice. */ public class ReactorContext { private final MavenExecutionResult result; private final ProjectIndex projectIndex; private final ClassLoader originalContextClassLoader; private final ReactorBuildStatus reactorBuildStatus; private final SessionScope.Memento sessionScope; public ReactorContext( MavenExecutionResult result, ProjectIndex projectIndex, ClassLoader originalContextClassLoader, ReactorBuildStatus reactorBuildStatus, SessionScope.Memento sessionScope ) { this.result = result; this.projectIndex = projectIndex; this.originalContextClassLoader = originalContextClassLoader; this.reactorBuildStatus = reactorBuildStatus; this.sessionScope = sessionScope; } public ReactorBuildStatus getReactorBuildStatus() { return reactorBuildStatus; } public MavenExecutionResult getResult() { return result; } public ProjectIndex getProjectIndex() { return projectIndex; } public ClassLoader getOriginalContextClassLoader() { return originalContextClassLoader; } /** * @since 3.3.0 */ public SessionScope.Memento getSessionScopeMemento() { return sessionScope; } } maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/lifecycle/internal/TaskSegment.java000066400000000000000000000041161317160430700324100ustar00rootroot00000000000000package org.apache.maven.lifecycle.internal; /* * 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.util.ArrayList; import java.util.Arrays; import java.util.List; /** * Describes the required task segment as provided on the maven command line; i.e. "clean jetty:run install" * * NOTE: This class is not part of any public api and can be changed or deleted without prior notice. * * @since 3.0 * @author Benjamin Bentmann * @author Kristian Rosenvold (extracted class only) */ public final class TaskSegment { // Can be both "LifeCycleTask" (clean/install) and "GoalTask" (org.mortbay.jetty:maven-jetty-plugin:6.1.19:run) private final List tasks; private final boolean aggregating; public TaskSegment( boolean aggregating ) { this.aggregating = aggregating; tasks = new ArrayList<>(); } public TaskSegment( boolean aggregating, Object... tasks ) { this.aggregating = aggregating; this.tasks = new ArrayList<>( Arrays.asList( tasks ) ); } @Override public String toString() { return getTasks().toString(); } public List getTasks() { return tasks; } public boolean isAggregating() { return aggregating; } // TODO Consider throwing UnsupportedSomething on hashCode/equals } maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/lifecycle/internal/builder/000077500000000000000000000000001317160430700307445ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/lifecycle/internal/builder/Builder.java000066400000000000000000000040311317160430700331730ustar00rootroot00000000000000package org.apache.maven.lifecycle.internal.builder; /* * 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.util.List; import java.util.concurrent.ExecutionException; import org.apache.maven.execution.MavenSession; import org.apache.maven.lifecycle.internal.ProjectBuildList; import org.apache.maven.lifecycle.internal.ReactorBuildStatus; import org.apache.maven.lifecycle.internal.ReactorContext; import org.apache.maven.lifecycle.internal.TaskSegment; /** *

* A {@link Builder} encapsulates a strategy for building a set of Maven projects. The default strategy in Maven builds * the the projects serially, but a {@link Builder} can employ any type of concurrency model to build the projects. *

* Note: This interface is part of work in progress and can be changed or removed without notice. * @author jvanzyl */ public interface Builder { // // Be nice to whittle this down to Session, maybe add task segments to the session. The session really is the // the place to store reactor related information. // void build( MavenSession session, ReactorContext reactorContext, ProjectBuildList projectBuilds, List taskSegments, ReactorBuildStatus reactorBuildStatus ) throws ExecutionException, InterruptedException; } BuilderCommon.java000066400000000000000000000220061317160430700342670ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/lifecycle/internal/builderpackage org.apache.maven.lifecycle.internal.builder; /* * 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 org.apache.maven.artifact.Artifact; import org.apache.maven.execution.BuildFailure; import org.apache.maven.execution.ExecutionEvent; import org.apache.maven.execution.MavenExecutionRequest; import org.apache.maven.execution.MavenSession; import org.apache.maven.lifecycle.LifecycleExecutionException; import org.apache.maven.lifecycle.LifecycleNotFoundException; import org.apache.maven.lifecycle.LifecyclePhaseNotFoundException; import org.apache.maven.lifecycle.MavenExecutionPlan; import org.apache.maven.lifecycle.internal.ExecutionEventCatapult; import org.apache.maven.lifecycle.internal.LifecycleDebugLogger; import org.apache.maven.lifecycle.internal.LifecycleExecutionPlanCalculator; import org.apache.maven.lifecycle.internal.ReactorContext; import org.apache.maven.lifecycle.internal.TaskSegment; import org.apache.maven.model.Plugin; import org.apache.maven.plugin.InvalidPluginDescriptorException; import org.apache.maven.plugin.MojoNotFoundException; import org.apache.maven.plugin.PluginDescriptorParsingException; import org.apache.maven.plugin.PluginNotFoundException; import org.apache.maven.plugin.PluginResolutionException; import org.apache.maven.plugin.descriptor.MojoDescriptor; import org.apache.maven.plugin.prefix.NoPluginFoundForPrefixException; import org.apache.maven.plugin.version.PluginVersionResolutionException; import org.apache.maven.project.MavenProject; import org.codehaus.plexus.classworlds.realm.ClassRealm; import org.codehaus.plexus.component.annotations.Component; import org.codehaus.plexus.component.annotations.Requirement; import org.codehaus.plexus.logging.Logger; import java.util.Set; /** * Common code that is shared by the LifecycleModuleBuilder and the LifeCycleWeaveBuilder * * @since 3.0 * @author Kristian Rosenvold * Builds one or more lifecycles for a full module * NOTE: This class is not part of any public api and can be changed or deleted without prior notice. */ @Component( role = BuilderCommon.class ) public class BuilderCommon { @Requirement private LifecycleDebugLogger lifecycleDebugLogger; @Requirement private LifecycleExecutionPlanCalculator lifeCycleExecutionPlanCalculator; @Requirement private ExecutionEventCatapult eventCatapult; @Requirement private Logger logger; public BuilderCommon() { } public BuilderCommon( LifecycleDebugLogger lifecycleDebugLogger, LifecycleExecutionPlanCalculator lifeCycleExecutionPlanCalculator, Logger logger ) { this.lifecycleDebugLogger = lifecycleDebugLogger; this.lifeCycleExecutionPlanCalculator = lifeCycleExecutionPlanCalculator; this.logger = logger; } public MavenExecutionPlan resolveBuildPlan( MavenSession session, MavenProject project, TaskSegment taskSegment, Set projectArtifacts ) throws PluginNotFoundException, PluginResolutionException, LifecyclePhaseNotFoundException, PluginDescriptorParsingException, MojoNotFoundException, InvalidPluginDescriptorException, NoPluginFoundForPrefixException, LifecycleNotFoundException, PluginVersionResolutionException, LifecycleExecutionException { MavenExecutionPlan executionPlan = lifeCycleExecutionPlanCalculator.calculateExecutionPlan( session, project, taskSegment.getTasks() ); lifecycleDebugLogger.debugProjectPlan( project, executionPlan ); if ( session.getRequest().getDegreeOfConcurrency() > 1 ) { final Set unsafePlugins = executionPlan.getNonThreadSafePlugins(); if ( !unsafePlugins.isEmpty() ) { logger.warn( "*****************************************************************" ); logger.warn( "* Your build is requesting parallel execution, but project *" ); logger.warn( "* contains the following plugin(s) that have goals not marked *" ); logger.warn( "* as @threadSafe to support parallel building. *" ); logger.warn( "* While this /may/ work fine, please look for plugin updates *" ); logger.warn( "* and/or request plugins be made thread-safe. *" ); logger.warn( "* If reporting an issue, report it against the plugin in *" ); logger.warn( "* question, not against maven-core *" ); logger.warn( "*****************************************************************" ); if ( logger.isDebugEnabled() ) { final Set unsafeGoals = executionPlan.getNonThreadSafeMojos(); logger.warn( "The following goals are not marked @threadSafe in " + project.getName() + ":" ); for ( MojoDescriptor unsafeGoal : unsafeGoals ) { logger.warn( unsafeGoal.getId() ); } } else { logger.warn( "The following plugins are not marked @threadSafe in " + project.getName() + ":" ); for ( Plugin unsafePlugin : unsafePlugins ) { logger.warn( unsafePlugin.getId() ); } logger.warn( "Enable debug to see more precisely which goals are not marked @threadSafe." ); } logger.warn( "*****************************************************************" ); } } return executionPlan; } public void handleBuildError( final ReactorContext buildContext, final MavenSession rootSession, final MavenSession currentSession, final MavenProject mavenProject, Throwable t, final long buildStartTime ) { // record the error and mark the project as failed long buildEndTime = System.currentTimeMillis(); buildContext.getResult().addException( t ); buildContext.getResult().addBuildSummary( new BuildFailure( mavenProject, buildEndTime - buildStartTime, t ) ); // notify listeners about "soft" project build failures only if ( t instanceof Exception && !( t instanceof RuntimeException ) ) { eventCatapult.fire( ExecutionEvent.Type.ProjectFailed, currentSession, null, (Exception) t ); } // reactor failure modes if ( t instanceof RuntimeException || !( t instanceof Exception ) ) { // fail fast on RuntimeExceptions, Errors and "other" Throwables // assume these are system errors and further build is meaningless buildContext.getReactorBuildStatus().halt(); } else if ( MavenExecutionRequest.REACTOR_FAIL_NEVER.equals( rootSession.getReactorFailureBehavior() ) ) { // continue the build } else if ( MavenExecutionRequest.REACTOR_FAIL_AT_END.equals( rootSession.getReactorFailureBehavior() ) ) { // continue the build but ban all projects that depend on the failed one buildContext.getReactorBuildStatus().blackList( mavenProject ); } else if ( MavenExecutionRequest.REACTOR_FAIL_FAST.equals( rootSession.getReactorFailureBehavior() ) ) { buildContext.getReactorBuildStatus().halt(); } else { logger.error( "invalid reactor failure behavior " + rootSession.getReactorFailureBehavior() ); buildContext.getReactorBuildStatus().halt(); } } public static void attachToThread( MavenProject currentProject ) { ClassRealm projectRealm = currentProject.getClassRealm(); if ( projectRealm != null ) { Thread.currentThread().setContextClassLoader( projectRealm ); } } // TODO I'm really wondering where this method belongs; smells like it should be on MavenProject, but for some // reason it isn't ? This localization is kind-of a code smell. public static String getKey( MavenProject project ) { return project.getGroupId() + ':' + project.getArtifactId() + ':' + project.getVersion(); } } BuilderNotFoundException.java000066400000000000000000000017721317160430700364610ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/lifecycle/internal/builderpackage org.apache.maven.lifecycle.internal.builder; /* * 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. */ public class BuilderNotFoundException extends Exception { public BuilderNotFoundException( String message ) { super( message ); } } multithreaded/000077500000000000000000000000001317160430700335205ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/lifecycle/internal/builderConcurrencyDependencyGraph.java000066400000000000000000000117751317160430700416510ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/lifecycle/internal/builder/multithreadedpackage org.apache.maven.lifecycle.internal.builder.multithreaded; /* * 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 org.apache.maven.execution.ProjectDependencyGraph; import org.apache.maven.lifecycle.internal.ProjectBuildList; import org.apache.maven.lifecycle.internal.ProjectSegment; import org.apache.maven.project.MavenProject; import java.util.ArrayList; import java.util.HashSet; import java.util.List; import java.util.Set; /** *

* Presents a view of the Dependency Graph that is suited for concurrent building. *

* NOTE: This class is not part of any public api and can be changed or deleted without prior notice. * * @since 3.0 * @author Kristian Rosenvold */ public class ConcurrencyDependencyGraph { private final ProjectBuildList projectBuilds; private final ProjectDependencyGraph projectDependencyGraph; private final HashSet finishedProjects = new HashSet<>(); public ConcurrencyDependencyGraph( ProjectBuildList projectBuilds, ProjectDependencyGraph projectDependencyGraph ) { this.projectDependencyGraph = projectDependencyGraph; this.projectBuilds = projectBuilds; } public int getNumberOfBuilds() { return projectBuilds.size(); } /** * Gets all the builds that have no reactor-dependencies * * @return A list of all the initial builds */ public List getRootSchedulableBuilds() { List result = new ArrayList<>(); for ( ProjectSegment projectBuild : projectBuilds ) { if ( projectDependencyGraph.getUpstreamProjects( projectBuild.getProject(), false ).size() == 0 ) { result.add( projectBuild.getProject() ); } } return result; } /** * Marks the provided project as finished. Returns a list of * * @param mavenProject The project * @return The list of builds that are eligible for starting now that the provided project is done */ public List markAsFinished( MavenProject mavenProject ) { finishedProjects.add( mavenProject ); return getSchedulableNewProcesses( mavenProject ); } private List getSchedulableNewProcesses( MavenProject finishedProject ) { List result = new ArrayList<>(); // schedule dependent projects, if all of their requirements are met for ( MavenProject dependentProject : projectDependencyGraph.getDownstreamProjects( finishedProject, false ) ) { final List upstreamProjects = projectDependencyGraph.getUpstreamProjects( dependentProject, false ); if ( finishedProjects.containsAll( upstreamProjects ) ) { result.add( dependentProject ); } } return result; } /** * @return set of projects that have yet to be processed successfully by the build. */ public Set getUnfinishedProjects() { Set unfinished = new HashSet<>( projectBuilds.getProjects() ); unfinished.remove( finishedProjects ); return unfinished; } /** * @return set of projects that have been successfully processed by the build. */ protected Set getFinishedProjects() { return finishedProjects; } protected ProjectBuildList getProjectBuilds() { return projectBuilds; } /** * For the given {@link MavenProject} {@code p}, return all of {@code p}'s dependencies. * * @param p * @return List of prerequisite projects */ protected List getDependencies( MavenProject p ) { return projectDependencyGraph.getUpstreamProjects( p, false ); } /** * For the given {@link MavenProject} {@code p} return {@code p}'s uncompleted dependencies. * * @param p * @return List of uncompleted prerequisite projects */ public List getActiveDependencies( MavenProject p ) { List activeDependencies = projectDependencyGraph.getUpstreamProjects( p, false ); activeDependencies.removeAll( finishedProjects ); return activeDependencies; } }MultiThreadedBuilder.java000066400000000000000000000214571317160430700404360ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/lifecycle/internal/builder/multithreadedpackage org.apache.maven.lifecycle.internal.builder.multithreaded; /* * 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.util.List; import java.util.Map; import java.util.concurrent.Callable; import java.util.concurrent.CompletionService; import java.util.concurrent.ExecutionException; import java.util.concurrent.ExecutorCompletionService; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.concurrent.Future; import org.apache.maven.execution.MavenSession; import org.apache.maven.lifecycle.internal.BuildThreadFactory; import org.apache.maven.lifecycle.internal.LifecycleModuleBuilder; import org.apache.maven.lifecycle.internal.ProjectBuildList; import org.apache.maven.lifecycle.internal.ProjectSegment; import org.apache.maven.lifecycle.internal.ReactorBuildStatus; import org.apache.maven.lifecycle.internal.ReactorContext; import org.apache.maven.lifecycle.internal.TaskSegment; import org.apache.maven.lifecycle.internal.builder.Builder; import org.apache.maven.project.MavenProject; import org.codehaus.plexus.component.annotations.Component; import org.codehaus.plexus.component.annotations.Requirement; import org.codehaus.plexus.logging.Logger; /** * Builds the full lifecycle in weave-mode (phase by phase as opposed to project-by-project). *

* This builder uses a number of threads equal to the minimum of the degree of concurrency (which is the thread count * set with -T on the command-line) and the number of projects to build. As such, building a single project * will always result in a sequential build, regardless of the thread count. *

* NOTE: This class is not part of any public api and can be changed or deleted without prior notice. * * @since 3.0 * @author Kristian Rosenvold * Builds one or more lifecycles for a full module * NOTE: This class is not part of any public api and can be changed or deleted without prior notice. */ @Component( role = Builder.class, hint = "multithreaded" ) public class MultiThreadedBuilder implements Builder { @Requirement private Logger logger; @Requirement private LifecycleModuleBuilder lifecycleModuleBuilder; public MultiThreadedBuilder() { } @Override public void build( MavenSession session, ReactorContext reactorContext, ProjectBuildList projectBuilds, List taskSegments, ReactorBuildStatus reactorBuildStatus ) throws ExecutionException, InterruptedException { int nThreads = Math.min( session.getRequest().getDegreeOfConcurrency(), session.getProjects().size() ); boolean parallel = nThreads >= 2; // Propagate the parallel flag to the root session and all of the cloned sessions in each project segment session.setParallel( parallel ); for ( ProjectSegment segment : projectBuilds ) { segment.getSession().setParallel( parallel ); } ExecutorService executor = Executors.newFixedThreadPool( nThreads, new BuildThreadFactory() ); CompletionService service = new ExecutorCompletionService<>( executor ); ConcurrencyDependencyGraph analyzer = new ConcurrencyDependencyGraph( projectBuilds, session.getProjectDependencyGraph() ); // Currently disabled ThreadOutputMuxer muxer = null; // new ThreadOutputMuxer( analyzer.getProjectBuilds(), System.out ); for ( TaskSegment taskSegment : taskSegments ) { Map projectBuildMap = projectBuilds.selectSegment( taskSegment ); try { multiThreadedProjectTaskSegmentBuild( analyzer, reactorContext, session, service, taskSegment, projectBuildMap, muxer ); if ( reactorContext.getReactorBuildStatus().isHalted() ) { break; } } catch ( Exception e ) { session.getResult().addException( e ); break; } } } private void multiThreadedProjectTaskSegmentBuild( ConcurrencyDependencyGraph analyzer, ReactorContext reactorContext, MavenSession rootSession, CompletionService service, TaskSegment taskSegment, Map projectBuildList, ThreadOutputMuxer muxer ) { // schedule independent projects for ( MavenProject mavenProject : analyzer.getRootSchedulableBuilds() ) { ProjectSegment projectSegment = projectBuildList.get( mavenProject ); logger.debug( "Scheduling: " + projectSegment.getProject() ); Callable cb = createBuildCallable( rootSession, projectSegment, reactorContext, taskSegment, muxer ); service.submit( cb ); } // for each finished project for ( int i = 0; i < analyzer.getNumberOfBuilds(); i++ ) { try { ProjectSegment projectBuild = service.take().get(); if ( reactorContext.getReactorBuildStatus().isHalted() ) { break; } // MNG-6170: Only schedule other modules from reactor if we have more modules to build than one. if ( analyzer.getNumberOfBuilds() > 1 ) { final List newItemsThatCanBeBuilt = analyzer.markAsFinished( projectBuild.getProject() ); for ( MavenProject mavenProject : newItemsThatCanBeBuilt ) { ProjectSegment scheduledDependent = projectBuildList.get( mavenProject ); logger.debug( "Scheduling: " + scheduledDependent ); Callable cb = createBuildCallable( rootSession, scheduledDependent, reactorContext, taskSegment, muxer ); service.submit( cb ); } } } catch ( InterruptedException e ) { rootSession.getResult().addException( e ); break; } catch ( ExecutionException e ) { // TODO MNG-5766 changes likely made this redundant rootSession.getResult().addException( e ); break; } } // cancel outstanding builds (if any) - this can happen if an exception is thrown in above block Future unprocessed; while ( ( unprocessed = service.poll() ) != null ) { try { unprocessed.get(); } catch ( InterruptedException | ExecutionException e ) { throw new RuntimeException( e ); } } } private Callable createBuildCallable( final MavenSession rootSession, final ProjectSegment projectBuild, final ReactorContext reactorContext, final TaskSegment taskSegment, final ThreadOutputMuxer muxer ) { return new Callable() { public ProjectSegment call() { // muxer.associateThreadWithProjectSegment( projectBuild ); lifecycleModuleBuilder.buildProject( projectBuild.getSession(), rootSession, reactorContext, projectBuild.getProject(), taskSegment ); // muxer.setThisModuleComplete( projectBuild ); return projectBuild; } }; } } ThreadOutputMuxer.java000066400000000000000000000336021317160430700400400ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/lifecycle/internal/builder/multithreadedpackage org.apache.maven.lifecycle.internal.builder.multithreaded; /* * 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.ByteArrayOutputStream; import java.io.IOException; import java.io.PrintStream; import java.util.Collections; import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; import java.util.Map; import java.util.Set; import org.apache.maven.lifecycle.internal.ProjectBuildList; import org.apache.maven.lifecycle.internal.ProjectSegment; /** * NOTE: This class is not part of any public api and can be changed or deleted without prior notice. * This class in particular may spontaneously self-combust and be replaced by a plexus-compliant thread aware * logger implementation at any time. * * @since 3.0 * @author Kristian Rosenvold */ @SuppressWarnings( { "SynchronizationOnLocalVariableOrMethodParameter" } ) public class ThreadOutputMuxer { private final Iterator projects; private final ThreadLocal projectBuildThreadLocal = new ThreadLocal<>(); private final Map streams = new HashMap<>(); private final Map printStreams = new HashMap<>(); private final ByteArrayOutputStream defaultOutputStreamForUnknownData = new ByteArrayOutputStream(); private final PrintStream defaultPrintStream = new PrintStream( defaultOutputStreamForUnknownData ); private final Set completedBuilds = Collections.synchronizedSet( new HashSet() ); private volatile ProjectSegment currentBuild; private final PrintStream originalSystemOUtStream; private final ConsolePrinter printer; /** * A simple but safe solution for printing to the console. */ class ConsolePrinter implements Runnable { public volatile boolean running; private final ProjectBuildList projectBuildList; ConsolePrinter( ProjectBuildList projectBuildList ) { this.projectBuildList = projectBuildList; } public void run() { running = true; for ( ProjectSegment projectBuild : projectBuildList ) { final PrintStream projectStream = printStreams.get( projectBuild ); ByteArrayOutputStream projectOs = streams.get( projectBuild ); do { synchronized ( projectStream ) { try { projectStream.wait( 100 ); } catch ( InterruptedException e ) { throw new RuntimeException( e ); } try { projectOs.writeTo( originalSystemOUtStream ); } catch ( IOException e ) { throw new RuntimeException( e ); } projectOs.reset(); } } while ( !completedBuilds.contains( projectBuild ) ); } running = false; } /* Wait until we are sure the print-stream thread is running. */ public void waitUntilRunning( boolean expect ) { while ( !running == expect ) { try { Thread.sleep( 10 ); } catch ( InterruptedException e ) { throw new RuntimeException( e ); } } } } public ThreadOutputMuxer( ProjectBuildList segmentChunks, PrintStream originalSystemOut ) { projects = segmentChunks.iterator(); for ( ProjectSegment segmentChunk : segmentChunks ) { final ByteArrayOutputStream value = new ByteArrayOutputStream(); streams.put( segmentChunk, value ); printStreams.put( segmentChunk, new PrintStream( value ) ); } setNext(); this.originalSystemOUtStream = originalSystemOut; System.setOut( new ThreadBoundPrintStream( this.originalSystemOUtStream ) ); printer = new ConsolePrinter( segmentChunks ); new Thread( printer ).start(); printer.waitUntilRunning( true ); } public void close() { printer.waitUntilRunning( false ); System.setOut( this.originalSystemOUtStream ); } private void setNext() { currentBuild = projects.hasNext() ? projects.next() : null; } private boolean ownsRealOutputStream( ProjectSegment projectBuild ) { return projectBuild.equals( currentBuild ); } private PrintStream getThreadBoundPrintStream() { ProjectSegment threadProject = projectBuildThreadLocal.get(); if ( threadProject == null ) { return defaultPrintStream; } if ( ownsRealOutputStream( threadProject ) ) { return originalSystemOUtStream; } return printStreams.get( threadProject ); } public void associateThreadWithProjectSegment( ProjectSegment projectBuild ) { projectBuildThreadLocal.set( projectBuild ); } public void setThisModuleComplete( ProjectSegment projectBuild ) { completedBuilds.add( projectBuild ); PrintStream stream = printStreams.get( projectBuild ); synchronized ( stream ) { stream.notifyAll(); } disconnectThreadFromProject(); } private void disconnectThreadFromProject() { projectBuildThreadLocal.remove(); } private class ThreadBoundPrintStream extends PrintStream { public ThreadBoundPrintStream( PrintStream systemOutStream ) { super( systemOutStream ); } private PrintStream getOutputStreamForCurrentThread() { return getThreadBoundPrintStream(); } @Override public void println() { final PrintStream currentStream = getOutputStreamForCurrentThread(); synchronized ( currentStream ) { currentStream.println(); currentStream.notifyAll(); } } @Override public void print( char c ) { final PrintStream currentStream = getOutputStreamForCurrentThread(); synchronized ( currentStream ) { currentStream.print( c ); currentStream.notifyAll(); } } @Override public void println( char x ) { final PrintStream currentStream = getOutputStreamForCurrentThread(); synchronized ( currentStream ) { currentStream.println( x ); currentStream.notifyAll(); } } @Override public void print( double d ) { final PrintStream currentStream = getOutputStreamForCurrentThread(); synchronized ( currentStream ) { currentStream.print( d ); currentStream.notifyAll(); } } @Override public void println( double x ) { final PrintStream currentStream = getOutputStreamForCurrentThread(); synchronized ( currentStream ) { currentStream.println( x ); currentStream.notifyAll(); } } @Override public void print( float f ) { final PrintStream currentStream = getOutputStreamForCurrentThread(); synchronized ( currentStream ) { currentStream.print( f ); currentStream.notifyAll(); } } @Override public void println( float x ) { final PrintStream currentStream = getOutputStreamForCurrentThread(); synchronized ( currentStream ) { currentStream.println( x ); currentStream.notifyAll(); } } @Override public void print( int i ) { final PrintStream currentStream = getOutputStreamForCurrentThread(); synchronized ( currentStream ) { currentStream.print( i ); currentStream.notifyAll(); } } @Override public void println( int x ) { final PrintStream currentStream = getOutputStreamForCurrentThread(); synchronized ( currentStream ) { currentStream.println( x ); currentStream.notifyAll(); } } @Override public void print( long l ) { final PrintStream currentStream = getOutputStreamForCurrentThread(); synchronized ( currentStream ) { currentStream.print( l ); currentStream.notifyAll(); } } @Override public void println( long x ) { final PrintStream currentStream = getOutputStreamForCurrentThread(); synchronized ( currentStream ) { currentStream.print( x ); currentStream.notifyAll(); } } @Override public void print( boolean b ) { final PrintStream currentStream = getOutputStreamForCurrentThread(); synchronized ( currentStream ) { currentStream.print( b ); currentStream.notifyAll(); } } @Override public void println( boolean x ) { final PrintStream currentStream = getOutputStreamForCurrentThread(); synchronized ( currentStream ) { currentStream.print( x ); currentStream.notifyAll(); } } @Override public void print( char s[] ) { final PrintStream currentStream = getOutputStreamForCurrentThread(); synchronized ( currentStream ) { currentStream.print( s ); currentStream.notifyAll(); } } @Override public void println( char x[] ) { final PrintStream currentStream = getOutputStreamForCurrentThread(); synchronized ( currentStream ) { currentStream.print( x ); currentStream.notifyAll(); } } @Override public void print( Object obj ) { final PrintStream currentStream = getOutputStreamForCurrentThread(); synchronized ( currentStream ) { currentStream.print( obj ); currentStream.notifyAll(); } } @Override public void println( Object x ) { final PrintStream currentStream = getOutputStreamForCurrentThread(); synchronized ( currentStream ) { currentStream.println( x ); currentStream.notifyAll(); } } @Override public void print( String s ) { final PrintStream currentStream = getOutputStreamForCurrentThread(); synchronized ( currentStream ) { currentStream.print( s ); currentStream.notifyAll(); } } @Override public void println( String x ) { final PrintStream currentStream = getOutputStreamForCurrentThread(); synchronized ( currentStream ) { currentStream.println( x ); currentStream.notifyAll(); } } @Override public void write( byte b[], int off, int len ) { final PrintStream currentStream = getOutputStreamForCurrentThread(); synchronized ( currentStream ) { currentStream.write( b, off, len ); currentStream.notifyAll(); } } @Override public void close() { getOutputStreamForCurrentThread().close(); } @Override public void flush() { getOutputStreamForCurrentThread().flush(); } @Override public void write( int b ) { final PrintStream currentStream = getOutputStreamForCurrentThread(); synchronized ( currentStream ) { currentStream.write( b ); currentStream.notifyAll(); } } @Override public void write( byte b[] ) throws IOException { final PrintStream currentStream = getOutputStreamForCurrentThread(); synchronized ( currentStream ) { currentStream.write( b ); currentStream.notifyAll(); } } } } singlethreaded/000077500000000000000000000000001317160430700336475ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/lifecycle/internal/builderSingleThreadedBuilder.java000066400000000000000000000051571317160430700407130ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/lifecycle/internal/builder/singlethreadedpackage org.apache.maven.lifecycle.internal.builder.singlethreaded; /* * 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.util.List; import org.apache.maven.execution.MavenSession; import org.apache.maven.lifecycle.internal.LifecycleModuleBuilder; import org.apache.maven.lifecycle.internal.ProjectBuildList; import org.apache.maven.lifecycle.internal.ProjectSegment; import org.apache.maven.lifecycle.internal.ReactorBuildStatus; import org.apache.maven.lifecycle.internal.ReactorContext; import org.apache.maven.lifecycle.internal.TaskSegment; import org.apache.maven.lifecycle.internal.builder.Builder; import org.codehaus.plexus.component.annotations.Component; import org.codehaus.plexus.component.annotations.Requirement; @Component( role = Builder.class, hint = "singlethreaded" ) public class SingleThreadedBuilder implements Builder { @Requirement private LifecycleModuleBuilder lifecycleModuleBuilder; public void build( MavenSession session, ReactorContext reactorContext, ProjectBuildList projectBuilds, List taskSegments, ReactorBuildStatus reactorBuildStatus ) { for ( TaskSegment taskSegment : taskSegments ) { for ( ProjectSegment projectBuild : projectBuilds.getByTaskSegment( taskSegment ) ) { try { lifecycleModuleBuilder.buildProject( session, reactorContext, projectBuild.getProject(), taskSegment ); if ( reactorBuildStatus.isHalted() ) { break; } } catch ( Exception e ) { break; // Why are we just ignoring this exception? Are exceptions are being used for flow control } } } } } maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/lifecycle/mapping/000077500000000000000000000000001317160430700271355ustar00rootroot00000000000000DefaultLifecycleMapping.java000066400000000000000000000064561317160430700344540ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/lifecycle/mappingpackage org.apache.maven.lifecycle.mapping; /* * 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.util.HashMap; import java.util.List; import java.util.Map; public class DefaultLifecycleMapping implements LifecycleMapping { private List lifecycles; private Map lifecycleMap; /** @deprecated use lifecycles instead */ private Map phases; /** * Populates the lifecycle map from the injected list of lifecycle mappings (if not already done). */ private void initLifecycleMap() { if ( lifecycleMap == null ) { lifecycleMap = new HashMap<>(); if ( lifecycles != null ) { for ( Lifecycle lifecycle : lifecycles ) { lifecycleMap.put( lifecycle.getId(), lifecycle ); } } else { /* * NOTE: This is to provide a migration path for implementors of the legacy API which did not know about * getLifecycles(). */ String[] lifecycleIds = { "default", "clean", "site" }; for ( String lifecycleId : lifecycleIds ) { Map phases = getLifecyclePhases( lifecycleId ); if ( phases != null ) { Lifecycle lifecycle = new Lifecycle(); lifecycle.setId( lifecycleId ); lifecycle.setLifecyclePhases( phases ); lifecycleMap.put( lifecycleId, lifecycle ); } } } } } public Map getLifecycles() { initLifecycleMap(); return lifecycleMap; } public List getOptionalMojos( String lifecycle ) { return null; } private Map getLifecyclePhases( String lifecycle ) { initLifecycleMap(); Lifecycle lifecycleMapping = lifecycleMap.get( lifecycle ); if ( lifecycleMapping != null ) { return lifecycleMapping.getLifecyclePhases(); } else if ( "default".equals( lifecycle ) ) { return phases; } else { return null; } } @Deprecated public Map getPhases( String lifecycle ) { return LifecyclePhase.toLegacyMap( getLifecyclePhases( lifecycle ) ); } } maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/lifecycle/mapping/Lifecycle.java000066400000000000000000000055721317160430700317100ustar00rootroot00000000000000package org.apache.maven.lifecycle.mapping; /* * 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.util.Collections; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; /** * Class Lifecycle. */ public class Lifecycle { /** * Field id */ private String id; /** * Field phases */ private Map lifecyclePhases; /* * NOTE: This exists merely for backward-compat with legacy-style lifecycle definitions and allows configuration * injection to work instead of failing. */ @SuppressWarnings( "unused" ) private List optionalMojos; /** * Method getId */ public String getId() { return this.id; } /** * Method getLifecyclePhases */ public Map getLifecyclePhases() { return this.lifecyclePhases; } /** * Method setId * * @param id */ public void setId( String id ) { this.id = id; } /** * Method setLifecyclePhases * * @param lifecyclePhases */ public void setLifecyclePhases( Map lifecyclePhases ) { this.lifecyclePhases = lifecyclePhases; } @Deprecated public Map getPhases() { Map lphases = getLifecyclePhases(); if ( lphases == null ) { return null; } if ( lphases.isEmpty() ) { return Collections.emptyMap(); } Map phases = new LinkedHashMap<>(); for ( Map.Entry e: lphases.entrySet() ) { phases.put( e.getKey(), e.getValue().toString() ); } return phases; } @Deprecated public void setPhases( Map phases ) { Map lphases = new LinkedHashMap<>(); for ( Map.Entry e: phases.entrySet() ) { lphases.put( e.getKey(), new LifecyclePhase( e.getValue() ) ); } setLifecyclePhases( lphases ); } } maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/lifecycle/mapping/LifecycleMapping.java000066400000000000000000000022541317160430700332160ustar00rootroot00000000000000package org.apache.maven.lifecycle.mapping; /* * 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.util.List; import java.util.Map; public interface LifecycleMapping { @Deprecated String ROLE = LifecycleMapping.class.getName(); Map getLifecycles(); @Deprecated List getOptionalMojos( String lifecycle ); @Deprecated Map getPhases( String lifecycle ); } maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/lifecycle/mapping/LifecycleMojo.java000066400000000000000000000032101317160430700325200ustar00rootroot00000000000000package org.apache.maven.lifecycle.mapping; /* * 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.util.List; import org.apache.maven.model.Dependency; import org.codehaus.plexus.util.xml.Xpp3Dom; public class LifecycleMojo { private String goal; private Xpp3Dom configuration; private List dependencies; public String getGoal() { return goal; } public Xpp3Dom getConfiguration() { return configuration; } public List getDependencies() { return dependencies; } public void setGoal( String goal ) { this.goal = goal; } public void setConfiguration( Xpp3Dom configuration ) { this.configuration = configuration; } public void setDependencies( List dependencies ) { this.dependencies = dependencies; } } maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/lifecycle/mapping/LifecyclePhase.java000066400000000000000000000057761317160430700326770ustar00rootroot00000000000000package org.apache.maven.lifecycle.mapping; /* * 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.util.ArrayList; import java.util.Collections; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import org.codehaus.plexus.util.StringUtils; public class LifecyclePhase { private List mojos; public LifecyclePhase() { } public LifecyclePhase( String goals ) { set( goals ); } public List getMojos() { return mojos; } public void setMojos( List mojos ) { this.mojos = mojos; } public void set( String goals ) { mojos = new ArrayList<>(); if ( StringUtils.isNotEmpty( goals ) ) { String[] mojoGoals = StringUtils.split( goals, "," ); for ( String mojoGoal: mojoGoals ) { LifecycleMojo lifecycleMojo = new LifecycleMojo(); lifecycleMojo.setGoal( mojoGoal.trim() ); mojos.add( lifecycleMojo ); } } } @Override public String toString() { StringBuilder sb = new StringBuilder(); boolean first = true; List mojos = getMojos(); if ( mojos != null ) { for ( LifecycleMojo mojo: mojos ) { if ( first ) { first = false; } else { sb.append( ',' ); } sb.append( mojo.getGoal() ); } } return sb.toString(); } @Deprecated public static Map toLegacyMap( Map lifecyclePhases ) { if ( lifecyclePhases == null ) { return null; } if ( lifecyclePhases.isEmpty() ) { return Collections.emptyMap(); } Map phases = new LinkedHashMap<>(); for ( Map.Entry e: lifecyclePhases.entrySet() ) { phases.put( e.getKey(), e.getValue().toString() ); } return phases; } } maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/model/000077500000000000000000000000001317160430700246435ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/model/plugin/000077500000000000000000000000001317160430700261415ustar00rootroot00000000000000DefaultLifecycleBindingsInjector.java000066400000000000000000000145571317160430700353210ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/model/pluginpackage org.apache.maven.model.plugin; /* * 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.util.ArrayList; import java.util.Collection; import java.util.Collections; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import org.apache.maven.lifecycle.LifeCyclePluginAnalyzer; import org.apache.maven.model.Build; import org.apache.maven.model.Model; import org.apache.maven.model.Plugin; import org.apache.maven.model.PluginContainer; import org.apache.maven.model.PluginExecution; import org.apache.maven.model.PluginManagement; import org.apache.maven.model.building.ModelBuildingRequest; import org.apache.maven.model.building.ModelProblemCollector; import org.apache.maven.model.building.ModelProblem.Severity; import org.apache.maven.model.building.ModelProblem.Version; import org.apache.maven.model.building.ModelProblemCollectorRequest; import org.apache.maven.model.merge.MavenModelMerger; import org.codehaus.plexus.component.annotations.Component; import org.codehaus.plexus.component.annotations.Requirement; /** * Handles injection of plugin executions induced by the lifecycle bindings for a packaging. * * @author Benjamin Bentmann */ @Component( role = LifecycleBindingsInjector.class ) public class DefaultLifecycleBindingsInjector implements LifecycleBindingsInjector { private LifecycleBindingsMerger merger = new LifecycleBindingsMerger(); @Requirement private LifeCyclePluginAnalyzer lifecycle; public void injectLifecycleBindings( Model model, ModelBuildingRequest request, ModelProblemCollector problems ) { String packaging = model.getPackaging(); Collection defaultPlugins = lifecycle.getPluginsBoundByDefaultToAllLifecycles( packaging ); if ( defaultPlugins == null ) { problems.add( new ModelProblemCollectorRequest( Severity.ERROR, Version.BASE ) .setMessage( "Unknown packaging: " + packaging ) .setLocation( model.getLocation( "packaging" ) ) ); } else if ( !defaultPlugins.isEmpty() ) { Model lifecycleModel = new Model(); lifecycleModel.setBuild( new Build() ); lifecycleModel.getBuild().getPlugins().addAll( defaultPlugins ); merger.merge( model, lifecycleModel ); } } protected static class LifecycleBindingsMerger extends MavenModelMerger { private static final String PLUGIN_MANAGEMENT = "plugin-management"; public void merge( Model target, Model source ) { if ( target.getBuild() == null ) { target.setBuild( new Build() ); } Map context = Collections.singletonMap( PLUGIN_MANAGEMENT, target.getBuild().getPluginManagement() ); mergePluginContainer_Plugins( target.getBuild(), source.getBuild(), false, context ); } @Override protected void mergePluginContainer_Plugins( PluginContainer target, PluginContainer source, boolean sourceDominant, Map context ) { List src = source.getPlugins(); if ( !src.isEmpty() ) { List tgt = target.getPlugins(); Map merged = new LinkedHashMap<>( ( src.size() + tgt.size() ) * 2 ); for ( Plugin element : tgt ) { Object key = getPluginKey( element ); merged.put( key, element ); } Map unmanaged = new LinkedHashMap<>(); for ( Plugin element : src ) { Object key = getPluginKey( element ); Plugin existing = merged.get( key ); if ( existing != null ) { mergePlugin( existing, element, sourceDominant, context ); } else { merged.put( key, element ); unmanaged.put( key, element ); } } if ( !unmanaged.isEmpty() ) { PluginManagement pluginMgmt = (PluginManagement) context.get( PLUGIN_MANAGEMENT ); if ( pluginMgmt != null ) { for ( Plugin managedPlugin : pluginMgmt.getPlugins() ) { Object key = getPluginKey( managedPlugin ); Plugin unmanagedPlugin = unmanaged.get( key ); if ( unmanagedPlugin != null ) { Plugin plugin = managedPlugin.clone(); mergePlugin( plugin, unmanagedPlugin, sourceDominant, Collections.emptyMap() ); merged.put( key, plugin ); } } } } List result = new ArrayList<>( merged.values() ); target.setPlugins( result ); } } @Override protected void mergePluginExecution( PluginExecution target, PluginExecution source, boolean sourceDominant, Map context ) { super.mergePluginExecution( target, source, sourceDominant, context ); target.setPriority( Math.min( target.getPriority(), source.getPriority() ) ); } } } maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/monitor/000077500000000000000000000000001317160430700252325ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/monitor/event/000077500000000000000000000000001317160430700263535ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/monitor/event/EventDispatcher.java000066400000000000000000000022071317160430700323070ustar00rootroot00000000000000package org.apache.maven.monitor.event; /* * 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 jdcasey */ @Deprecated public interface EventDispatcher { void addEventMonitor( EventMonitor monitor ); void dispatchStart( String event, String target ); void dispatchEnd( String event, String target ); void dispatchError( String event, String target, Throwable cause ); }maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/monitor/event/EventMonitor.java000066400000000000000000000022041317160430700316450ustar00rootroot00000000000000package org.apache.maven.monitor.event; /* * 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 jdcasey */ @Deprecated public interface EventMonitor { void startEvent( String eventName, String target, long timestamp ); void endEvent( String eventName, String target, long timestamp ); void errorEvent( String eventName, String target, long timestamp, Throwable cause ); }maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/plugin/000077500000000000000000000000001317160430700250415ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/plugin/BuildPluginManager.java000066400000000000000000000044561317160430700314260ustar00rootroot00000000000000package org.apache.maven.plugin; /* * 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.util.List; import org.apache.maven.execution.MavenSession; import org.apache.maven.model.Plugin; import org.apache.maven.plugin.descriptor.MojoDescriptor; import org.apache.maven.plugin.descriptor.PluginDescriptor; import org.codehaus.plexus.classworlds.realm.ClassRealm; import org.eclipse.aether.RepositorySystemSession; import org.eclipse.aether.repository.RemoteRepository; /** * @author Jason van Zyl */ public interface BuildPluginManager { // igorf: Way too many declared exceptions! PluginDescriptor loadPlugin( Plugin plugin, List repositories, RepositorySystemSession session ) throws PluginNotFoundException, PluginResolutionException, PluginDescriptorParsingException, InvalidPluginDescriptorException; // igorf: Way too many declared exceptions! MojoDescriptor getMojoDescriptor( Plugin plugin, String goal, List repositories, RepositorySystemSession session ) throws PluginNotFoundException, PluginResolutionException, PluginDescriptorParsingException, MojoNotFoundException, InvalidPluginDescriptorException; ClassRealm getPluginRealm( MavenSession session, PluginDescriptor pluginDescriptor ) throws PluginResolutionException, PluginManagerException; void executeMojo( MavenSession session, MojoExecution execution ) throws MojoFailureException, MojoExecutionException, PluginConfigurationException, PluginManagerException; } maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/plugin/CacheUtils.java000066400000000000000000000145411317160430700277350ustar00rootroot00000000000000package org.apache.maven.plugin; /* * 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.util.Iterator; import java.util.List; import org.apache.maven.model.Dependency; import org.apache.maven.model.Exclusion; import org.apache.maven.model.Plugin; import org.eclipse.aether.RepositorySystemSession; import org.eclipse.aether.repository.RemoteRepository; import org.eclipse.aether.repository.RepositoryPolicy; import org.eclipse.aether.repository.WorkspaceReader; import org.eclipse.aether.repository.WorkspaceRepository; /** * @author Benjamin Bentmann */ class CacheUtils { public static boolean eq( T s1, T s2 ) { return s1 != null ? s1.equals( s2 ) : s2 == null; } public static int hash( Object obj ) { return obj != null ? obj.hashCode() : 0; } public static int repositoriesHashCode( List repositories ) { int result = 17; for ( RemoteRepository repository : repositories ) { result = 31 * result + repositoryHashCode( repository ); } return result; } private static int repositoryHashCode( RemoteRepository repository ) { int result = 17; result = 31 * result + hash( repository.getUrl() ); return result; } private static boolean repositoryEquals( RemoteRepository r1, RemoteRepository r2 ) { if ( r1 == r2 ) { return true; } return eq( r1.getId(), r2.getId() ) && eq( r1.getUrl(), r2.getUrl() ) && policyEquals( r1.getPolicy( false ), r2.getPolicy( false ) ) && policyEquals( r1.getPolicy( true ), r2.getPolicy( true ) ); } private static boolean policyEquals( RepositoryPolicy p1, RepositoryPolicy p2 ) { if ( p1 == p2 ) { return true; } // update policy doesn't affect contents return p1.isEnabled() == p2.isEnabled() && eq( p1.getChecksumPolicy(), p2.getChecksumPolicy() ); } public static boolean repositoriesEquals( List r1, List r2 ) { if ( r1.size() != r2.size() ) { return false; } for ( Iterator it1 = r1.iterator(), it2 = r2.iterator(); it1.hasNext(); ) { if ( !repositoryEquals( it1.next(), it2.next() ) ) { return false; } } return true; } public static int pluginHashCode( Plugin plugin ) { int hash = 17; hash = hash * 31 + hash( plugin.getGroupId() ); hash = hash * 31 + hash( plugin.getArtifactId() ); hash = hash * 31 + hash( plugin.getVersion() ); hash = hash * 31 + ( plugin.isExtensions() ? 1 : 0 ); for ( Dependency dependency : plugin.getDependencies() ) { hash = hash * 31 + hash( dependency.getGroupId() ); hash = hash * 31 + hash( dependency.getArtifactId() ); hash = hash * 31 + hash( dependency.getVersion() ); hash = hash * 31 + hash( dependency.getType() ); hash = hash * 31 + hash( dependency.getClassifier() ); hash = hash * 31 + hash( dependency.getScope() ); for ( Exclusion exclusion : dependency.getExclusions() ) { hash = hash * 31 + hash( exclusion.getGroupId() ); hash = hash * 31 + hash( exclusion.getArtifactId() ); } } return hash; } public static boolean pluginEquals( Plugin a, Plugin b ) { return eq( a.getArtifactId(), b.getArtifactId() ) // && eq( a.getGroupId(), b.getGroupId() ) // && eq( a.getVersion(), b.getVersion() ) // && a.isExtensions() == b.isExtensions() // && dependenciesEquals( a.getDependencies(), b.getDependencies() ); } private static boolean dependenciesEquals( List a, List b ) { if ( a.size() != b.size() ) { return false; } Iterator aI = a.iterator(); Iterator bI = b.iterator(); while ( aI.hasNext() ) { Dependency aD = aI.next(); Dependency bD = bI.next(); boolean r = eq( aD.getGroupId(), bD.getGroupId() ) // && eq( aD.getArtifactId(), bD.getArtifactId() ) // && eq( aD.getVersion(), bD.getVersion() ) // && eq( aD.getType(), bD.getType() ) // && eq( aD.getClassifier(), bD.getClassifier() ) // && eq( aD.getScope(), bD.getScope() ); r &= exclusionsEquals( aD.getExclusions(), bD.getExclusions() ); if ( !r ) { return false; } } return true; } private static boolean exclusionsEquals( List a, List b ) { if ( a.size() != b.size() ) { return false; } Iterator aI = a.iterator(); Iterator bI = b.iterator(); while ( aI.hasNext() ) { Exclusion aD = aI.next(); Exclusion bD = bI.next(); boolean r = eq( aD.getGroupId(), bD.getGroupId() ) // && eq( aD.getArtifactId(), bD.getArtifactId() ); if ( !r ) { return false; } } return true; } public static WorkspaceRepository getWorkspace( RepositorySystemSession session ) { WorkspaceReader reader = session.getWorkspaceReader(); return ( reader != null ) ? reader.getRepository() : null; } } CompoundMojoExecutionListener.java000066400000000000000000000037371317160430700336420ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/pluginpackage org.apache.maven.plugin; /* * 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.util.Collection; import org.apache.maven.execution.MojoExecutionEvent; import org.apache.maven.execution.MojoExecutionListener; class CompoundMojoExecutionListener implements MojoExecutionListener { private final Collection listeners; public CompoundMojoExecutionListener( Collection listeners ) { this.listeners = listeners; // NB this is live injected collection } public void beforeMojoExecution( MojoExecutionEvent event ) throws MojoExecutionException { for ( MojoExecutionListener listener : listeners ) { listener.beforeMojoExecution( event ); } } public void afterMojoExecutionSuccess( MojoExecutionEvent event ) throws MojoExecutionException { for ( MojoExecutionListener listener : listeners ) { listener.afterMojoExecutionSuccess( event ); } } public void afterExecutionFailure( MojoExecutionEvent event ) { for ( MojoExecutionListener listener : listeners ) { listener.afterExecutionFailure( event ); } } } CycleDetectedInPluginGraphException.java000066400000000000000000000027631317160430700346450ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/pluginpackage org.apache.maven.plugin; /* * 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 org.apache.maven.model.Plugin; import org.codehaus.plexus.component.composition.CycleDetectedInComponentGraphException; /** * Exception occurring trying to resolve a plugin. * * @author Brett Porter */ public class CycleDetectedInPluginGraphException extends Exception { private final Plugin plugin; public CycleDetectedInPluginGraphException( Plugin plugin, CycleDetectedInComponentGraphException e ) { super( "A cycle was detected in the component graph of the plugin: " + plugin.getArtifactId() ); this.plugin = plugin; } public Plugin getPlugin() { return plugin; } } maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/plugin/DebugConfigurationListener.java000066400000000000000000000053231317160430700331730ustar00rootroot00000000000000package org.apache.maven.plugin; /* * 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.lang.reflect.Array; import org.codehaus.plexus.component.configurator.ConfigurationListener; import org.codehaus.plexus.logging.Logger; /** * Log at debug level the mojo configuration. * * @author Brett Porter */ @Deprecated public class DebugConfigurationListener implements ConfigurationListener { private Logger logger; public DebugConfigurationListener( Logger logger ) { this.logger = logger; } public void notifyFieldChangeUsingSetter( String fieldName, Object value, Object target ) { if ( logger.isDebugEnabled() ) { logger.debug( " (s) " + fieldName + " = " + toString( value ) ); } } public void notifyFieldChangeUsingReflection( String fieldName, Object value, Object target ) { if ( logger.isDebugEnabled() ) { logger.debug( " (f) " + fieldName + " = " + toString( value ) ); } } /** * Creates a human-friendly string representation of the specified object. * * @param obj The object to create a string representation for, may be null. * @return The string representation, never null. */ private String toString( Object obj ) { String str; if ( obj != null && obj.getClass().isArray() ) { int n = Array.getLength( obj ); StringBuilder buf = new StringBuilder( 256 ); buf.append( '[' ); for ( int i = 0; i < n; i++ ) { if ( i > 0 ) { buf.append( ", " ); } buf.append( String.valueOf( Array.get( obj, i ) ) ); } buf.append( ']' ); str = buf.toString(); } else { str = String.valueOf( obj ); } return str; } } maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/plugin/DefaultBuildPluginManager.java000066400000000000000000000234311317160430700327250ustar00rootroot00000000000000package org.apache.maven.plugin; /* * 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.ByteArrayOutputStream; import java.io.PrintStream; import java.util.List; import org.apache.maven.execution.MavenSession; import org.apache.maven.execution.MojoExecutionEvent; import org.apache.maven.execution.MojoExecutionListener; import org.apache.maven.execution.scope.internal.MojoExecutionScope; import org.apache.maven.model.Plugin; import org.apache.maven.plugin.descriptor.MojoDescriptor; import org.apache.maven.plugin.descriptor.PluginDescriptor; import org.apache.maven.project.MavenProject; import org.codehaus.plexus.classworlds.realm.ClassRealm; import org.codehaus.plexus.component.annotations.Component; import org.codehaus.plexus.component.annotations.Requirement; import org.eclipse.aether.RepositorySystemSession; import org.eclipse.aether.repository.RemoteRepository; // TODO the antrun plugin has its own configurator, the only plugin that does. might need to think about how that works // TODO remove the coreArtifactFilterManager @Component( role = BuildPluginManager.class ) public class DefaultBuildPluginManager implements BuildPluginManager { @Requirement private MavenPluginManager mavenPluginManager; @Requirement private LegacySupport legacySupport; @Requirement private MojoExecutionScope scope; private MojoExecutionListener mojoExecutionListener; // this tricks plexus-component-metadata generate required metadata @Requirement( role = MojoExecutionListener.class ) private List mojoExecutionListeners; public void setMojoExecutionListeners( final List listeners ) { this.mojoExecutionListeners = listeners; this.mojoExecutionListener = new CompoundMojoExecutionListener( listeners ); } /** * @param plugin * @param repositories * @param session * @return PluginDescriptor The component descriptor for the Maven plugin. * @throws PluginNotFoundException The plugin could not be found in any repositories. * @throws PluginResolutionException The plugin could be found but could not be resolved. * @throws InvalidPluginDescriptorException */ public PluginDescriptor loadPlugin( Plugin plugin, List repositories, RepositorySystemSession session ) throws PluginNotFoundException, PluginResolutionException, PluginDescriptorParsingException, InvalidPluginDescriptorException { return mavenPluginManager.getPluginDescriptor( plugin, repositories, session ); } // ---------------------------------------------------------------------- // Mojo execution // ---------------------------------------------------------------------- public void executeMojo( MavenSession session, MojoExecution mojoExecution ) throws MojoFailureException, MojoExecutionException, PluginConfigurationException, PluginManagerException { MavenProject project = session.getCurrentProject(); MojoDescriptor mojoDescriptor = mojoExecution.getMojoDescriptor(); Mojo mojo = null; ClassRealm pluginRealm; try { pluginRealm = getPluginRealm( session, mojoDescriptor.getPluginDescriptor() ); } catch ( PluginResolutionException e ) { throw new PluginExecutionException( mojoExecution, project, e ); } ClassLoader oldClassLoader = Thread.currentThread().getContextClassLoader(); Thread.currentThread().setContextClassLoader( pluginRealm ); MavenSession oldSession = legacySupport.getSession(); scope.enter(); try { scope.seed( MavenProject.class, project ); scope.seed( MojoExecution.class, mojoExecution ); mojo = mavenPluginManager.getConfiguredMojo( Mojo.class, session, mojoExecution ); legacySupport.setSession( session ); // NOTE: DuplicateArtifactAttachmentException is currently unchecked, so be careful removing this try/catch! // This is necessary to avoid creating compatibility problems for existing plugins that use // MavenProjectHelper.attachArtifact(..). try { MojoExecutionEvent mojoExecutionEvent = new MojoExecutionEvent( session, project, mojoExecution, mojo ); mojoExecutionListener.beforeMojoExecution( mojoExecutionEvent ); mojo.execute(); mojoExecutionListener.afterMojoExecutionSuccess( mojoExecutionEvent ); } catch ( ClassCastException e ) { // to be processed in the outer catch block throw e; } catch ( RuntimeException e ) { throw new PluginExecutionException( mojoExecution, project, e ); } } catch ( PluginContainerException e ) { mojoExecutionListener.afterExecutionFailure( new MojoExecutionEvent( session, project, mojoExecution, mojo, e ) ); throw new PluginExecutionException( mojoExecution, project, e ); } catch ( NoClassDefFoundError e ) { mojoExecutionListener.afterExecutionFailure( new MojoExecutionEvent( session, project, mojoExecution, mojo, e ) ); ByteArrayOutputStream os = new ByteArrayOutputStream( 1024 ); PrintStream ps = new PrintStream( os ); ps.println( "A required class was missing while executing " + mojoDescriptor.getId() + ": " + e.getMessage() ); pluginRealm.display( ps ); Exception wrapper = new PluginContainerException( mojoDescriptor, pluginRealm, os.toString(), e ); throw new PluginExecutionException( mojoExecution, project, wrapper ); } catch ( LinkageError e ) { mojoExecutionListener.afterExecutionFailure( new MojoExecutionEvent( session, project, mojoExecution, mojo, e ) ); ByteArrayOutputStream os = new ByteArrayOutputStream( 1024 ); PrintStream ps = new PrintStream( os ); ps.println( "An API incompatibility was encountered while executing " + mojoDescriptor.getId() + ": " + e.getClass().getName() + ": " + e.getMessage() ); pluginRealm.display( ps ); Exception wrapper = new PluginContainerException( mojoDescriptor, pluginRealm, os.toString(), e ); throw new PluginExecutionException( mojoExecution, project, wrapper ); } catch ( ClassCastException e ) { mojoExecutionListener.afterExecutionFailure( new MojoExecutionEvent( session, project, mojoExecution, mojo, e ) ); ByteArrayOutputStream os = new ByteArrayOutputStream( 1024 ); PrintStream ps = new PrintStream( os ); ps.println( "A type incompatibility occurred while executing " + mojoDescriptor.getId() + ": " + e.getMessage() ); pluginRealm.display( ps ); throw new PluginExecutionException( mojoExecution, project, os.toString(), e ); } catch ( RuntimeException e ) { mojoExecutionListener.afterExecutionFailure( new MojoExecutionEvent( session, project, mojoExecution, mojo, e ) ); throw e; } finally { mavenPluginManager.releaseMojo( mojo, mojoExecution ); scope.exit(); Thread.currentThread().setContextClassLoader( oldClassLoader ); legacySupport.setSession( oldSession ); } } /** * TODO pluginDescriptor classRealm and artifacts are set as a side effect of this * call, which is not nice. * @throws PluginResolutionException */ public ClassRealm getPluginRealm( MavenSession session, PluginDescriptor pluginDescriptor ) throws PluginResolutionException, PluginManagerException { ClassRealm pluginRealm = pluginDescriptor.getClassRealm(); if ( pluginRealm != null ) { return pluginRealm; } mavenPluginManager.setupPluginRealm( pluginDescriptor, session, null, null, null ); return pluginDescriptor.getClassRealm(); } public MojoDescriptor getMojoDescriptor( Plugin plugin, String goal, List repositories, RepositorySystemSession session ) throws PluginNotFoundException, PluginResolutionException, PluginDescriptorParsingException, MojoNotFoundException, InvalidPluginDescriptorException { return mavenPluginManager.getMojoDescriptor( plugin, goal, repositories, session ); } } maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/plugin/DefaultExtensionRealmCache.java000066400000000000000000000116341317160430700330770ustar00rootroot00000000000000package org.apache.maven.plugin; /* * 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.File; import java.util.ArrayList; import java.util.List; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; import org.apache.commons.lang3.Validate; import org.apache.maven.artifact.Artifact; import org.apache.maven.project.ExtensionDescriptor; import org.apache.maven.project.MavenProject; import org.codehaus.plexus.classworlds.realm.ClassRealm; import org.codehaus.plexus.classworlds.realm.NoSuchRealmException; import org.codehaus.plexus.component.annotations.Component; import org.codehaus.plexus.personality.plexus.lifecycle.phase.Disposable; /** * Default extension realm cache implementation. Assumes cached data does not change. */ @Component( role = ExtensionRealmCache.class ) public class DefaultExtensionRealmCache implements ExtensionRealmCache, Disposable { protected static class CacheKey implements Key { private final List files; private final List timestamps; private final List sizes; private final List ids; private final int hashCode; public CacheKey( List extensionArtifacts ) { this.files = new ArrayList<>( extensionArtifacts.size() ); this.timestamps = new ArrayList<>( extensionArtifacts.size() ); this.sizes = new ArrayList<>( extensionArtifacts.size() ); this.ids = new ArrayList<>( extensionArtifacts.size() ); for ( Artifact artifact : extensionArtifacts ) { File file = artifact.getFile(); files.add( file ); timestamps.add( ( file != null ) ? Long.valueOf( file.lastModified() ) : Long.valueOf( 0 ) ); sizes.add( ( file != null ) ? Long.valueOf( file.length() ) : Long.valueOf( 0 ) ); ids.add( artifact.getVersion() ); } this.hashCode = 31 * files.hashCode() + 31 * ids.hashCode() + 31 * timestamps.hashCode() + 31 * sizes.hashCode(); } @Override public int hashCode() { return hashCode; } @Override public boolean equals( Object o ) { if ( o == this ) { return true; } if ( !( o instanceof CacheKey ) ) { return false; } CacheKey other = (CacheKey) o; return ids.equals( other.ids ) && files.equals( other.files ) && timestamps.equals( other.timestamps ) && sizes.equals( other.sizes ); } @Override public String toString() { return files.toString(); } } protected final Map cache = new ConcurrentHashMap<>(); @Override public Key createKey( List extensionArtifacts ) { return new CacheKey( extensionArtifacts ); } public CacheRecord get( Key key ) { return cache.get( key ); } public CacheRecord put( Key key, ClassRealm extensionRealm, ExtensionDescriptor extensionDescriptor, List artifacts ) { Validate.notNull( extensionRealm, "extensionRealm cannot be null" ); if ( cache.containsKey( key ) ) { throw new IllegalStateException( "Duplicate extension realm for extension " + key ); } CacheRecord record = new CacheRecord( extensionRealm, extensionDescriptor, artifacts ); cache.put( key, record ); return record; } public void flush() { for ( CacheRecord record : cache.values() ) { ClassRealm realm = record.realm; try { realm.getWorld().disposeRealm( realm.getId() ); } catch ( NoSuchRealmException e ) { // ignore } } cache.clear(); } public void register( MavenProject project, Key key, CacheRecord record ) { // default cache does not track extension usage } public void dispose() { flush(); } } maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginArtifactsCache.java000066400000000000000000000142561317160430700332440ustar00rootroot00000000000000package org.apache.maven.plugin; /* * 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.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; import org.apache.commons.lang3.Validate; import org.apache.maven.artifact.Artifact; import org.apache.maven.model.Plugin; import org.apache.maven.project.MavenProject; import org.codehaus.plexus.component.annotations.Component; import org.eclipse.aether.RepositorySystemSession; import org.eclipse.aether.graph.DependencyFilter; import org.eclipse.aether.repository.LocalRepository; import org.eclipse.aether.repository.RemoteRepository; import org.eclipse.aether.repository.WorkspaceRepository; /** * @author Igor Fedorenko * @author Benjamin Bentmann */ @Component( role = PluginArtifactsCache.class ) public class DefaultPluginArtifactsCache implements PluginArtifactsCache { protected static class CacheKey implements Key { private final Plugin plugin; private final WorkspaceRepository workspace; private final LocalRepository localRepo; private final List repositories; private final DependencyFilter filter; private final int hashCode; public CacheKey( Plugin plugin, DependencyFilter extensionFilter, List repositories, RepositorySystemSession session ) { this.plugin = plugin.clone(); workspace = CacheUtils.getWorkspace( session ); this.localRepo = session.getLocalRepository(); this.repositories = new ArrayList<>( repositories.size() ); for ( RemoteRepository repository : repositories ) { if ( repository.isRepositoryManager() ) { this.repositories.addAll( repository.getMirroredRepositories() ); } else { this.repositories.add( repository ); } } this.filter = extensionFilter; int hash = 17; hash = hash * 31 + CacheUtils.pluginHashCode( plugin ); hash = hash * 31 + hash( workspace ); hash = hash * 31 + hash( localRepo ); hash = hash * 31 + CacheUtils.repositoriesHashCode( repositories ); hash = hash * 31 + hash( extensionFilter ); this.hashCode = hash; } @Override public String toString() { return plugin.getId(); } @Override public int hashCode() { return hashCode; } private static int hash( Object obj ) { return obj != null ? obj.hashCode() : 0; } @Override public boolean equals( Object o ) { if ( o == this ) { return true; } if ( !( o instanceof CacheKey ) ) { return false; } CacheKey that = (CacheKey) o; return CacheUtils.pluginEquals( plugin, that.plugin ) && eq( workspace, that.workspace ) && eq( localRepo, that.localRepo ) && CacheUtils.repositoriesEquals( repositories, that.repositories ) && eq( filter, that.filter ); } private static boolean eq( T s1, T s2 ) { return s1 != null ? s1.equals( s2 ) : s2 == null; } } protected final Map cache = new ConcurrentHashMap<>(); public Key createKey( Plugin plugin, DependencyFilter extensionFilter, List repositories, RepositorySystemSession session ) { return new CacheKey( plugin, extensionFilter, repositories, session ); } public CacheRecord get( Key key ) throws PluginResolutionException { CacheRecord cacheRecord = cache.get( key ); if ( cacheRecord != null && cacheRecord.exception != null ) { throw cacheRecord.exception; } return cacheRecord; } public CacheRecord put( Key key, List pluginArtifacts ) { Validate.notNull( pluginArtifacts, "pluginArtifacts cannot be null" ); assertUniqueKey( key ); CacheRecord record = new CacheRecord( Collections.unmodifiableList( new ArrayList<>( pluginArtifacts ) ) ); cache.put( key, record ); return record; } protected void assertUniqueKey( Key key ) { if ( cache.containsKey( key ) ) { throw new IllegalStateException( "Duplicate artifact resolution result for plugin " + key ); } } public CacheRecord put( Key key, PluginResolutionException exception ) { Validate.notNull( exception, "exception cannot be null" ); assertUniqueKey( key ); CacheRecord record = new CacheRecord( exception ); cache.put( key, record ); return record; } public void flush() { cache.clear(); } protected static int pluginHashCode( Plugin plugin ) { return CacheUtils.pluginHashCode( plugin ); } protected static boolean pluginEquals( Plugin a, Plugin b ) { return CacheUtils.pluginEquals( a, b ); } public void register( MavenProject project, Key cacheKey, CacheRecord record ) { // default cache does not track record usage } } maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginDescriptorCache.java000066400000000000000000000161161317160430700334370ustar00rootroot00000000000000package org.apache.maven.plugin; /* * 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.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import org.apache.maven.artifact.ArtifactUtils; import org.apache.maven.model.Plugin; import org.apache.maven.plugin.descriptor.MojoDescriptor; import org.apache.maven.plugin.descriptor.PluginDescriptor; import org.codehaus.plexus.component.annotations.Component; import org.codehaus.plexus.component.repository.ComponentDescriptor; import org.eclipse.aether.RepositorySystemSession; import org.eclipse.aether.repository.LocalRepository; import org.eclipse.aether.repository.RemoteRepository; import org.eclipse.aether.repository.WorkspaceRepository; /** * Caches raw plugin descriptors. A raw plugin descriptor is a descriptor that has just been extracted from the plugin * artifact and does not contain any runtime specific data. The cache must not be used for descriptors that hold runtime * data like the plugin realm. Warning: This is an internal utility interface that is only public for * technical reasons, it is not part of the public API. In particular, this interface can be changed or deleted without * prior notice. * * @since 3.0 * @author Benjamin Bentmann */ @Component( role = PluginDescriptorCache.class ) public class DefaultPluginDescriptorCache implements PluginDescriptorCache { private Map descriptors = new HashMap<>( 128 ); public void flush() { descriptors.clear(); } public Key createKey( Plugin plugin, List repositories, RepositorySystemSession session ) { return new CacheKey( plugin, repositories, session ); } public PluginDescriptor get( Key cacheKey ) { return clone( descriptors.get( cacheKey ) ); } public void put( Key cacheKey, PluginDescriptor pluginDescriptor ) { descriptors.put( cacheKey, clone( pluginDescriptor ) ); } protected static PluginDescriptor clone( PluginDescriptor original ) { PluginDescriptor clone = null; if ( original != null ) { clone = new PluginDescriptor(); clone.setGroupId( original.getGroupId() ); clone.setArtifactId( original.getArtifactId() ); clone.setVersion( original.getVersion() ); clone.setGoalPrefix( original.getGoalPrefix() ); clone.setInheritedByDefault( original.isInheritedByDefault() ); clone.setName( original.getName() ); clone.setDescription( original.getDescription() ); clone.setRequiredMavenVersion( original.getRequiredMavenVersion() ); clone.setPluginArtifact( ArtifactUtils.copyArtifactSafe( original.getPluginArtifact() ) ); clone.setComponents( clone( original.getMojos(), clone ) ); clone.setId( original.getId() ); clone.setIsolatedRealm( original.isIsolatedRealm() ); clone.setSource( original.getSource() ); clone.setDependencies( original.getDependencies() ); } return clone; } private static List> clone( List mojos, PluginDescriptor pluginDescriptor ) { List> clones = null; if ( mojos != null ) { clones = new ArrayList<>( mojos.size() ); for ( MojoDescriptor mojo : mojos ) { MojoDescriptor clone = mojo.clone(); clone.setPluginDescriptor( pluginDescriptor ); clones.add( clone ); } } return clones; } private static final class CacheKey implements Key { private final String groupId; private final String artifactId; private final String version; private final WorkspaceRepository workspace; private final LocalRepository localRepo; private final List repositories; private final int hashCode; public CacheKey( Plugin plugin, List repositories, RepositorySystemSession session ) { groupId = plugin.getGroupId(); artifactId = plugin.getArtifactId(); version = plugin.getVersion(); workspace = CacheUtils.getWorkspace( session ); localRepo = session.getLocalRepository(); this.repositories = new ArrayList<>( repositories.size() ); for ( RemoteRepository repository : repositories ) { if ( repository.isRepositoryManager() ) { this.repositories.addAll( repository.getMirroredRepositories() ); } else { this.repositories.add( repository ); } } int hash = 17; hash = hash * 31 + groupId.hashCode(); hash = hash * 31 + artifactId.hashCode(); hash = hash * 31 + version.hashCode(); hash = hash * 31 + hash( workspace ); hash = hash * 31 + localRepo.hashCode(); hash = hash * 31 + CacheUtils.repositoriesHashCode( repositories ); this.hashCode = hash; } @Override public int hashCode() { return hashCode; } @Override public boolean equals( Object obj ) { if ( this == obj ) { return true; } if ( !( obj instanceof CacheKey ) ) { return false; } CacheKey that = (CacheKey) obj; return eq( this.artifactId, that.artifactId ) && eq( this.groupId, that.groupId ) && eq( this.version, that.version ) && eq( this.localRepo, that.localRepo ) && eq( this.workspace, that.workspace ) && CacheUtils.repositoriesEquals( this.repositories, that.repositories ); } @Override public String toString() { return groupId + ':' + artifactId + ':' + version; } private static int hash( Object obj ) { return obj != null ? obj.hashCode() : 0; } private static boolean eq( T s1, T s2 ) { return s1 != null ? s1.equals( s2 ) : s2 == null; } } } maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginRealmCache.java000066400000000000000000000156241317160430700323640ustar00rootroot00000000000000package org.apache.maven.plugin; /* * 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.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; import org.apache.commons.lang3.Validate; import org.apache.maven.artifact.Artifact; import org.apache.maven.model.Plugin; import org.apache.maven.project.MavenProject; import org.codehaus.plexus.classworlds.realm.ClassRealm; import org.codehaus.plexus.classworlds.realm.NoSuchRealmException; import org.codehaus.plexus.component.annotations.Component; import org.codehaus.plexus.personality.plexus.lifecycle.phase.Disposable; import org.eclipse.aether.RepositorySystemSession; import org.eclipse.aether.graph.DependencyFilter; import org.eclipse.aether.repository.LocalRepository; import org.eclipse.aether.repository.RemoteRepository; import org.eclipse.aether.repository.WorkspaceRepository; /** * Default PluginCache implementation. Assumes cached data does not change. */ @Component( role = PluginRealmCache.class ) public class DefaultPluginRealmCache implements PluginRealmCache, Disposable { protected static class CacheKey implements Key { private final Plugin plugin; private final WorkspaceRepository workspace; private final LocalRepository localRepo; private final List repositories; private final ClassLoader parentRealm; private final Map foreignImports; private final DependencyFilter filter; private final int hashCode; public CacheKey( Plugin plugin, ClassLoader parentRealm, Map foreignImports, DependencyFilter dependencyFilter, List repositories, RepositorySystemSession session ) { this.plugin = plugin.clone(); this.workspace = CacheUtils.getWorkspace( session ); this.localRepo = session.getLocalRepository(); this.repositories = new ArrayList<>( repositories.size() ); for ( RemoteRepository repository : repositories ) { if ( repository.isRepositoryManager() ) { this.repositories.addAll( repository.getMirroredRepositories() ); } else { this.repositories.add( repository ); } } this.parentRealm = parentRealm; this.foreignImports = ( foreignImports != null ) ? foreignImports : Collections.emptyMap(); this.filter = dependencyFilter; int hash = 17; hash = hash * 31 + CacheUtils.pluginHashCode( plugin ); hash = hash * 31 + hash( workspace ); hash = hash * 31 + hash( localRepo ); hash = hash * 31 + CacheUtils.repositoriesHashCode( repositories ); hash = hash * 31 + hash( parentRealm ); hash = hash * 31 + this.foreignImports.hashCode(); hash = hash * 31 + hash( dependencyFilter ); this.hashCode = hash; } @Override public String toString() { return plugin.getId(); } @Override public int hashCode() { return hashCode; } private static int hash( Object obj ) { return obj != null ? obj.hashCode() : 0; } @Override public boolean equals( Object o ) { if ( o == this ) { return true; } if ( !( o instanceof CacheKey ) ) { return false; } CacheKey that = (CacheKey) o; return parentRealm == that.parentRealm && CacheUtils.pluginEquals( plugin, that.plugin ) && eq( workspace, that.workspace ) && eq( localRepo, that.localRepo ) && CacheUtils.repositoriesEquals( this.repositories, that.repositories ) && eq( filter, that.filter ) && eq( foreignImports, that.foreignImports ); } private static boolean eq( T s1, T s2 ) { return s1 != null ? s1.equals( s2 ) : s2 == null; } } protected final Map cache = new ConcurrentHashMap<>(); public Key createKey( Plugin plugin, ClassLoader parentRealm, Map foreignImports, DependencyFilter dependencyFilter, List repositories, RepositorySystemSession session ) { return new CacheKey( plugin, parentRealm, foreignImports, dependencyFilter, repositories, session ); } public CacheRecord get( Key key ) { return cache.get( key ); } public CacheRecord put( Key key, ClassRealm pluginRealm, List pluginArtifacts ) { Validate.notNull( pluginRealm, "pluginRealm cannot be null" ); Validate.notNull( pluginArtifacts, "pluginArtifacts cannot be null" ); if ( cache.containsKey( key ) ) { throw new IllegalStateException( "Duplicate plugin realm for plugin " + key ); } CacheRecord record = new CacheRecord( pluginRealm, pluginArtifacts ); cache.put( key, record ); return record; } public void flush() { for ( CacheRecord record : cache.values() ) { ClassRealm realm = record.realm; try { realm.getWorld().disposeRealm( realm.getId() ); } catch ( NoSuchRealmException e ) { // ignore } } cache.clear(); } protected static int pluginHashCode( Plugin plugin ) { return CacheUtils.pluginHashCode( plugin ); } protected static boolean pluginEquals( Plugin a, Plugin b ) { return CacheUtils.pluginEquals( a, b ); } public void register( MavenProject project, Key key, CacheRecord record ) { // default cache does not track plugin usage } public void dispose() { flush(); } } maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/plugin/DefaultProjectArtifactsCache.java000066400000000000000000000177461317160430700334230ustar00rootroot00000000000000package org.apache.maven.plugin; /* * 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.util.ArrayList; import java.util.Collection; import java.util.Collections; import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Set; import java.util.concurrent.ConcurrentHashMap; import org.apache.commons.lang3.Validate; import org.apache.maven.artifact.Artifact; import org.apache.maven.lifecycle.LifecycleExecutionException; import org.apache.maven.model.Plugin; import org.apache.maven.project.MavenProject; import org.codehaus.plexus.component.annotations.Component; import org.eclipse.aether.RepositorySystemSession; import org.eclipse.aether.repository.LocalRepository; import org.eclipse.aether.repository.RemoteRepository; import org.eclipse.aether.repository.WorkspaceRepository; /** * @author Igor Fedorenko * @author Benjamin Bentmann * @author Anton Tanasenko */ @Component( role = ProjectArtifactsCache.class ) public class DefaultProjectArtifactsCache implements ProjectArtifactsCache { protected static class CacheKey implements Key { private final String groupId; private final String artifactId; private final String version; private final Set dependencyArtifacts; private final WorkspaceRepository workspace; private final LocalRepository localRepo; private final List repositories; private final Set collect; private final Set resolve; private boolean aggregating; private final int hashCode; public CacheKey( MavenProject project, List repositories, Collection scopesToCollect, Collection scopesToResolve, boolean aggregating, RepositorySystemSession session ) { groupId = project.getGroupId(); artifactId = project.getArtifactId(); version = project.getVersion(); Set deps = new HashSet<>(); if ( project.getDependencyArtifacts() != null ) { for ( Artifact dep: project.getDependencyArtifacts() ) { deps.add( dep.toString() ); } } dependencyArtifacts = Collections.unmodifiableSet( deps ); workspace = CacheUtils.getWorkspace( session ); this.localRepo = session.getLocalRepository(); this.repositories = new ArrayList<>( repositories.size() ); for ( RemoteRepository repository : repositories ) { if ( repository.isRepositoryManager() ) { this.repositories.addAll( repository.getMirroredRepositories() ); } else { this.repositories.add( repository ); } } collect = scopesToCollect == null ? Collections.emptySet() : Collections.unmodifiableSet( new HashSet<>( scopesToCollect ) ); resolve = scopesToResolve == null ? Collections.emptySet() : Collections.unmodifiableSet( new HashSet<>( scopesToResolve ) ); this.aggregating = aggregating; int hash = 17; hash = hash * 31 + hash( groupId ); hash = hash * 31 + hash( artifactId ); hash = hash * 31 + hash( version ); hash = hash * 31 + hash( dependencyArtifacts ); hash = hash * 31 + hash( workspace ); hash = hash * 31 + hash( localRepo ); hash = hash * 31 + CacheUtils.repositoriesHashCode( repositories ); hash = hash * 31 + hash( collect ); hash = hash * 31 + hash( resolve ); hash = hash * 31 + hash( aggregating ); this.hashCode = hash; } @Override public String toString() { return groupId + ":" + artifactId + ":" + version; } @Override public int hashCode() { return hashCode; } private static int hash( Object obj ) { return obj != null ? obj.hashCode() : 0; } @Override public boolean equals( Object o ) { if ( o == this ) { return true; } if ( !( o instanceof CacheKey ) ) { return false; } CacheKey that = (CacheKey) o; return eq( groupId, that.groupId ) && eq( artifactId, that.artifactId ) && eq( version, that.version ) && eq( dependencyArtifacts, that.dependencyArtifacts ) && eq( workspace, that.workspace ) && eq( localRepo, that.localRepo ) && CacheUtils.repositoriesEquals( repositories, that.repositories ) && eq( collect, that.collect ) && eq( resolve, that.resolve ) && aggregating == that.aggregating; } private static boolean eq( T s1, T s2 ) { return s1 != null ? s1.equals( s2 ) : s2 == null; } } protected final Map cache = new ConcurrentHashMap<>(); public Key createKey( MavenProject project, Collection scopesToCollect, Collection scopesToResolve, boolean aggregating, RepositorySystemSession session ) { return new CacheKey( project, project.getRemoteProjectRepositories(), scopesToCollect, scopesToResolve, aggregating, session ); } public CacheRecord get( Key key ) throws LifecycleExecutionException { CacheRecord cacheRecord = cache.get( key ); if ( cacheRecord != null && cacheRecord.exception != null ) { throw cacheRecord.exception; } return cacheRecord; } public CacheRecord put( Key key, Set projectArtifacts ) { Validate.notNull( projectArtifacts, "projectArtifacts cannot be null" ); assertUniqueKey( key ); CacheRecord record = new CacheRecord( Collections.unmodifiableSet( new HashSet<>( projectArtifacts ) ) ); cache.put( key, record ); return record; } protected void assertUniqueKey( Key key ) { if ( cache.containsKey( key ) ) { throw new IllegalStateException( "Duplicate artifact resolution result for project " + key ); } } public CacheRecord put( Key key, LifecycleExecutionException exception ) { Validate.notNull( exception, "exception cannot be null" ); assertUniqueKey( key ); CacheRecord record = new CacheRecord( exception ); cache.put( key, record ); return record; } public void flush() { cache.clear(); } protected static int pluginHashCode( Plugin plugin ) { return CacheUtils.pluginHashCode( plugin ); } protected static boolean pluginEquals( Plugin a, Plugin b ) { return CacheUtils.pluginEquals( a, b ); } public void register( MavenProject project, Key cacheKey, CacheRecord record ) { // default cache does not track record usage } } maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/plugin/ExtensionRealmCache.java000066400000000000000000000052771317160430700316000ustar00rootroot00000000000000package org.apache.maven.plugin; /* * 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.util.List; import org.apache.maven.artifact.Artifact; import org.apache.maven.project.ExtensionDescriptor; import org.apache.maven.project.MavenProject; import org.codehaus.plexus.classworlds.realm.ClassRealm; /** * Caches extension class realms. Warning: This is an internal utility interface that is only public * for technical reasons, it is not part of the public API. In particular, this interface can be changed or deleted * without prior notice. * * @author Igor Fedorenko * @author Benjamin Bentmann */ public interface ExtensionRealmCache { /** * A cache key. */ interface Key { // marker interface for cache keys } static class CacheRecord { public final ClassRealm realm; public final ExtensionDescriptor descriptor; public final List artifacts; public CacheRecord( ClassRealm realm, ExtensionDescriptor descriptor, List artifacts ) { this.realm = realm; this.descriptor = descriptor; this.artifacts = artifacts; } } Key createKey( List extensionArtifacts ); CacheRecord get( Key key ); CacheRecord put( Key key, ClassRealm extensionRealm, ExtensionDescriptor extensionDescriptor, List artifacts ); void flush(); /** * Registers the specified cache record for usage with the given project. Integrators can use the information * collected from this method in combination with a custom cache implementation to dispose unused records from the * cache. * * @param project The project that employs the plugin realm, must not be {@code null}. * @param record The cache record being used for the project, must not be {@code null}. */ void register( MavenProject project, Key key, CacheRecord record ); } InvalidPluginDescriptorException.java000066400000000000000000000025751317160430700343210ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/pluginpackage org.apache.maven.plugin; /* * 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.util.List; public class InvalidPluginDescriptorException extends Exception { public InvalidPluginDescriptorException( String message, List errors ) { super( toMessage( message, errors ) ); } private static String toMessage( String message, List errors ) { StringBuilder buffer = new StringBuilder( 256 ); buffer.append( message ); for ( String error : errors ) { buffer.append( ", " ).append( error ); } return buffer.toString(); } } maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/plugin/InvalidPluginException.java000066400000000000000000000027461317160430700323410ustar00rootroot00000000000000package org.apache.maven.plugin; /* * 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 org.apache.maven.project.ProjectBuildingException; import org.apache.maven.project.artifact.InvalidDependencyVersionException; /** * Thrown when a plugin is not internally consistent. * * @author Brett Porter */ public class InvalidPluginException extends Exception { public InvalidPluginException( String message, ProjectBuildingException e ) { super( message, e ); } public InvalidPluginException( String message, InvalidDependencyVersionException e ) { super( message, e ); } public InvalidPluginException( String message ) { super( message ); } } maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/plugin/LegacySupport.java000066400000000000000000000042171317160430700305110ustar00rootroot00000000000000package org.apache.maven.plugin; /* * 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 org.apache.maven.execution.MavenSession; import org.eclipse.aether.RepositorySystemSession; /** * Helps to provide backward-compatibility with plugins that use legacy components. Warning: This is an * internal utility interface that is only public for technical reasons, it is not part of the public API. In * particular, this interface can be changed or deleted without prior notice. * * @since 3.0 * @author Benjamin Bentmann */ public interface LegacySupport { /** * Sets the currently active session. Some legacy components are basically stateful and their API is missing * parameters that would be required to delegate to a stateless component. Saving the session (in a thread-local * variable) is our best effort to record any state that is required to enable proper delegation. * * @param session The currently active session, may be {@code null}. */ void setSession( MavenSession session ); /** * Gets the currently active session. * * @return The currently active session or {@code null} if none. */ MavenSession getSession(); /** * Gets the currently active repository session. * * @return The currently active repository session or {@code null} if none. */ RepositorySystemSession getRepositorySession(); } maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/plugin/MavenPluginManager.java000066400000000000000000000145261317160430700314340ustar00rootroot00000000000000package org.apache.maven.plugin; /* * 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.util.List; import org.apache.maven.execution.MavenSession; import org.apache.maven.model.Plugin; import org.apache.maven.plugin.descriptor.MojoDescriptor; import org.apache.maven.plugin.descriptor.PluginDescriptor; import org.apache.maven.project.MavenProject; import org.eclipse.aether.RepositorySystemSession; import org.eclipse.aether.graph.DependencyFilter; import org.eclipse.aether.repository.RemoteRepository; /** * Provides basic services to manage Maven plugins and their mojos. This component is kept general in its design such * that the plugins/mojos can be used in arbitrary contexts. In particular, the mojos can be used for ordinary build * plugins as well as special purpose plugins like reports. * * @since 3.0 * @author Benjamin Bentmann */ public interface MavenPluginManager { /** * Retrieves the descriptor for the specified plugin from its main artifact. * * @param plugin The plugin whose descriptor should be retrieved, must not be {@code null}. * @param repositories The plugin repositories to use for resolving the plugin's main artifact, must not be {@code * null}. * @param session The repository session to use for resolving the plugin's main artifact, must not be {@code null}. * @return The plugin descriptor, never {@code null}. */ PluginDescriptor getPluginDescriptor( Plugin plugin, List repositories, RepositorySystemSession session ) throws PluginResolutionException, PluginDescriptorParsingException, InvalidPluginDescriptorException; /** * Retrieves the descriptor for the specified plugin goal from the plugin's main artifact. * * @param plugin The plugin whose mojo descriptor should be retrieved, must not be {@code null}. * @param goal The simple name of the mojo whose descriptor should be retrieved, must not be {@code null}. * @param repositories The plugin repositories to use for resolving the plugin's main artifact, must not be {@code * null}. * @param session The repository session to use for resolving the plugin's main artifact, must not be {@code null}. * @return The mojo descriptor, never {@code null}. */ MojoDescriptor getMojoDescriptor( Plugin plugin, String goal, List repositories, RepositorySystemSession session ) throws MojoNotFoundException, PluginResolutionException, PluginDescriptorParsingException, InvalidPluginDescriptorException; /** * Verifies the specified plugin is compatible with the current Maven runtime. * * @param pluginDescriptor The descriptor of the plugin to check, must not be {@code null}. */ void checkRequiredMavenVersion( PluginDescriptor pluginDescriptor ) throws PluginIncompatibleException; /** * Sets up the class realm for the specified plugin. Both the class realm and the plugin artifacts that constitute * it will be stored in the plugin descriptor. * * @param pluginDescriptor The plugin descriptor in which to save the class realm and the plugin artifacts, must not * be {@code null}. * @param session The build session from which to pick the current project and repository settings, must not be * {@code null}. * @param parent The parent class realm for the plugin, may be {@code null} to use the Maven core realm. * @param imports The packages/types to import from the parent realm, may be {@code null}. * @param filter The filter used to exclude certain plugin dependencies, may be {@code null}. */ void setupPluginRealm( PluginDescriptor pluginDescriptor, MavenSession session, ClassLoader parent, List imports, DependencyFilter filter ) throws PluginResolutionException, PluginContainerException; /** * Sets up class realm for the specified build extensions plugin. * * @since 3.3.0 */ ExtensionRealmCache.CacheRecord setupExtensionsRealm( MavenProject project, Plugin plugin, RepositorySystemSession session ) throws PluginManagerException; /** * Looks up the mojo for the specified mojo execution and populates its parameters from the configuration given by * the mojo execution. The mojo/plugin descriptor associated with the mojo execution provides the class realm to * lookup the mojo from. Warning: The returned mojo instance must be released via * {@link #releaseMojo(Object, MojoExecution)} when the mojo is no longer needed to free any resources allocated for * it. * * @param mojoInterface The component role of the mojo, must not be {@code null}. * @param session The build session in whose context the mojo will be used, must not be {@code null}. * @param mojoExecution The mojo execution to retrieve the mojo for, must not be {@code null}. * @return The ready-to-execute mojo, never {@code null}. */ T getConfiguredMojo( Class mojoInterface, MavenSession session, MojoExecution mojoExecution ) throws PluginConfigurationException, PluginContainerException; /** * Releases the specified mojo back to the container. * * @param mojo The mojo to release, may be {@code null}. * @param mojoExecution The mojo execution the mojo was originally retrieved for, must not be {@code null}. */ void releaseMojo( Object mojo, MojoExecution mojoExecution ); } maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/plugin/MavenPluginValidator.java000066400000000000000000000047041317160430700320040ustar00rootroot00000000000000package org.apache.maven.plugin; /* * 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.util.ArrayList; import java.util.List; import org.apache.maven.artifact.Artifact; import org.apache.maven.plugin.descriptor.PluginDescriptor; public class MavenPluginValidator { private final Artifact pluginArtifact; private List errors = new ArrayList<>(); private boolean firstDescriptor = true; public MavenPluginValidator( Artifact pluginArtifact ) { this.pluginArtifact = pluginArtifact; } public void validate( PluginDescriptor pluginDescriptor ) { /* * NOTE: For plugins that depend on other plugin artifacts the plugin realm contains more than one plugin * descriptor. However, only the first descriptor is of interest. */ if ( !firstDescriptor ) { return; } firstDescriptor = false; if ( !pluginArtifact.getGroupId().equals( pluginDescriptor.getGroupId() ) ) { errors.add( "Plugin's descriptor contains the wrong group ID: " + pluginDescriptor.getGroupId() ); } if ( !pluginArtifact.getArtifactId().equals( pluginDescriptor.getArtifactId() ) ) { errors.add( "Plugin's descriptor contains the wrong artifact ID: " + pluginDescriptor.getArtifactId() ); } if ( !pluginArtifact.getBaseVersion().equals( pluginDescriptor.getVersion() ) ) { errors.add( "Plugin's descriptor contains the wrong version: " + pluginDescriptor.getVersion() ); } } public boolean hasErrors() { return !errors.isEmpty(); } public List getErrors() { return errors; } } maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/plugin/MojoExecution.java000066400000000000000000000134631317160430700305030ustar00rootroot00000000000000package org.apache.maven.plugin; /* * 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.util.LinkedHashMap; import java.util.List; import java.util.Map; import org.apache.maven.model.Plugin; import org.apache.maven.plugin.descriptor.MojoDescriptor; import org.codehaus.plexus.util.xml.Xpp3Dom; public class MojoExecution { private Plugin plugin; private String goal; private String executionId; private MojoDescriptor mojoDescriptor; private Xpp3Dom configuration; /** * Describes the source of an execution. */ public enum Source { /** * An execution that originates from the direct invocation of a goal from the CLI. */ CLI, /** * An execution that originates from a goal bound to a lifecycle phase. */ LIFECYCLE, } private Source source = Source.LIFECYCLE; /** * The phase may or may not have been bound to a phase but once the plan has been calculated we know what phase * this mojo execution is going to run in. */ private String lifecyclePhase; /** * The executions to fork before this execution, indexed by the groupId:artifactId:version of the project on which * the forked execution are to be run and in reactor build order. */ private Map> forkedExecutions = new LinkedHashMap<>(); public MojoExecution( Plugin plugin, String goal, String executionId ) { this.plugin = plugin; this.goal = goal; this.executionId = executionId; } public MojoExecution( MojoDescriptor mojoDescriptor ) { this.mojoDescriptor = mojoDescriptor; this.executionId = null; this.configuration = null; } public MojoExecution( MojoDescriptor mojoDescriptor, String executionId, Source source ) { this.mojoDescriptor = mojoDescriptor; this.executionId = executionId; this.configuration = null; this.source = source; } public MojoExecution( MojoDescriptor mojoDescriptor, String executionId ) { this.mojoDescriptor = mojoDescriptor; this.executionId = executionId; this.configuration = null; } public MojoExecution( MojoDescriptor mojoDescriptor, Xpp3Dom configuration ) { this.mojoDescriptor = mojoDescriptor; this.configuration = configuration; this.executionId = null; } /** * Gets the source of this execution. * * @return The source of this execution or {@code null} if unknown. */ public Source getSource() { return source; } public String getExecutionId() { return executionId; } public Plugin getPlugin() { if ( mojoDescriptor != null ) { return mojoDescriptor.getPluginDescriptor().getPlugin(); } return plugin; } public MojoDescriptor getMojoDescriptor() { return mojoDescriptor; } public Xpp3Dom getConfiguration() { return configuration; } public void setConfiguration( Xpp3Dom configuration ) { this.configuration = configuration; } public String identify() { StringBuilder sb = new StringBuilder( 256 ); sb.append( executionId ); sb.append( configuration.toString() ); return sb.toString(); } public String getLifecyclePhase() { return lifecyclePhase; } public void setLifecyclePhase( String lifecyclePhase ) { this.lifecyclePhase = lifecyclePhase; } @Override public String toString() { StringBuilder buffer = new StringBuilder( 128 ); if ( mojoDescriptor != null ) { buffer.append( mojoDescriptor.getId() ); } buffer.append( " {execution: " ).append( executionId ).append( '}' ); return buffer.toString(); } public String getGroupId() { if ( mojoDescriptor != null ) { return mojoDescriptor.getPluginDescriptor().getGroupId(); } return plugin.getGroupId(); } public String getArtifactId() { if ( mojoDescriptor != null ) { return mojoDescriptor.getPluginDescriptor().getArtifactId(); } return plugin.getArtifactId(); } public String getVersion() { if ( mojoDescriptor != null ) { return mojoDescriptor.getPluginDescriptor().getVersion(); } return plugin.getVersion(); } public String getGoal() { if ( mojoDescriptor != null ) { return mojoDescriptor.getGoal(); } return goal; } public void setMojoDescriptor( MojoDescriptor mojoDescriptor ) { this.mojoDescriptor = mojoDescriptor; } public Map> getForkedExecutions() { return forkedExecutions; } public void setForkedExecutions( String projectKey, List forkedExecutions ) { this.forkedExecutions.put( projectKey, forkedExecutions ); } } maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/plugin/PluginArtifactsCache.java000066400000000000000000000056541317160430700317410ustar00rootroot00000000000000package org.apache.maven.plugin; /* * 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.util.List; import org.apache.maven.artifact.Artifact; import org.apache.maven.model.Plugin; import org.apache.maven.project.MavenProject; import org.eclipse.aether.RepositorySystemSession; import org.eclipse.aether.graph.DependencyFilter; import org.eclipse.aether.repository.RemoteRepository; /** * Caches plugin artifacts. Warning: This is an internal utility interface that is only public for * technical reasons, it is not part of the public API. In particular, this interface can be changed or deleted without * prior notice. * * @author Igor Fedorenko * @author Benjamin Bentmann */ public interface PluginArtifactsCache { /** * A cache key. */ interface Key { // marker interface for cache keys } static class CacheRecord { public final List artifacts; public final PluginResolutionException exception; public CacheRecord( List artifacts ) { this.artifacts = artifacts; this.exception = null; } public CacheRecord( PluginResolutionException exception ) { this.artifacts = null; this.exception = exception; } } Key createKey( Plugin plugin, DependencyFilter extensionFilter, List repositories, RepositorySystemSession session ); CacheRecord get( Key key ) throws PluginResolutionException; CacheRecord put( Key key, List pluginArtifacts ); CacheRecord put( Key key, PluginResolutionException e ); void flush(); /** * Registers the specified cache record for usage with the given project. Integrators can use the information * collected from this method in combination with a custom cache implementation to dispose unused records from the * cache. * * @param project The project that employs the plugin realm, must not be {@code null}. * @param record The cache record being used for the project, must not be {@code null}. */ void register( MavenProject project, Key cacheKey, CacheRecord record ); } maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/plugin/PluginConfigurationException.java000066400000000000000000000054451317160430700335610ustar00rootroot00000000000000package org.apache.maven.plugin; /* * 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 org.apache.maven.plugin.descriptor.PluginDescriptor; import org.codehaus.plexus.component.configurator.ComponentConfigurationException; import org.codehaus.plexus.component.configurator.expression.ExpressionEvaluationException; import org.codehaus.plexus.component.repository.exception.ComponentLookupException; /** * @author Jason van Zyl */ public class PluginConfigurationException extends Exception { private PluginDescriptor pluginDescriptor; private String originalMessage; public PluginConfigurationException( PluginDescriptor pluginDescriptor, String originalMessage ) { super( originalMessage ); this.pluginDescriptor = pluginDescriptor; this.originalMessage = originalMessage; } public PluginConfigurationException( PluginDescriptor pluginDescriptor, String originalMessage, Throwable cause ) { super( originalMessage, cause ); this.pluginDescriptor = pluginDescriptor; this.originalMessage = originalMessage; } public PluginConfigurationException( PluginDescriptor pluginDescriptor, String originalMessage, ExpressionEvaluationException cause ) { super( originalMessage, cause ); this.pluginDescriptor = pluginDescriptor; this.originalMessage = originalMessage; } public PluginConfigurationException( PluginDescriptor pluginDescriptor, String originalMessage, ComponentConfigurationException cause ) { super( originalMessage, cause ); this.pluginDescriptor = pluginDescriptor; this.originalMessage = originalMessage; } public PluginConfigurationException( PluginDescriptor pluginDescriptor, String originalMessage, ComponentLookupException cause ) { super( originalMessage, cause ); this.pluginDescriptor = pluginDescriptor; this.originalMessage = originalMessage; } } maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/plugin/PluginContainerException.java000066400000000000000000000060161317160430700326670ustar00rootroot00000000000000package org.apache.maven.plugin; /* * 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 org.apache.maven.model.Plugin; import org.apache.maven.plugin.descriptor.MojoDescriptor; import org.codehaus.plexus.classworlds.realm.ClassRealm; import org.codehaus.plexus.component.repository.exception.ComponentLookupException; import org.codehaus.plexus.component.repository.exception.ComponentRepositoryException; import org.codehaus.plexus.configuration.PlexusConfigurationException; /** * Exception which occurs to indicate that the plugin cannot be initialized due * to some deeper problem with Plexus. Context information includes the groupId, * artifactId, and version for the plugin; at times, the goal name for which * execution failed; a message detailing the problem; the ClassRealm used to * lookup the plugin; and the Plexus exception that caused this error. * * @author jdcasey * */ public class PluginContainerException extends PluginManagerException { private ClassRealm pluginRealm; public PluginContainerException( MojoDescriptor mojoDescriptor, ClassRealm pluginRealm, String message, Throwable e ) { super( mojoDescriptor, message, e ); this.pluginRealm = pluginRealm; } public PluginContainerException( MojoDescriptor mojoDescriptor, ClassRealm pluginRealm, String message, ComponentLookupException e ) { super( mojoDescriptor, message, e ); this.pluginRealm = pluginRealm; } public PluginContainerException( Plugin plugin, ClassRealm pluginRealm, String message, Throwable e ) { super( plugin, message, e ); this.pluginRealm = pluginRealm; } public PluginContainerException( Plugin plugin, ClassRealm pluginRealm, String message, PlexusConfigurationException e ) { super( plugin, message, e ); this.pluginRealm = pluginRealm; } public PluginContainerException( Plugin plugin, ClassRealm pluginRealm, String message, ComponentRepositoryException e ) { super( plugin, message, e ); this.pluginRealm = pluginRealm; } public ClassRealm getPluginRealm() { return pluginRealm; } } maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/plugin/PluginDescriptorCache.java000066400000000000000000000037211317160430700321300ustar00rootroot00000000000000package org.apache.maven.plugin; /* * 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.util.List; import org.apache.maven.model.Plugin; import org.apache.maven.plugin.descriptor.PluginDescriptor; import org.eclipse.aether.RepositorySystemSession; import org.eclipse.aether.repository.RemoteRepository; /** * Caches raw plugin descriptors. A raw plugin descriptor is a descriptor that has just been extracted from the plugin * artifact and does not contain any runtime specific data. The cache must not be used for descriptors that hold runtime * data like the plugin realm. Warning: This is an internal utility interface that is only public for * technical reasons, it is not part of the public API. In particular, this interface can be changed or deleted without * prior notice. * * @since 3.0 * @author Benjamin Bentmann */ public interface PluginDescriptorCache { /** * A cache key. */ interface Key { // marker interface for cache keys } Key createKey( Plugin plugin, List repositories, RepositorySystemSession session ); void put( Key key, PluginDescriptor pluginDescriptor ); PluginDescriptor get( Key key ); void flush(); } PluginDescriptorParsingException.java000066400000000000000000000032151317160430700343260ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/pluginpackage org.apache.maven.plugin; /* * 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 org.apache.maven.model.Plugin; /** * @author Jason van Zyl */ public class PluginDescriptorParsingException extends Exception { public PluginDescriptorParsingException( Plugin plugin, String descriptorLocation, Throwable e ) { super( createMessage( plugin, descriptorLocation, e ), e ); } private static String createMessage( Plugin plugin, String descriptorLocation, Throwable e ) { String message = "Failed to parse plugin descriptor"; if ( plugin != null ) { message += " for " + plugin.getId(); } if ( descriptorLocation != null ) { message += " (" + descriptorLocation + ")"; } if ( e != null ) { message += ": " + e.getMessage(); } return message; } } maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/plugin/PluginExecutionException.java000066400000000000000000000057231317160430700327140ustar00rootroot00000000000000package org.apache.maven.plugin; /* * 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 org.apache.maven.project.DuplicateArtifactAttachmentException; import org.apache.maven.project.MavenProject; import org.codehaus.plexus.util.StringUtils; public class PluginExecutionException extends PluginManagerException { private final MojoExecution mojoExecution; public PluginExecutionException( MojoExecution mojoExecution, MavenProject project, String message ) { super( mojoExecution.getMojoDescriptor(), project, message ); this.mojoExecution = mojoExecution; } public PluginExecutionException( MojoExecution mojoExecution, MavenProject project, String message, Throwable cause ) { super( mojoExecution.getMojoDescriptor(), project, message, cause ); this.mojoExecution = mojoExecution; } public PluginExecutionException( MojoExecution mojoExecution, MavenProject project, Exception cause ) { super( mojoExecution.getMojoDescriptor(), project, constructMessage( mojoExecution, cause ), cause ); this.mojoExecution = mojoExecution; } public PluginExecutionException( MojoExecution mojoExecution, MavenProject project, DuplicateArtifactAttachmentException cause ) { super( mojoExecution.getMojoDescriptor(), project, constructMessage( mojoExecution, cause ), cause ); this.mojoExecution = mojoExecution; } public MojoExecution getMojoExecution() { return mojoExecution; } private static String constructMessage( MojoExecution mojoExecution, Throwable cause ) { String message; if ( mojoExecution != null ) { message = "Execution " + mojoExecution.getExecutionId() + " of goal " + mojoExecution.getMojoDescriptor().getId() + " failed"; } else { message = "Mojo execution failed"; } if ( cause != null && StringUtils.isNotEmpty( cause.getMessage() ) ) { message += ": " + cause.getMessage(); } else { message += "."; } return message; } } maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/plugin/PluginIncompatibleException.java000066400000000000000000000022371317160430700333540ustar00rootroot00000000000000package org.apache.maven.plugin; /* * 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 org.apache.maven.model.Plugin; /** * Signals a plugin which is not compatible with the current Maven runtime. */ public class PluginIncompatibleException extends PluginManagerException { public PluginIncompatibleException( Plugin plugin, String message ) { super( plugin, message, (Throwable) null ); } } maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/plugin/PluginLoaderException.java000066400000000000000000000073631317160430700321610ustar00rootroot00000000000000package org.apache.maven.plugin; /* * 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 org.apache.maven.artifact.resolver.ArtifactNotFoundException; import org.apache.maven.artifact.resolver.ArtifactResolutionException; import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException; import org.apache.maven.model.Plugin; import org.apache.maven.model.ReportPlugin; import org.apache.maven.plugin.version.PluginVersionNotFoundException; import org.apache.maven.plugin.version.PluginVersionResolutionException; /** * Signifies a failure to load a plugin. This is used to abstract the specific errors which may be * encountered at lower levels, and provide a dependable interface to the plugin-loading framework. * * @author jdcasey * */ public class PluginLoaderException extends Exception { private String pluginKey; public PluginLoaderException( Plugin plugin, String message, ArtifactResolutionException cause ) { super( message, cause ); pluginKey = plugin.getKey(); } public PluginLoaderException( Plugin plugin, String message, ArtifactNotFoundException cause ) { super( message, cause ); pluginKey = plugin.getKey(); } public PluginLoaderException( Plugin plugin, String message, PluginNotFoundException cause ) { super( message, cause ); pluginKey = plugin.getKey(); } public PluginLoaderException( Plugin plugin, String message, PluginVersionResolutionException cause ) { super( message, cause ); pluginKey = plugin.getKey(); } public PluginLoaderException( Plugin plugin, String message, InvalidVersionSpecificationException cause ) { super( message, cause ); pluginKey = plugin.getKey(); } public PluginLoaderException( Plugin plugin, String message, InvalidPluginException cause ) { super( message, cause ); pluginKey = plugin.getKey(); } public PluginLoaderException( Plugin plugin, String message, PluginManagerException cause ) { super( message, cause ); pluginKey = plugin.getKey(); } public PluginLoaderException( Plugin plugin, String message, PluginVersionNotFoundException cause ) { super( message, cause ); pluginKey = plugin.getKey(); } public PluginLoaderException( Plugin plugin, String message ) { super( message ); pluginKey = plugin.getKey(); } public PluginLoaderException( String message ) { super( message ); } public PluginLoaderException( String message, Throwable cause ) { super( message, cause ); } public PluginLoaderException( ReportPlugin plugin, String message, Throwable cause ) { super( message, cause ); pluginKey = plugin.getKey(); } public PluginLoaderException( ReportPlugin plugin, String message ) { super( message ); pluginKey = plugin.getKey(); } public String getPluginKey() { return pluginKey; } } maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/plugin/PluginManager.java000066400000000000000000000074141317160430700304430ustar00rootroot00000000000000package org.apache.maven.plugin; /* * 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 org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.resolver.ArtifactNotFoundException; import org.apache.maven.artifact.resolver.ArtifactResolutionException; import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException; import org.apache.maven.execution.MavenSession; import org.apache.maven.model.Plugin; import org.apache.maven.plugin.descriptor.PluginDescriptor; import org.apache.maven.plugin.version.PluginVersionNotFoundException; import org.apache.maven.plugin.version.PluginVersionResolutionException; import org.apache.maven.project.MavenProject; import org.apache.maven.project.artifact.InvalidDependencyVersionException; import org.apache.maven.settings.Settings; import org.codehaus.plexus.component.repository.exception.ComponentLookupException; import java.util.Map; /** * @author Jason van Zyl */ @Deprecated public interface PluginManager { String ROLE = PluginManager.class.getName(); void executeMojo( MavenProject project, MojoExecution execution, MavenSession session ) throws MojoExecutionException, ArtifactResolutionException, MojoFailureException, ArtifactNotFoundException, InvalidDependencyVersionException, PluginManagerException, PluginConfigurationException; PluginDescriptor getPluginDescriptorForPrefix( String prefix ); Plugin getPluginDefinitionForPrefix( String prefix, MavenSession session, MavenProject project ); PluginDescriptor verifyPlugin( Plugin plugin, MavenProject project, Settings settings, ArtifactRepository localRepository ) throws ArtifactResolutionException, PluginVersionResolutionException, ArtifactNotFoundException, InvalidVersionSpecificationException, InvalidPluginException, PluginManagerException, PluginNotFoundException, PluginVersionNotFoundException; Object getPluginComponent( Plugin plugin, String role, String roleHint ) throws PluginManagerException, ComponentLookupException; Map getPluginComponents( Plugin plugin, String role ) throws ComponentLookupException, PluginManagerException; /** * @since 2.2.1 */ PluginDescriptor loadPluginDescriptor( Plugin plugin, MavenProject project, MavenSession session ) throws ArtifactResolutionException, PluginVersionResolutionException, ArtifactNotFoundException, InvalidVersionSpecificationException, InvalidPluginException, PluginManagerException, PluginNotFoundException, PluginVersionNotFoundException; /** * @since 2.2.1 */ PluginDescriptor loadPluginFully( Plugin plugin, MavenProject project, MavenSession session ) throws ArtifactResolutionException, PluginVersionResolutionException, ArtifactNotFoundException, InvalidVersionSpecificationException, InvalidPluginException, PluginManagerException, PluginNotFoundException, PluginVersionNotFoundException; } maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/plugin/PluginManagerException.java000066400000000000000000000146731317160430700323270ustar00rootroot00000000000000package org.apache.maven.plugin; /* * 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 org.apache.maven.artifact.versioning.InvalidVersionSpecificationException; import org.apache.maven.model.Plugin; import org.apache.maven.plugin.descriptor.MojoDescriptor; import org.apache.maven.plugin.descriptor.PluginDescriptor; import org.apache.maven.project.MavenProject; import org.codehaus.plexus.PlexusContainerException; import org.codehaus.plexus.classworlds.realm.NoSuchRealmException; import org.codehaus.plexus.component.repository.exception.ComponentRepositoryException; import org.codehaus.plexus.configuration.PlexusConfigurationException; /** * Exception in the plugin manager. * * @author Brett Porter */ public class PluginManagerException extends Exception { private final String pluginGroupId; private final String pluginArtifactId; private final String pluginVersion; private String goal; private MavenProject project; protected PluginManagerException( Plugin plugin, String message, MavenProject project, Throwable cause ) { super( message, cause ); this.project = project; pluginGroupId = plugin.getGroupId(); pluginArtifactId = plugin.getArtifactId(); pluginVersion = plugin.getVersion(); } public PluginManagerException( Plugin plugin, String message, Throwable cause ) { super( message, cause ); pluginGroupId = plugin.getGroupId(); pluginArtifactId = plugin.getArtifactId(); pluginVersion = plugin.getVersion(); } protected PluginManagerException( MojoDescriptor mojoDescriptor, String message, Throwable cause ) { super( message, cause ); pluginGroupId = mojoDescriptor.getPluginDescriptor().getGroupId(); pluginArtifactId = mojoDescriptor.getPluginDescriptor().getArtifactId(); pluginVersion = mojoDescriptor.getPluginDescriptor().getVersion(); goal = mojoDescriptor.getGoal(); } protected PluginManagerException( MojoDescriptor mojoDescriptor, MavenProject project, String message ) { super( message ); this.project = project; pluginGroupId = mojoDescriptor.getPluginDescriptor().getGroupId(); pluginArtifactId = mojoDescriptor.getPluginDescriptor().getArtifactId(); pluginVersion = mojoDescriptor.getPluginDescriptor().getVersion(); goal = mojoDescriptor.getGoal(); } protected PluginManagerException( MojoDescriptor mojoDescriptor, MavenProject project, String message, Throwable cause ) { super( message, cause ); this.project = project; pluginGroupId = mojoDescriptor.getPluginDescriptor().getGroupId(); pluginArtifactId = mojoDescriptor.getPluginDescriptor().getArtifactId(); pluginVersion = mojoDescriptor.getPluginDescriptor().getVersion(); goal = mojoDescriptor.getGoal(); } public PluginManagerException( Plugin plugin, InvalidVersionSpecificationException cause ) { super( cause ); pluginGroupId = plugin.getGroupId(); pluginArtifactId = plugin.getArtifactId(); pluginVersion = plugin.getVersion(); } public PluginManagerException( Plugin plugin, String message, PlexusConfigurationException cause ) { super( message, cause ); pluginGroupId = plugin.getGroupId(); pluginArtifactId = plugin.getArtifactId(); pluginVersion = plugin.getVersion(); } public PluginManagerException( Plugin plugin, String message, ComponentRepositoryException cause ) { super( message, cause ); pluginGroupId = plugin.getGroupId(); pluginArtifactId = plugin.getArtifactId(); pluginVersion = plugin.getVersion(); } public PluginManagerException( MojoDescriptor mojoDescriptor, MavenProject project, String message, NoSuchRealmException cause ) { super( message, cause ); this.project = project; pluginGroupId = mojoDescriptor.getPluginDescriptor().getGroupId(); pluginArtifactId = mojoDescriptor.getPluginDescriptor().getArtifactId(); pluginVersion = mojoDescriptor.getPluginDescriptor().getVersion(); goal = mojoDescriptor.getGoal(); } public PluginManagerException( MojoDescriptor mojoDescriptor, String message, MavenProject project, PlexusContainerException cause ) { super( message, cause ); this.project = project; PluginDescriptor pd = mojoDescriptor.getPluginDescriptor(); pluginGroupId = pd.getGroupId(); pluginArtifactId = pd.getArtifactId(); pluginVersion = pd.getVersion(); goal = mojoDescriptor.getGoal(); } public PluginManagerException( Plugin plugin, String message, PlexusContainerException cause ) { super( message, cause ); pluginGroupId = plugin.getGroupId(); pluginArtifactId = plugin.getArtifactId(); pluginVersion = plugin.getVersion(); } public PluginManagerException( Plugin plugin, String message, MavenProject project ) { super( message ); pluginGroupId = plugin.getGroupId(); pluginArtifactId = plugin.getArtifactId(); pluginVersion = plugin.getVersion(); this.project = project; } public String getPluginGroupId() { return pluginGroupId; } public String getPluginArtifactId() { return pluginArtifactId; } public String getPluginVersion() { return pluginVersion; } public String getGoal() { return goal; } public MavenProject getProject() { return project; } } maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/plugin/PluginNotFoundException.java000066400000000000000000000042601317160430700325000ustar00rootroot00000000000000package org.apache.maven.plugin; /* * 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.util.List; import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.resolver.AbstractArtifactResolutionException; import org.apache.maven.artifact.resolver.ArtifactNotFoundException; import org.apache.maven.model.Plugin; /** * Exception occurring trying to resolve a plugin. * * @author Brett Porter */ public class PluginNotFoundException extends AbstractArtifactResolutionException { private Plugin plugin; public PluginNotFoundException( Plugin plugin, ArtifactNotFoundException e ) { super( "Plugin could not be found - check that the goal name is correct: " + e.getMessage(), e.getGroupId(), e.getArtifactId(), e.getVersion(), "maven-plugin", null, e.getRemoteRepositories(), null, e.getCause() ); this.plugin = plugin; } public PluginNotFoundException( Plugin plugin, List remoteRepositories ) { super( "Plugin could not be found, please check its coordinates for typos and ensure the required" + " plugin repositories are defined in the POM", plugin.getGroupId(), plugin.getArtifactId(), plugin.getVersion(), "maven-plugin", null, remoteRepositories, null ); this.plugin = plugin; } public Plugin getPlugin() { return plugin; } } maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/plugin/PluginParameterException.java000066400000000000000000000150401317160430700326620ustar00rootroot00000000000000package org.apache.maven.plugin; /* * 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.util.Collection; import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Properties; import org.apache.maven.plugin.descriptor.MojoDescriptor; import org.apache.maven.plugin.descriptor.Parameter; import org.codehaus.plexus.util.StringUtils; public class PluginParameterException extends PluginConfigurationException { private final List parameters; private final MojoDescriptor mojo; public PluginParameterException( MojoDescriptor mojo, List parameters ) { super( mojo.getPluginDescriptor(), "The parameters " + format( parameters ) + " for goal " + mojo.getRoleHint() + " are missing or invalid" ); this.mojo = mojo; this.parameters = parameters; } private static String format( List parameters ) { StringBuilder buffer = new StringBuilder( 128 ); if ( parameters != null ) { for ( Parameter parameter : parameters ) { if ( buffer.length() > 0 ) { buffer.append( ", " ); } buffer.append( '\'' ).append( parameter.getName() ).append( '\'' ); } } return buffer.toString(); } public MojoDescriptor getMojoDescriptor() { return mojo; } public List getParameters() { return parameters; } private static void decomposeParameterIntoUserInstructions( MojoDescriptor mojo, Parameter param, StringBuilder messageBuffer ) { String expression = param.getExpression(); if ( param.isEditable() ) { boolean isArray = param.getType().endsWith( "[]" ); boolean isCollection = false; boolean isMap = false; boolean isProperties = false; if ( !isArray ) { try { //assuming Type is available in current ClassLoader isCollection = Collection.class.isAssignableFrom( Class.forName( param.getType() ) ); isMap = Map.class.isAssignableFrom( Class.forName( param.getType() ) ); isProperties = Properties.class.isAssignableFrom( Class.forName( param.getType() ) ); } catch ( ClassNotFoundException e ) { // assume it is not assignable from Collection or Map } } messageBuffer.append( "Inside the definition for plugin \'" ); messageBuffer.append( mojo.getPluginDescriptor().getArtifactId() ); messageBuffer.append( "\', specify the following:\n\n\n ...\n" ); messageBuffer.append( " <" ).append( param.getName() ).append( '>' ); if ( isArray || isCollection ) { messageBuffer.append( '\n' ); messageBuffer.append( " " ); } else if ( isProperties ) { messageBuffer.append( '\n' ); messageBuffer.append( " \n" ); messageBuffer.append( " KEY\n" ); messageBuffer.append( " " ); } else if ( isMap ) { messageBuffer.append( '\n' ); messageBuffer.append( " " ); } messageBuffer.append( "VALUE" ); if ( isArray || isCollection ) { messageBuffer.append( "\n" ); messageBuffer.append( " " ); } else if ( isProperties ) { messageBuffer.append( "\n" ); messageBuffer.append( " \n" ); messageBuffer.append( " " ); } else if ( isMap ) { messageBuffer.append( "\n" ); messageBuffer.append( " " ); } messageBuffer.append( "\n" ); messageBuffer.append( "" ); String alias = param.getAlias(); if ( StringUtils.isNotEmpty( alias ) && !alias.equals( param.getName() ) ) { messageBuffer.append( "\n\n-OR-\n\n\n ...\n <" ).append( alias ).append( ">VALUE\n\n" ); } } if ( StringUtils.isEmpty( expression ) ) { messageBuffer.append( '.' ); } else { if ( param.isEditable() ) { messageBuffer.append( "\n\n-OR-\n\n" ); } //addParameterUsageInfo( expression, messageBuffer ); } } public String buildDiagnosticMessage() { StringBuilder messageBuffer = new StringBuilder( 256 ); List params = getParameters(); MojoDescriptor mojo = getMojoDescriptor(); messageBuffer.append( "One or more required plugin parameters are invalid/missing for \'" ) .append( mojo.getPluginDescriptor().getGoalPrefix() ).append( ':' ).append( mojo.getGoal() ) .append( "\'\n" ); int idx = 0; for ( Iterator it = params.iterator(); it.hasNext(); idx++ ) { Parameter param = it.next(); messageBuffer.append( "\n[" ).append( idx ).append( "] " ); decomposeParameterIntoUserInstructions( mojo, param, messageBuffer ); messageBuffer.append( '\n' ); } return messageBuffer.toString(); } } PluginParameterExpressionEvaluator.java000066400000000000000000000444221317160430700346750ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/pluginpackage org.apache.maven.plugin; /* * 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.File; import java.util.Properties; import org.apache.maven.execution.MavenSession; import org.apache.maven.plugin.descriptor.MojoDescriptor; import org.apache.maven.plugin.descriptor.PluginDescriptor; import org.apache.maven.project.MavenProject; import org.apache.maven.project.path.PathTranslator; import org.codehaus.plexus.component.configurator.expression.ExpressionEvaluationException; import org.codehaus.plexus.component.configurator.expression.TypeAwareExpressionEvaluator; import org.codehaus.plexus.logging.Logger; import org.codehaus.plexus.util.introspection.ReflectionValueExtractor; /** * Evaluator for plugin parameters expressions. Content surrounded by ${ and } is evaluated. * Recognized values are: * * * * * * * * * * * * * * * * * * * * * * * * * * *
expression evaluation result
session the actual {@link MavenSession}
session.* (since Maven 3)
localRepository {@link MavenSession#getLocalRepository()}
reactorProjects {@link MavenSession#getProjects()}
repositorySystemSession (since Maven 3){@link MavenSession#getRepositorySession()}
project {@link MavenSession#getCurrentProject()}
project.*
pom.* (since Maven 3)same as project.*
executedProject {@link MavenProject#getExecutionProject()}
settings {@link MavenSession#getSettings()}
settings.*
basedir {@link MavenSession#getExecutionRootDirectory()} or * System.getProperty( "user.dir" ) if null
mojoExecution the actual {@link MojoExecution}
mojo (since Maven 3)same as mojoExecution
mojo.* (since Maven 3)
plugin (since Maven 3){@link MojoExecution#getMojoDescriptor()}.{@link MojoDescriptor#getPluginDescriptor() * getPluginDescriptor()}
plugin.*
* system properties
* project properties
* Notice: reports was supported in Maven 2.x but was removed in Maven 3 * * @author Jason van Zyl * @see MavenSession * @see MojoExecution */ public class PluginParameterExpressionEvaluator implements TypeAwareExpressionEvaluator { private MavenSession session; private MojoExecution mojoExecution; private MavenProject project; private String basedir; private Properties properties; @Deprecated //TODO used by the Enforcer plugin public PluginParameterExpressionEvaluator( MavenSession session, MojoExecution mojoExecution, PathTranslator pathTranslator, Logger logger, MavenProject project, Properties properties ) { this( session, mojoExecution ); } public PluginParameterExpressionEvaluator( MavenSession session ) { this( session, null ); } public PluginParameterExpressionEvaluator( MavenSession session, MojoExecution mojoExecution ) { this.session = session; this.mojoExecution = mojoExecution; this.properties = new Properties(); this.project = session.getCurrentProject(); // // Maven4: We may want to evaluate how this is used but we add these separate as the // getExecutionProperties is deprecated in MavenSession. // this.properties.putAll( session.getUserProperties() ); this.properties.putAll( session.getSystemProperties() ); String basedir = null; if ( project != null ) { File projectFile = project.getBasedir(); // this should always be the case for non-super POM instances... if ( projectFile != null ) { basedir = projectFile.getAbsolutePath(); } } if ( basedir == null ) { basedir = session.getExecutionRootDirectory(); } if ( basedir == null ) { basedir = System.getProperty( "user.dir" ); } this.basedir = basedir; } @Override public Object evaluate( String expr ) throws ExpressionEvaluationException { return evaluate( expr, null ); } @Override public Object evaluate( String expr, Class type ) throws ExpressionEvaluationException { Object value = null; if ( expr == null ) { return null; } String expression = stripTokens( expr ); if ( expression.equals( expr ) ) { int index = expr.indexOf( "${" ); if ( index >= 0 ) { int lastIndex = expr.indexOf( '}', index ); if ( lastIndex >= 0 ) { String retVal = expr.substring( 0, index ); if ( ( index > 0 ) && ( expr.charAt( index - 1 ) == '$' ) ) { retVal += expr.substring( index + 1, lastIndex + 1 ); } else { Object subResult = evaluate( expr.substring( index, lastIndex + 1 ) ); if ( subResult != null ) { retVal += subResult; } else { retVal += "$" + expr.substring( index + 1, lastIndex + 1 ); } } retVal += evaluate( expr.substring( lastIndex + 1 ) ); return retVal; } } // Was not an expression if ( expression.contains( "$$" ) ) { return expression.replaceAll( "\\$\\$", "\\$" ); } else { return expression; } } MojoDescriptor mojoDescriptor = mojoExecution.getMojoDescriptor(); if ( "localRepository".equals( expression ) ) { value = session.getLocalRepository(); } else if ( "session".equals( expression ) ) { value = session; } else if ( expression.startsWith( "session" ) ) { try { int pathSeparator = expression.indexOf( '/' ); if ( pathSeparator > 0 ) { String pathExpression = expression.substring( 1, pathSeparator ); value = ReflectionValueExtractor.evaluate( pathExpression, session ); value = value + expression.substring( pathSeparator ); } else { value = ReflectionValueExtractor.evaluate( expression.substring( 1 ), session ); } } catch ( Exception e ) { // TODO don't catch exception throw new ExpressionEvaluationException( "Error evaluating plugin parameter expression: " + expression, e ); } } else if ( "reactorProjects".equals( expression ) ) { value = session.getProjects(); } else if ( "mojoExecution".equals( expression ) ) { value = mojoExecution; } else if ( "project".equals( expression ) ) { value = project; } else if ( "executedProject".equals( expression ) ) { value = project.getExecutionProject(); } else if ( expression.startsWith( "project" ) || expression.startsWith( "pom" ) ) { try { int pathSeparator = expression.indexOf( '/' ); if ( pathSeparator > 0 ) { String pathExpression = expression.substring( 0, pathSeparator ); value = ReflectionValueExtractor.evaluate( pathExpression, project ); value = value + expression.substring( pathSeparator ); } else { value = ReflectionValueExtractor.evaluate( expression.substring( 1 ), project ); } } catch ( Exception e ) { // TODO don't catch exception throw new ExpressionEvaluationException( "Error evaluating plugin parameter expression: " + expression, e ); } } else if ( expression.equals( "repositorySystemSession" ) ) { value = session.getRepositorySession(); } else if ( expression.equals( "mojo" ) ) { value = mojoExecution; } else if ( expression.startsWith( "mojo" ) ) { try { int pathSeparator = expression.indexOf( '/' ); if ( pathSeparator > 0 ) { String pathExpression = expression.substring( 1, pathSeparator ); value = ReflectionValueExtractor.evaluate( pathExpression, mojoExecution ); value = value + expression.substring( pathSeparator ); } else { value = ReflectionValueExtractor.evaluate( expression.substring( 1 ), mojoExecution ); } } catch ( Exception e ) { // TODO don't catch exception throw new ExpressionEvaluationException( "Error evaluating plugin parameter expression: " + expression, e ); } } else if ( expression.equals( "plugin" ) ) { value = mojoDescriptor.getPluginDescriptor(); } else if ( expression.startsWith( "plugin" ) ) { try { int pathSeparator = expression.indexOf( '/' ); PluginDescriptor pluginDescriptor = mojoDescriptor.getPluginDescriptor(); if ( pathSeparator > 0 ) { String pathExpression = expression.substring( 1, pathSeparator ); value = ReflectionValueExtractor.evaluate( pathExpression, pluginDescriptor ); value = value + expression.substring( pathSeparator ); } else { value = ReflectionValueExtractor.evaluate( expression.substring( 1 ), pluginDescriptor ); } } catch ( Exception e ) { throw new ExpressionEvaluationException( "Error evaluating plugin parameter expression: " + expression, e ); } } else if ( "settings".equals( expression ) ) { value = session.getSettings(); } else if ( expression.startsWith( "settings" ) ) { try { int pathSeparator = expression.indexOf( '/' ); if ( pathSeparator > 0 ) { String pathExpression = expression.substring( 1, pathSeparator ); value = ReflectionValueExtractor.evaluate( pathExpression, session.getSettings() ); value = value + expression.substring( pathSeparator ); } else { value = ReflectionValueExtractor.evaluate( expression.substring( 1 ), session.getSettings() ); } } catch ( Exception e ) { // TODO don't catch exception throw new ExpressionEvaluationException( "Error evaluating plugin parameter expression: " + expression, e ); } } else if ( "basedir".equals( expression ) ) { value = basedir; } else if ( expression.startsWith( "basedir" ) ) { int pathSeparator = expression.indexOf( '/' ); if ( pathSeparator > 0 ) { value = basedir + expression.substring( pathSeparator ); } } /* * MNG-4312: We neither have reserved all of the above magic expressions nor is their set fixed/well-known (it * gets occasionally extended by newer Maven versions). This imposes the risk for existing plugins to * unintentionally use such a magic expression for an ordinary system property. So here we check whether we * ended up with a magic value that is not compatible with the type of the configured mojo parameter (a string * could still be converted by the configurator so we leave those alone). If so, back off to evaluating the * expression from properties only. */ if ( value != null && type != null && !( value instanceof String ) && !isTypeCompatible( type, value ) ) { value = null; } if ( value == null ) { // The CLI should win for defining properties if ( properties != null ) { // We will attempt to get nab a system property as a way to specify a // parameter to a plugins. My particular case here is allowing the surefire // plugin to run a single test so I want to specify that class on the cli // as a parameter. value = properties.getProperty( expression ); } if ( ( value == null ) && ( ( project != null ) && ( project.getProperties() != null ) ) ) { value = project.getProperties().getProperty( expression ); } } if ( value instanceof String ) { // TODO without #, this could just be an evaluate call... String val = (String) value; int exprStartDelimiter = val.indexOf( "${" ); if ( exprStartDelimiter >= 0 ) { if ( exprStartDelimiter > 0 ) { value = val.substring( 0, exprStartDelimiter ) + evaluate( val.substring( exprStartDelimiter ) ); } else { value = evaluate( val.substring( exprStartDelimiter ) ); } } } return value; } private static boolean isTypeCompatible( Class type, Object value ) { if ( type.isInstance( value ) ) { return true; } // likely Boolean -> boolean, Short -> int etc. conversions, it's not the problem case we try to avoid return ( ( type.isPrimitive() || type.getName().startsWith( "java.lang." ) ) && value.getClass().getName().startsWith( "java.lang." ) ); } private String stripTokens( String expr ) { if ( expr.startsWith( "${" ) && ( expr.indexOf( '}' ) == expr.length() - 1 ) ) { expr = expr.substring( 2, expr.length() - 1 ); } return expr; } @Override public File alignToBaseDirectory( File file ) { // TODO Copied from the DefaultInterpolator. We likely want to resurrect the PathTranslator or at least a // similar component for re-usage if ( file != null ) { if ( file.isAbsolute() ) { // path was already absolute, just normalize file separator and we're done } else if ( file.getPath().startsWith( File.separator ) ) { // drive-relative Windows path, don't align with project directory but with drive root file = file.getAbsoluteFile(); } else { // an ordinary relative path, align with project directory file = new File( new File( basedir, file.getPath() ).toURI().normalize() ).getAbsoluteFile(); } } return file; } } maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/plugin/PluginRealmCache.java000066400000000000000000000055351317160430700310570ustar00rootroot00000000000000package org.apache.maven.plugin; /* * 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.util.List; import java.util.Map; import org.apache.maven.artifact.Artifact; import org.apache.maven.model.Plugin; import org.apache.maven.project.MavenProject; import org.codehaus.plexus.classworlds.realm.ClassRealm; import org.eclipse.aether.RepositorySystemSession; import org.eclipse.aether.graph.DependencyFilter; import org.eclipse.aether.repository.RemoteRepository; /** * Caches plugin class realms. Warning: This is an internal utility interface that is only public for * technical reasons, it is not part of the public API. In particular, this interface can be changed or deleted without * prior notice. * * @author Igor Fedorenko * @author Benjamin Bentmann */ public interface PluginRealmCache { static class CacheRecord { public final ClassRealm realm; public final List artifacts; public CacheRecord( ClassRealm realm, List artifacts ) { this.realm = realm; this.artifacts = artifacts; } } /** * A cache key. */ interface Key { // marker interface for cache keys } Key createKey( Plugin plugin, ClassLoader parentRealm, Map foreignImports, DependencyFilter dependencyFilter, List repositories, RepositorySystemSession session ); CacheRecord get( Key key ); CacheRecord put( Key key, ClassRealm pluginRealm, List pluginArtifacts ); void flush(); /** * Registers the specified cache record for usage with the given project. Integrators can use the information * collected from this method in combination with a custom cache implementation to dispose unused records from the * cache. * * @param project The project that employs the plugin realm, must not be {@code null}. * @param record The cache record being used for the project, must not be {@code null}. */ void register( MavenProject project, Key key, CacheRecord record ); } maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/plugin/PluginResolutionException.java000066400000000000000000000026251317160430700331120ustar00rootroot00000000000000package org.apache.maven.plugin; /* * 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 org.apache.maven.model.Plugin; /** * Exception occurring trying to resolve a plugin. * * @author Brett Porter */ public class PluginResolutionException extends Exception { private final Plugin plugin; public PluginResolutionException( Plugin plugin, Throwable cause ) { super( "Plugin " + plugin.getId() + " or one of its dependencies could not be resolved: " + cause.getMessage(), cause ); this.plugin = plugin; } public Plugin getPlugin() { return plugin; } } maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/plugin/ProjectArtifactsCache.java000066400000000000000000000056541317160430700321110ustar00rootroot00000000000000package org.apache.maven.plugin; /* * 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.util.Collection; import java.util.Set; import org.apache.maven.artifact.Artifact; import org.apache.maven.lifecycle.LifecycleExecutionException; import org.apache.maven.project.MavenProject; import org.eclipse.aether.RepositorySystemSession; /** * Caches project artifacts. Warning: This is an internal utility interface that is only public for * technical reasons, it is not part of the public API. In particular, this interface can be changed or deleted without * prior notice. * * @author Igor Fedorenko * @author Benjamin Bentmann * @author Anton Tanasenko */ public interface ProjectArtifactsCache { /** * A cache key. */ interface Key { // marker interface for cache keys } static class CacheRecord { public final Set artifacts; public final LifecycleExecutionException exception; public CacheRecord( Set artifacts ) { this.artifacts = artifacts; this.exception = null; } public CacheRecord( LifecycleExecutionException exception ) { this.artifacts = null; this.exception = exception; } } Key createKey( MavenProject project, Collection scopesToCollect, Collection scopesToResolve, boolean aggregating, RepositorySystemSession session ); CacheRecord get( Key key ) throws LifecycleExecutionException; CacheRecord put( Key key, Set pluginArtifacts ); CacheRecord put( Key key, LifecycleExecutionException e ); void flush(); /** * Registers the specified cache record for usage with the given project. Integrators can use the information * collected from this method in combination with a custom cache implementation to dispose unused records from the * cache. * * @param project The project that employs the plugin realm, must not be {@code null}. * @param record The cache record being used for the project, must not be {@code null}. */ void register( MavenProject project, Key cacheKey, CacheRecord record ); } maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/plugin/internal/000077500000000000000000000000001317160430700266555ustar00rootroot00000000000000DefaultLegacySupport.java000066400000000000000000000050241317160430700335500ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/plugin/internalpackage org.apache.maven.plugin.internal; /* * 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.util.concurrent.atomic.AtomicReference; import org.apache.maven.execution.MavenSession; import org.apache.maven.plugin.LegacySupport; import org.codehaus.plexus.component.annotations.Component; import org.eclipse.aether.RepositorySystemSession; /** * Helps to provide backward-compatibility with plugins that use legacy components. Warning: This is an * internal utility component that is only public for technical reasons, it is not part of the public API. In * particular, this component can be changed or deleted without prior notice. * * @since 3.0 * @author Benjamin Bentmann */ @Component( role = LegacySupport.class ) public class DefaultLegacySupport implements LegacySupport { private static final ThreadLocal> SESSION = new InheritableThreadLocal<>(); public void setSession( MavenSession session ) { AtomicReference reference = DefaultLegacySupport.SESSION.get(); if ( reference != null ) { reference.set( null ); } if ( session == null && reference != null ) { DefaultLegacySupport.SESSION.remove(); } else { DefaultLegacySupport.SESSION.set( new AtomicReference<>( session ) ); } } public MavenSession getSession() { AtomicReference currentSession = DefaultLegacySupport.SESSION.get(); return currentSession != null ? currentSession.get() : null; } public RepositorySystemSession getRepositorySession() { MavenSession session = getSession(); return ( session != null ) ? session.getRepositorySession() : null; } } DefaultMavenPluginManager.java000066400000000000000000001113471317160430700344750ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/plugin/internalpackage org.apache.maven.plugin.internal; /* * 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 org.apache.commons.lang3.Validate; import org.apache.maven.RepositoryUtils; import org.apache.maven.artifact.Artifact; import org.apache.maven.classrealm.ClassRealmManager; import org.apache.maven.execution.MavenSession; import org.apache.maven.execution.scope.internal.MojoExecutionScopeModule; import org.apache.maven.model.Plugin; import org.apache.maven.monitor.logging.DefaultLog; import org.apache.maven.plugin.ContextEnabled; import org.apache.maven.plugin.DebugConfigurationListener; import org.apache.maven.plugin.ExtensionRealmCache; import org.apache.maven.plugin.InvalidPluginDescriptorException; import org.apache.maven.plugin.MavenPluginManager; import org.apache.maven.plugin.MavenPluginValidator; import org.apache.maven.plugin.Mojo; import org.apache.maven.plugin.MojoExecution; import org.apache.maven.plugin.MojoNotFoundException; import org.apache.maven.plugin.PluginArtifactsCache; import org.apache.maven.plugin.PluginConfigurationException; import org.apache.maven.plugin.PluginContainerException; import org.apache.maven.plugin.PluginDescriptorCache; import org.apache.maven.plugin.PluginDescriptorParsingException; import org.apache.maven.plugin.PluginIncompatibleException; import org.apache.maven.plugin.PluginManagerException; import org.apache.maven.plugin.PluginParameterException; import org.apache.maven.plugin.PluginParameterExpressionEvaluator; import org.apache.maven.plugin.PluginRealmCache; import org.apache.maven.plugin.PluginResolutionException; import org.apache.maven.plugin.descriptor.MojoDescriptor; import org.apache.maven.plugin.descriptor.Parameter; import org.apache.maven.plugin.descriptor.PluginDescriptor; import org.apache.maven.plugin.descriptor.PluginDescriptorBuilder; import org.apache.maven.plugin.version.DefaultPluginVersionRequest; import org.apache.maven.plugin.version.PluginVersionRequest; import org.apache.maven.plugin.version.PluginVersionResolutionException; import org.apache.maven.plugin.version.PluginVersionResolver; import org.apache.maven.project.ExtensionDescriptor; import org.apache.maven.project.ExtensionDescriptorBuilder; import org.apache.maven.project.MavenProject; import org.apache.maven.rtinfo.RuntimeInformation; import org.apache.maven.session.scope.internal.SessionScopeModule; import org.codehaus.plexus.DefaultPlexusContainer; import org.codehaus.plexus.PlexusContainer; import org.codehaus.plexus.classworlds.realm.ClassRealm; import org.codehaus.plexus.component.annotations.Component; import org.codehaus.plexus.component.annotations.Requirement; import org.codehaus.plexus.component.composition.CycleDetectedInComponentGraphException; import org.codehaus.plexus.component.configurator.ComponentConfigurationException; import org.codehaus.plexus.component.configurator.ComponentConfigurator; import org.codehaus.plexus.component.configurator.ConfigurationListener; import org.codehaus.plexus.component.configurator.expression.ExpressionEvaluationException; import org.codehaus.plexus.component.configurator.expression.ExpressionEvaluator; import org.codehaus.plexus.component.repository.ComponentDescriptor; import org.codehaus.plexus.component.repository.exception.ComponentLifecycleException; import org.codehaus.plexus.component.repository.exception.ComponentLookupException; import org.codehaus.plexus.configuration.PlexusConfiguration; import org.codehaus.plexus.configuration.PlexusConfigurationException; import org.codehaus.plexus.configuration.xml.XmlPlexusConfiguration; import org.codehaus.plexus.logging.Logger; import org.codehaus.plexus.logging.LoggerManager; import org.codehaus.plexus.util.ReaderFactory; import org.codehaus.plexus.util.StringUtils; import org.codehaus.plexus.util.xml.Xpp3Dom; import org.eclipse.aether.RepositorySystemSession; import org.eclipse.aether.graph.DependencyFilter; import org.eclipse.aether.graph.DependencyNode; import org.eclipse.aether.repository.RemoteRepository; import org.eclipse.aether.util.filter.AndDependencyFilter; import org.eclipse.aether.util.graph.visitor.PreorderNodeListGenerator; import java.io.BufferedInputStream; import java.io.ByteArrayOutputStream; import java.io.File; import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintStream; import java.io.Reader; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.jar.JarFile; import java.util.zip.ZipEntry; /** * Provides basic services to manage Maven plugins and their mojos. This component is kept general in its design such * that the plugins/mojos can be used in arbitrary contexts. In particular, the mojos can be used for ordinary build * plugins as well as special purpose plugins like reports. * * @author Benjamin Bentmann * @since 3.0 */ @Component( role = MavenPluginManager.class ) public class DefaultMavenPluginManager implements MavenPluginManager { /** *

* PluginId => ExtensionRealmCache.CacheRecord map MavenProject context value key. The map is used to ensure the * same class realm is used to load build extensions and load mojos for extensions=true plugins. *

* Note: This is part of internal implementation and may be changed or removed without notice * * @since 3.3.0 */ public static final String KEY_EXTENSIONS_REALMS = DefaultMavenPluginManager.class.getName() + "/extensionsRealms"; @Requirement private Logger logger; @Requirement private LoggerManager loggerManager; @Requirement private PlexusContainer container; @Requirement private ClassRealmManager classRealmManager; @Requirement private PluginDescriptorCache pluginDescriptorCache; @Requirement private PluginRealmCache pluginRealmCache; @Requirement private PluginDependenciesResolver pluginDependenciesResolver; @Requirement private RuntimeInformation runtimeInformation; @Requirement private ExtensionRealmCache extensionRealmCache; @Requirement private PluginVersionResolver pluginVersionResolver; @Requirement private PluginArtifactsCache pluginArtifactsCache; private ExtensionDescriptorBuilder extensionDescriptorBuilder = new ExtensionDescriptorBuilder(); private PluginDescriptorBuilder builder = new PluginDescriptorBuilder(); public synchronized PluginDescriptor getPluginDescriptor( Plugin plugin, List repositories, RepositorySystemSession session ) throws PluginResolutionException, PluginDescriptorParsingException, InvalidPluginDescriptorException { PluginDescriptorCache.Key cacheKey = pluginDescriptorCache.createKey( plugin, repositories, session ); PluginDescriptor pluginDescriptor = pluginDescriptorCache.get( cacheKey ); if ( pluginDescriptor == null ) { org.eclipse.aether.artifact.Artifact artifact = pluginDependenciesResolver.resolve( plugin, repositories, session ); Artifact pluginArtifact = RepositoryUtils.toArtifact( artifact ); pluginDescriptor = extractPluginDescriptor( pluginArtifact, plugin ); pluginDescriptor.setRequiredMavenVersion( artifact.getProperty( "requiredMavenVersion", null ) ); pluginDescriptorCache.put( cacheKey, pluginDescriptor ); } pluginDescriptor.setPlugin( plugin ); return pluginDescriptor; } private PluginDescriptor extractPluginDescriptor( Artifact pluginArtifact, Plugin plugin ) throws PluginDescriptorParsingException, InvalidPluginDescriptorException { PluginDescriptor pluginDescriptor = null; File pluginFile = pluginArtifact.getFile(); try { if ( pluginFile.isFile() ) { try ( JarFile pluginJar = new JarFile( pluginFile, false ) ) { ZipEntry pluginDescriptorEntry = pluginJar.getEntry( getPluginDescriptorLocation() ); if ( pluginDescriptorEntry != null ) { InputStream is = pluginJar.getInputStream( pluginDescriptorEntry ); pluginDescriptor = parsePluginDescriptor( is, plugin, pluginFile.getAbsolutePath() ); } } } else { File pluginXml = new File( pluginFile, getPluginDescriptorLocation() ); if ( pluginXml.isFile() ) { try ( InputStream is = new BufferedInputStream( new FileInputStream( pluginXml ) ) ) { pluginDescriptor = parsePluginDescriptor( is, plugin, pluginXml.getAbsolutePath() ); } } } if ( pluginDescriptor == null ) { throw new IOException( "No plugin descriptor found at " + getPluginDescriptorLocation() ); } } catch ( IOException e ) { throw new PluginDescriptorParsingException( plugin, pluginFile.getAbsolutePath(), e ); } MavenPluginValidator validator = new MavenPluginValidator( pluginArtifact ); validator.validate( pluginDescriptor ); if ( validator.hasErrors() ) { throw new InvalidPluginDescriptorException( "Invalid plugin descriptor for " + plugin.getId() + " (" + pluginFile + ")", validator.getErrors() ); } pluginDescriptor.setPluginArtifact( pluginArtifact ); return pluginDescriptor; } private String getPluginDescriptorLocation() { return "META-INF/maven/plugin.xml"; } private PluginDescriptor parsePluginDescriptor( InputStream is, Plugin plugin, String descriptorLocation ) throws PluginDescriptorParsingException { try { Reader reader = ReaderFactory.newXmlReader( is ); PluginDescriptor pluginDescriptor = builder.build( reader, descriptorLocation ); return pluginDescriptor; } catch ( IOException | PlexusConfigurationException e ) { throw new PluginDescriptorParsingException( plugin, descriptorLocation, e ); } } public MojoDescriptor getMojoDescriptor( Plugin plugin, String goal, List repositories, RepositorySystemSession session ) throws MojoNotFoundException, PluginResolutionException, PluginDescriptorParsingException, InvalidPluginDescriptorException { PluginDescriptor pluginDescriptor = getPluginDescriptor( plugin, repositories, session ); MojoDescriptor mojoDescriptor = pluginDescriptor.getMojo( goal ); if ( mojoDescriptor == null ) { throw new MojoNotFoundException( goal, pluginDescriptor ); } return mojoDescriptor; } public void checkRequiredMavenVersion( PluginDescriptor pluginDescriptor ) throws PluginIncompatibleException { String requiredMavenVersion = pluginDescriptor.getRequiredMavenVersion(); if ( StringUtils.isNotBlank( requiredMavenVersion ) ) { try { if ( !runtimeInformation.isMavenVersion( requiredMavenVersion ) ) { throw new PluginIncompatibleException( pluginDescriptor.getPlugin(), "The plugin " + pluginDescriptor.getId() + " requires Maven version " + requiredMavenVersion ); } } catch ( RuntimeException e ) { logger.warn( "Could not verify plugin's Maven prerequisite: " + e.getMessage() ); } } } public synchronized void setupPluginRealm( PluginDescriptor pluginDescriptor, MavenSession session, ClassLoader parent, List imports, DependencyFilter filter ) throws PluginResolutionException, PluginContainerException { Plugin plugin = pluginDescriptor.getPlugin(); MavenProject project = session.getCurrentProject(); if ( plugin.isExtensions() ) { ExtensionRealmCache.CacheRecord extensionRecord; try { RepositorySystemSession repositorySession = session.getRepositorySession(); extensionRecord = setupExtensionsRealm( project, plugin, repositorySession ); } catch ( PluginManagerException e ) { // extensions realm is expected to be fully setup at this point // any exception means a problem in maven code, not a user error throw new IllegalStateException( e ); } ClassRealm pluginRealm = extensionRecord.realm; List pluginArtifacts = extensionRecord.artifacts; for ( ComponentDescriptor componentDescriptor : pluginDescriptor.getComponents() ) { componentDescriptor.setRealm( pluginRealm ); } pluginDescriptor.setClassRealm( pluginRealm ); pluginDescriptor.setArtifacts( pluginArtifacts ); } else { Map foreignImports = calcImports( project, parent, imports ); PluginRealmCache.Key cacheKey = pluginRealmCache.createKey( plugin, parent, foreignImports, filter, project.getRemotePluginRepositories(), session.getRepositorySession() ); PluginRealmCache.CacheRecord cacheRecord = pluginRealmCache.get( cacheKey ); if ( cacheRecord != null ) { pluginDescriptor.setClassRealm( cacheRecord.realm ); pluginDescriptor.setArtifacts( new ArrayList<>( cacheRecord.artifacts ) ); for ( ComponentDescriptor componentDescriptor : pluginDescriptor.getComponents() ) { componentDescriptor.setRealm( cacheRecord.realm ); } } else { createPluginRealm( pluginDescriptor, session, parent, foreignImports, filter ); cacheRecord = pluginRealmCache.put( cacheKey, pluginDescriptor.getClassRealm(), pluginDescriptor.getArtifacts() ); } pluginRealmCache.register( project, cacheKey, cacheRecord ); } } private void createPluginRealm( PluginDescriptor pluginDescriptor, MavenSession session, ClassLoader parent, Map foreignImports, DependencyFilter filter ) throws PluginResolutionException, PluginContainerException { Plugin plugin = Validate.notNull( pluginDescriptor.getPlugin(), "pluginDescriptor.plugin cannot be null" ); Artifact pluginArtifact = Validate.notNull( pluginDescriptor.getPluginArtifact(), "pluginDescriptor.pluginArtifact cannot be null" ); MavenProject project = session.getCurrentProject(); final ClassRealm pluginRealm; final List pluginArtifacts; RepositorySystemSession repositorySession = session.getRepositorySession(); DependencyFilter dependencyFilter = project.getExtensionDependencyFilter(); dependencyFilter = AndDependencyFilter.newInstance( dependencyFilter, filter ); DependencyNode root = pluginDependenciesResolver.resolve( plugin, RepositoryUtils.toArtifact( pluginArtifact ), dependencyFilter, project.getRemotePluginRepositories(), repositorySession ); PreorderNodeListGenerator nlg = new PreorderNodeListGenerator(); root.accept( nlg ); pluginArtifacts = toMavenArtifacts( root, nlg ); pluginRealm = classRealmManager.createPluginRealm( plugin, parent, null, foreignImports, toAetherArtifacts( pluginArtifacts ) ); discoverPluginComponents( pluginRealm, plugin, pluginDescriptor ); pluginDescriptor.setClassRealm( pluginRealm ); pluginDescriptor.setArtifacts( pluginArtifacts ); } private void discoverPluginComponents( final ClassRealm pluginRealm, Plugin plugin, PluginDescriptor pluginDescriptor ) throws PluginContainerException { try { if ( pluginDescriptor != null ) { for ( ComponentDescriptor componentDescriptor : pluginDescriptor.getComponents() ) { componentDescriptor.setRealm( pluginRealm ); container.addComponentDescriptor( componentDescriptor ); } } ( (DefaultPlexusContainer) container ).discoverComponents( pluginRealm, new SessionScopeModule( container ), new MojoExecutionScopeModule( container ) ); } catch ( ComponentLookupException | CycleDetectedInComponentGraphException e ) { throw new PluginContainerException( plugin, pluginRealm, "Error in component graph of plugin " + plugin.getId() + ": " + e.getMessage(), e ); } } private List toAetherArtifacts( final List pluginArtifacts ) { return new ArrayList<>( RepositoryUtils.toArtifacts( pluginArtifacts ) ); } private List toMavenArtifacts( DependencyNode root, PreorderNodeListGenerator nlg ) { List artifacts = new ArrayList<>( nlg.getNodes().size() ); RepositoryUtils.toArtifacts( artifacts, Collections.singleton( root ), Collections.emptyList(), null ); for ( Iterator it = artifacts.iterator(); it.hasNext(); ) { Artifact artifact = it.next(); if ( artifact.getFile() == null ) { it.remove(); } } return artifacts; } private Map calcImports( MavenProject project, ClassLoader parent, List imports ) { Map foreignImports = new HashMap<>(); ClassLoader projectRealm = project.getClassRealm(); if ( projectRealm != null ) { foreignImports.put( "", projectRealm ); } else { foreignImports.put( "", classRealmManager.getMavenApiRealm() ); } if ( parent != null && imports != null ) { for ( String parentImport : imports ) { foreignImports.put( parentImport, parent ); } } return foreignImports; } public T getConfiguredMojo( Class mojoInterface, MavenSession session, MojoExecution mojoExecution ) throws PluginConfigurationException, PluginContainerException { MojoDescriptor mojoDescriptor = mojoExecution.getMojoDescriptor(); PluginDescriptor pluginDescriptor = mojoDescriptor.getPluginDescriptor(); ClassRealm pluginRealm = pluginDescriptor.getClassRealm(); if ( logger.isDebugEnabled() ) { logger.debug( "Configuring mojo " + mojoDescriptor.getId() + " from plugin realm " + pluginRealm ); } // We are forcing the use of the plugin realm for all lookups that might occur during // the lifecycle that is part of the lookup. Here we are specifically trying to keep // lookups that occur in contextualize calls in line with the right realm. ClassRealm oldLookupRealm = container.setLookupRealm( pluginRealm ); ClassLoader oldClassLoader = Thread.currentThread().getContextClassLoader(); Thread.currentThread().setContextClassLoader( pluginRealm ); try { T mojo; try { mojo = container.lookup( mojoInterface, mojoDescriptor.getRoleHint() ); } catch ( ComponentLookupException e ) { Throwable cause = e.getCause(); while ( cause != null && !( cause instanceof LinkageError ) && !( cause instanceof ClassNotFoundException ) ) { cause = cause.getCause(); } if ( ( cause instanceof NoClassDefFoundError ) || ( cause instanceof ClassNotFoundException ) ) { ByteArrayOutputStream os = new ByteArrayOutputStream( 1024 ); PrintStream ps = new PrintStream( os ); ps.println( "Unable to load the mojo '" + mojoDescriptor.getGoal() + "' in the plugin '" + pluginDescriptor.getId() + "'. A required class is missing: " + cause.getMessage() ); pluginRealm.display( ps ); throw new PluginContainerException( mojoDescriptor, pluginRealm, os.toString(), cause ); } else if ( cause instanceof LinkageError ) { ByteArrayOutputStream os = new ByteArrayOutputStream( 1024 ); PrintStream ps = new PrintStream( os ); ps.println( "Unable to load the mojo '" + mojoDescriptor.getGoal() + "' in the plugin '" + pluginDescriptor.getId() + "' due to an API incompatibility: " + e.getClass().getName() + ": " + cause.getMessage() ); pluginRealm.display( ps ); throw new PluginContainerException( mojoDescriptor, pluginRealm, os.toString(), cause ); } throw new PluginContainerException( mojoDescriptor, pluginRealm, "Unable to load the mojo '" + mojoDescriptor.getGoal() + "' (or one of its required components) from the plugin '" + pluginDescriptor.getId() + "'", e ); } if ( mojo instanceof ContextEnabled ) { MavenProject project = session.getCurrentProject(); Map pluginContext = session.getPluginContext( pluginDescriptor, project ); if ( pluginContext != null ) { pluginContext.put( "project", project ); pluginContext.put( "pluginDescriptor", pluginDescriptor ); ( (ContextEnabled) mojo ).setPluginContext( pluginContext ); } } if ( mojo instanceof Mojo ) { Logger mojoLogger = loggerManager.getLoggerForComponent( mojoDescriptor.getImplementation() ); ( (Mojo) mojo ).setLog( new DefaultLog( mojoLogger ) ); } Xpp3Dom dom = mojoExecution.getConfiguration(); PlexusConfiguration pomConfiguration; if ( dom == null ) { pomConfiguration = new XmlPlexusConfiguration( "configuration" ); } else { pomConfiguration = new XmlPlexusConfiguration( dom ); } ExpressionEvaluator expressionEvaluator = new PluginParameterExpressionEvaluator( session, mojoExecution ); populatePluginFields( mojo, mojoDescriptor, pluginRealm, pomConfiguration, expressionEvaluator ); return mojo; } finally { Thread.currentThread().setContextClassLoader( oldClassLoader ); container.setLookupRealm( oldLookupRealm ); } } private void populatePluginFields( Object mojo, MojoDescriptor mojoDescriptor, ClassRealm pluginRealm, PlexusConfiguration configuration, ExpressionEvaluator expressionEvaluator ) throws PluginConfigurationException { ComponentConfigurator configurator = null; String configuratorId = mojoDescriptor.getComponentConfigurator(); if ( StringUtils.isEmpty( configuratorId ) ) { configuratorId = "basic"; } try { // TODO could the configuration be passed to lookup and the configurator known to plexus via the descriptor // so that this method could entirely be handled by a plexus lookup? configurator = container.lookup( ComponentConfigurator.class, configuratorId ); ConfigurationListener listener = new DebugConfigurationListener( logger ); ValidatingConfigurationListener validator = new ValidatingConfigurationListener( mojo, mojoDescriptor, listener ); logger.debug( "Configuring mojo '" + mojoDescriptor.getId() + "' with " + configuratorId + " configurator -->" ); configurator.configureComponent( mojo, configuration, expressionEvaluator, pluginRealm, validator ); logger.debug( "-- end configuration --" ); Collection missingParameters = validator.getMissingParameters(); if ( !missingParameters.isEmpty() ) { if ( "basic".equals( configuratorId ) ) { throw new PluginParameterException( mojoDescriptor, new ArrayList<>( missingParameters ) ); } else { /* * NOTE: Other configurators like the map-oriented one don't call into the listener, so do it the * hard way. */ validateParameters( mojoDescriptor, configuration, expressionEvaluator ); } } } catch ( ComponentConfigurationException e ) { String message = "Unable to parse configuration of mojo " + mojoDescriptor.getId(); if ( e.getFailedConfiguration() != null ) { message += " for parameter " + e.getFailedConfiguration().getName(); } message += ": " + e.getMessage(); throw new PluginConfigurationException( mojoDescriptor.getPluginDescriptor(), message, e ); } catch ( ComponentLookupException e ) { throw new PluginConfigurationException( mojoDescriptor.getPluginDescriptor(), "Unable to retrieve component configurator " + configuratorId + " for configuration of mojo " + mojoDescriptor.getId(), e ); } catch ( NoClassDefFoundError e ) { ByteArrayOutputStream os = new ByteArrayOutputStream( 1024 ); PrintStream ps = new PrintStream( os ); ps.println( "A required class was missing during configuration of mojo " + mojoDescriptor.getId() + ": " + e.getMessage() ); pluginRealm.display( ps ); throw new PluginConfigurationException( mojoDescriptor.getPluginDescriptor(), os.toString(), e ); } catch ( LinkageError e ) { ByteArrayOutputStream os = new ByteArrayOutputStream( 1024 ); PrintStream ps = new PrintStream( os ); ps.println( "An API incompatibility was encountered during configuration of mojo " + mojoDescriptor.getId() + ": " + e.getClass().getName() + ": " + e.getMessage() ); pluginRealm.display( ps ); throw new PluginConfigurationException( mojoDescriptor.getPluginDescriptor(), os.toString(), e ); } finally { if ( configurator != null ) { try { container.release( configurator ); } catch ( ComponentLifecycleException e ) { logger.debug( "Failed to release mojo configurator - ignoring." ); } } } } private void validateParameters( MojoDescriptor mojoDescriptor, PlexusConfiguration configuration, ExpressionEvaluator expressionEvaluator ) throws ComponentConfigurationException, PluginParameterException { if ( mojoDescriptor.getParameters() == null ) { return; } List invalidParameters = new ArrayList<>(); for ( Parameter parameter : mojoDescriptor.getParameters() ) { if ( !parameter.isRequired() ) { continue; } Object value = null; PlexusConfiguration config = configuration.getChild( parameter.getName(), false ); if ( config != null ) { String expression = config.getValue( null ); try { value = expressionEvaluator.evaluate( expression ); if ( value == null ) { value = config.getAttribute( "default-value", null ); } } catch ( ExpressionEvaluationException e ) { String msg = "Error evaluating the expression '" + expression + "' for configuration value '" + configuration.getName() + "'"; throw new ComponentConfigurationException( configuration, msg, e ); } } if ( value == null && ( config == null || config.getChildCount() <= 0 ) ) { invalidParameters.add( parameter ); } } if ( !invalidParameters.isEmpty() ) { throw new PluginParameterException( mojoDescriptor, invalidParameters ); } } public void releaseMojo( Object mojo, MojoExecution mojoExecution ) { if ( mojo != null ) { try { container.release( mojo ); } catch ( ComponentLifecycleException e ) { String goalExecId = mojoExecution.getGoal(); if ( mojoExecution.getExecutionId() != null ) { goalExecId += " {execution: " + mojoExecution.getExecutionId() + "}"; } logger.debug( "Error releasing mojo for " + goalExecId, e ); } } } public ExtensionRealmCache.CacheRecord setupExtensionsRealm( MavenProject project, Plugin plugin, RepositorySystemSession session ) throws PluginManagerException { @SuppressWarnings( "unchecked" ) Map pluginRealms = (Map) project.getContextValue( KEY_EXTENSIONS_REALMS ); if ( pluginRealms == null ) { pluginRealms = new HashMap<>(); project.setContextValue( KEY_EXTENSIONS_REALMS, pluginRealms ); } final String pluginKey = plugin.getId(); ExtensionRealmCache.CacheRecord extensionRecord = pluginRealms.get( pluginKey ); if ( extensionRecord != null ) { return extensionRecord; } final List repositories = project.getRemotePluginRepositories(); // resolve plugin version as necessary if ( plugin.getVersion() == null ) { PluginVersionRequest versionRequest = new DefaultPluginVersionRequest( plugin, session, repositories ); try { plugin.setVersion( pluginVersionResolver.resolve( versionRequest ).getVersion() ); } catch ( PluginVersionResolutionException e ) { throw new PluginManagerException( plugin, e.getMessage(), e ); } } // resolve plugin artifacts List artifacts; PluginArtifactsCache.Key cacheKey = pluginArtifactsCache.createKey( plugin, null, repositories, session ); PluginArtifactsCache.CacheRecord recordArtifacts; try { recordArtifacts = pluginArtifactsCache.get( cacheKey ); } catch ( PluginResolutionException e ) { throw new PluginManagerException( plugin, e.getMessage(), e ); } if ( recordArtifacts != null ) { artifacts = recordArtifacts.artifacts; } else { try { artifacts = resolveExtensionArtifacts( plugin, repositories, session ); recordArtifacts = pluginArtifactsCache.put( cacheKey, artifacts ); } catch ( PluginResolutionException e ) { pluginArtifactsCache.put( cacheKey, e ); pluginArtifactsCache.register( project, cacheKey, recordArtifacts ); throw new PluginManagerException( plugin, e.getMessage(), e ); } } pluginArtifactsCache.register( project, cacheKey, recordArtifacts ); // create and cache extensions realms final ExtensionRealmCache.Key extensionKey = extensionRealmCache.createKey( artifacts ); extensionRecord = extensionRealmCache.get( extensionKey ); if ( extensionRecord == null ) { ClassRealm extensionRealm = classRealmManager.createExtensionRealm( plugin, toAetherArtifacts( artifacts ) ); // TODO figure out how to use the same PluginDescriptor when running mojos PluginDescriptor pluginDescriptor = null; if ( plugin.isExtensions() && !artifacts.isEmpty() ) { // ignore plugin descriptor parsing errors at this point // these errors will reported during calculation of project build execution plan try { pluginDescriptor = extractPluginDescriptor( artifacts.get( 0 ), plugin ); } catch ( PluginDescriptorParsingException | InvalidPluginDescriptorException e ) { // ignore, see above } } discoverPluginComponents( extensionRealm, plugin, pluginDescriptor ); ExtensionDescriptor extensionDescriptor = null; Artifact extensionArtifact = artifacts.get( 0 ); try { extensionDescriptor = extensionDescriptorBuilder.build( extensionArtifact.getFile() ); } catch ( IOException e ) { String message = "Invalid extension descriptor for " + plugin.getId() + ": " + e.getMessage(); if ( logger.isDebugEnabled() ) { logger.error( message, e ); } else { logger.error( message ); } } extensionRecord = extensionRealmCache.put( extensionKey, extensionRealm, extensionDescriptor, artifacts ); } extensionRealmCache.register( project, extensionKey, extensionRecord ); pluginRealms.put( pluginKey, extensionRecord ); return extensionRecord; } private List resolveExtensionArtifacts( Plugin extensionPlugin, List repositories, RepositorySystemSession session ) throws PluginResolutionException { DependencyNode root = pluginDependenciesResolver.resolve( extensionPlugin, null, null, repositories, session ); PreorderNodeListGenerator nlg = new PreorderNodeListGenerator(); root.accept( nlg ); return toMavenArtifacts( root, nlg ); } } DefaultPluginDependenciesResolver.java000066400000000000000000000242241317160430700362410ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/plugin/internalpackage org.apache.maven.plugin.internal; /* * 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.util.LinkedHashMap; import java.util.List; import java.util.Map; import org.apache.maven.RepositoryUtils; import org.apache.maven.model.Dependency; import org.apache.maven.model.Plugin; import org.apache.maven.plugin.PluginResolutionException; import org.codehaus.plexus.component.annotations.Component; import org.codehaus.plexus.component.annotations.Requirement; import org.codehaus.plexus.logging.Logger; import org.eclipse.aether.DefaultRepositorySystemSession; import org.eclipse.aether.RepositorySystem; import org.eclipse.aether.RepositorySystemSession; import org.eclipse.aether.RequestTrace; import org.eclipse.aether.artifact.Artifact; import org.eclipse.aether.artifact.DefaultArtifact; import org.eclipse.aether.collection.CollectRequest; import org.eclipse.aether.collection.DependencyCollectionException; import org.eclipse.aether.collection.DependencyGraphTransformer; import org.eclipse.aether.collection.DependencySelector; import org.eclipse.aether.graph.DependencyFilter; import org.eclipse.aether.graph.DependencyNode; import org.eclipse.aether.graph.DependencyVisitor; import org.eclipse.aether.repository.RemoteRepository; import org.eclipse.aether.resolution.ArtifactDescriptorException; import org.eclipse.aether.resolution.ArtifactDescriptorRequest; import org.eclipse.aether.resolution.ArtifactDescriptorResult; import org.eclipse.aether.resolution.ArtifactRequest; import org.eclipse.aether.resolution.ArtifactResolutionException; import org.eclipse.aether.resolution.DependencyRequest; import org.eclipse.aether.resolution.DependencyResolutionException; import org.eclipse.aether.util.artifact.JavaScopes; import org.eclipse.aether.util.filter.AndDependencyFilter; import org.eclipse.aether.util.filter.ScopeDependencyFilter; import org.eclipse.aether.util.graph.selector.AndDependencySelector; import org.eclipse.aether.util.graph.transformer.ChainedDependencyGraphTransformer; import org.eclipse.aether.util.repository.SimpleArtifactDescriptorPolicy; /** * Assists in resolving the dependencies of a plugin. Warning: This is an internal utility class that * is only public for technical reasons, it is not part of the public API. In particular, this class can be changed or * deleted without prior notice. * * @since 3.0 * @author Benjamin Bentmann */ @Component( role = PluginDependenciesResolver.class ) public class DefaultPluginDependenciesResolver implements PluginDependenciesResolver { private static final String REPOSITORY_CONTEXT = "plugin"; @Requirement private Logger logger; @Requirement private RepositorySystem repoSystem; private Artifact toArtifact( Plugin plugin, RepositorySystemSession session ) { return new DefaultArtifact( plugin.getGroupId(), plugin.getArtifactId(), null, "jar", plugin.getVersion(), session.getArtifactTypeRegistry().get( "maven-plugin" ) ); } public Artifact resolve( Plugin plugin, List repositories, RepositorySystemSession session ) throws PluginResolutionException { RequestTrace trace = RequestTrace.newChild( null, plugin ); Artifact pluginArtifact = toArtifact( plugin, session ); try { DefaultRepositorySystemSession pluginSession = new DefaultRepositorySystemSession( session ); pluginSession.setArtifactDescriptorPolicy( new SimpleArtifactDescriptorPolicy( true, false ) ); ArtifactDescriptorRequest request = new ArtifactDescriptorRequest( pluginArtifact, repositories, REPOSITORY_CONTEXT ); request.setTrace( trace ); ArtifactDescriptorResult result = repoSystem.readArtifactDescriptor( pluginSession, request ); pluginArtifact = result.getArtifact(); String requiredMavenVersion = (String) result.getProperties().get( "prerequisites.maven" ); if ( requiredMavenVersion != null ) { Map props = new LinkedHashMap<>( pluginArtifact.getProperties() ); props.put( "requiredMavenVersion", requiredMavenVersion ); pluginArtifact = pluginArtifact.setProperties( props ); } } catch ( ArtifactDescriptorException e ) { throw new PluginResolutionException( plugin, e ); } try { ArtifactRequest request = new ArtifactRequest( pluginArtifact, repositories, REPOSITORY_CONTEXT ); request.setTrace( trace ); pluginArtifact = repoSystem.resolveArtifact( session, request ).getArtifact(); } catch ( ArtifactResolutionException e ) { throw new PluginResolutionException( plugin, e ); } return pluginArtifact; } /** * @since 3.3.0 */ public DependencyNode resolveCoreExtension( Plugin plugin, DependencyFilter dependencyFilter, List repositories, RepositorySystemSession session ) throws PluginResolutionException { return resolveInternal( plugin, null /* pluginArtifact */, dependencyFilter, null /* transformer */, repositories, session ); } public DependencyNode resolve( Plugin plugin, Artifact pluginArtifact, DependencyFilter dependencyFilter, List repositories, RepositorySystemSession session ) throws PluginResolutionException { return resolveInternal( plugin, pluginArtifact, dependencyFilter, new PlexusUtilsInjector(), repositories, session ); } private DependencyNode resolveInternal( Plugin plugin, Artifact pluginArtifact, DependencyFilter dependencyFilter, DependencyGraphTransformer transformer, List repositories, RepositorySystemSession session ) throws PluginResolutionException { RequestTrace trace = RequestTrace.newChild( null, plugin ); if ( pluginArtifact == null ) { pluginArtifact = toArtifact( plugin, session ); } DependencyFilter collectionFilter = new ScopeDependencyFilter( "provided", "test" ); DependencyFilter resolutionFilter = AndDependencyFilter.newInstance( collectionFilter, dependencyFilter ); DependencyNode node; try { DependencySelector selector = AndDependencySelector.newInstance( session.getDependencySelector(), new WagonExcluder() ); transformer = ChainedDependencyGraphTransformer.newInstance( session.getDependencyGraphTransformer(), transformer ); DefaultRepositorySystemSession pluginSession = new DefaultRepositorySystemSession( session ); pluginSession.setDependencySelector( selector ); pluginSession.setDependencyGraphTransformer( transformer ); CollectRequest request = new CollectRequest(); request.setRequestContext( REPOSITORY_CONTEXT ); request.setRepositories( repositories ); request.setRoot( new org.eclipse.aether.graph.Dependency( pluginArtifact, null ) ); for ( Dependency dependency : plugin.getDependencies() ) { org.eclipse.aether.graph.Dependency pluginDep = RepositoryUtils.toDependency( dependency, session.getArtifactTypeRegistry() ); if ( !JavaScopes.SYSTEM.equals( pluginDep.getScope() ) ) { pluginDep = pluginDep.setScope( JavaScopes.RUNTIME ); } request.addDependency( pluginDep ); } DependencyRequest depRequest = new DependencyRequest( request, resolutionFilter ); depRequest.setTrace( trace ); request.setTrace( RequestTrace.newChild( trace, depRequest ) ); node = repoSystem.collectDependencies( pluginSession, request ).getRoot(); if ( logger.isDebugEnabled() ) { node.accept( new GraphLogger() ); } depRequest.setRoot( node ); repoSystem.resolveDependencies( session, depRequest ); } catch ( DependencyCollectionException e ) { throw new PluginResolutionException( plugin, e ); } catch ( DependencyResolutionException e ) { throw new PluginResolutionException( plugin, e.getCause() ); } return node; } class GraphLogger implements DependencyVisitor { private String indent = ""; public boolean visitEnter( DependencyNode node ) { StringBuilder buffer = new StringBuilder( 128 ); buffer.append( indent ); org.eclipse.aether.graph.Dependency dep = node.getDependency(); if ( dep != null ) { Artifact art = dep.getArtifact(); buffer.append( art ); buffer.append( ':' ).append( dep.getScope() ); } logger.debug( buffer.toString() ); indent += " "; return true; } public boolean visitLeave( DependencyNode node ) { indent = indent.substring( 0, indent.length() - 3 ); return true; } } } DefaultPluginManager.java000066400000000000000000000237701317160430700335100ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/plugin/internalpackage org.apache.maven.plugin.internal; /* * 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 org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.resolver.ArtifactNotFoundException; import org.apache.maven.artifact.resolver.ArtifactResolutionException; import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException; import org.apache.maven.execution.MavenSession; import org.apache.maven.model.Plugin; import org.apache.maven.plugin.InvalidPluginDescriptorException; import org.apache.maven.plugin.InvalidPluginException; import org.apache.maven.plugin.LegacySupport; import org.apache.maven.plugin.MavenPluginManager; import org.apache.maven.plugin.MojoExecution; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoFailureException; import org.apache.maven.plugin.PluginConfigurationException; import org.apache.maven.plugin.PluginDescriptorParsingException; import org.apache.maven.plugin.PluginManager; import org.apache.maven.plugin.PluginManagerException; import org.apache.maven.plugin.PluginNotFoundException; import org.apache.maven.plugin.PluginResolutionException; import org.apache.maven.plugin.descriptor.PluginDescriptor; import org.apache.maven.plugin.prefix.DefaultPluginPrefixRequest; import org.apache.maven.plugin.prefix.NoPluginFoundForPrefixException; import org.apache.maven.plugin.prefix.PluginPrefixRequest; import org.apache.maven.plugin.prefix.PluginPrefixResolver; import org.apache.maven.plugin.prefix.PluginPrefixResult; import org.apache.maven.plugin.version.DefaultPluginVersionRequest; import org.apache.maven.plugin.version.PluginVersionNotFoundException; import org.apache.maven.plugin.version.PluginVersionRequest; import org.apache.maven.plugin.version.PluginVersionResolutionException; import org.apache.maven.plugin.version.PluginVersionResolver; import org.apache.maven.project.MavenProject; import org.apache.maven.project.artifact.InvalidDependencyVersionException; import org.apache.maven.settings.Settings; import org.codehaus.plexus.PlexusContainer; import org.codehaus.plexus.component.annotations.Component; import org.codehaus.plexus.component.annotations.Requirement; import org.codehaus.plexus.component.repository.exception.ComponentLookupException; import java.util.Map; /** * @author Benjamin Bentmann */ @Component( role = PluginManager.class ) public class DefaultPluginManager implements PluginManager { @Requirement private PlexusContainer container; @Requirement private MavenPluginManager pluginManager; @Requirement private PluginVersionResolver pluginVersionResolver; @Requirement private PluginPrefixResolver pluginPrefixResolver; @Requirement private LegacySupport legacySupport; public void executeMojo( MavenProject project, MojoExecution execution, MavenSession session ) throws MojoExecutionException, ArtifactResolutionException, MojoFailureException, ArtifactNotFoundException, InvalidDependencyVersionException, PluginManagerException, PluginConfigurationException { throw new UnsupportedOperationException(); } public Object getPluginComponent( Plugin plugin, String role, String roleHint ) throws PluginManagerException, ComponentLookupException { MavenSession session = legacySupport.getSession(); PluginDescriptor pluginDescriptor; try { pluginDescriptor = pluginManager.getPluginDescriptor( plugin, session.getCurrentProject().getRemotePluginRepositories(), session.getRepositorySession() ); pluginManager.setupPluginRealm( pluginDescriptor, session, null, null, null ); } catch ( Exception e ) { throw new PluginManagerException( plugin, e.getMessage(), e ); } ClassLoader oldClassLoader = Thread.currentThread().getContextClassLoader(); try { Thread.currentThread().setContextClassLoader( pluginDescriptor.getClassRealm() ); return container.lookup( role, roleHint ); } finally { Thread.currentThread().setContextClassLoader( oldClassLoader ); } } public Map getPluginComponents( Plugin plugin, String role ) throws ComponentLookupException, PluginManagerException { MavenSession session = legacySupport.getSession(); PluginDescriptor pluginDescriptor; try { pluginDescriptor = pluginManager.getPluginDescriptor( plugin, session.getCurrentProject().getRemotePluginRepositories(), session.getRepositorySession() ); pluginManager.setupPluginRealm( pluginDescriptor, session, null, null, null ); } catch ( Exception e ) { throw new PluginManagerException( plugin, e.getMessage(), e ); } ClassLoader oldClassLoader = Thread.currentThread().getContextClassLoader(); try { Thread.currentThread().setContextClassLoader( pluginDescriptor.getClassRealm() ); return container.lookupMap( role ); } finally { Thread.currentThread().setContextClassLoader( oldClassLoader ); } } public Plugin getPluginDefinitionForPrefix( String prefix, MavenSession session, MavenProject project ) { PluginPrefixRequest request = new DefaultPluginPrefixRequest( prefix, session ); request.setPom( project.getModel() ); try { PluginPrefixResult result = pluginPrefixResolver.resolve( request ); Plugin plugin = new Plugin(); plugin.setGroupId( result.getGroupId() ); plugin.setArtifactId( result.getArtifactId() ); return plugin; } catch ( NoPluginFoundForPrefixException e ) { return null; } } public PluginDescriptor getPluginDescriptorForPrefix( String prefix ) { MavenSession session = legacySupport.getSession(); PluginPrefixRequest request = new DefaultPluginPrefixRequest( prefix, session ); try { PluginPrefixResult result = pluginPrefixResolver.resolve( request ); Plugin plugin = new Plugin(); plugin.setGroupId( result.getGroupId() ); plugin.setArtifactId( result.getArtifactId() ); return loadPluginDescriptor( plugin, session.getCurrentProject(), session ); } catch ( Exception e ) { return null; } } public PluginDescriptor loadPluginDescriptor( Plugin plugin, MavenProject project, MavenSession session ) throws ArtifactResolutionException, PluginVersionResolutionException, ArtifactNotFoundException, InvalidVersionSpecificationException, InvalidPluginException, PluginManagerException, PluginNotFoundException, PluginVersionNotFoundException { return verifyPlugin( plugin, project, session.getSettings(), session.getLocalRepository() ); } public PluginDescriptor loadPluginFully( Plugin plugin, MavenProject project, MavenSession session ) throws ArtifactResolutionException, PluginVersionResolutionException, ArtifactNotFoundException, InvalidVersionSpecificationException, InvalidPluginException, PluginManagerException, PluginNotFoundException, PluginVersionNotFoundException { PluginDescriptor pluginDescriptor = loadPluginDescriptor( plugin, project, session ); try { pluginManager.setupPluginRealm( pluginDescriptor, session, null, null, null ); } catch ( PluginResolutionException e ) { throw new PluginManagerException( plugin, e.getMessage(), e ); } return pluginDescriptor; } public PluginDescriptor verifyPlugin( Plugin plugin, MavenProject project, Settings settings, ArtifactRepository localRepository ) throws ArtifactResolutionException, PluginVersionResolutionException, ArtifactNotFoundException, InvalidVersionSpecificationException, InvalidPluginException, PluginManagerException, PluginNotFoundException, PluginVersionNotFoundException { MavenSession session = legacySupport.getSession(); if ( plugin.getVersion() == null ) { PluginVersionRequest versionRequest = new DefaultPluginVersionRequest( plugin, session.getRepositorySession(), project.getRemotePluginRepositories() ); plugin.setVersion( pluginVersionResolver.resolve( versionRequest ).getVersion() ); } try { return pluginManager.getPluginDescriptor( plugin, project.getRemotePluginRepositories(), session.getRepositorySession() ); } catch ( PluginResolutionException e ) { throw new PluginNotFoundException( plugin, project.getPluginArtifactRepositories() ); } catch ( PluginDescriptorParsingException | InvalidPluginDescriptorException e ) { throw new PluginManagerException( plugin, e.getMessage(), e ); } } } maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/plugin/internal/PlexusUtilsInjector.java000066400000000000000000000060141317160430700335200ustar00rootroot00000000000000package org.apache.maven.plugin.internal; /* * 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 org.eclipse.aether.RepositoryException; import org.eclipse.aether.artifact.Artifact; import org.eclipse.aether.artifact.DefaultArtifact; import org.eclipse.aether.collection.DependencyGraphTransformationContext; import org.eclipse.aether.collection.DependencyGraphTransformer; import org.eclipse.aether.graph.DefaultDependencyNode; import org.eclipse.aether.graph.Dependency; import org.eclipse.aether.graph.DependencyNode; import org.eclipse.aether.util.artifact.JavaScopes; /** * Injects plexus-utils:1.1 into a plugin's class path if it doesn't already declare a dependency on plexus-utils. This * is another legacy bit to provide backward-compat with Maven 2.x. * * @author Benjamin Bentmann */ class PlexusUtilsInjector implements DependencyGraphTransformer { private static final String GID = "org.codehaus.plexus"; private static final String AID = "plexus-utils"; private static final String VER = "1.1"; private static final String EXT = "jar"; public DependencyNode transformGraph( DependencyNode node, DependencyGraphTransformationContext context ) throws RepositoryException { if ( findPlexusUtils( node ) == null ) { Artifact pu = new DefaultArtifact( GID, AID, null, EXT, VER ); DefaultDependencyNode child = new DefaultDependencyNode( new Dependency( pu, JavaScopes.RUNTIME ) ); child.setRepositories( node.getRepositories() ); child.setRequestContext( node.getRequestContext() ); node.getChildren().add( child ); } return node; } private DependencyNode findPlexusUtils( DependencyNode node ) { Artifact artifact = node.getDependency().getArtifact(); if ( AID.equals( artifact.getArtifactId() ) && GID.equals( artifact.getGroupId() ) && EXT.equals( artifact.getExtension() ) && "".equals( artifact.getClassifier() ) ) { return node; } for ( DependencyNode child : node.getChildren() ) { DependencyNode result = findPlexusUtils( child ); if ( result != null ) { return result; } } return null; } } PluginDependenciesResolver.java000066400000000000000000000065001317160430700347310ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/plugin/internalpackage org.apache.maven.plugin.internal; /* * 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.util.List; import org.apache.maven.model.Plugin; import org.apache.maven.plugin.PluginResolutionException; import org.eclipse.aether.RepositorySystemSession; import org.eclipse.aether.artifact.Artifact; import org.eclipse.aether.graph.DependencyFilter; import org.eclipse.aether.graph.DependencyNode; import org.eclipse.aether.repository.RemoteRepository; /** * Assists in resolving the dependencies of a plugin. Warning: This is an internal utility interface * that is only public for technical reasons, it is not part of the public API. In particular, this interface can be * changed or deleted without prior notice. * * @since 3.0 * @author Benjamin Bentmann */ public interface PluginDependenciesResolver { /** * Resolves the main artifact of the specified plugin. * * @param plugin The plugin for which to resolve the main artifact, must not be {@code null}. * @param repositories The plugin repositories to use for resolving the plugin's main artifact, must not be {@code * null}. * @param session The repository session to use for resolving the plugin's main artifact, must not be {@code null}. * @return The resolved plugin artifact, never {@code null}. * @throws PluginResolutionException If the plugin artifact could not be resolved. */ Artifact resolve( Plugin plugin, List repositories, RepositorySystemSession session ) throws PluginResolutionException; /** * Resolves the runtime dependencies of the specified plugin. * * @param plugin The plugin for which to resolve the dependencies, must not be {@code null}. * @param pluginArtifact The plugin's main artifact, may be {@code null}. * @param dependencyFilter A filter to exclude artifacts from resolution (but not collection), may be {@code null}. * @param repositories The plugin repositories to use for resolving the plugin artifacts, must not be {@code null}. * @param session The repository session to use for resolving the plugin artifacts, must not be {@code null}. * @return The dependency tree denoting the resolved plugin class path, never {@code null}. * @throws PluginResolutionException If any dependency could not be resolved. */ DependencyNode resolve( Plugin plugin, Artifact pluginArtifact, DependencyFilter dependencyFilter, List repositories, RepositorySystemSession session ) throws PluginResolutionException; } PluginDependencyResolutionListener.java000066400000000000000000000112271317160430700364730ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/plugin/internalpackage org.apache.maven.plugin.internal; /* * 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.util.Collection; import java.util.IdentityHashMap; import java.util.Iterator; import java.util.LinkedList; import java.util.Map; import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.resolver.ResolutionListener; import org.apache.maven.artifact.resolver.filter.ArtifactFilter; import org.apache.maven.artifact.versioning.VersionRange; /** * Assists in detecting wagon providers brought into the plugin class path via legacy Maven core artifacts (e.g. * maven-core:2.0.6) and excluding them. A plugin should be able to explicitly declare dependencies on specific wagons * for its use. However, the (old) wagons pulled in transitively via legacy Maven core artifacts are usually not * intended as dependencies and more importantly screw up artifact resolution because they would get preferred over the * core wagon versions. This is a hack to provide backward-compat with Maven 2 (MNG-4528, MNG-4561). * * @since 3.0 * @author Benjamin Bentmann */ class PluginDependencyResolutionListener implements ResolutionListener { private ArtifactFilter coreFilter; private LinkedList coreArtifacts = new LinkedList<>(); private Artifact wagonProvider; private Map bannedArtifacts = new IdentityHashMap<>(); public PluginDependencyResolutionListener( ArtifactFilter coreFilter ) { this.coreFilter = coreFilter; } public void removeBannedDependencies( Collection artifacts ) { if ( !bannedArtifacts.isEmpty() && artifacts != null ) { for ( Iterator it = artifacts.iterator(); it.hasNext(); ) { Artifact artifact = it.next(); if ( bannedArtifacts.containsKey( artifact ) ) { it.remove(); } } } } public void startProcessChildren( Artifact artifact ) { if ( wagonProvider == null ) { if ( isLegacyCoreArtifact( artifact ) ) { coreArtifacts.addFirst( artifact ); } else if ( !coreArtifacts.isEmpty() && isWagonProvider( artifact ) ) { wagonProvider = artifact; bannedArtifacts.put( artifact, null ); } } } private boolean isLegacyCoreArtifact( Artifact artifact ) { String version = artifact.getVersion(); return version != null && version.startsWith( "2." ) && !coreFilter.include( artifact ); } public void endProcessChildren( Artifact artifact ) { if ( wagonProvider == artifact ) { wagonProvider = null; } else if ( coreArtifacts.peek() == artifact ) { coreArtifacts.removeFirst(); } } public void includeArtifact( Artifact artifact ) { if ( wagonProvider != null ) { bannedArtifacts.put( artifact, null ); } } private boolean isWagonProvider( Artifact artifact ) { if ( "org.apache.maven.wagon".equals( artifact.getGroupId() ) ) { return artifact.getArtifactId().startsWith( "wagon-" ); } return false; } public void manageArtifact( Artifact artifact, Artifact replacement ) { } public void omitForCycle( Artifact artifact ) { } public void omitForNearer( Artifact omitted, Artifact kept ) { } public void restrictRange( Artifact artifact, Artifact replacement, VersionRange newRange ) { } public void selectVersionFromRange( Artifact artifact ) { } public void testArtifact( Artifact node ) { } public void updateScope( Artifact artifact, String scope ) { } public void updateScopeCurrentPom( Artifact artifact, String ignoredScope ) { } } ValidatingConfigurationListener.java000066400000000000000000000055351317160430700357710ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/plugin/internalpackage org.apache.maven.plugin.internal; /* * 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.util.Collection; import java.util.HashMap; import java.util.Map; import org.apache.maven.plugin.descriptor.MojoDescriptor; import org.apache.maven.plugin.descriptor.Parameter; import org.codehaus.plexus.component.configurator.ConfigurationListener; /** * A configuration listener to help validate the plugin configuration. For instance, check for required but missing * parameters. * * @author Benjamin Bentmann */ class ValidatingConfigurationListener implements ConfigurationListener { private final Object mojo; private final ConfigurationListener delegate; private final Map missingParameters; public ValidatingConfigurationListener( Object mojo, MojoDescriptor mojoDescriptor, ConfigurationListener delegate ) { this.mojo = mojo; this.delegate = delegate; this.missingParameters = new HashMap<>(); if ( mojoDescriptor.getParameters() != null ) { for ( Parameter param : mojoDescriptor.getParameters() ) { if ( param.isRequired() ) { missingParameters.put( param.getName(), param ); } } } } public Collection getMissingParameters() { return missingParameters.values(); } public void notifyFieldChangeUsingSetter( String fieldName, Object value, Object target ) { delegate.notifyFieldChangeUsingSetter( fieldName, value, target ); if ( mojo == target ) { notify( fieldName, value ); } } public void notifyFieldChangeUsingReflection( String fieldName, Object value, Object target ) { delegate.notifyFieldChangeUsingReflection( fieldName, value, target ); if ( mojo == target ) { notify( fieldName, value ); } } private void notify( String fieldName, Object value ) { if ( value != null ) { missingParameters.remove( fieldName ); } } } maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/plugin/internal/WagonExcluder.java000066400000000000000000000066441317160430700323010ustar00rootroot00000000000000package org.apache.maven.plugin.internal; /* * 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 org.eclipse.aether.artifact.Artifact; import org.eclipse.aether.collection.DependencyCollectionContext; import org.eclipse.aether.collection.DependencySelector; import org.eclipse.aether.graph.Dependency; /** * Assists in detecting wagon providers brought into the plugin class path via legacy Maven core artifacts (e.g. * maven-core:2.0.6) and excluding them. A plugin should be able to explicitly declare dependencies on specific wagons * for its use. However, the (old) wagons pulled in transitively via legacy Maven core artifacts are usually not * intended as dependencies and more importantly screw up artifact resolution because they would get preferred over the * core wagon versions. This is a hack to provide backward-compat with Maven 2 (MNG-4528, MNG-4561). * * @author Benjamin Bentmann */ class WagonExcluder implements DependencySelector { private final boolean coreArtifact; public WagonExcluder() { this( false ); } private WagonExcluder( boolean coreArtifact ) { this.coreArtifact = coreArtifact; } public boolean selectDependency( Dependency dependency ) { return !coreArtifact || !isWagonProvider( dependency.getArtifact() ); } public DependencySelector deriveChildSelector( DependencyCollectionContext context ) { if ( coreArtifact || !isLegacyCoreArtifact( context.getDependency().getArtifact() ) ) { return this; } else { return new WagonExcluder( true ); } } private boolean isLegacyCoreArtifact( Artifact artifact ) { String version = artifact.getVersion(); return version != null && version.startsWith( "2." ) && artifact.getArtifactId().startsWith( "maven-" ) && artifact.getGroupId().equals( "org.apache.maven" ); } private boolean isWagonProvider( Artifact artifact ) { if ( "org.apache.maven.wagon".equals( artifact.getGroupId() ) ) { return artifact.getArtifactId().startsWith( "wagon-" ); } return false; } @Override public boolean equals( Object obj ) { if ( obj == this ) { return true; } else if ( obj == null || !getClass().equals( obj.getClass() ) ) { return false; } WagonExcluder that = (WagonExcluder) obj; return coreArtifact == that.coreArtifact; } @Override public int hashCode() { int hash = getClass().hashCode(); hash = hash * 31 + ( coreArtifact ? 1 : 0 ); return hash; } } maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/plugin/prefix/000077500000000000000000000000001317160430700263365ustar00rootroot00000000000000DefaultPluginPrefixRequest.java000066400000000000000000000077061317160430700344260ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/plugin/prefixpackage org.apache.maven.plugin.prefix; /* * 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.util.Collections; import java.util.List; import org.apache.maven.execution.MavenSession; import org.apache.maven.model.Model; import org.apache.maven.project.MavenProject; import org.eclipse.aether.RepositorySystemSession; import org.eclipse.aether.repository.RemoteRepository; /** * Collects settings required to resolve a plugin prefix. * * @since 3.0 * @author Benjamin Bentmann */ public class DefaultPluginPrefixRequest implements PluginPrefixRequest { private String prefix; private List pluginGroups = Collections.emptyList(); private Model pom; private List repositories = Collections.emptyList(); private RepositorySystemSession session; /** * Creates an empty request. */ public DefaultPluginPrefixRequest() { } /** * Creates a request for the specified plugin prefix and build session. The provided build session will be used to * configure repository settings. If the session has a current project, its plugin repositories and model will be * used as well. * * @param prefix The plugin prefix to resolve, must not be {@code null}. * @param session The build session from which to derive further settings, must not be {@code null}. */ public DefaultPluginPrefixRequest( String prefix, MavenSession session ) { setPrefix( prefix ); setRepositorySession( session.getRepositorySession() ); MavenProject project = session.getCurrentProject(); if ( project != null ) { setRepositories( project.getRemotePluginRepositories() ); setPom( project.getModel() ); } setPluginGroups( session.getPluginGroups() ); } public String getPrefix() { return prefix; } public DefaultPluginPrefixRequest setPrefix( String prefix ) { this.prefix = prefix; return this; } public List getPluginGroups() { return pluginGroups; } public DefaultPluginPrefixRequest setPluginGroups( List pluginGroups ) { if ( pluginGroups != null ) { this.pluginGroups = pluginGroups; } else { this.pluginGroups = Collections.emptyList(); } return this; } public Model getPom() { return pom; } public DefaultPluginPrefixRequest setPom( Model pom ) { this.pom = pom; return this; } public List getRepositories() { return repositories; } public DefaultPluginPrefixRequest setRepositories( List repositories ) { if ( repositories != null ) { this.repositories = repositories; } else { this.repositories = Collections.emptyList(); } return this; } public RepositorySystemSession getRepositorySession() { return session; } public DefaultPluginPrefixRequest setRepositorySession( RepositorySystemSession session ) { this.session = session; return this; } } NoPluginFoundForPrefixException.java000066400000000000000000000042741317160430700353640ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/plugin/prefixpackage org.apache.maven.plugin.prefix; /* * 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.util.List; import org.eclipse.aether.repository.LocalRepository; import org.eclipse.aether.repository.RemoteRepository; public class NoPluginFoundForPrefixException extends Exception { public NoPluginFoundForPrefixException( String prefix, List pluginGroups, LocalRepository localRepository, List remoteRepositories ) { super( "No plugin found for prefix '" + prefix + "' in the current project and in the plugin groups " + pluginGroups + " available from the repositories " + format( localRepository, remoteRepositories ) ); } private static String format( LocalRepository localRepository, List remoteRepositories ) { String repos = "["; if ( localRepository != null ) { repos += localRepository.getId() + " (" + localRepository.getBasedir() + ")"; } if ( remoteRepositories != null && !remoteRepositories.isEmpty() ) { for ( RemoteRepository repository : remoteRepositories ) { repos += ", "; if ( repository != null ) { repos += repository.getId() + " (" + repository.getUrl() + ")"; } } } repos += "]"; return repos; } } maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/plugin/prefix/PluginPrefixRequest.java000066400000000000000000000071671317160430700332010ustar00rootroot00000000000000package org.apache.maven.plugin.prefix; /* * 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.util.List; import org.apache.maven.model.Model; import org.eclipse.aether.RepositorySystemSession; import org.eclipse.aether.repository.RemoteRepository; /** * Collects settings required to resolve a plugin prefix. * * @since 3.0 * @author Benjamin Bentmann */ public interface PluginPrefixRequest { /** * Gets the prefix of the plugin. * * @return The prefix of the plugin. */ String getPrefix(); /** * Sets the prefix of the plugin. * * @param prefix The prefix of the plugin. * @return This request, never {@code null}. */ PluginPrefixRequest setPrefix( String prefix ); /** * Gets the list of group ids to scan for the plugin prefix. * * @return The list of group ids to scan for the plugin prefix, never {@code null}. */ List getPluginGroups(); /** * Sets the list of group ids to scan for the plugin prefix. * * @param pluginGroups The list of group ids to scan for the plugin prefix, may be {@code null}. * @return This request, never {@code null}. */ PluginPrefixRequest setPluginGroups( List pluginGroups ); /** * Gets the POM whose build plugins are to be scanned for the prefix. * * @return The POM whose build plugins are to be scanned for the prefix or {@code null} to only search the plugin * repositories. */ Model getPom(); /** * Sets the POM whose build plugins are to be scanned for the prefix. * * @param pom The POM whose build plugins are to be scanned for the prefix, may be {@code null} to only search the * plugin repositories. * @return This request, never {@code null}. */ PluginPrefixRequest setPom( Model pom ); /** * Gets the remote repositories to use. * * @return The remote repositories to use, never {@code null}. */ List getRepositories(); /** * Sets the remote repositories to use. Note: When creating a request from a project, be sure to use the * plugin repositories and not the regular project repositories. * * @param repositories The remote repositories to use. * @return This request, never {@code null}. */ PluginPrefixRequest setRepositories( List repositories ); /** * Gets the session to use for repository access. * * @return The repository session or {@code null} if not set. */ RepositorySystemSession getRepositorySession(); /** * Sets the session to use for repository access. * * @param repositorySession The repository session to use. * @return This request, never {@code null}. */ PluginPrefixRequest setRepositorySession( RepositorySystemSession repositorySession ); } maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/plugin/prefix/PluginPrefixResolver.java000066400000000000000000000027151317160430700333440ustar00rootroot00000000000000package org.apache.maven.plugin.prefix; /* * 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. */ /** * Resolves a plugin prefix. * * @since 3.0 * @author Benjamin Bentmann */ public interface PluginPrefixResolver { /** * Resolves the plugin prefix for the specified request. * * @param request The request that holds the details about the plugin and the repositories to consult, must not be * {@code null}. * @return The result of the prefix resolution, never {@code null}. * @throws NoPluginFoundForPrefixException If the plugin prefix could not be resolved. */ PluginPrefixResult resolve( PluginPrefixRequest request ) throws NoPluginFoundForPrefixException; } maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/plugin/prefix/PluginPrefixResult.java000066400000000000000000000032321317160430700330140ustar00rootroot00000000000000package org.apache.maven.plugin.prefix; /* * 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 org.eclipse.aether.repository.ArtifactRepository; /** * Describes the result of a plugin prefix resolution request. * * @since 3.0 * @author Benjamin Bentmann */ public interface PluginPrefixResult { /** * The resolved group id for the plugin. * * @return The resolved group id for the plugin, never {@code null}. */ String getGroupId(); /** * The resolved artifact id for the plugin. * * @return The resolved artifact id for the plugin, never {@code null}. */ String getArtifactId(); /** * The repository from which the plugin prefix was resolved. * * @return The repository from which the plugin prefix was resolved or {@code null} if the prefix was resolved from * the supplied POM. */ ArtifactRepository getRepository(); } maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/plugin/prefix/internal/000077500000000000000000000000001317160430700301525ustar00rootroot00000000000000DefaultPluginPrefixResolver.java000066400000000000000000000255371317160430700364150ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/plugin/prefix/internalpackage org.apache.maven.plugin.prefix.internal; /* * 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.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.Map; import org.apache.maven.artifact.repository.metadata.Metadata; import org.apache.maven.artifact.repository.metadata.io.MetadataReader; import org.apache.maven.model.Build; import org.apache.maven.model.Plugin; import org.apache.maven.plugin.BuildPluginManager; import org.apache.maven.plugin.descriptor.PluginDescriptor; import org.apache.maven.plugin.prefix.NoPluginFoundForPrefixException; import org.apache.maven.plugin.prefix.PluginPrefixRequest; import org.apache.maven.plugin.prefix.PluginPrefixResolver; import org.apache.maven.plugin.prefix.PluginPrefixResult; import org.codehaus.plexus.component.annotations.Component; import org.codehaus.plexus.component.annotations.Requirement; import org.codehaus.plexus.logging.Logger; import org.eclipse.aether.RepositoryEvent.EventType; import org.eclipse.aether.DefaultRepositorySystemSession; import org.eclipse.aether.RepositoryEvent; import org.eclipse.aether.RepositoryListener; import org.eclipse.aether.RepositorySystem; import org.eclipse.aether.RepositorySystemSession; import org.eclipse.aether.RequestTrace; import org.eclipse.aether.metadata.DefaultMetadata; import org.eclipse.aether.repository.ArtifactRepository; import org.eclipse.aether.repository.RemoteRepository; import org.eclipse.aether.repository.RepositoryPolicy; import org.eclipse.aether.resolution.MetadataRequest; import org.eclipse.aether.resolution.MetadataResult; /** * Resolves a plugin prefix. * * @since 3.0 * @author Benjamin Bentmann */ @Component( role = PluginPrefixResolver.class ) public class DefaultPluginPrefixResolver implements PluginPrefixResolver { private static final String REPOSITORY_CONTEXT = "plugin"; @Requirement private Logger logger; @Requirement private BuildPluginManager pluginManager; @Requirement private RepositorySystem repositorySystem; @Requirement private MetadataReader metadataReader; public PluginPrefixResult resolve( PluginPrefixRequest request ) throws NoPluginFoundForPrefixException { logger.debug( "Resolving plugin prefix " + request.getPrefix() + " from " + request.getPluginGroups() ); PluginPrefixResult result = resolveFromProject( request ); if ( result == null ) { result = resolveFromRepository( request ); if ( result == null ) { throw new NoPluginFoundForPrefixException( request.getPrefix(), request.getPluginGroups(), request.getRepositorySession().getLocalRepository(), request.getRepositories() ); } else if ( logger.isDebugEnabled() ) { logger.debug( "Resolved plugin prefix " + request.getPrefix() + " to " + result.getGroupId() + ":" + result.getArtifactId() + " from repository " + ( result.getRepository() != null ? result.getRepository().getId() : "null" ) ); } } else if ( logger.isDebugEnabled() ) { logger.debug( "Resolved plugin prefix " + request.getPrefix() + " to " + result.getGroupId() + ":" + result.getArtifactId() + " from POM " + request.getPom() ); } return result; } private PluginPrefixResult resolveFromProject( PluginPrefixRequest request ) { PluginPrefixResult result = null; if ( request.getPom() != null && request.getPom().getBuild() != null ) { Build build = request.getPom().getBuild(); result = resolveFromProject( request, build.getPlugins() ); if ( result == null && build.getPluginManagement() != null ) { result = resolveFromProject( request, build.getPluginManagement().getPlugins() ); } } return result; } private PluginPrefixResult resolveFromProject( PluginPrefixRequest request, List plugins ) { for ( Plugin plugin : plugins ) { try { PluginDescriptor pluginDescriptor = pluginManager.loadPlugin( plugin, request.getRepositories(), request.getRepositorySession() ); if ( request.getPrefix().equals( pluginDescriptor.getGoalPrefix() ) ) { return new DefaultPluginPrefixResult( plugin ); } } catch ( Exception e ) { if ( logger.isDebugEnabled() ) { logger.warn( "Failed to retrieve plugin descriptor for " + plugin.getId() + ": " + e.getMessage(), e ); } else { logger.warn( "Failed to retrieve plugin descriptor for " + plugin.getId() + ": " + e.getMessage() ); } } } return null; } private PluginPrefixResult resolveFromRepository( PluginPrefixRequest request ) { RequestTrace trace = RequestTrace.newChild( null, request ); List requests = new ArrayList<>(); for ( String pluginGroup : request.getPluginGroups() ) { org.eclipse.aether.metadata.Metadata metadata = new DefaultMetadata( pluginGroup, "maven-metadata.xml", DefaultMetadata.Nature.RELEASE_OR_SNAPSHOT ); requests.add( new MetadataRequest( metadata, null, REPOSITORY_CONTEXT ).setTrace( trace ) ); for ( RemoteRepository repository : request.getRepositories() ) { requests.add( new MetadataRequest( metadata, repository, REPOSITORY_CONTEXT ).setTrace( trace ) ); } } // initial try, use locally cached metadata List results = repositorySystem.resolveMetadata( request.getRepositorySession(), requests ); requests.clear(); PluginPrefixResult result = processResults( request, trace, results, requests ); if ( result != null ) { return result; } // second try, refetch all (possibly outdated) metadata that wasn't updated in the first attempt if ( !request.getRepositorySession().isOffline() && !requests.isEmpty() ) { DefaultRepositorySystemSession session = new DefaultRepositorySystemSession( request.getRepositorySession() ); session.setUpdatePolicy( RepositoryPolicy.UPDATE_POLICY_ALWAYS ); results = repositorySystem.resolveMetadata( session, requests ); return processResults( request, trace, results, null ); } return null; } private PluginPrefixResult processResults( PluginPrefixRequest request, RequestTrace trace, List results, List requests ) { for ( MetadataResult res : results ) { org.eclipse.aether.metadata.Metadata metadata = res.getMetadata(); if ( metadata != null ) { ArtifactRepository repository = res.getRequest().getRepository(); if ( repository == null ) { repository = request.getRepositorySession().getLocalRepository(); } PluginPrefixResult result = resolveFromRepository( request, trace, metadata.getGroupId(), metadata, repository ); if ( result != null ) { return result; } } if ( requests != null && !res.isUpdated() ) { requests.add( res.getRequest() ); } } return null; } private PluginPrefixResult resolveFromRepository( PluginPrefixRequest request, RequestTrace trace, String pluginGroup, org.eclipse.aether.metadata.Metadata metadata, ArtifactRepository repository ) { if ( metadata != null && metadata.getFile() != null && metadata.getFile().isFile() ) { try { Map options = Collections.singletonMap( MetadataReader.IS_STRICT, Boolean.FALSE ); Metadata pluginGroupMetadata = metadataReader.read( metadata.getFile(), options ); List plugins = pluginGroupMetadata.getPlugins(); if ( plugins != null ) { for ( org.apache.maven.artifact.repository.metadata.Plugin plugin : plugins ) { if ( request.getPrefix().equals( plugin.getPrefix() ) ) { return new DefaultPluginPrefixResult( pluginGroup, plugin.getArtifactId(), repository ); } } } } catch ( IOException e ) { invalidMetadata( request.getRepositorySession(), trace, metadata, repository, e ); } } return null; } private void invalidMetadata( RepositorySystemSession session, RequestTrace trace, org.eclipse.aether.metadata.Metadata metadata, ArtifactRepository repository, Exception exception ) { RepositoryListener listener = session.getRepositoryListener(); if ( listener != null ) { RepositoryEvent.Builder event = new RepositoryEvent.Builder( session, EventType.METADATA_INVALID ); event.setTrace( trace ); event.setMetadata( metadata ); event.setException( exception ); event.setRepository( repository ); listener.metadataInvalid( event.build() ); } } } DefaultPluginPrefixResult.java000066400000000000000000000043651317160430700360660ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/plugin/prefix/internalpackage org.apache.maven.plugin.prefix.internal; /* * 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 org.apache.maven.model.Plugin; import org.apache.maven.plugin.prefix.PluginPrefixResult; import org.eclipse.aether.repository.ArtifactRepository; /** * Describes the result of a plugin prefix resolution request. * * @since 3.0 * @author Benjamin Bentmann */ class DefaultPluginPrefixResult implements PluginPrefixResult { private String groupId; private String artifactId; private ArtifactRepository repository; public DefaultPluginPrefixResult() { // does nothing } public DefaultPluginPrefixResult( Plugin plugin ) { groupId = plugin.getGroupId(); artifactId = plugin.getArtifactId(); } public DefaultPluginPrefixResult( String groupId, String artifactId, ArtifactRepository repository ) { this.groupId = groupId; this.artifactId = artifactId; this.repository = repository; } public String getGroupId() { return groupId; } public void setGroupId( String groupId ) { this.groupId = groupId; } public String getArtifactId() { return artifactId; } public void setArtifactId( String artifactId ) { this.artifactId = artifactId; } public ArtifactRepository getRepository() { return repository; } public void setRepository( ArtifactRepository repository ) { this.repository = repository; } } maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/plugin/version/000077500000000000000000000000001317160430700265265ustar00rootroot00000000000000DefaultPluginVersionRequest.java000066400000000000000000000106461317160430700350030ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/plugin/versionpackage org.apache.maven.plugin.version; /* * 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.util.Collections; import java.util.List; import org.apache.maven.execution.MavenSession; import org.apache.maven.model.Model; import org.apache.maven.model.Plugin; import org.apache.maven.project.MavenProject; import org.eclipse.aether.RepositorySystemSession; import org.eclipse.aether.repository.RemoteRepository; /** * Collects settings required to resolve the version for a plugin. * * @since 3.0 * @author Benjamin Bentmann */ public class DefaultPluginVersionRequest implements PluginVersionRequest { private String groupId; private String artifactId; private Model pom; private List repositories = Collections.emptyList(); private RepositorySystemSession session; /** * Creates an empty request. */ public DefaultPluginVersionRequest() { } /** * Creates a request for the specified plugin by copying settings from the specified build session. If the session * has a current project, its plugin repositories will be used as well. * * @param plugin The plugin for which to resolve a version, must not be {@code null}. * @param session The Maven session to use, must not be {@code null}. */ public DefaultPluginVersionRequest( Plugin plugin, MavenSession session ) { setGroupId( plugin.getGroupId() ); setArtifactId( plugin.getArtifactId() ); setRepositorySession( session.getRepositorySession() ); MavenProject project = session.getCurrentProject(); if ( project != null ) { setRepositories( project.getRemotePluginRepositories() ); } } /** * Creates a request for the specified plugin using the given repository session and plugin repositories. * * @param plugin The plugin for which to resolve a version, must not be {@code null}. * @param session The repository session to use, must not be {@code null}. * @param repositories The plugin repositories to query, may be {@code null}. */ public DefaultPluginVersionRequest( Plugin plugin, RepositorySystemSession session, List repositories ) { setGroupId( plugin.getGroupId() ); setArtifactId( plugin.getArtifactId() ); setRepositorySession( session ); setRepositories( repositories ); } public String getGroupId() { return groupId; } public DefaultPluginVersionRequest setGroupId( String groupId ) { this.groupId = groupId; return this; } public String getArtifactId() { return artifactId; } public DefaultPluginVersionRequest setArtifactId( String artifactId ) { this.artifactId = artifactId; return this; } public Model getPom() { return pom; } public DefaultPluginVersionRequest setPom( Model pom ) { this.pom = pom; return this; } public List getRepositories() { return repositories; } public DefaultPluginVersionRequest setRepositories( List repositories ) { if ( repositories != null ) { this.repositories = repositories; } else { this.repositories = Collections.emptyList(); } return this; } public RepositorySystemSession getRepositorySession() { return session; } public DefaultPluginVersionRequest setRepositorySession( RepositorySystemSession session ) { this.session = session; return this; } } PluginVersionNotFoundException.java000066400000000000000000000026121317160430700354530ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/plugin/versionpackage org.apache.maven.plugin.version; /* * 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. */ public class PluginVersionNotFoundException extends Exception { private final String groupId; private final String artifactId; public PluginVersionNotFoundException( String groupId, String artifactId ) { super( "The plugin \'" + groupId + ":" + artifactId + "\' does not exist or no valid version could be found" ); this.groupId = groupId; this.artifactId = artifactId; } public String getGroupId() { return groupId; } public String getArtifactId() { return artifactId; } } maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/plugin/version/PluginVersionRequest.java000066400000000000000000000070021317160430700335450ustar00rootroot00000000000000package org.apache.maven.plugin.version; /* * 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.util.List; import org.apache.maven.model.Model; import org.eclipse.aether.RepositorySystemSession; import org.eclipse.aether.repository.RemoteRepository; /** * Collects settings required to resolve the version for a plugin. * * @since 3.0 * @author Benjamin Bentmann */ public interface PluginVersionRequest { /** * Gets the group id of the plugin. * * @return The group id of the plugin. */ String getGroupId(); /** * Sets the group id of the plugin. * * @param groupId The group id of the plugin. * @return This request, never {@code null}. */ PluginVersionRequest setGroupId( String groupId ); /** * Gets the artifact id of the plugin. * * @return The artifact id of the plugin. */ String getArtifactId(); /** * Sets the artifact id of the plugin. * * @param artifactId The artifact id of the plugin. * @return This request, never {@code null}. */ PluginVersionRequest setArtifactId( String artifactId ); /** * Gets the POM whose build plugins are to be scanned for the version. * * @return The POM whose build plugins are to be scanned for the version or {@code null} to only search the plugin * repositories. */ Model getPom(); /** * Sets the POM whose build plugins are to be scanned for the version. * * @param pom The POM whose build plugins are to be scanned for the version, may be {@code null} to only search the * plugin repositories. * @return This request, never {@code null}. */ PluginVersionRequest setPom( Model pom ); /** * Gets the remote repositories to use. * * @return The remote repositories to use, never {@code null}. */ List getRepositories(); /** * Sets the remote repositories to use. Note: When creating a request from a project, be sure to use the * plugin repositories and not the regular project repositories. * * @param repositories The remote repositories to use. * @return This request, never {@code null}. */ PluginVersionRequest setRepositories( List repositories ); /** * Gets the session to use for repository access. * * @return The repository session or {@code null} if not set. */ RepositorySystemSession getRepositorySession(); /** * Sets the session to use for repository access. * * @param repositorySession The repository session to use. * @return This request, never {@code null}. */ PluginVersionRequest setRepositorySession( RepositorySystemSession repositorySession ); } PluginVersionResolutionException.java000066400000000000000000000064371317160430700360730ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/plugin/versionpackage org.apache.maven.plugin.version; /* * 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.util.List; import org.eclipse.aether.repository.LocalRepository; import org.eclipse.aether.repository.RemoteRepository; public class PluginVersionResolutionException extends Exception { private final String groupId; private final String artifactId; private final String baseMessage; public PluginVersionResolutionException( String groupId, String artifactId, String baseMessage, Throwable cause ) { super( "Error resolving version for plugin \'" + groupId + ":" + artifactId + "\': " + baseMessage, cause ); this.groupId = groupId; this.artifactId = artifactId; this.baseMessage = baseMessage; } public PluginVersionResolutionException( String groupId, String artifactId, String baseMessage ) { super( "Error resolving version for plugin \'" + groupId + ":" + artifactId + "\': " + baseMessage ); this.groupId = groupId; this.artifactId = artifactId; this.baseMessage = baseMessage; } public PluginVersionResolutionException( String groupId, String artifactId, LocalRepository localRepository, List remoteRepositories, String baseMessage ) { super( "Error resolving version for plugin \'" + groupId + ":" + artifactId + "\' from the repositories " + format( localRepository, remoteRepositories ) + ": " + baseMessage ); this.groupId = groupId; this.artifactId = artifactId; this.baseMessage = baseMessage; } public String getGroupId() { return groupId; } public String getArtifactId() { return artifactId; } public String getBaseMessage() { return baseMessage; } private static String format( LocalRepository localRepository, List remoteRepositories ) { String repos = "["; if ( localRepository != null ) { repos += localRepository.getId() + " (" + localRepository.getBasedir() + ")"; } if ( remoteRepositories != null && !remoteRepositories.isEmpty() ) { for ( RemoteRepository repository : remoteRepositories ) { repos += ", "; if ( repository != null ) { repos += repository.getId() + " (" + repository.getUrl() + ")"; } } } repos += "]"; return repos; } } PluginVersionResolver.java000066400000000000000000000027261317160430700336470ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/plugin/versionpackage org.apache.maven.plugin.version; /* * 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. */ /** * Resolves a version for a plugin. * * @since 3.0 * @author Benjamin Bentmann */ public interface PluginVersionResolver { /** * Resolves the version for the specified request. * * @param request The request that holds the details about the plugin and the repositories to consult, must not be * {@code null}. * @return The result of the version resolution, never {@code null}. * @throws PluginVersionResolutionException If the plugin version could not be resolved. */ PluginVersionResult resolve( PluginVersionRequest request ) throws PluginVersionResolutionException; } maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/plugin/version/PluginVersionResult.java000066400000000000000000000026421317160430700334000ustar00rootroot00000000000000package org.apache.maven.plugin.version; /* * 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 org.eclipse.aether.repository.ArtifactRepository; /** * Describes the result of a plugin version resolution request. * * @since 3.0 * @author Benjamin Bentmann */ public interface PluginVersionResult { /** * The resolved plugin version. * * @return The resolved plugin version, never {@code null}. */ String getVersion(); /** * The repository from which the plugin version was resolved. * * @return The repository from which the plugin version was resolved, never {@code null}. */ ArtifactRepository getRepository(); } maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/plugin/version/internal/000077500000000000000000000000001317160430700303425ustar00rootroot00000000000000DefaultPluginVersionResolver.java000066400000000000000000000335241317160430700367700ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/plugin/version/internalpackage org.apache.maven.plugin.version.internal; /* * 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.util.ArrayList; import java.util.Collections; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import java.util.TreeSet; import org.apache.maven.artifact.repository.metadata.Metadata; import org.apache.maven.artifact.repository.metadata.Versioning; import org.apache.maven.artifact.repository.metadata.io.MetadataReader; import org.apache.maven.model.Build; import org.apache.maven.model.Plugin; import org.apache.maven.plugin.MavenPluginManager; import org.apache.maven.plugin.PluginResolutionException; import org.apache.maven.plugin.descriptor.PluginDescriptor; import org.apache.maven.plugin.version.PluginVersionRequest; import org.apache.maven.plugin.version.PluginVersionResolutionException; import org.apache.maven.plugin.version.PluginVersionResolver; import org.apache.maven.plugin.version.PluginVersionResult; import org.codehaus.plexus.component.annotations.Component; import org.codehaus.plexus.component.annotations.Requirement; import org.codehaus.plexus.logging.Logger; import org.codehaus.plexus.util.StringUtils; import org.eclipse.aether.RepositoryEvent.EventType; import org.eclipse.aether.RepositoryEvent; import org.eclipse.aether.RepositoryListener; import org.eclipse.aether.RepositorySystem; import org.eclipse.aether.RepositorySystemSession; import org.eclipse.aether.RequestTrace; import org.eclipse.aether.metadata.DefaultMetadata; import org.eclipse.aether.repository.ArtifactRepository; import org.eclipse.aether.repository.RemoteRepository; import org.eclipse.aether.resolution.MetadataRequest; import org.eclipse.aether.resolution.MetadataResult; import org.eclipse.aether.util.version.GenericVersionScheme; import org.eclipse.aether.version.InvalidVersionSpecificationException; import org.eclipse.aether.version.Version; import org.eclipse.aether.version.VersionScheme; /** * Resolves a version for a plugin. * * @since 3.0 * @author Benjamin Bentmann */ @Component( role = PluginVersionResolver.class ) public class DefaultPluginVersionResolver implements PluginVersionResolver { private static final String REPOSITORY_CONTEXT = "plugin"; @Requirement private Logger logger; @Requirement private RepositorySystem repositorySystem; @Requirement private MetadataReader metadataReader; @Requirement private MavenPluginManager pluginManager; public PluginVersionResult resolve( PluginVersionRequest request ) throws PluginVersionResolutionException { PluginVersionResult result = resolveFromProject( request ); if ( result == null ) { result = resolveFromRepository( request ); if ( logger.isDebugEnabled() ) { logger.debug( "Resolved plugin version for " + request.getGroupId() + ":" + request.getArtifactId() + " to " + result.getVersion() + " from repository " + result.getRepository() ); } } else if ( logger.isDebugEnabled() ) { logger.debug( "Resolved plugin version for " + request.getGroupId() + ":" + request.getArtifactId() + " to " + result.getVersion() + " from POM " + request.getPom() ); } return result; } private PluginVersionResult resolveFromRepository( PluginVersionRequest request ) throws PluginVersionResolutionException { RequestTrace trace = RequestTrace.newChild( null, request ); DefaultPluginVersionResult result = new DefaultPluginVersionResult(); org.eclipse.aether.metadata.Metadata metadata = new DefaultMetadata( request.getGroupId(), request.getArtifactId(), "maven-metadata.xml", DefaultMetadata.Nature.RELEASE_OR_SNAPSHOT ); List requests = new ArrayList<>(); requests.add( new MetadataRequest( metadata, null, REPOSITORY_CONTEXT ).setTrace( trace ) ); for ( RemoteRepository repository : request.getRepositories() ) { requests.add( new MetadataRequest( metadata, repository, REPOSITORY_CONTEXT ).setTrace( trace ) ); } List results = repositorySystem.resolveMetadata( request.getRepositorySession(), requests ); Versions versions = new Versions(); for ( MetadataResult res : results ) { ArtifactRepository repository = res.getRequest().getRepository(); if ( repository == null ) { repository = request.getRepositorySession().getLocalRepository(); } mergeMetadata( request.getRepositorySession(), trace, versions, res.getMetadata(), repository ); } selectVersion( result, request, versions ); return result; } private void selectVersion( DefaultPluginVersionResult result, PluginVersionRequest request, Versions versions ) throws PluginVersionResolutionException { String version = null; ArtifactRepository repo = null; if ( StringUtils.isNotEmpty( versions.releaseVersion ) ) { version = versions.releaseVersion; repo = versions.releaseRepository; } else if ( StringUtils.isNotEmpty( versions.latestVersion ) ) { version = versions.latestVersion; repo = versions.latestRepository; } if ( version != null && !isCompatible( request, version ) ) { versions.versions.remove( version ); version = null; } if ( version == null ) { VersionScheme versionScheme = new GenericVersionScheme(); TreeSet releases = new TreeSet<>( Collections.reverseOrder() ); TreeSet snapshots = new TreeSet<>( Collections.reverseOrder() ); for ( String ver : versions.versions.keySet() ) { try { Version v = versionScheme.parseVersion( ver ); if ( ver.endsWith( "-SNAPSHOT" ) ) { snapshots.add( v ); } else { releases.add( v ); } } catch ( InvalidVersionSpecificationException e ) { // ignore } } for ( Version v : releases ) { String ver = v.toString(); if ( isCompatible( request, ver ) ) { version = ver; repo = versions.versions.get( version ); break; } } if ( version == null ) { for ( Version v : snapshots ) { String ver = v.toString(); if ( isCompatible( request, ver ) ) { version = ver; repo = versions.versions.get( version ); break; } } } } if ( version != null ) { result.setVersion( version ); result.setRepository( repo ); } else { throw new PluginVersionResolutionException( request.getGroupId(), request.getArtifactId(), request.getRepositorySession().getLocalRepository(), request.getRepositories(), "Plugin not found in any plugin repository" ); } } private boolean isCompatible( PluginVersionRequest request, String version ) { Plugin plugin = new Plugin(); plugin.setGroupId( request.getGroupId() ); plugin.setArtifactId( request.getArtifactId() ); plugin.setVersion( version ); PluginDescriptor pluginDescriptor; try { pluginDescriptor = pluginManager.getPluginDescriptor( plugin, request.getRepositories(), request.getRepositorySession() ); } catch ( PluginResolutionException e ) { logger.debug( "Ignoring unresolvable plugin version " + version, e ); return false; } catch ( Exception e ) { // ignore for now and delay failure to higher level processing return true; } try { pluginManager.checkRequiredMavenVersion( pluginDescriptor ); } catch ( Exception e ) { logger.debug( "Ignoring incompatible plugin version " + version + ": " + e.getMessage() ); return false; } return true; } private void mergeMetadata( RepositorySystemSession session, RequestTrace trace, Versions versions, org.eclipse.aether.metadata.Metadata metadata, ArtifactRepository repository ) { if ( metadata != null && metadata.getFile() != null && metadata.getFile().isFile() ) { try { Map options = Collections.singletonMap( MetadataReader.IS_STRICT, Boolean.FALSE ); Metadata repoMetadata = metadataReader.read( metadata.getFile(), options ); mergeMetadata( versions, repoMetadata, repository ); } catch ( IOException e ) { invalidMetadata( session, trace, metadata, repository, e ); } } } private void invalidMetadata( RepositorySystemSession session, RequestTrace trace, org.eclipse.aether.metadata.Metadata metadata, ArtifactRepository repository, Exception exception ) { RepositoryListener listener = session.getRepositoryListener(); if ( listener != null ) { RepositoryEvent.Builder event = new RepositoryEvent.Builder( session, EventType.METADATA_INVALID ); event.setTrace( trace ); event.setMetadata( metadata ); event.setException( exception ); event.setRepository( repository ); listener.metadataInvalid( event.build() ); } } private void mergeMetadata( Versions versions, Metadata source, ArtifactRepository repository ) { Versioning versioning = source.getVersioning(); if ( versioning != null ) { String timestamp = StringUtils.clean( versioning.getLastUpdated() ); if ( StringUtils.isNotEmpty( versioning.getRelease() ) && timestamp.compareTo( versions.releaseTimestamp ) > 0 ) { versions.releaseVersion = versioning.getRelease(); versions.releaseTimestamp = timestamp; versions.releaseRepository = repository; } if ( StringUtils.isNotEmpty( versioning.getLatest() ) && timestamp.compareTo( versions.latestTimestamp ) > 0 ) { versions.latestVersion = versioning.getLatest(); versions.latestTimestamp = timestamp; versions.latestRepository = repository; } for ( String version : versioning.getVersions() ) { if ( !versions.versions.containsKey( version ) ) { versions.versions.put( version, repository ); } } } } private PluginVersionResult resolveFromProject( PluginVersionRequest request ) { PluginVersionResult result = null; if ( request.getPom() != null && request.getPom().getBuild() != null ) { Build build = request.getPom().getBuild(); result = resolveFromProject( request, build.getPlugins() ); if ( result == null && build.getPluginManagement() != null ) { result = resolveFromProject( request, build.getPluginManagement().getPlugins() ); } } return result; } private PluginVersionResult resolveFromProject( PluginVersionRequest request, List plugins ) { for ( Plugin plugin : plugins ) { if ( request.getGroupId().equals( plugin.getGroupId() ) && request.getArtifactId().equals( plugin.getArtifactId() ) ) { if ( plugin.getVersion() != null ) { return new DefaultPluginVersionResult( plugin.getVersion() ); } else { return null; } } } return null; } static class Versions { String releaseVersion = ""; String releaseTimestamp = ""; ArtifactRepository releaseRepository; String latestVersion = ""; String latestTimestamp = ""; ArtifactRepository latestRepository; Map versions = new LinkedHashMap<>(); } } DefaultPluginVersionResult.java000066400000000000000000000033621317160430700364420ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/plugin/version/internalpackage org.apache.maven.plugin.version.internal; /* * 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 org.apache.maven.plugin.version.PluginVersionResult; import org.eclipse.aether.repository.ArtifactRepository; /** * Describes the result of a plugin version resolution request. * * @since 3.0 * @author Benjamin Bentmann */ class DefaultPluginVersionResult implements PluginVersionResult { private String version; private ArtifactRepository repository; public DefaultPluginVersionResult() { // does nothing } public DefaultPluginVersionResult( String version ) { this.version = version; } public String getVersion() { return version; } public void setVersion( String version ) { this.version = version; } public ArtifactRepository getRepository() { return repository; } public void setRepository( ArtifactRepository repository ) { this.repository = repository; } } maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/project/000077500000000000000000000000001317160430700252115ustar00rootroot00000000000000DefaultDependencyResolutionRequest.java000066400000000000000000000042631317160430700350220ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/projectpackage org.apache.maven.project; /* * 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 org.eclipse.aether.RepositorySystemSession; import org.eclipse.aether.graph.DependencyFilter; /** * @author Benjamin Bentmann */ public class DefaultDependencyResolutionRequest implements DependencyResolutionRequest { private MavenProject project; private DependencyFilter filter; private RepositorySystemSession session; public DefaultDependencyResolutionRequest() { // enables default constructor } public DefaultDependencyResolutionRequest( MavenProject project, RepositorySystemSession session ) { setMavenProject( project ); setRepositorySession( session ); } public DependencyFilter getResolutionFilter() { return filter; } public MavenProject getMavenProject() { return project; } public RepositorySystemSession getRepositorySession() { return session; } public DependencyResolutionRequest setResolutionFilter( DependencyFilter filter ) { this.filter = filter; return this; } public DependencyResolutionRequest setMavenProject( MavenProject project ) { this.project = project; return this; } public DependencyResolutionRequest setRepositorySession( RepositorySystemSession repositorySession ) { this.session = repositorySession; return this; } } DefaultDependencyResolutionResult.java000066400000000000000000000060111317160430700346410ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/projectpackage org.apache.maven.project; /* * 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.util.ArrayList; import java.util.Collections; import java.util.IdentityHashMap; import java.util.List; import java.util.Map; import org.eclipse.aether.graph.Dependency; import org.eclipse.aether.graph.DependencyNode; /** * @author Benjamin Bentmann */ class DefaultDependencyResolutionResult implements DependencyResolutionResult { private DependencyNode root; private List dependencies = new ArrayList<>(); private List resolvedDependencies = new ArrayList<>(); private List unresolvedDependencies = new ArrayList<>(); private List collectionErrors = new ArrayList<>(); private Map> resolutionErrors = new IdentityHashMap<>(); public DependencyNode getDependencyGraph() { return root; } public void setDependencyGraph( DependencyNode root ) { this.root = root; } public List getDependencies() { return dependencies; } public List getResolvedDependencies() { return resolvedDependencies; } public void addResolvedDependency( Dependency dependency ) { dependencies.add( dependency ); resolvedDependencies.add( dependency ); } public List getUnresolvedDependencies() { return unresolvedDependencies; } public List getCollectionErrors() { return collectionErrors; } public void setCollectionErrors( List exceptions ) { if ( exceptions != null ) { this.collectionErrors = exceptions; } else { this.collectionErrors = new ArrayList<>(); } } public List getResolutionErrors( Dependency dependency ) { List errors = resolutionErrors.get( dependency ); return ( errors != null ) ? errors : Collections.emptyList(); } public void setResolutionErrors( Dependency dependency, List errors ) { dependencies.add( dependency ); unresolvedDependencies.add( dependency ); resolutionErrors.put( dependency, errors ); } } maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/project/DefaultMavenProjectHelper.java000066400000000000000000000105741317160430700331250ustar00rootroot00000000000000package org.apache.maven.project; /* * 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.File; import java.util.List; import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.handler.ArtifactHandler; import org.apache.maven.artifact.handler.manager.ArtifactHandlerManager; import org.apache.maven.model.Resource; import org.apache.maven.project.artifact.AttachedArtifact; import org.codehaus.plexus.component.annotations.Component; import org.codehaus.plexus.component.annotations.Requirement; import org.codehaus.plexus.logging.AbstractLogEnabled; @SuppressWarnings( "deprecation" ) @Component( role = MavenProjectHelper.class ) public class DefaultMavenProjectHelper extends AbstractLogEnabled implements MavenProjectHelper { @Requirement private ArtifactHandlerManager artifactHandlerManager; public void attachArtifact( MavenProject project, String artifactType, String artifactClassifier, File artifactFile ) { String type = artifactType; ArtifactHandler handler = null; if ( type != null ) { handler = artifactHandlerManager.getArtifactHandler( artifactType ); } if ( handler == null ) { handler = artifactHandlerManager.getArtifactHandler( "jar" ); } Artifact artifact = new AttachedArtifact( project.getArtifact(), artifactType, artifactClassifier, handler ); artifact.setFile( artifactFile ); artifact.setResolved( true ); attachArtifact( project, artifact ); } public void attachArtifact( MavenProject project, String artifactType, File artifactFile ) { ArtifactHandler handler = artifactHandlerManager.getArtifactHandler( artifactType ); Artifact artifact = new AttachedArtifact( project.getArtifact(), artifactType, handler ); artifact.setFile( artifactFile ); artifact.setResolved( true ); attachArtifact( project, artifact ); } public void attachArtifact( MavenProject project, File artifactFile, String artifactClassifier ) { Artifact projectArtifact = project.getArtifact(); Artifact artifact = new AttachedArtifact( projectArtifact, projectArtifact.getType(), artifactClassifier, projectArtifact.getArtifactHandler() ); artifact.setFile( artifactFile ); artifact.setResolved( true ); attachArtifact( project, artifact ); } /** * Add an attached artifact or replace the file for an existing artifact. * * @see MavenProject#addAttachedArtifact(org.apache.maven.artifact.Artifact) * @param project project reference. * @param artifact artifact to add or replace. */ public void attachArtifact( MavenProject project, Artifact artifact ) { project.addAttachedArtifact( artifact ); } public void addResource( MavenProject project, String resourceDirectory, List includes, List excludes ) { Resource resource = new Resource(); resource.setDirectory( resourceDirectory ); resource.setIncludes( includes ); resource.setExcludes( excludes ); project.addResource( resource ); } public void addTestResource( MavenProject project, String resourceDirectory, List includes, List excludes ) { Resource resource = new Resource(); resource.setDirectory( resourceDirectory ); resource.setIncludes( includes ); resource.setExcludes( excludes ); project.addTestResource( resource ); } } DefaultModelBuildingListener.java000066400000000000000000000122321317160430700335260ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/projectpackage org.apache.maven.project; /* * 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.util.List; import org.apache.commons.lang3.Validate; import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.model.Model; import org.apache.maven.model.building.AbstractModelBuildingListener; import org.apache.maven.model.building.ModelBuildingEvent; import org.apache.maven.model.building.ModelProblem.Severity; import org.apache.maven.model.building.ModelProblem.Version; import org.apache.maven.model.building.ModelProblemCollectorRequest; import org.apache.maven.plugin.PluginManagerException; import org.apache.maven.plugin.PluginResolutionException; import org.apache.maven.plugin.version.PluginVersionResolutionException; /** * Processes events from the model builder while building the effective model for a {@link MavenProject} instance. * * @author Benjamin Bentmann */ public class DefaultModelBuildingListener extends AbstractModelBuildingListener { private MavenProject project; private ProjectBuildingHelper projectBuildingHelper; private ProjectBuildingRequest projectBuildingRequest; private List remoteRepositories; private List pluginRepositories; public DefaultModelBuildingListener( MavenProject project, ProjectBuildingHelper projectBuildingHelper, ProjectBuildingRequest projectBuildingRequest ) { this.project = Validate.notNull( project, "project cannot be null" ); this.projectBuildingHelper = Validate.notNull( projectBuildingHelper, "projectBuildingHelper cannot be null" ); this.projectBuildingRequest = Validate.notNull( projectBuildingRequest, "projectBuildingRequest cannot be null" ); this.remoteRepositories = projectBuildingRequest.getRemoteRepositories(); this.pluginRepositories = projectBuildingRequest.getPluginArtifactRepositories(); } /** * Gets the project whose model is being built. * * @return The project, never {@code null}. */ public MavenProject getProject() { return project; } @Override public void buildExtensionsAssembled( ModelBuildingEvent event ) { Model model = event.getModel(); try { pluginRepositories = projectBuildingHelper.createArtifactRepositories( model.getPluginRepositories(), pluginRepositories, projectBuildingRequest ); } catch ( Exception e ) { event.getProblems().add( new ModelProblemCollectorRequest( Severity.ERROR, Version.BASE ) .setMessage( "Invalid plugin repository: " + e.getMessage() ) .setException( e ) ); } project.setPluginArtifactRepositories( pluginRepositories ); if ( event.getRequest().isProcessPlugins() ) { try { ProjectRealmCache.CacheRecord record = projectBuildingHelper.createProjectRealm( project, model, projectBuildingRequest ); project.setClassRealm( record.realm ); project.setExtensionDependencyFilter( record.extensionArtifactFilter ); } catch ( PluginResolutionException | PluginManagerException | PluginVersionResolutionException e ) { event.getProblems().add( new ModelProblemCollectorRequest( Severity.ERROR, Version.BASE ) .setMessage( "Unresolveable build extension: " + e.getMessage() ) .setException( e ) ); } projectBuildingHelper.selectProjectRealm( project ); } // build the regular repos after extensions are loaded to allow for custom layouts try { remoteRepositories = projectBuildingHelper.createArtifactRepositories( model.getRepositories(), remoteRepositories, projectBuildingRequest ); } catch ( Exception e ) { event.getProblems().add( new ModelProblemCollectorRequest( Severity.ERROR, Version.BASE ) .setMessage( "Invalid artifact repository: " + e.getMessage() ) .setException( e ) ); } project.setRemoteArtifactRepositories( remoteRepositories ); } } maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/project/DefaultProjectBuilder.java000066400000000000000000001077641317160430700323150ustar00rootroot00000000000000package org.apache.maven.project; /* * 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.File; import java.io.IOException; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.HashMap; import java.util.HashSet; import java.util.LinkedHashSet; import java.util.List; import java.util.Map; import java.util.Set; import org.apache.maven.RepositoryUtils; import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.InvalidRepositoryException; import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.repository.LegacyLocalRepositoryManager; import org.apache.maven.bridge.MavenRepositorySystem; import org.apache.maven.model.Build; import org.apache.maven.model.Dependency; import org.apache.maven.model.DependencyManagement; import org.apache.maven.model.DeploymentRepository; import org.apache.maven.model.Extension; import org.apache.maven.model.Model; import org.apache.maven.model.Plugin; import org.apache.maven.model.Profile; import org.apache.maven.model.ReportPlugin; import org.apache.maven.model.building.DefaultModelBuildingRequest; import org.apache.maven.model.building.DefaultModelProblem; import org.apache.maven.model.building.FileModelSource; import org.apache.maven.model.building.ModelBuilder; import org.apache.maven.model.building.ModelBuildingException; import org.apache.maven.model.building.ModelBuildingRequest; import org.apache.maven.model.building.ModelBuildingResult; import org.apache.maven.model.building.ModelProblem; import org.apache.maven.model.building.ModelProcessor; import org.apache.maven.model.building.ModelSource; import org.apache.maven.model.building.StringModelSource; import org.apache.maven.model.resolution.ModelResolver; import org.apache.maven.repository.internal.ArtifactDescriptorUtils; import org.codehaus.plexus.component.annotations.Component; import org.codehaus.plexus.component.annotations.Requirement; import org.codehaus.plexus.logging.Logger; import org.codehaus.plexus.util.Os; import org.codehaus.plexus.util.StringUtils; import org.eclipse.aether.RepositorySystemSession; import org.eclipse.aether.RequestTrace; import org.eclipse.aether.impl.RemoteRepositoryManager; import org.eclipse.aether.repository.LocalRepositoryManager; import org.eclipse.aether.repository.RemoteRepository; import org.eclipse.aether.repository.WorkspaceRepository; import org.eclipse.aether.resolution.ArtifactRequest; import org.eclipse.aether.resolution.ArtifactResult; /** */ @Component( role = ProjectBuilder.class ) public class DefaultProjectBuilder implements ProjectBuilder { @Requirement private Logger logger; @Requirement private ModelBuilder modelBuilder; @Requirement private ModelProcessor modelProcessor; @Requirement private ProjectBuildingHelper projectBuildingHelper; @Requirement private MavenRepositorySystem repositorySystem; @Requirement private org.eclipse.aether.RepositorySystem repoSystem; @Requirement private RemoteRepositoryManager repositoryManager; @Requirement private ProjectDependenciesResolver dependencyResolver; // ---------------------------------------------------------------------- // MavenProjectBuilder Implementation // ---------------------------------------------------------------------- @Override public ProjectBuildingResult build( File pomFile, ProjectBuildingRequest request ) throws ProjectBuildingException { return build( pomFile, new FileModelSource( pomFile ), new InternalConfig( request, null, null ) ); } @Override public ProjectBuildingResult build( ModelSource modelSource, ProjectBuildingRequest request ) throws ProjectBuildingException { return build( null, modelSource, new InternalConfig( request, null, null ) ); } private ProjectBuildingResult build( File pomFile, ModelSource modelSource, InternalConfig config ) throws ProjectBuildingException { ClassLoader oldContextClassLoader = Thread.currentThread().getContextClassLoader(); try { ProjectBuildingRequest projectBuildingRequest = config.request; MavenProject project = projectBuildingRequest.getProject(); List modelProblems = null; Throwable error = null; if ( project == null ) { ModelBuildingRequest request = getModelBuildingRequest( config ); project = new MavenProject(); project.setFile( pomFile ); DefaultModelBuildingListener listener = new DefaultModelBuildingListener( project, projectBuildingHelper, projectBuildingRequest ); request.setModelBuildingListener( listener ); request.setPomFile( pomFile ); request.setModelSource( modelSource ); request.setLocationTracking( true ); ModelBuildingResult result; try { result = modelBuilder.build( request ); } catch ( ModelBuildingException e ) { result = e.getResult(); if ( result == null || result.getEffectiveModel() == null ) { throw new ProjectBuildingException( e.getModelId(), e.getMessage(), pomFile, e ); } // validation error, continue project building and delay failing to help IDEs error = e; } modelProblems = result.getProblems(); initProject( project, Collections.emptyMap(), result, new HashMap(), projectBuildingRequest ); } else if ( projectBuildingRequest.isResolveDependencies() ) { projectBuildingHelper.selectProjectRealm( project ); } DependencyResolutionResult resolutionResult = null; if ( projectBuildingRequest.isResolveDependencies() ) { resolutionResult = resolveDependencies( project, config.session ); } ProjectBuildingResult result = new DefaultProjectBuildingResult( project, modelProblems, resolutionResult ); if ( error != null ) { ProjectBuildingException e = new ProjectBuildingException( Arrays.asList( result ) ); e.initCause( error ); throw e; } return result; } finally { Thread.currentThread().setContextClassLoader( oldContextClassLoader ); } } private DependencyResolutionResult resolveDependencies( MavenProject project, RepositorySystemSession session ) { DependencyResolutionResult resolutionResult; try { DefaultDependencyResolutionRequest resolution = new DefaultDependencyResolutionRequest( project, session ); resolutionResult = dependencyResolver.resolve( resolution ); } catch ( DependencyResolutionException e ) { resolutionResult = e.getResult(); } Set artifacts = new LinkedHashSet<>(); if ( resolutionResult.getDependencyGraph() != null ) { RepositoryUtils.toArtifacts( artifacts, resolutionResult.getDependencyGraph().getChildren(), Collections.singletonList( project.getArtifact().getId() ), null ); // Maven 2.x quirk: an artifact always points at the local repo, regardless whether resolved or not LocalRepositoryManager lrm = session.getLocalRepositoryManager(); for ( Artifact artifact : artifacts ) { if ( !artifact.isResolved() ) { String path = lrm.getPathForLocalArtifact( RepositoryUtils.toArtifact( artifact ) ); artifact.setFile( new File( lrm.getRepository().getBasedir(), path ) ); } } } project.setResolvedArtifacts( artifacts ); project.setArtifacts( artifacts ); return resolutionResult; } private List getProfileIds( List profiles ) { List ids = new ArrayList<>( profiles.size() ); for ( Profile profile : profiles ) { ids.add( profile.getId() ); } return ids; } private ModelBuildingRequest getModelBuildingRequest( InternalConfig config ) { ProjectBuildingRequest configuration = config.request; ModelBuildingRequest request = new DefaultModelBuildingRequest(); RequestTrace trace = RequestTrace.newChild( null, configuration ).newChild( request ); ModelResolver resolver = new ProjectModelResolver( config.session, trace, repoSystem, repositoryManager, config.repositories, configuration.getRepositoryMerging(), config.modelPool ); request.setValidationLevel( configuration.getValidationLevel() ); request.setProcessPlugins( configuration.isProcessPlugins() ); request.setProfiles( configuration.getProfiles() ); request.setActiveProfileIds( configuration.getActiveProfileIds() ); request.setInactiveProfileIds( configuration.getInactiveProfileIds() ); request.setSystemProperties( configuration.getSystemProperties() ); request.setUserProperties( configuration.getUserProperties() ); request.setBuildStartTime( configuration.getBuildStartTime() ); request.setModelResolver( resolver ); request.setModelCache( config.modelCache ); return request; } @Override public ProjectBuildingResult build( Artifact artifact, ProjectBuildingRequest request ) throws ProjectBuildingException { return build( artifact, false, request ); } @Override public ProjectBuildingResult build( Artifact artifact, boolean allowStubModel, ProjectBuildingRequest request ) throws ProjectBuildingException { org.eclipse.aether.artifact.Artifact pomArtifact = RepositoryUtils.toArtifact( artifact ); pomArtifact = ArtifactDescriptorUtils.toPomArtifact( pomArtifact ); InternalConfig config = new InternalConfig( request, null, null ); boolean localProject; try { ArtifactRequest pomRequest = new ArtifactRequest(); pomRequest.setArtifact( pomArtifact ); pomRequest.setRepositories( config.repositories ); ArtifactResult pomResult = repoSystem.resolveArtifact( config.session, pomRequest ); pomArtifact = pomResult.getArtifact(); localProject = pomResult.getRepository() instanceof WorkspaceRepository; } catch ( org.eclipse.aether.resolution.ArtifactResolutionException e ) { if ( e.getResults().get( 0 ).isMissing() && allowStubModel ) { return build( null, createStubModelSource( artifact ), config ); } throw new ProjectBuildingException( artifact.getId(), "Error resolving project artifact: " + e.getMessage(), e ); } File pomFile = pomArtifact.getFile(); if ( "pom".equals( artifact.getType() ) ) { artifact.selectVersion( pomArtifact.getVersion() ); artifact.setFile( pomFile ); artifact.setResolved( true ); } return build( localProject ? pomFile : null, new FileModelSource( pomFile ), config ); } private ModelSource createStubModelSource( Artifact artifact ) { StringBuilder buffer = new StringBuilder( 1024 ); buffer.append( "" ); buffer.append( "" ); buffer.append( "4.0.0" ); buffer.append( "" ).append( artifact.getGroupId() ).append( "" ); buffer.append( "" ).append( artifact.getArtifactId() ).append( "" ); buffer.append( "" ).append( artifact.getBaseVersion() ).append( "" ); buffer.append( "" ).append( artifact.getType() ).append( "" ); buffer.append( "" ); return new StringModelSource( buffer, artifact.getId() ); } @Override public List build( List pomFiles, boolean recursive, ProjectBuildingRequest request ) throws ProjectBuildingException { List results = new ArrayList<>(); List interimResults = new ArrayList<>(); ReactorModelPool modelPool = new ReactorModelPool(); ReactorModelCache modelCache = new ReactorModelCache(); InternalConfig config = new InternalConfig( request, modelPool, modelCache ); Map projectIndex = new HashMap<>( 256 ); boolean noErrors = build( results, interimResults, projectIndex, pomFiles, new LinkedHashSet(), true, recursive, config ); populateReactorModelPool( modelPool, interimResults ); ClassLoader oldContextClassLoader = Thread.currentThread().getContextClassLoader(); try { noErrors = build( results, new ArrayList(), projectIndex, interimResults, request, new HashMap() ) && noErrors; } finally { Thread.currentThread().setContextClassLoader( oldContextClassLoader ); } if ( !noErrors ) { throw new ProjectBuildingException( results ); } return results; } private boolean build( List results, List interimResults, Map projectIndex, List pomFiles, Set aggregatorFiles, boolean isRoot, boolean recursive, InternalConfig config ) { boolean noErrors = true; for ( File pomFile : pomFiles ) { aggregatorFiles.add( pomFile ); if ( !build( results, interimResults, projectIndex, pomFile, aggregatorFiles, isRoot, recursive, config ) ) { noErrors = false; } aggregatorFiles.remove( pomFile ); } return noErrors; } private boolean build( List results, List interimResults, Map projectIndex, File pomFile, Set aggregatorFiles, boolean isRoot, boolean recursive, InternalConfig config ) { boolean noErrors = true; ModelBuildingRequest request = getModelBuildingRequest( config ); MavenProject project = new MavenProject(); request.setPomFile( pomFile ); request.setTwoPhaseBuilding( true ); request.setLocationTracking( true ); DefaultModelBuildingListener listener = new DefaultModelBuildingListener( project, projectBuildingHelper, config.request ); request.setModelBuildingListener( listener ); try { ModelBuildingResult result = modelBuilder.build( request ); Model model = result.getEffectiveModel(); projectIndex.put( result.getModelIds().get( 0 ), project ); InterimResult interimResult = new InterimResult( pomFile, request, result, listener, isRoot ); interimResults.add( interimResult ); if ( recursive && !model.getModules().isEmpty() ) { File basedir = pomFile.getParentFile(); List moduleFiles = new ArrayList<>(); for ( String module : model.getModules() ) { if ( StringUtils.isEmpty( module ) ) { continue; } module = module.replace( '\\', File.separatorChar ).replace( '/', File.separatorChar ); File moduleFile = new File( basedir, module ); if ( moduleFile.isDirectory() ) { moduleFile = modelProcessor.locatePom( moduleFile ); } if ( !moduleFile.isFile() ) { ModelProblem problem = new DefaultModelProblem( "Child module " + moduleFile + " of " + pomFile + " does not exist", ModelProblem.Severity.ERROR, ModelProblem.Version.BASE, model, -1, -1, null ); result.getProblems().add( problem ); noErrors = false; continue; } if ( Os.isFamily( Os.FAMILY_WINDOWS ) ) { // we don't canonicalize on unix to avoid interfering with symlinks try { moduleFile = moduleFile.getCanonicalFile(); } catch ( IOException e ) { moduleFile = moduleFile.getAbsoluteFile(); } } else { moduleFile = new File( moduleFile.toURI().normalize() ); } if ( aggregatorFiles.contains( moduleFile ) ) { StringBuilder buffer = new StringBuilder( 256 ); for ( File aggregatorFile : aggregatorFiles ) { buffer.append( aggregatorFile ).append( " -> " ); } buffer.append( moduleFile ); ModelProblem problem = new DefaultModelProblem( "Child module " + moduleFile + " of " + pomFile + " forms aggregation cycle " + buffer, ModelProblem.Severity.ERROR, ModelProblem.Version.BASE, model, -1, -1, null ); result.getProblems().add( problem ); noErrors = false; continue; } moduleFiles.add( moduleFile ); } interimResult.modules = new ArrayList<>(); if ( !build( results, interimResult.modules, projectIndex, moduleFiles, aggregatorFiles, false, recursive, config ) ) { noErrors = false; } } } catch ( ModelBuildingException e ) { results.add( new DefaultProjectBuildingResult( e.getModelId(), pomFile, e.getProblems() ) ); noErrors = false; } return noErrors; } static class InterimResult { File pomFile; ModelBuildingRequest request; ModelBuildingResult result; DefaultModelBuildingListener listener; boolean root; List modules = Collections.emptyList(); InterimResult( File pomFile, ModelBuildingRequest request, ModelBuildingResult result, DefaultModelBuildingListener listener, boolean root ) { this.pomFile = pomFile; this.request = request; this.result = result; this.listener = listener; this.root = root; } } private void populateReactorModelPool( ReactorModelPool reactorModelPool, List interimResults ) { for ( InterimResult interimResult : interimResults ) { Model model = interimResult.result.getEffectiveModel(); reactorModelPool.put( model.getGroupId(), model.getArtifactId(), model.getVersion(), model.getPomFile() ); populateReactorModelPool( reactorModelPool, interimResult.modules ); } } private boolean build( List results, List projects, Map projectIndex, List interimResults, ProjectBuildingRequest request, Map profilesXmls ) { boolean noErrors = true; for ( InterimResult interimResult : interimResults ) { try { ModelBuildingResult result = modelBuilder.build( interimResult.request, interimResult.result ); MavenProject project = interimResult.listener.getProject(); initProject( project, projectIndex, result, profilesXmls, request ); List modules = new ArrayList<>(); noErrors = build( results, modules, projectIndex, interimResult.modules, request, profilesXmls ) && noErrors; projects.addAll( modules ); projects.add( project ); project.setExecutionRoot( interimResult.root ); project.setCollectedProjects( modules ); results.add( new DefaultProjectBuildingResult( project, result.getProblems(), null ) ); } catch ( ModelBuildingException e ) { results.add( new DefaultProjectBuildingResult( e.getModelId(), interimResult.pomFile, e.getProblems() ) ); noErrors = false; } } return noErrors; } private void initProject( MavenProject project, Map projects, ModelBuildingResult result, Map profilesXmls, ProjectBuildingRequest projectBuildingRequest ) { Model model = result.getEffectiveModel(); project.setModel( model ); project.setOriginalModel( result.getRawModel() ); project.setFile( model.getPomFile() ); Model parentModel = result.getModelIds().size() > 1 && !result.getModelIds().get( 1 ).isEmpty() ? result.getRawModel( result.getModelIds().get( 1 ) ) : null; if ( parentModel != null ) { final String parentGroupId = inheritedGroupId( result, 1 ); final String parentVersion = inheritedVersion( result, 1 ); project.setParentArtifact( repositorySystem.createProjectArtifact( parentGroupId, parentModel.getArtifactId(), parentVersion ) ); // org.apache.maven.its.mng4834:parent:0.1 String parentModelId = result.getModelIds().get( 1 ); File parentPomFile = result.getRawModel( parentModelId ).getPomFile(); MavenProject parent = projects.get( parentModelId ); if ( parent == null ) { // // At this point the DefaultModelBuildingListener has fired and it populates the // remote repositories with those found in the pom.xml, along with the existing externally // defined repositories. // projectBuildingRequest.setRemoteRepositories( project.getRemoteArtifactRepositories() ); if ( parentPomFile != null ) { project.setParentFile( parentPomFile ); try { parent = build( parentPomFile, projectBuildingRequest ).getProject(); } catch ( ProjectBuildingException e ) { // MNG-4488 where let invalid parents slide on by if ( logger.isDebugEnabled() ) { // Message below is checked for in the MNG-2199 core IT. logger.warn( "Failed to build parent project for " + project.getId(), e ); } else { // Message below is checked for in the MNG-2199 core IT. logger.warn( "Failed to build parent project for " + project.getId() ); } } } else { Artifact parentArtifact = project.getParentArtifact(); try { parent = build( parentArtifact, projectBuildingRequest ).getProject(); } catch ( ProjectBuildingException e ) { // MNG-4488 where let invalid parents slide on by if ( logger.isDebugEnabled() ) { // Message below is checked for in the MNG-2199 core IT. logger.warn( "Failed to build parent project for " + project.getId(), e ); } else { // Message below is checked for in the MNG-2199 core IT. logger.warn( "Failed to build parent project for " + project.getId() ); } } } } project.setParent( parent ); } Artifact projectArtifact = repositorySystem.createArtifact( project.getGroupId(), project.getArtifactId(), project.getVersion(), null, project.getPackaging() ); project.setArtifact( projectArtifact ); if ( project.getFile() != null ) { Build build = project.getBuild(); project.addScriptSourceRoot( build.getScriptSourceDirectory() ); project.addCompileSourceRoot( build.getSourceDirectory() ); project.addTestCompileSourceRoot( build.getTestSourceDirectory() ); } List activeProfiles = new ArrayList<>(); activeProfiles.addAll( result.getActivePomProfiles( result.getModelIds().get( 0 ) ) ); activeProfiles.addAll( result.getActiveExternalProfiles() ); project.setActiveProfiles( activeProfiles ); project.setInjectedProfileIds( "external", getProfileIds( result.getActiveExternalProfiles() ) ); for ( String modelId : result.getModelIds() ) { project.setInjectedProfileIds( modelId, getProfileIds( result.getActivePomProfiles( modelId ) ) ); } String modelId = findProfilesXml( result, profilesXmls ); if ( modelId != null ) { ModelProblem problem = new DefaultModelProblem( "Detected profiles.xml alongside " + modelId + ", this file is no longer supported and was ignored" + ", please use the settings.xml instead", ModelProblem.Severity.WARNING, ModelProblem.Version.V30, model, -1, -1, null ); result.getProblems().add( problem ); } // // All the parts that were taken out of MavenProject for Maven 4.0.0 // project.setProjectBuildingRequest( projectBuildingRequest ); // pluginArtifacts Set pluginArtifacts = new HashSet<>(); for ( Plugin plugin : project.getBuildPlugins() ) { Artifact artifact = repositorySystem.createPluginArtifact( plugin ); if ( artifact != null ) { pluginArtifacts.add( artifact ); } } project.setPluginArtifacts( pluginArtifacts ); // reportArtifacts Set reportArtifacts = new HashSet<>(); for ( ReportPlugin report : project.getReportPlugins() ) { Plugin pp = new Plugin(); pp.setGroupId( report.getGroupId() ); pp.setArtifactId( report.getArtifactId() ); pp.setVersion( report.getVersion() ); Artifact artifact = repositorySystem.createPluginArtifact( pp ); if ( artifact != null ) { reportArtifacts.add( artifact ); } } project.setReportArtifacts( reportArtifacts ); // extensionArtifacts Set extensionArtifacts = new HashSet<>(); List extensions = project.getBuildExtensions(); if ( extensions != null ) { for ( Extension ext : extensions ) { String version; if ( StringUtils.isEmpty( ext.getVersion() ) ) { version = "RELEASE"; } else { version = ext.getVersion(); } Artifact artifact = repositorySystem.createArtifact( ext.getGroupId(), ext.getArtifactId(), version, null, "jar" ); if ( artifact != null ) { extensionArtifacts.add( artifact ); } } } project.setExtensionArtifacts( extensionArtifacts ); // managedVersionMap Map map = null; if ( repositorySystem != null ) { List deps; DependencyManagement dependencyManagement = project.getDependencyManagement(); if ( ( dependencyManagement != null ) && ( ( deps = dependencyManagement.getDependencies() ) != null ) && ( deps.size() > 0 ) ) { map = new HashMap<>(); for ( Dependency d : dependencyManagement.getDependencies() ) { Artifact artifact = repositorySystem.createDependencyArtifact( d ); if ( artifact != null ) { map.put( d.getManagementKey(), artifact ); } } } else { map = Collections.emptyMap(); } } project.setManagedVersionMap( map ); // release artifact repository if ( project.getDistributionManagement() != null && project.getDistributionManagement().getRepository() != null ) { try { DeploymentRepository r = project.getDistributionManagement().getRepository(); if ( !StringUtils.isEmpty( r.getId() ) && !StringUtils.isEmpty( r.getUrl() ) ) { ArtifactRepository repo = repositorySystem.buildArtifactRepository( r ); repositorySystem.injectProxy( projectBuildingRequest.getRepositorySession(), Arrays.asList( repo ) ); repositorySystem.injectAuthentication( projectBuildingRequest.getRepositorySession(), Arrays.asList( repo ) ); project.setReleaseArtifactRepository( repo ); } } catch ( InvalidRepositoryException e ) { throw new IllegalStateException( "Failed to create release distribution repository for " + project.getId(), e ); } } // snapshot artifact repository if ( project.getDistributionManagement() != null && project.getDistributionManagement().getSnapshotRepository() != null ) { try { DeploymentRepository r = project.getDistributionManagement().getSnapshotRepository(); if ( !StringUtils.isEmpty( r.getId() ) && !StringUtils.isEmpty( r.getUrl() ) ) { ArtifactRepository repo = repositorySystem.buildArtifactRepository( r ); repositorySystem.injectProxy( projectBuildingRequest.getRepositorySession(), Arrays.asList( repo ) ); repositorySystem.injectAuthentication( projectBuildingRequest.getRepositorySession(), Arrays.asList( repo ) ); project.setSnapshotArtifactRepository( repo ); } } catch ( InvalidRepositoryException e ) { throw new IllegalStateException( "Failed to create snapshot distribution repository for " + project.getId(), e ); } } } private static String inheritedGroupId( final ModelBuildingResult result, final int modelIndex ) { String groupId = null; final String modelId = result.getModelIds().get( modelIndex ); if ( !modelId.isEmpty() ) { final Model model = result.getRawModel( modelId ); groupId = model.getGroupId() != null ? model.getGroupId() : inheritedGroupId( result, modelIndex + 1 ); } return groupId; } private static String inheritedVersion( final ModelBuildingResult result, final int modelIndex ) { String version = null; final String modelId = result.getModelIds().get( modelIndex ); if ( !modelId.isEmpty() ) { final Model model = result.getRawModel( modelId ); version = model.getVersion() != null ? model.getVersion() : inheritedVersion( result, modelIndex + 1 ); } return version; } private String findProfilesXml( ModelBuildingResult result, Map profilesXmls ) { for ( String modelId : result.getModelIds() ) { Model model = result.getRawModel( modelId ); File basedir = model.getProjectDirectory(); if ( basedir == null ) { break; } Boolean profilesXml = profilesXmls.get( basedir ); if ( profilesXml == null ) { profilesXml = new File( basedir, "profiles.xml" ).exists(); profilesXmls.put( basedir, profilesXml ); } if ( profilesXml ) { return modelId; } } return null; } class InternalConfig { public final ProjectBuildingRequest request; public final RepositorySystemSession session; public final List repositories; public final ReactorModelPool modelPool; public final ReactorModelCache modelCache; InternalConfig( ProjectBuildingRequest request, ReactorModelPool modelPool, ReactorModelCache modelCache ) { this.request = request; this.modelPool = modelPool; this.modelCache = modelCache; session = LegacyLocalRepositoryManager.overlay( request.getLocalRepository(), request.getRepositorySession(), repoSystem ); repositories = RepositoryUtils.toRepos( request.getRemoteRepositories() ); } } } DefaultProjectBuildingHelper.java000066400000000000000000000254141317160430700335340ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/projectpackage org.apache.maven.project; /* * 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.util.ArrayList; import java.util.Arrays; import java.util.Collection; import java.util.HashMap; import java.util.HashSet; import java.util.LinkedHashSet; import java.util.List; import java.util.Map; import java.util.Set; import org.apache.maven.RepositoryUtils; import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.InvalidRepositoryException; import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.classrealm.ClassRealmManager; import org.apache.maven.model.Build; import org.apache.maven.model.Extension; import org.apache.maven.model.Model; import org.apache.maven.model.Plugin; import org.apache.maven.model.Repository; import org.apache.maven.plugin.ExtensionRealmCache; import org.apache.maven.plugin.MavenPluginManager; import org.apache.maven.plugin.PluginManagerException; import org.apache.maven.plugin.PluginResolutionException; import org.apache.maven.plugin.version.PluginVersionResolutionException; import org.apache.maven.repository.RepositorySystem; import org.codehaus.plexus.PlexusContainer; import org.codehaus.plexus.classworlds.realm.ClassRealm; import org.codehaus.plexus.component.annotations.Component; import org.codehaus.plexus.component.annotations.Requirement; import org.codehaus.plexus.logging.Logger; import org.eclipse.aether.graph.DependencyFilter; import org.eclipse.aether.util.filter.ExclusionsDependencyFilter; /** * Assists the project builder. Warning: This is an internal utility class that is only public for * technical reasons, it is not part of the public API. In particular, this class can be changed or deleted without * prior notice. * * @author Benjamin Bentmann */ @Component( role = ProjectBuildingHelper.class ) public class DefaultProjectBuildingHelper implements ProjectBuildingHelper { @Requirement private Logger logger; @Requirement private PlexusContainer container; @Requirement private ClassRealmManager classRealmManager; @Requirement private ProjectRealmCache projectRealmCache; @Requirement private RepositorySystem repositorySystem; @Requirement private MavenPluginManager pluginManager; public List createArtifactRepositories( List pomRepositories, List externalRepositories, ProjectBuildingRequest request ) throws InvalidRepositoryException { List internalRepositories = new ArrayList<>(); for ( Repository repository : pomRepositories ) { internalRepositories.add( repositorySystem.buildArtifactRepository( repository ) ); } repositorySystem.injectMirror( request.getRepositorySession(), internalRepositories ); repositorySystem.injectProxy( request.getRepositorySession(), internalRepositories ); repositorySystem.injectAuthentication( request.getRepositorySession(), internalRepositories ); List dominantRepositories; List recessiveRepositories; if ( ProjectBuildingRequest.RepositoryMerging.REQUEST_DOMINANT.equals( request.getRepositoryMerging() ) ) { dominantRepositories = externalRepositories; recessiveRepositories = internalRepositories; } else { dominantRepositories = internalRepositories; recessiveRepositories = externalRepositories; } List artifactRepositories = new ArrayList<>(); Collection repoIds = new HashSet<>(); if ( dominantRepositories != null ) { for ( ArtifactRepository repository : dominantRepositories ) { repoIds.add( repository.getId() ); artifactRepositories.add( repository ); } } if ( recessiveRepositories != null ) { for ( ArtifactRepository repository : recessiveRepositories ) { if ( repoIds.add( repository.getId() ) ) { artifactRepositories.add( repository ); } } } artifactRepositories = repositorySystem.getEffectiveRepositories( artifactRepositories ); return artifactRepositories; } public synchronized ProjectRealmCache.CacheRecord createProjectRealm( MavenProject project, Model model, ProjectBuildingRequest request ) throws PluginResolutionException, PluginVersionResolutionException, PluginManagerException { ClassRealm projectRealm; List extensionPlugins = new ArrayList<>(); Build build = model.getBuild(); if ( build != null ) { for ( Extension extension : build.getExtensions() ) { Plugin plugin = new Plugin(); plugin.setGroupId( extension.getGroupId() ); plugin.setArtifactId( extension.getArtifactId() ); plugin.setVersion( extension.getVersion() ); extensionPlugins.add( plugin ); } for ( Plugin plugin : build.getPlugins() ) { if ( plugin.isExtensions() ) { extensionPlugins.add( plugin ); } } } if ( extensionPlugins.isEmpty() ) { if ( logger.isDebugEnabled() ) { logger.debug( "Extension realms for project " + model.getId() + ": (none)" ); } return new ProjectRealmCache.CacheRecord( null, null ); } List extensionRealms = new ArrayList<>(); Map> exportedPackages = new HashMap<>(); Map> exportedArtifacts = new HashMap<>(); List publicArtifacts = new ArrayList<>(); for ( Plugin plugin : extensionPlugins ) { ExtensionRealmCache.CacheRecord recordRealm = pluginManager.setupExtensionsRealm( project, plugin, request.getRepositorySession() ); final ClassRealm extensionRealm = recordRealm.realm; final ExtensionDescriptor extensionDescriptor = recordRealm.descriptor; final List artifacts = recordRealm.artifacts; extensionRealms.add( extensionRealm ); if ( extensionDescriptor != null ) { exportedPackages.put( extensionRealm, extensionDescriptor.getExportedPackages() ); exportedArtifacts.put( extensionRealm, extensionDescriptor.getExportedArtifacts() ); } if ( !plugin.isExtensions() && artifacts.size() == 2 && artifacts.get( 0 ).getFile() != null && "plexus-utils".equals( artifacts.get( 1 ).getArtifactId() ) ) { /* * This is purely for backward-compat with 2.x where consisting of a single artifact where * loaded into the core and hence available to plugins, in contrast to bigger extensions that were * loaded into a dedicated realm which is invisible to plugins (MNG-2749). */ publicArtifacts.add( artifacts.get( 0 ) ); } } if ( logger.isDebugEnabled() ) { logger.debug( "Extension realms for project " + model.getId() + ": " + extensionRealms ); } ProjectRealmCache.Key projectRealmKey = projectRealmCache.createKey( extensionRealms ); ProjectRealmCache.CacheRecord record = projectRealmCache.get( projectRealmKey ); if ( record == null ) { projectRealm = classRealmManager.createProjectRealm( model, toAetherArtifacts( publicArtifacts ) ); Set exclusions = new LinkedHashSet<>(); for ( ClassRealm extensionRealm : extensionRealms ) { List excludes = exportedArtifacts.get( extensionRealm ); if ( excludes != null ) { exclusions.addAll( excludes ); } List exports = exportedPackages.get( extensionRealm ); if ( exports == null || exports.isEmpty() ) { /* * Most existing extensions don't define exported packages, i.e. no classes are to be exposed to * plugins, yet the components provided by the extension (e.g. artifact handlers) must be * accessible, i.e. we still must import the extension realm into the project realm. */ exports = Arrays.asList( extensionRealm.getId() ); } for ( String export : exports ) { projectRealm.importFrom( extensionRealm, export ); } } DependencyFilter extensionArtifactFilter = null; if ( !exclusions.isEmpty() ) { extensionArtifactFilter = new ExclusionsDependencyFilter( exclusions ); } record = projectRealmCache.put( projectRealmKey, projectRealm, extensionArtifactFilter ); } projectRealmCache.register( project, projectRealmKey, record ); return record; } public void selectProjectRealm( MavenProject project ) { ClassLoader projectRealm = project.getClassRealm(); if ( projectRealm == null ) { projectRealm = classRealmManager.getCoreRealm(); } Thread.currentThread().setContextClassLoader( projectRealm ); } private List toAetherArtifacts( final List pluginArtifacts ) { return new ArrayList<>( RepositoryUtils.toArtifacts( pluginArtifacts ) ); } } DefaultProjectBuildingRequest.java000066400000000000000000000222341317160430700337420ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/projectpackage org.apache.maven.project; /* * 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.util.ArrayList; import java.util.Date; import java.util.List; import java.util.Properties; import org.apache.commons.lang3.Validate; import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.model.Profile; import org.apache.maven.model.building.ModelBuildingRequest; import org.apache.maven.properties.internal.SystemProperties; import org.eclipse.aether.RepositorySystemSession; public class DefaultProjectBuildingRequest implements ProjectBuildingRequest { private RepositorySystemSession repositorySession; private ArtifactRepository localRepository; private List remoteRepositories; private List pluginArtifactRepositories; private MavenProject project; private int validationLevel = ModelBuildingRequest.VALIDATION_LEVEL_STRICT; private boolean processPlugins; private List profiles; private List activeProfileIds; private List inactiveProfileIds; private Properties systemProperties; private Properties userProperties; private Date buildStartTime; private boolean resolveDependencies; @Deprecated private boolean resolveVersionRanges; private RepositoryMerging repositoryMerging = RepositoryMerging.POM_DOMINANT; public DefaultProjectBuildingRequest() { processPlugins = true; profiles = new ArrayList<>(); activeProfileIds = new ArrayList<>(); inactiveProfileIds = new ArrayList<>(); systemProperties = new Properties(); userProperties = new Properties(); remoteRepositories = new ArrayList<>(); pluginArtifactRepositories = new ArrayList<>(); } public DefaultProjectBuildingRequest( ProjectBuildingRequest request ) { this(); setProcessPlugins( request.isProcessPlugins() ); setProfiles( request.getProfiles() ); setActiveProfileIds( request.getActiveProfileIds() ); setInactiveProfileIds( request.getInactiveProfileIds() ); setSystemProperties( request.getSystemProperties() ); setUserProperties( request.getUserProperties() ); setRemoteRepositories( request.getRemoteRepositories() ); setPluginArtifactRepositories( request.getPluginArtifactRepositories() ); setRepositorySession( request.getRepositorySession() ); setLocalRepository( request.getLocalRepository() ); setBuildStartTime( request.getBuildStartTime() ); setProject( request.getProject() ); setResolveDependencies( request.isResolveDependencies() ); setValidationLevel( request.getValidationLevel() ); } public MavenProject getProject() { return project; } public void setProject( MavenProject mavenProject ) { this.project = mavenProject; } public ProjectBuildingRequest setLocalRepository( ArtifactRepository localRepository ) { this.localRepository = localRepository; return this; } public ArtifactRepository getLocalRepository() { return localRepository; } public List getRemoteRepositories() { return remoteRepositories; } public ProjectBuildingRequest setRemoteRepositories( List remoteRepositories ) { if ( remoteRepositories != null ) { this.remoteRepositories = new ArrayList<>( remoteRepositories ); } else { this.remoteRepositories.clear(); } return this; } public List getPluginArtifactRepositories() { return pluginArtifactRepositories; } public ProjectBuildingRequest setPluginArtifactRepositories( List pluginArtifactRepositories ) { if ( pluginArtifactRepositories != null ) { this.pluginArtifactRepositories = new ArrayList<>( pluginArtifactRepositories ); } else { this.pluginArtifactRepositories.clear(); } return this; } public Properties getSystemProperties() { return systemProperties; } public ProjectBuildingRequest setSystemProperties( Properties systemProperties ) { if ( systemProperties != null ) { this.systemProperties = SystemProperties.copyProperties( systemProperties ); } else { this.systemProperties.clear(); } return this; } public Properties getUserProperties() { return userProperties; } public ProjectBuildingRequest setUserProperties( Properties userProperties ) { if ( userProperties != null ) { this.userProperties = new Properties(); this.userProperties.putAll( userProperties ); } else { this.userProperties.clear(); } return this; } public boolean isProcessPlugins() { return processPlugins; } public ProjectBuildingRequest setProcessPlugins( boolean processPlugins ) { this.processPlugins = processPlugins; return this; } public ProjectBuildingRequest setResolveDependencies( boolean resolveDependencies ) { this.resolveDependencies = resolveDependencies; return this; } public boolean isResolveDependencies() { return resolveDependencies; } /** * @since 3.2.2 * @deprecated This got added when implementing MNG-2199 and is no longer used. * Commit 6cf9320942c34bc68205425ab696b1712ace9ba4 updated the way 'MavenProject' objects are initialized. */ @Deprecated public ProjectBuildingRequest setResolveVersionRanges( boolean value ) { this.resolveVersionRanges = value; return this; } /** * @since 3.2.2 * @deprecated This got added when implementing MNG-2199 and is no longer used. * Commit 6cf9320942c34bc68205425ab696b1712ace9ba4 updated the way 'MavenProject' objects are initialized. */ @Deprecated public boolean isResolveVersionRanges() { return this.resolveVersionRanges; } public ProjectBuildingRequest setValidationLevel( int validationLevel ) { this.validationLevel = validationLevel; return this; } public int getValidationLevel() { return validationLevel; } public List getActiveProfileIds() { return activeProfileIds; } public void setActiveProfileIds( List activeProfileIds ) { if ( activeProfileIds != null ) { this.activeProfileIds = new ArrayList<>( activeProfileIds ); } else { this.activeProfileIds.clear(); } } public List getInactiveProfileIds() { return inactiveProfileIds; } public void setInactiveProfileIds( List inactiveProfileIds ) { if ( inactiveProfileIds != null ) { this.inactiveProfileIds = new ArrayList<>( inactiveProfileIds ); } else { this.inactiveProfileIds.clear(); } } public void setProfiles( List profiles ) { if ( profiles != null ) { this.profiles = new ArrayList<>( profiles ); } else { this.profiles.clear(); } } public void addProfile( Profile profile ) { profiles.add( profile ); } public List getProfiles() { return profiles; } public Date getBuildStartTime() { return buildStartTime; } public void setBuildStartTime( Date buildStartTime ) { this.buildStartTime = buildStartTime; } public RepositorySystemSession getRepositorySession() { return repositorySession; } public DefaultProjectBuildingRequest setRepositorySession( RepositorySystemSession repositorySession ) { this.repositorySession = repositorySession; return this; } public DefaultProjectBuildingRequest setRepositoryMerging( RepositoryMerging repositoryMerging ) { this.repositoryMerging = Validate.notNull( repositoryMerging, "repositoryMerging cannot be null" ); return this; } public RepositoryMerging getRepositoryMerging() { return repositoryMerging; } } DefaultProjectBuildingResult.java000066400000000000000000000064421317160430700335730ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/projectpackage org.apache.maven.project; /* * 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.File; import java.util.ArrayList; import java.util.List; import org.apache.maven.model.building.ModelProblem; /** * Collects the output of the project builder. * * @author Benjamin Bentmann */ class DefaultProjectBuildingResult implements ProjectBuildingResult { private String projectId; private File pomFile; private MavenProject project; private List problems; private DependencyResolutionResult dependencyResolutionResult; /** * Creates a new result with the specified contents. * * @param project The project that was built, may be {@code null}. * @param problems The problems that were encountered, may be {@code null}. * @param dependencyResolutionResult The result of the resolution for the project dependencies, may be {@code null}. */ public DefaultProjectBuildingResult( MavenProject project, List problems, DependencyResolutionResult dependencyResolutionResult ) { this.projectId = ( project != null ) ? project.getGroupId() + ':' + project.getArtifactId() + ':' + project.getVersion() : ""; this.pomFile = ( project != null ) ? project.getFile() : null; this.project = project; this.problems = problems; this.dependencyResolutionResult = dependencyResolutionResult; } /** * Creates a new result with the specified contents. * * @param projectId The identifier of the project, may be {@code null}. * @param pomFile The POM file from which the project was built, may be {@code null}. * @param problems The problems that were encountered, may be {@code null}. */ public DefaultProjectBuildingResult( String projectId, File pomFile, List problems ) { this.projectId = ( projectId != null ) ? projectId : ""; this.pomFile = pomFile; this.problems = problems; } public String getProjectId() { return projectId; } public File getPomFile() { return pomFile; } public MavenProject getProject() { return project; } public List getProblems() { if ( problems == null ) { problems = new ArrayList<>(); } return problems; } public DependencyResolutionResult getDependencyResolutionResult() { return dependencyResolutionResult; } } DefaultProjectDependenciesResolver.java000066400000000000000000000316511317160430700347470ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/projectpackage org.apache.maven.project; /* * 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.util.Collection; import java.util.HashMap; import java.util.List; import java.util.Map; import org.apache.maven.RepositoryUtils; import org.apache.maven.artifact.Artifact; import org.apache.maven.model.Dependency; import org.apache.maven.model.DependencyManagement; import org.apache.maven.model.Exclusion; import org.codehaus.plexus.component.annotations.Component; import org.codehaus.plexus.component.annotations.Requirement; import org.codehaus.plexus.logging.Logger; import org.codehaus.plexus.util.StringUtils; import org.eclipse.aether.DefaultRepositorySystemSession; import org.eclipse.aether.RepositorySystem; import org.eclipse.aether.RepositorySystemSession; import org.eclipse.aether.RequestTrace; import org.eclipse.aether.artifact.ArtifactType; import org.eclipse.aether.artifact.ArtifactTypeRegistry; import org.eclipse.aether.collection.CollectRequest; import org.eclipse.aether.collection.DependencyCollectionException; import org.eclipse.aether.graph.DependencyFilter; import org.eclipse.aether.graph.DependencyNode; import org.eclipse.aether.graph.DependencyVisitor; import org.eclipse.aether.resolution.ArtifactResult; import org.eclipse.aether.resolution.DependencyRequest; import org.eclipse.aether.util.artifact.ArtifactIdUtils; import org.eclipse.aether.util.artifact.JavaScopes; import org.eclipse.aether.util.graph.manager.DependencyManagerUtils; /** * @author Benjamin Bentmann */ @Component( role = ProjectDependenciesResolver.class ) public class DefaultProjectDependenciesResolver implements ProjectDependenciesResolver { @Requirement private Logger logger; @Requirement private RepositorySystem repoSystem; @Requirement private List decorators; public DependencyResolutionResult resolve( DependencyResolutionRequest request ) throws DependencyResolutionException { final RequestTrace trace = RequestTrace.newChild( null, request ); final DefaultDependencyResolutionResult result = new DefaultDependencyResolutionResult(); final MavenProject project = request.getMavenProject(); final DependencyFilter filter = request.getResolutionFilter(); RepositorySystemSession session = request.getRepositorySession(); ArtifactTypeRegistry stereotypes = session.getArtifactTypeRegistry(); if ( logger.isDebugEnabled() && session.getConfigProperties().get( DependencyManagerUtils.CONFIG_PROP_VERBOSE ) == null ) { DefaultRepositorySystemSession verbose = new DefaultRepositorySystemSession( session ); verbose.setConfigProperty( DependencyManagerUtils.CONFIG_PROP_VERBOSE, Boolean.TRUE ); session = verbose; } for ( RepositorySessionDecorator decorator : decorators ) { RepositorySystemSession decorated = decorator.decorate( project, session ); if ( decorated != null ) { session = decorated; } } CollectRequest collect = new CollectRequest(); collect.setRootArtifact( RepositoryUtils.toArtifact( project.getArtifact() ) ); collect.setRequestContext( "project" ); collect.setRepositories( project.getRemoteProjectRepositories() ); if ( project.getDependencyArtifacts() == null ) { for ( Dependency dependency : project.getDependencies() ) { if ( StringUtils.isEmpty( dependency.getGroupId() ) || StringUtils.isEmpty( dependency.getArtifactId() ) || StringUtils.isEmpty( dependency.getVersion() ) ) { // guard against case where best-effort resolution for invalid models is requested continue; } collect.addDependency( RepositoryUtils.toDependency( dependency, stereotypes ) ); } } else { Map dependencies = new HashMap<>(); for ( Dependency dependency : project.getDependencies() ) { String classifier = dependency.getClassifier(); if ( classifier == null ) { ArtifactType type = stereotypes.get( dependency.getType() ); if ( type != null ) { classifier = type.getClassifier(); } } String key = ArtifactIdUtils.toVersionlessId( dependency.getGroupId(), dependency.getArtifactId(), dependency.getType(), classifier ); dependencies.put( key, dependency ); } for ( Artifact artifact : project.getDependencyArtifacts() ) { String key = artifact.getDependencyConflictId(); Dependency dependency = dependencies.get( key ); Collection exclusions = dependency != null ? dependency.getExclusions() : null; org.eclipse.aether.graph.Dependency dep = RepositoryUtils.toDependency( artifact, exclusions ); if ( !JavaScopes.SYSTEM.equals( dep.getScope() ) && dep.getArtifact().getFile() != null ) { // enable re-resolution org.eclipse.aether.artifact.Artifact art = dep.getArtifact(); art = art.setFile( null ).setVersion( art.getBaseVersion() ); dep = dep.setArtifact( art ); } collect.addDependency( dep ); } } DependencyManagement depMgmt = project.getDependencyManagement(); if ( depMgmt != null ) { for ( Dependency dependency : depMgmt.getDependencies() ) { collect.addManagedDependency( RepositoryUtils.toDependency( dependency, stereotypes ) ); } } DependencyRequest depRequest = new DependencyRequest( collect, filter ); depRequest.setTrace( trace ); DependencyNode node; try { collect.setTrace( RequestTrace.newChild( trace, depRequest ) ); node = repoSystem.collectDependencies( session, collect ).getRoot(); result.setDependencyGraph( node ); } catch ( DependencyCollectionException e ) { result.setDependencyGraph( e.getResult().getRoot() ); result.setCollectionErrors( e.getResult().getExceptions() ); throw new DependencyResolutionException( result, "Could not resolve dependencies for project " + project.getId() + ": " + e.getMessage(), e ); } depRequest.setRoot( node ); if ( logger.isWarnEnabled() ) { for ( DependencyNode child : node.getChildren() ) { if ( !child.getRelocations().isEmpty() ) { logger.warn( "The artifact " + child.getRelocations().get( 0 ) + " has been relocated to " + child.getDependency().getArtifact() ); } } } if ( logger.isDebugEnabled() ) { node.accept( new GraphLogger( project ) ); } try { process( result, repoSystem.resolveDependencies( session, depRequest ).getArtifactResults() ); } catch ( org.eclipse.aether.resolution.DependencyResolutionException e ) { process( result, e.getResult().getArtifactResults() ); throw new DependencyResolutionException( result, "Could not resolve dependencies for project " + project.getId() + ": " + e.getMessage(), e ); } return result; } private void process( DefaultDependencyResolutionResult result, Collection results ) { for ( ArtifactResult ar : results ) { DependencyNode node = ar.getRequest().getDependencyNode(); if ( ar.isResolved() ) { result.addResolvedDependency( node.getDependency() ); } else { result.setResolutionErrors( node.getDependency(), ar.getExceptions() ); } } } class GraphLogger implements DependencyVisitor { private final MavenProject project; private String indent = ""; public GraphLogger( MavenProject project ) { this.project = project; } public boolean visitEnter( DependencyNode node ) { StringBuilder buffer = new StringBuilder( 128 ); buffer.append( indent ); org.eclipse.aether.graph.Dependency dep = node.getDependency(); if ( dep != null ) { org.eclipse.aether.artifact.Artifact art = dep.getArtifact(); buffer.append( art ); buffer.append( ':' ).append( dep.getScope() ); // TODO We currently cannot tell which section contained the management // information. When resolver 1.1 provides this information, these log messages should be updated // to contain it. if ( ( node.getManagedBits() & DependencyNode.MANAGED_SCOPE ) == DependencyNode.MANAGED_SCOPE ) { final String premanagedScope = DependencyManagerUtils.getPremanagedScope( node ); buffer.append( " (scope managed from " ); buffer.append( StringUtils.defaultString( premanagedScope, "default" ) ); buffer.append( ')' ); } if ( ( node.getManagedBits() & DependencyNode.MANAGED_VERSION ) == DependencyNode.MANAGED_VERSION ) { final String premanagedVersion = DependencyManagerUtils.getPremanagedVersion( node ); buffer.append( " (version managed from " ); buffer.append( StringUtils.defaultString( premanagedVersion, "default" ) ); buffer.append( ')' ); } if ( ( node.getManagedBits() & DependencyNode.MANAGED_OPTIONAL ) == DependencyNode.MANAGED_OPTIONAL ) { final Boolean premanagedOptional = DependencyManagerUtils.getPremanagedOptional( node ); buffer.append( " (optionality managed from " ); buffer.append( StringUtils.defaultString( premanagedOptional, "default" ) ); buffer.append( ')' ); } if ( ( node.getManagedBits() & DependencyNode.MANAGED_EXCLUSIONS ) == DependencyNode.MANAGED_EXCLUSIONS ) { // TODO As of resolver 1.1, use DependencyManagerUtils.getPremanagedExclusions( node ). // The resolver 1.0.x releases do not record premanaged state of exclusions. buffer.append( " (exclusions managed)" ); } if ( ( node.getManagedBits() & DependencyNode.MANAGED_PROPERTIES ) == DependencyNode.MANAGED_PROPERTIES ) { // TODO As of resolver 1.1, use DependencyManagerUtils.getPremanagedProperties( node ). // The resolver 1.0.x releases do not record premanaged state of properties. buffer.append( " (properties managed)" ); } if ( dep.isOptional() ) { buffer.append( " (optional)" ); } } else { buffer.append( project.getGroupId() ); buffer.append( ':' ).append( project.getArtifactId() ); buffer.append( ':' ).append( project.getPackaging() ); buffer.append( ':' ).append( project.getVersion() ); } logger.debug( buffer.toString() ); indent += " "; return true; } public boolean visitLeave( DependencyNode node ) { indent = indent.substring( 0, indent.length() - 3 ); return true; } } } maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/project/DefaultProjectRealmCache.java000066400000000000000000000076321317160430700327040ustar00rootroot00000000000000package org.apache.maven.project; /* * 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.util.Collections; import java.util.List; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; import org.apache.commons.lang3.Validate; import org.codehaus.plexus.classworlds.realm.ClassRealm; import org.codehaus.plexus.classworlds.realm.NoSuchRealmException; import org.codehaus.plexus.component.annotations.Component; import org.codehaus.plexus.personality.plexus.lifecycle.phase.Disposable; import org.eclipse.aether.graph.DependencyFilter; /** * Default project realm cache implementation. Assumes cached data does not change. */ @Component( role = ProjectRealmCache.class ) public class DefaultProjectRealmCache implements ProjectRealmCache, Disposable { protected static class CacheKey implements Key { private final List extensionRealms; private final int hashCode; public CacheKey( List extensionRealms ) { this.extensionRealms = ( extensionRealms != null ) ? extensionRealms : Collections.emptyList(); this.hashCode = this.extensionRealms.hashCode(); } @Override public int hashCode() { return hashCode; } @Override public boolean equals( Object o ) { if ( o == this ) { return true; } if ( !( o instanceof CacheKey ) ) { return false; } CacheKey other = (CacheKey) o; return extensionRealms.equals( other.extensionRealms ); } @Override public String toString() { return extensionRealms.toString(); } } protected final Map cache = new ConcurrentHashMap<>(); @Override public Key createKey( List extensionRealms ) { return new CacheKey( extensionRealms ); } public CacheRecord get( Key key ) { return cache.get( key ); } public CacheRecord put( Key key, ClassRealm projectRealm, DependencyFilter extensionArtifactFilter ) { Validate.notNull( projectRealm, "projectRealm cannot be null" ); if ( cache.containsKey( key ) ) { throw new IllegalStateException( "Duplicate project realm for extensions " + key ); } CacheRecord record = new CacheRecord( projectRealm, extensionArtifactFilter ); cache.put( key, record ); return record; } public void flush() { for ( CacheRecord record : cache.values() ) { ClassRealm realm = record.realm; try { realm.getWorld().disposeRealm( realm.getId() ); } catch ( NoSuchRealmException e ) { // ignore } } cache.clear(); } public void register( MavenProject project, Key key, CacheRecord record ) { // default cache does not track record usage } @Override public void dispose() { flush(); } } DependencyResolutionException.java000066400000000000000000000023701317160430700340200ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/projectpackage org.apache.maven.project; /* * 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 Benjamin Bentmann */ public class DependencyResolutionException extends Exception { private DependencyResolutionResult result; public DependencyResolutionException( DependencyResolutionResult result, String message, Throwable cause ) { super( message, cause ); this.result = result; } public DependencyResolutionResult getResult() { return result; } } maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/project/DependencyResolutionRequest.java000066400000000000000000000055051317160430700335740ustar00rootroot00000000000000package org.apache.maven.project; /* * 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 org.eclipse.aether.RepositorySystemSession; import org.eclipse.aether.graph.DependencyFilter; /** * A request to resolve the dependencies of a project. * * @author Benjamin Bentmann */ public interface DependencyResolutionRequest { /** * Gets the project to resolve dependencies for. * * @return The project to resolve dependencies for or {@code null} if not set. */ MavenProject getMavenProject(); /** * Sets the project to resolve dependencies for. * * @param project The project to resolve dependencies for, may be {@code null}. * @return This request for chaining, never {@code null}. */ DependencyResolutionRequest setMavenProject( MavenProject project ); /** * Gets the filter used to exclude some dependencies from resolution. * * @return The filter to exclude dependencies from resolution or {@code null} to resolve all dependencies. */ DependencyFilter getResolutionFilter(); /** * Sets the filter used to exclude some dependencies from resolution. Note that this filter only controls the * resolution/download of dependency artifacts, not the inclusion of dependency nodes in the resolved dependency * graph. * * @param filter The filter to exclude dependencies from resolution, may be {@code null} to resolve all * dependencies. * @return This request for chaining, never {@code null}. */ DependencyResolutionRequest setResolutionFilter( DependencyFilter filter ); /** * Gets the session to use for repository access. * * @return The repository session or {@code null} if not set. */ RepositorySystemSession getRepositorySession(); /** * Sets the session to use for repository access. * * @param repositorySession The repository session to use. * @return This request for chaining, never {@code null}. */ DependencyResolutionRequest setRepositorySession( RepositorySystemSession repositorySession ); } maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/project/DependencyResolutionResult.java000066400000000000000000000051551317160430700334230ustar00rootroot00000000000000package org.apache.maven.project; /* * 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.util.List; import org.eclipse.aether.graph.Dependency; import org.eclipse.aether.graph.DependencyNode; /** * The result of a project dependency resolution. * * @author Benjamin Bentmann */ public interface DependencyResolutionResult { /** * Gets the dependency graph of the project. * * @return The dependency graph or {@code null} if not available. */ DependencyNode getDependencyGraph(); /** * Gets the transitive dependencies of the project that were not excluded by * {@link DependencyResolutionRequest#getResolutionFilter()}. This list is a union of the results from * {@link #getResolvedDependencies()} and {@link #getUnresolvedDependencies()}. * * @return The transitive dependencies, never {@code null}. */ List getDependencies(); /** * Gets the dependencies that were successfully resolved. * * @return The resolved dependencies, never {@code null}. */ List getResolvedDependencies(); /** * Gets the dependencies that could not be resolved. * * @return The unresolved dependencies, never {@code null}. */ List getUnresolvedDependencies(); /** * Gets the errors that occurred while building the dependency graph. * * @return The errors that occurred while building the dependency graph, never {@code null}. */ List getCollectionErrors(); /** * Gets the errors that occurred while resolving the specified dependency. * * @param dependency The dependency for which to retrieve the errors, must not be {@code null}. * @return The resolution errors for the specified dependency, never {@code null}. */ List getResolutionErrors( Dependency dependency ); } DuplicateArtifactAttachmentException.java000066400000000000000000000040131317160430700352530ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/projectpackage org.apache.maven.project; /* * 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 org.apache.maven.artifact.Artifact; /** * This exception is thrown if an application attempts to attach * two of the same artifacts to a single project. * * @author pgier * @author jdcasey * TODO Make this a checked exception, and modify the API of MavenProjectHelper. * Currently, this modification would create compatibility problems for existing plugins. */ public class DuplicateArtifactAttachmentException extends RuntimeException { private static final String DEFAULT_MESSAGE = "Duplicate artifact attachment detected."; private Artifact artifact; private final MavenProject project; public DuplicateArtifactAttachmentException( MavenProject project, Artifact artifact ) { super( constructMessage( project, artifact ) ); this.project = project; this.artifact = artifact; } private static String constructMessage( MavenProject project, Artifact artifact ) { return DEFAULT_MESSAGE + " (project: " + project.getId() + "; illegal attachment: " + artifact.getId() + ")"; } public MavenProject getProject() { return project; } public Artifact getArtifact() { return artifact; } } maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/project/DuplicateProjectException.java000066400000000000000000000045261317160430700332030ustar00rootroot00000000000000package org.apache.maven.project; /* * 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.File; /** * Exception that occurs when the project list contains duplicate projects instead of ignoring one. * * @author Brett Porter */ public class DuplicateProjectException extends Exception { private final String projectId; private final File existingProjectFile; private final File conflictingProjectFile; /** * @deprecated use {@link #DuplicateProjectException(String, File, File, String)} */ public DuplicateProjectException( String message ) { this( null, null, null, message ); } /** * @deprecated use {@link #DuplicateProjectException(String, File, File, String)} */ public DuplicateProjectException( String message, Exception e ) { super( message, e ); this.projectId = null; this.existingProjectFile = null; this.conflictingProjectFile = null; } public DuplicateProjectException( String projectId, File existingProjectFile, File conflictingProjectFile, String message ) { super( message ); this.projectId = projectId; this.existingProjectFile = existingProjectFile; this.conflictingProjectFile = conflictingProjectFile; } public String getProjectId() { return projectId; } public File getExistingProjectFile() { return existingProjectFile; } public File getConflictingProjectFile() { return conflictingProjectFile; } } maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/project/ExtensionDescriptor.java000066400000000000000000000045251317160430700320750ustar00rootroot00000000000000package org.apache.maven.project; /* * 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.util.ArrayList; import java.util.List; /** * Provides metadata about a build extension. Warning: This is an internal utility class that is only * public for technical reasons, it is not part of the public API. In particular, this class can be changed or deleted * without prior notice. * * @author Benjamin Bentmann */ public class ExtensionDescriptor { private List exportedPackages; private List exportedArtifacts; ExtensionDescriptor() { // hide constructor } public List getExportedPackages() { if ( exportedPackages == null ) { exportedPackages = new ArrayList<>(); } return exportedPackages; } public void setExportedPackages( List exportedPackages ) { if ( exportedPackages == null ) { this.exportedPackages = null; } else { this.exportedPackages = new ArrayList<>( exportedPackages ); } } public List getExportedArtifacts() { if ( exportedArtifacts == null ) { exportedArtifacts = new ArrayList<>(); } return exportedArtifacts; } public void setExportedArtifacts( List exportedArtifacts ) { if ( exportedArtifacts == null ) { this.exportedArtifacts = null; } else { this.exportedArtifacts = new ArrayList<>( exportedArtifacts ); } } } maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/project/ExtensionDescriptorBuilder.java000066400000000000000000000110251317160430700333750ustar00rootroot00000000000000package org.apache.maven.project; /* * 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 org.codehaus.plexus.util.ReaderFactory; import org.codehaus.plexus.util.xml.Xpp3Dom; import org.codehaus.plexus.util.xml.Xpp3DomBuilder; import org.codehaus.plexus.util.xml.pull.XmlPullParserException; import java.io.BufferedInputStream; import java.io.File; import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; import java.util.ArrayList; import java.util.List; import java.util.jar.JarFile; import java.util.zip.ZipEntry; /** * Creates an extension descriptor from some XML stream. * * @author Benjamin Bentmann */ public class ExtensionDescriptorBuilder { /** * @since 3.3.0 */ public String getExtensionDescriptorLocation() { return "META-INF/maven/extension.xml"; } /** * Extracts the extension descriptor (if any) from the specified JAR file. * * @param extensionJar The JAR file or directory to extract the descriptor from, must not be {@code null}. * @return The extracted descriptor or {@code null} if no descriptor was found. * @throws IOException If the descriptor is present but could not be parsed. */ public ExtensionDescriptor build( File extensionJar ) throws IOException { ExtensionDescriptor extensionDescriptor = null; if ( extensionJar.isFile() ) { try ( JarFile pluginJar = new JarFile( extensionJar, false ) ) { ZipEntry pluginDescriptorEntry = pluginJar.getEntry( getExtensionDescriptorLocation() ); if ( pluginDescriptorEntry != null ) { try ( InputStream is = pluginJar.getInputStream( pluginDescriptorEntry ) ) { extensionDescriptor = build( is ); } } } } else { File pluginXml = new File( extensionJar, getExtensionDescriptorLocation() ); if ( pluginXml.canRead() ) { try ( InputStream is = new BufferedInputStream( new FileInputStream( pluginXml ) ) ) { extensionDescriptor = build( is ); } } } return extensionDescriptor; } /** * @since 3.3.0 */ public ExtensionDescriptor build( InputStream is ) throws IOException { ExtensionDescriptor extensionDescriptor = new ExtensionDescriptor(); Xpp3Dom dom; try { dom = Xpp3DomBuilder.build( ReaderFactory.newXmlReader( is ) ); } catch ( XmlPullParserException e ) { throw (IOException) new IOException( e.getMessage() ).initCause( e ); } if ( !"extension".equals( dom.getName() ) ) { throw new IOException( "Unexpected root element \"" + dom.getName() + "\", expected \"extension\"" ); } extensionDescriptor.setExportedPackages( parseStrings( dom.getChild( "exportedPackages" ) ) ); extensionDescriptor.setExportedArtifacts( parseStrings( dom.getChild( "exportedArtifacts" ) ) ); return extensionDescriptor; } private List parseStrings( Xpp3Dom dom ) { List strings = null; if ( dom != null ) { strings = new ArrayList<>(); for ( Xpp3Dom child : dom.getChildren() ) { String string = child.getValue(); if ( string != null ) { string = string.trim(); if ( string.length() > 0 ) { strings.add( string ); } } } } return strings; } } InvalidProjectVersionException.java000066400000000000000000000040451317160430700341420ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/projectpackage org.apache.maven.project; /* * 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.File; import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException; public class InvalidProjectVersionException extends ProjectBuildingException { private final String locationInPom; private final String offendingVersion; public InvalidProjectVersionException( String projectId, String locationInPom, String offendingVersion, File pomFile, InvalidVersionSpecificationException cause ) { super( projectId, formatMessage( projectId, locationInPom, offendingVersion, cause ), pomFile, cause ); this.locationInPom = locationInPom; this.offendingVersion = offendingVersion; } private static String formatMessage( String projectId, String locationInPom, String offendingVersion, InvalidVersionSpecificationException cause ) { return "Invalid version: " + offendingVersion + " found for: " + locationInPom + " in project: " + projectId + ". Reason: " + cause.getMessage(); } public String getOffendingVersion() { return offendingVersion; } public String getLocationInPom() { return locationInPom; } } maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/project/MavenProject.java000066400000000000000000001607421317160430700304630ustar00rootroot00000000000000package org.apache.maven.project; /* * 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.File; import java.io.IOException; import java.io.Writer; import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; import java.util.LinkedHashMap; import java.util.LinkedHashSet; import java.util.List; import java.util.Map; import java.util.Properties; import java.util.Set; import org.apache.maven.RepositoryUtils; import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.ArtifactUtils; import org.apache.maven.artifact.DependencyResolutionRequiredException; // remove once createArtifacts() is removed import org.apache.maven.artifact.factory.ArtifactFactory; import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.resolver.filter.ArtifactFilter; import org.apache.maven.model.Build; import org.apache.maven.model.CiManagement; import org.apache.maven.model.Contributor; import org.apache.maven.model.Dependency; import org.apache.maven.model.DependencyManagement; import org.apache.maven.model.Developer; import org.apache.maven.model.DistributionManagement; import org.apache.maven.model.Extension; import org.apache.maven.model.IssueManagement; import org.apache.maven.model.License; import org.apache.maven.model.MailingList; import org.apache.maven.model.Model; import org.apache.maven.model.Organization; import org.apache.maven.model.Plugin; import org.apache.maven.model.PluginExecution; import org.apache.maven.model.PluginManagement; import org.apache.maven.model.Prerequisites; import org.apache.maven.model.Profile; import org.apache.maven.model.ReportPlugin; import org.apache.maven.model.ReportSet; import org.apache.maven.model.Reporting; import org.apache.maven.model.Repository; import org.apache.maven.model.Resource; import org.apache.maven.model.Scm; import org.apache.maven.model.io.xpp3.MavenXpp3Writer; import org.apache.maven.project.artifact.InvalidDependencyVersionException; import org.apache.maven.project.artifact.MavenMetadataSource; import org.codehaus.plexus.classworlds.realm.ClassRealm; import org.codehaus.plexus.util.xml.Xpp3Dom; import org.eclipse.aether.graph.DependencyFilter; import org.eclipse.aether.repository.RemoteRepository; /** * The concern of the project is provide runtime values based on the model. *

* The values in the model remain untouched but during the process of building a project notions like inheritance and * interpolation can be added. This allows to have an entity which is useful in a runtime while preserving the model so * that it can be marshalled and unmarshalled without being tainted by runtime requirements. *

*

* With changes during 3.2.2 release MavenProject is closer to being immutable after construction with the removal of * all components from this class, and the upfront construction taken care of entirely by the @{ProjectBuilder}. There * is still the issue of having to run the lifecycle in order to find all the compile source roots and resource * directories but I hope to take care of this during the Maven 4.0 release (jvz). *

*/ public class MavenProject implements Cloneable { public static final String EMPTY_PROJECT_GROUP_ID = "unknown"; public static final String EMPTY_PROJECT_ARTIFACT_ID = "empty-project"; public static final String EMPTY_PROJECT_VERSION = "0"; private Model model; private MavenProject parent; private File file; private File basedir; private Set resolvedArtifacts; private ArtifactFilter artifactFilter; private Set artifacts; private Artifact parentArtifact; private Set pluginArtifacts; private List remoteArtifactRepositories; private List pluginArtifactRepositories; private List remoteProjectRepositories; private List remotePluginRepositories; private List attachedArtifacts; private MavenProject executionProject; private List collectedProjects; private List compileSourceRoots = new ArrayList<>(); private List testCompileSourceRoots = new ArrayList<>(); private List scriptSourceRoots = new ArrayList<>(); private ArtifactRepository releaseArtifactRepository; private ArtifactRepository snapshotArtifactRepository; private List activeProfiles = new ArrayList<>(); private Map> injectedProfileIds = new LinkedHashMap<>(); private Set dependencyArtifacts; private Artifact artifact; // calculated. private Map artifactMap; private Model originalModel; private Map pluginArtifactMap; private Set reportArtifacts; private Map reportArtifactMap; private Set extensionArtifacts; private Map extensionArtifactMap; private Map managedVersionMap; private Map projectReferences = new HashMap<>(); private boolean executionRoot; private File parentFile; private Map context; private ClassRealm classRealm; private DependencyFilter extensionDependencyFilter; private final Set lifecyclePhases = Collections.synchronizedSet( new LinkedHashSet() ); public MavenProject() { Model model = new Model(); model.setGroupId( EMPTY_PROJECT_GROUP_ID ); model.setArtifactId( EMPTY_PROJECT_ARTIFACT_ID ); model.setVersion( EMPTY_PROJECT_VERSION ); setModel( model ); } public MavenProject( Model model ) { setModel( model ); } public MavenProject( MavenProject project ) { deepCopy( project ); } public File getParentFile() { return parentFile; } public void setParentFile( File parentFile ) { this.parentFile = parentFile; } // ---------------------------------------------------------------------- // Accessors // ---------------------------------------------------------------------- public Artifact getArtifact() { return artifact; } public void setArtifact( Artifact artifact ) { this.artifact = artifact; } // TODO I would like to get rid of this. jvz. public Model getModel() { return model; } /** * Returns the project corresponding to a declared parent. * * @return the parent, or null if no parent is declared or there was an error building it */ public MavenProject getParent() { return parent; } public void setParent( MavenProject parent ) { this.parent = parent; } public boolean hasParent() { return getParent() != null; } public File getFile() { return file; } public void setFile( File file ) { this.file = file; this.basedir = file != null ? file.getParentFile() : null; } /** * Sets project {@code file} without changing project {@code basedir}. * * @since 3.2.4 */ public void setPomFile( File file ) { this.file = file; } public File getBasedir() { return basedir; } public void setDependencies( List dependencies ) { getModel().setDependencies( dependencies ); } public List getDependencies() { return getModel().getDependencies(); } public DependencyManagement getDependencyManagement() { return getModel().getDependencyManagement(); } // ---------------------------------------------------------------------- // Test and compile sourceroots. // ---------------------------------------------------------------------- private void addPath( List paths, String path ) { if ( path != null ) { path = path.trim(); if ( path.length() > 0 ) { File file = new File( path ); if ( file.isAbsolute() ) { path = file.getAbsolutePath(); } else { path = new File( getBasedir(), path ).getAbsolutePath(); } if ( !paths.contains( path ) ) { paths.add( path ); } } } } public void addCompileSourceRoot( String path ) { addPath( getCompileSourceRoots(), path ); } public void addTestCompileSourceRoot( String path ) { addPath( getTestCompileSourceRoots(), path ); } public List getCompileSourceRoots() { return compileSourceRoots; } public List getTestCompileSourceRoots() { return testCompileSourceRoots; } public List getCompileClasspathElements() throws DependencyResolutionRequiredException { List list = new ArrayList<>( getArtifacts().size() + 1 ); String d = getBuild().getOutputDirectory(); if ( d != null ) { list.add( d ); } for ( Artifact a : getArtifacts() ) { if ( a.getArtifactHandler().isAddedToClasspath() ) { // TODO let the scope handler deal with this if ( Artifact.SCOPE_COMPILE.equals( a.getScope() ) || Artifact.SCOPE_PROVIDED.equals( a.getScope() ) || Artifact.SCOPE_SYSTEM.equals( a.getScope() ) ) { addArtifactPath( a, list ); } } } return list; } // TODO this checking for file == null happens because the resolver has been confused about the root // artifact or not. things like the stupid dummy artifact coming from surefire. public List getTestClasspathElements() throws DependencyResolutionRequiredException { List list = new ArrayList<>( getArtifacts().size() + 2 ); String d = getBuild().getTestOutputDirectory(); if ( d != null ) { list.add( d ); } d = getBuild().getOutputDirectory(); if ( d != null ) { list.add( d ); } for ( Artifact a : getArtifacts() ) { if ( a.getArtifactHandler().isAddedToClasspath() ) { addArtifactPath( a, list ); } } return list; } public List getRuntimeClasspathElements() throws DependencyResolutionRequiredException { List list = new ArrayList<>( getArtifacts().size() + 1 ); String d = getBuild().getOutputDirectory(); if ( d != null ) { list.add( d ); } for ( Artifact a : getArtifacts() ) { if ( a.getArtifactHandler().isAddedToClasspath() // TODO let the scope handler deal with this && ( Artifact.SCOPE_COMPILE.equals( a.getScope() ) || Artifact.SCOPE_RUNTIME.equals( a.getScope() ) ) ) { addArtifactPath( a, list ); } } return list; } // ---------------------------------------------------------------------- // Delegate to the model // ---------------------------------------------------------------------- public void setModelVersion( String pomVersion ) { getModel().setModelVersion( pomVersion ); } public String getModelVersion() { return getModel().getModelVersion(); } public String getId() { return getModel().getId(); } public void setGroupId( String groupId ) { getModel().setGroupId( groupId ); } public String getGroupId() { String groupId = getModel().getGroupId(); if ( ( groupId == null ) && ( getModel().getParent() != null ) ) { groupId = getModel().getParent().getGroupId(); } return groupId; } public void setArtifactId( String artifactId ) { getModel().setArtifactId( artifactId ); } public String getArtifactId() { return getModel().getArtifactId(); } public void setName( String name ) { getModel().setName( name ); } public String getName() { // TODO this should not be allowed to be null. if ( getModel().getName() != null ) { return getModel().getName(); } else { return getArtifactId(); } } public void setVersion( String version ) { getModel().setVersion( version ); } public String getVersion() { String version = getModel().getVersion(); if ( ( version == null ) && ( getModel().getParent() != null ) ) { version = getModel().getParent().getVersion(); } return version; } public String getPackaging() { return getModel().getPackaging(); } public void setPackaging( String packaging ) { getModel().setPackaging( packaging ); } public void setInceptionYear( String inceptionYear ) { getModel().setInceptionYear( inceptionYear ); } public String getInceptionYear() { return getModel().getInceptionYear(); } public void setUrl( String url ) { getModel().setUrl( url ); } public String getUrl() { return getModel().getUrl(); } public Prerequisites getPrerequisites() { return getModel().getPrerequisites(); } public void setIssueManagement( IssueManagement issueManagement ) { getModel().setIssueManagement( issueManagement ); } public CiManagement getCiManagement() { return getModel().getCiManagement(); } public void setCiManagement( CiManagement ciManagement ) { getModel().setCiManagement( ciManagement ); } public IssueManagement getIssueManagement() { return getModel().getIssueManagement(); } public void setDistributionManagement( DistributionManagement distributionManagement ) { getModel().setDistributionManagement( distributionManagement ); } public DistributionManagement getDistributionManagement() { return getModel().getDistributionManagement(); } public void setDescription( String description ) { getModel().setDescription( description ); } public String getDescription() { return getModel().getDescription(); } public void setOrganization( Organization organization ) { getModel().setOrganization( organization ); } public Organization getOrganization() { return getModel().getOrganization(); } public void setScm( Scm scm ) { getModel().setScm( scm ); } public Scm getScm() { return getModel().getScm(); } public void setMailingLists( List mailingLists ) { getModel().setMailingLists( mailingLists ); } public List getMailingLists() { return getModel().getMailingLists(); } public void addMailingList( MailingList mailingList ) { getModel().addMailingList( mailingList ); } public void setDevelopers( List developers ) { getModel().setDevelopers( developers ); } public List getDevelopers() { return getModel().getDevelopers(); } public void addDeveloper( Developer developer ) { getModel().addDeveloper( developer ); } public void setContributors( List contributors ) { getModel().setContributors( contributors ); } public List getContributors() { return getModel().getContributors(); } public void addContributor( Contributor contributor ) { getModel().addContributor( contributor ); } public void setBuild( Build build ) { getModel().setBuild( build ); } public Build getBuild() { return getModelBuild(); } public List getResources() { return getBuild().getResources(); } public List getTestResources() { return getBuild().getTestResources(); } public void addResource( Resource resource ) { getBuild().addResource( resource ); } public void addTestResource( Resource testResource ) { getBuild().addTestResource( testResource ); } public void setLicenses( List licenses ) { getModel().setLicenses( licenses ); } public List getLicenses() { return getModel().getLicenses(); } public void addLicense( License license ) { getModel().addLicense( license ); } public void setArtifacts( Set artifacts ) { this.artifacts = artifacts; // flush the calculated artifactMap artifactMap = null; } /** * All dependencies that this project has, including transitive ones. Contents are lazily populated, so depending on * what phases have run dependencies in some scopes won't be included. eg. if only compile phase has run, * dependencies with scope test won't be included. * * @return {@link Set} < {@link Artifact} > * @see #getDependencyArtifacts() to get only direct dependencies */ public Set getArtifacts() { if ( artifacts == null ) { if ( artifactFilter == null || resolvedArtifacts == null ) { artifacts = new LinkedHashSet<>(); } else { artifacts = new LinkedHashSet<>( resolvedArtifacts.size() * 2 ); for ( Artifact artifact : resolvedArtifacts ) { if ( artifactFilter.include( artifact ) ) { artifacts.add( artifact ); } } } } return artifacts; } public Map getArtifactMap() { if ( artifactMap == null ) { artifactMap = ArtifactUtils.artifactMapByVersionlessId( getArtifacts() ); } return artifactMap; } public void setPluginArtifacts( Set pluginArtifacts ) { this.pluginArtifacts = pluginArtifacts; this.pluginArtifactMap = null; } public Set getPluginArtifacts() { return pluginArtifacts; } public Map getPluginArtifactMap() { if ( pluginArtifactMap == null ) { pluginArtifactMap = ArtifactUtils.artifactMapByVersionlessId( getPluginArtifacts() ); } return pluginArtifactMap; } public void setParentArtifact( Artifact parentArtifact ) { this.parentArtifact = parentArtifact; } public Artifact getParentArtifact() { return parentArtifact; } public List getRepositories() { return getModel().getRepositories(); } // ---------------------------------------------------------------------- // Plugins // ---------------------------------------------------------------------- public List getBuildPlugins() { if ( getModel().getBuild() == null ) { return Collections.emptyList(); } return getModel().getBuild().getPlugins(); } public List getModules() { return getModel().getModules(); } public PluginManagement getPluginManagement() { PluginManagement pluginMgmt = null; Build build = getModel().getBuild(); if ( build != null ) { pluginMgmt = build.getPluginManagement(); } return pluginMgmt; } private Build getModelBuild() { Build build = getModel().getBuild(); if ( build == null ) { build = new Build(); getModel().setBuild( build ); } return build; } public void setRemoteArtifactRepositories( List remoteArtifactRepositories ) { this.remoteArtifactRepositories = remoteArtifactRepositories; this.remoteProjectRepositories = RepositoryUtils.toRepos( getRemoteArtifactRepositories() ); } public List getRemoteArtifactRepositories() { if ( remoteArtifactRepositories == null ) { remoteArtifactRepositories = new ArrayList<>(); } return remoteArtifactRepositories; } public void setPluginArtifactRepositories( List pluginArtifactRepositories ) { this.pluginArtifactRepositories = pluginArtifactRepositories; this.remotePluginRepositories = RepositoryUtils.toRepos( getPluginArtifactRepositories() ); } /** * @return a list of ArtifactRepository objects constructed from the Repository objects returned by * getPluginRepositories. */ public List getPluginArtifactRepositories() { if ( pluginArtifactRepositories == null ) { pluginArtifactRepositories = new ArrayList<>(); } return pluginArtifactRepositories; } public ArtifactRepository getDistributionManagementArtifactRepository() { return getArtifact().isSnapshot() && ( getSnapshotArtifactRepository() != null ) ? getSnapshotArtifactRepository() : getReleaseArtifactRepository(); } public List getPluginRepositories() { return getModel().getPluginRepositories(); } public List getRemoteProjectRepositories() { return remoteProjectRepositories; } public List getRemotePluginRepositories() { return remotePluginRepositories; } public void setActiveProfiles( List activeProfiles ) { this.activeProfiles = activeProfiles; } public List getActiveProfiles() { return activeProfiles; } public void setInjectedProfileIds( String source, List injectedProfileIds ) { if ( injectedProfileIds != null ) { this.injectedProfileIds.put( source, new ArrayList<>( injectedProfileIds ) ); } else { this.injectedProfileIds.remove( source ); } } /** * Gets the identifiers of all profiles that contributed to this project's effective model. This includes active * profiles from the project's POM and all its parent POMs as well as from external sources like the * {@code settings.xml}. The profile identifiers are grouped by the identifier of their source, e.g. * {@code ::} for a POM profile or {@code external} for profiles from the * {@code settings.xml}. * * @return The identifiers of all injected profiles, indexed by the source from which the profiles originated, never * {@code null}. */ public Map> getInjectedProfileIds() { return this.injectedProfileIds; } /** * Add or replace an artifact. This method is now deprecated. Use the @{MavenProjectHelper} to attach artifacts to a * project. In spite of the 'throws' declaration on this API, this method has never thrown an exception since Maven * 3.0.x. Historically, it logged and ignored a second addition of the same g/a/v/c/t. Now it replaces the file for * the artifact, so that plugins (e.g. shade) can change the pathname of the file for a particular set of * coordinates. * * @param artifact the artifact to add or replace. * @throws DuplicateArtifactAttachmentException */ public void addAttachedArtifact( Artifact artifact ) throws DuplicateArtifactAttachmentException { getAttachedArtifacts().add( artifact ); } public List getAttachedArtifacts() { if ( attachedArtifacts == null ) { attachedArtifacts = new ArrayList<>(); } return attachedArtifacts; } public Xpp3Dom getGoalConfiguration( String pluginGroupId, String pluginArtifactId, String executionId, String goalId ) { Xpp3Dom dom = null; if ( getBuildPlugins() != null ) { for ( Plugin plugin : getBuildPlugins() ) { if ( pluginGroupId.equals( plugin.getGroupId() ) && pluginArtifactId.equals( plugin.getArtifactId() ) ) { dom = (Xpp3Dom) plugin.getConfiguration(); if ( executionId != null ) { PluginExecution execution = plugin.getExecutionsAsMap().get( executionId ); if ( execution != null ) { // NOTE: The PluginConfigurationExpander already merged the plugin-level config in dom = (Xpp3Dom) execution.getConfiguration(); } } break; } } } if ( dom != null ) { // make a copy so the original in the POM doesn't get messed with dom = new Xpp3Dom( dom ); } return dom; } public MavenProject getExecutionProject() { return ( executionProject == null ? this : executionProject ); } public void setExecutionProject( MavenProject executionProject ) { this.executionProject = executionProject; } public List getCollectedProjects() { return collectedProjects; } public void setCollectedProjects( List collectedProjects ) { this.collectedProjects = collectedProjects; } /** * Direct dependencies that this project has. * * @return {@link Set} < {@link Artifact} > * @see #getArtifacts() to get all transitive dependencies */ @Deprecated public Set getDependencyArtifacts() { return dependencyArtifacts; } @Deprecated public void setDependencyArtifacts( Set dependencyArtifacts ) { this.dependencyArtifacts = dependencyArtifacts; } public void setReleaseArtifactRepository( ArtifactRepository releaseArtifactRepository ) { this.releaseArtifactRepository = releaseArtifactRepository; } public void setSnapshotArtifactRepository( ArtifactRepository snapshotArtifactRepository ) { this.snapshotArtifactRepository = snapshotArtifactRepository; } public void setOriginalModel( Model originalModel ) { this.originalModel = originalModel; } public Model getOriginalModel() { return originalModel; } public void setManagedVersionMap( Map map ) { managedVersionMap = map; } public Map getManagedVersionMap() { return managedVersionMap; } @Override public boolean equals( Object other ) { if ( other == this ) { return true; } else if ( !( other instanceof MavenProject ) ) { return false; } MavenProject that = (MavenProject) other; return eq( getArtifactId(), that.getArtifactId() ) && eq( getGroupId(), that.getGroupId() ) && eq( getVersion(), that.getVersion() ); } private static boolean eq( T s1, T s2 ) { return ( s1 != null ) ? s1.equals( s2 ) : s2 == null; } @Override public int hashCode() { int hash = 17; hash = 31 * hash + getGroupId().hashCode(); hash = 31 * hash + getArtifactId().hashCode(); hash = 31 * hash + getVersion().hashCode(); return hash; } public List getBuildExtensions() { Build build = getBuild(); if ( ( build == null ) || ( build.getExtensions() == null ) ) { return Collections.emptyList(); } else { return build.getExtensions(); } } public void addProjectReference( MavenProject project ) { projectReferences.put( getProjectReferenceId( project.getGroupId(), project.getArtifactId(), project.getVersion() ), project ); } public Properties getProperties() { return getModel().getProperties(); } public List getFilters() { return getBuild().getFilters(); } public Map getProjectReferences() { return projectReferences; } public boolean isExecutionRoot() { return executionRoot; } public void setExecutionRoot( boolean executionRoot ) { this.executionRoot = executionRoot; } public String getDefaultGoal() { return getBuild() != null ? getBuild().getDefaultGoal() : null; } public Plugin getPlugin( String pluginKey ) { return getBuild().getPluginsAsMap().get( pluginKey ); } /** * Default toString */ @Override public String toString() { StringBuilder sb = new StringBuilder( 128 ); sb.append( "MavenProject: " ); sb.append( getGroupId() ); sb.append( ':' ); sb.append( getArtifactId() ); sb.append( ':' ); sb.append( getVersion() ); sb.append( " @ " ); try { sb.append( getFile().getPath() ); } catch ( NullPointerException e ) { // don't log it. } return sb.toString(); } /** * @since 2.0.9 */ @Override public MavenProject clone() { MavenProject clone; try { clone = (MavenProject) super.clone(); } catch ( CloneNotSupportedException e ) { throw new UnsupportedOperationException( e ); } clone.deepCopy( this ); return clone; } public void setModel( Model model ) { this.model = model; } protected void setAttachedArtifacts( List attachedArtifacts ) { this.attachedArtifacts = attachedArtifacts; } protected void setCompileSourceRoots( List compileSourceRoots ) { this.compileSourceRoots = compileSourceRoots; } protected void setTestCompileSourceRoots( List testCompileSourceRoots ) { this.testCompileSourceRoots = testCompileSourceRoots; } protected ArtifactRepository getReleaseArtifactRepository() { return releaseArtifactRepository; } protected ArtifactRepository getSnapshotArtifactRepository() { return snapshotArtifactRepository; } private void deepCopy( MavenProject project ) { // disown the parent // copy fields setFile( project.getFile() ); // don't need a deep copy, they don't get modified or added/removed to/from - but make them unmodifiable to be // sure! if ( project.getDependencyArtifacts() != null ) { setDependencyArtifacts( Collections.unmodifiableSet( project.getDependencyArtifacts() ) ); } if ( project.getArtifacts() != null ) { setArtifacts( Collections.unmodifiableSet( project.getArtifacts() ) ); } if ( project.getParentFile() != null ) { parentFile = new File( project.getParentFile().getAbsolutePath() ); } if ( project.getPluginArtifacts() != null ) { setPluginArtifacts( Collections.unmodifiableSet( project.getPluginArtifacts() ) ); } if ( project.getReportArtifacts() != null ) { setReportArtifacts( Collections.unmodifiableSet( project.getReportArtifacts() ) ); } if ( project.getExtensionArtifacts() != null ) { setExtensionArtifacts( Collections.unmodifiableSet( project.getExtensionArtifacts() ) ); } setParentArtifact( ( project.getParentArtifact() ) ); if ( project.getRemoteArtifactRepositories() != null ) { setRemoteArtifactRepositories( Collections.unmodifiableList( project.getRemoteArtifactRepositories() ) ); } if ( project.getPluginArtifactRepositories() != null ) { setPluginArtifactRepositories( Collections.unmodifiableList( project.getPluginArtifactRepositories() ) ); } if ( project.getActiveProfiles() != null ) { setActiveProfiles( ( Collections.unmodifiableList( project.getActiveProfiles() ) ) ); } if ( project.getAttachedArtifacts() != null ) { // clone properties modifyable by plugins in a forked lifecycle setAttachedArtifacts( new ArrayList<>( project.getAttachedArtifacts() ) ); } if ( project.getCompileSourceRoots() != null ) { // clone source roots setCompileSourceRoots( ( new ArrayList<>( project.getCompileSourceRoots() ) ) ); } if ( project.getTestCompileSourceRoots() != null ) { setTestCompileSourceRoots( ( new ArrayList<>( project.getTestCompileSourceRoots() ) ) ); } if ( project.getScriptSourceRoots() != null ) { setScriptSourceRoots( ( new ArrayList<>( project.getScriptSourceRoots() ) ) ); } if ( project.getModel() != null ) { setModel( project.getModel().clone() ); } if ( project.getOriginalModel() != null ) { setOriginalModel( project.getOriginalModel() ); } setExecutionRoot( project.isExecutionRoot() ); if ( project.getArtifact() != null ) { setArtifact( ArtifactUtils.copyArtifact( project.getArtifact() ) ); } if ( project.getManagedVersionMap() != null ) { setManagedVersionMap( new HashMap<>( project.getManagedVersionMap() ) ); } lifecyclePhases.addAll( project.lifecyclePhases ); } private void addArtifactPath( Artifact artifact, List classpath ) { File file = artifact.getFile(); if ( file != null ) { classpath.add( file.getPath() ); } } private static String getProjectReferenceId( String groupId, String artifactId, String version ) { StringBuilder buffer = new StringBuilder( 128 ); buffer.append( groupId ).append( ':' ).append( artifactId ).append( ':' ).append( version ); return buffer.toString(); } /** * Sets the value of the context value of this project identified by the given key. If the supplied value is * null, the context value is removed from this project. Context values are intended to allow core * extensions to associate derived state with project instances. */ public void setContextValue( String key, Object value ) { if ( context == null ) { context = new HashMap<>(); } if ( value != null ) { context.put( key, value ); } else { context.remove( key ); } } /** * Returns context value of this project associated with the given key or null if this project has no such value. */ public Object getContextValue( String key ) { if ( context == null ) { return null; } return context.get( key ); } /** * Sets the project's class realm. Warning: This is an internal utility method that is only public * for technical reasons, it is not part of the public API. In particular, this method can be changed or deleted * without prior notice and must not be used by plugins. * * @param classRealm The class realm hosting the build extensions of this project, may be {@code null}. */ public void setClassRealm( ClassRealm classRealm ) { this.classRealm = classRealm; } /** * Gets the project's class realm. This class realm hosts the build extensions of the project. * Warning: This is an internal utility method that is only public for technical reasons, it is not * part of the public API. In particular, this method can be changed or deleted without prior notice and must not be * used by plugins. * * @return The project's class realm or {@code null}. */ public ClassRealm getClassRealm() { return classRealm; } /** * Sets the artifact filter used to exclude shared extension artifacts from plugin realms. Warning: * This is an internal utility method that is only public for technical reasons, it is not part of the public API. * In particular, this method can be changed or deleted without prior notice and must not be used by plugins. * * @param extensionDependencyFilter The dependency filter to apply to plugins, may be {@code null}. */ public void setExtensionDependencyFilter( DependencyFilter extensionDependencyFilter ) { this.extensionDependencyFilter = extensionDependencyFilter; } /** * Gets the dependency filter used to exclude shared extension artifacts from plugin realms. * Warning: This is an internal utility method that is only public for technical reasons, it is not * part of the public API. In particular, this method can be changed or deleted without prior notice and must not be * used by plugins. * * @return The dependency filter or {@code null}. */ public DependencyFilter getExtensionDependencyFilter() { return extensionDependencyFilter; } /** * Sets the transitive dependency artifacts that have been resolved/collected for this project. * Warning: This is an internal utility method that is only public for technical reasons, it is not * part of the public API. In particular, this method can be changed or deleted without prior notice and must not be * used by plugins. * * @param artifacts The set of artifacts, may be {@code null}. */ public void setResolvedArtifacts( Set artifacts ) { this.resolvedArtifacts = ( artifacts != null ) ? artifacts : Collections.emptySet(); this.artifacts = null; this.artifactMap = null; } /** * Sets the scope filter to select the artifacts being exposed to the currently executed mojo. * Warning: This is an internal utility method that is only public for technical reasons, it is not * part of the public API. In particular, this method can be changed or deleted without prior notice and must not be * used by plugins. * * @param artifactFilter The artifact filter, may be {@code null} to exclude all artifacts. */ public void setArtifactFilter( ArtifactFilter artifactFilter ) { this.artifactFilter = artifactFilter; this.artifacts = null; this.artifactMap = null; } /** * Warning: This is an internal utility method that is only public for technical reasons, it is not * part of the public API. In particular, this method can be changed or deleted without prior notice and must not be * used by plugins. * * @param phase The phase to check for, must not be {@code null}. * @return {@code true} if the phase has been seen. */ public boolean hasLifecyclePhase( String phase ) { return lifecyclePhases.contains( phase ); } /** * Warning: This is an internal utility method that is only public for technical reasons, it is not * part of the public API. In particular, this method can be changed or deleted without prior notice and must not be * used by plugins. * * @param lifecyclePhase The lifecycle phase to add, must not be {@code null}. */ public void addLifecyclePhase( String lifecyclePhase ) { lifecyclePhases.add( lifecyclePhase ); } // ---------------------------------------------------------------------------------------------------------------- // // // D E P R E C A T E D // // // ---------------------------------------------------------------------------------------------------------------- // // Everything below will be removed for Maven 4.0.0 // // ---------------------------------------------------------------------------------------------------------------- private ProjectBuildingRequest projectBuilderConfiguration; private Map moduleAdjustments; @Deprecated // This appears only to be used in test code public String getModulePathAdjustment( MavenProject moduleProject ) throws IOException { // FIXME: This is hacky. What if module directory doesn't match artifactid, and parent // is coming from the repository?? String module = moduleProject.getArtifactId(); File moduleFile = moduleProject.getFile(); if ( moduleFile != null ) { File moduleDir = moduleFile.getCanonicalFile().getParentFile(); module = moduleDir.getName(); } if ( moduleAdjustments == null ) { moduleAdjustments = new HashMap<>(); List modules = getModules(); if ( modules != null ) { for ( String modulePath : modules ) { String moduleName = modulePath; if ( moduleName.endsWith( "/" ) || moduleName.endsWith( "\\" ) ) { moduleName = moduleName.substring( 0, moduleName.length() - 1 ); } int lastSlash = moduleName.lastIndexOf( '/' ); if ( lastSlash < 0 ) { lastSlash = moduleName.lastIndexOf( '\\' ); } String adjustment = null; if ( lastSlash > -1 ) { moduleName = moduleName.substring( lastSlash + 1 ); adjustment = modulePath.substring( 0, lastSlash ); } moduleAdjustments.put( moduleName, adjustment ); } } } return moduleAdjustments.get( module ); } @Deprecated public Set createArtifacts( ArtifactFactory artifactFactory, String inheritedScope, ArtifactFilter filter ) throws InvalidDependencyVersionException { return MavenMetadataSource.createArtifacts( artifactFactory, getDependencies(), inheritedScope, filter, this ); } @Deprecated protected void setScriptSourceRoots( List scriptSourceRoots ) { this.scriptSourceRoots = scriptSourceRoots; } @Deprecated public void addScriptSourceRoot( String path ) { if ( path != null ) { path = path.trim(); if ( path.length() != 0 ) { if ( !getScriptSourceRoots().contains( path ) ) { getScriptSourceRoots().add( path ); } } } } @Deprecated public List getScriptSourceRoots() { return scriptSourceRoots; } @Deprecated public List getCompileArtifacts() { List list = new ArrayList<>( getArtifacts().size() ); for ( Artifact a : getArtifacts() ) { // TODO classpath check doesn't belong here - that's the other method if ( a.getArtifactHandler().isAddedToClasspath() ) { // TODO let the scope handler deal with this if ( Artifact.SCOPE_COMPILE.equals( a.getScope() ) || Artifact.SCOPE_PROVIDED.equals( a.getScope() ) || Artifact.SCOPE_SYSTEM.equals( a.getScope() ) ) { list.add( a ); } } } return list; } @Deprecated public List getCompileDependencies() { Set artifacts = getArtifacts(); if ( ( artifacts == null ) || artifacts.isEmpty() ) { return Collections.emptyList(); } List list = new ArrayList<>( artifacts.size() ); for ( Artifact a : getArtifacts() ) { // TODO let the scope handler deal with this if ( Artifact.SCOPE_COMPILE.equals( a.getScope() ) || Artifact.SCOPE_PROVIDED.equals( a.getScope() ) || Artifact.SCOPE_SYSTEM.equals( a.getScope() ) ) { Dependency dependency = new Dependency(); dependency.setArtifactId( a.getArtifactId() ); dependency.setGroupId( a.getGroupId() ); dependency.setVersion( a.getVersion() ); dependency.setScope( a.getScope() ); dependency.setType( a.getType() ); dependency.setClassifier( a.getClassifier() ); list.add( dependency ); } } return list; } @Deprecated public List getTestArtifacts() { List list = new ArrayList<>( getArtifacts().size() ); for ( Artifact a : getArtifacts() ) { // TODO classpath check doesn't belong here - that's the other method if ( a.getArtifactHandler().isAddedToClasspath() ) { list.add( a ); } } return list; } @Deprecated public List getTestDependencies() { Set artifacts = getArtifacts(); if ( ( artifacts == null ) || artifacts.isEmpty() ) { return Collections.emptyList(); } List list = new ArrayList<>( artifacts.size() ); for ( Artifact a : getArtifacts() ) { Dependency dependency = new Dependency(); dependency.setArtifactId( a.getArtifactId() ); dependency.setGroupId( a.getGroupId() ); dependency.setVersion( a.getVersion() ); dependency.setScope( a.getScope() ); dependency.setType( a.getType() ); dependency.setClassifier( a.getClassifier() ); list.add( dependency ); } return list; } @Deprecated // used by the Maven ITs public List getRuntimeDependencies() { Set artifacts = getArtifacts(); if ( ( artifacts == null ) || artifacts.isEmpty() ) { return Collections.emptyList(); } List list = new ArrayList<>( artifacts.size() ); for ( Artifact a : getArtifacts() ) { // TODO let the scope handler deal with this if ( Artifact.SCOPE_COMPILE.equals( a.getScope() ) || Artifact.SCOPE_RUNTIME.equals( a.getScope() ) ) { Dependency dependency = new Dependency(); dependency.setArtifactId( a.getArtifactId() ); dependency.setGroupId( a.getGroupId() ); dependency.setVersion( a.getVersion() ); dependency.setScope( a.getScope() ); dependency.setType( a.getType() ); dependency.setClassifier( a.getClassifier() ); list.add( dependency ); } } return list; } @Deprecated public List getRuntimeArtifacts() { List list = new ArrayList<>( getArtifacts().size() ); for ( Artifact a : getArtifacts() ) { // TODO classpath check doesn't belong here - that's the other method if ( a.getArtifactHandler().isAddedToClasspath() // TODO let the scope handler deal with this && ( Artifact.SCOPE_COMPILE.equals( a.getScope() ) || Artifact.SCOPE_RUNTIME.equals( a.getScope() ) ) ) { list.add( a ); } } return list; } @Deprecated public List getSystemClasspathElements() throws DependencyResolutionRequiredException { List list = new ArrayList<>( getArtifacts().size() ); String d = getBuild().getOutputDirectory(); if ( d != null ) { list.add( d ); } for ( Artifact a : getArtifacts() ) { if ( a.getArtifactHandler().isAddedToClasspath() ) { // TODO let the scope handler deal with this if ( Artifact.SCOPE_SYSTEM.equals( a.getScope() ) ) { addArtifactPath( a, list ); } } } return list; } @Deprecated public List getSystemArtifacts() { List list = new ArrayList<>( getArtifacts().size() ); for ( Artifact a : getArtifacts() ) { // TODO classpath check doesn't belong here - that's the other method if ( a.getArtifactHandler().isAddedToClasspath() ) { // TODO let the scope handler deal with this if ( Artifact.SCOPE_SYSTEM.equals( a.getScope() ) ) { list.add( a ); } } } return list; } @Deprecated public List getSystemDependencies() { Set artifacts = getArtifacts(); if ( ( artifacts == null ) || artifacts.isEmpty() ) { return Collections.emptyList(); } List list = new ArrayList<>( artifacts.size() ); for ( Artifact a : getArtifacts() ) { // TODO let the scope handler deal with this if ( Artifact.SCOPE_SYSTEM.equals( a.getScope() ) ) { Dependency dependency = new Dependency(); dependency.setArtifactId( a.getArtifactId() ); dependency.setGroupId( a.getGroupId() ); dependency.setVersion( a.getVersion() ); dependency.setScope( a.getScope() ); dependency.setType( a.getType() ); dependency.setClassifier( a.getClassifier() ); list.add( dependency ); } } return list; } @Deprecated public void setReporting( Reporting reporting ) { getModel().setReporting( reporting ); } @Deprecated public Reporting getReporting() { return getModel().getReporting(); } @Deprecated public void setReportArtifacts( Set reportArtifacts ) { this.reportArtifacts = reportArtifacts; reportArtifactMap = null; } @Deprecated public Set getReportArtifacts() { return reportArtifacts; } @Deprecated public Map getReportArtifactMap() { if ( reportArtifactMap == null ) { reportArtifactMap = ArtifactUtils.artifactMapByVersionlessId( getReportArtifacts() ); } return reportArtifactMap; } @Deprecated public void setExtensionArtifacts( Set extensionArtifacts ) { this.extensionArtifacts = extensionArtifacts; extensionArtifactMap = null; } @Deprecated public Set getExtensionArtifacts() { return extensionArtifacts; } @Deprecated public Map getExtensionArtifactMap() { if ( extensionArtifactMap == null ) { extensionArtifactMap = ArtifactUtils.artifactMapByVersionlessId( getExtensionArtifacts() ); } return extensionArtifactMap; } @Deprecated public List getReportPlugins() { if ( getModel().getReporting() == null ) { return Collections.emptyList(); } return getModel().getReporting().getPlugins(); } @Deprecated public Xpp3Dom getReportConfiguration( String pluginGroupId, String pluginArtifactId, String reportSetId ) { Xpp3Dom dom = null; // ---------------------------------------------------------------------- // I would like to be able to lookup the Mojo object using a key but // we have a limitation in modello that will be remedied shortly. So // for now I have to iterate through and see what we have. // ---------------------------------------------------------------------- if ( getReportPlugins() != null ) { for ( ReportPlugin plugin : getReportPlugins() ) { if ( pluginGroupId.equals( plugin.getGroupId() ) && pluginArtifactId.equals( plugin.getArtifactId() ) ) { dom = (Xpp3Dom) plugin.getConfiguration(); if ( reportSetId != null ) { ReportSet reportSet = plugin.getReportSetsAsMap().get( reportSetId ); if ( reportSet != null ) { Xpp3Dom executionConfiguration = (Xpp3Dom) reportSet.getConfiguration(); if ( executionConfiguration != null ) { Xpp3Dom newDom = new Xpp3Dom( executionConfiguration ); dom = Xpp3Dom.mergeXpp3Dom( newDom, dom ); } } } break; } } } if ( dom != null ) { // make a copy so the original in the POM doesn't get messed with dom = new Xpp3Dom( dom ); } return dom; } /** * @deprecated Use MavenProjectHelper.attachArtifact(..) instead. */ @Deprecated public void attachArtifact( String type, String classifier, File file ) { } /** * @deprecated Use {@link org.apache.maven.model.io.ModelWriter}. */ @Deprecated public void writeModel( Writer writer ) throws IOException { MavenXpp3Writer pomWriter = new MavenXpp3Writer(); pomWriter.write( writer, getModel() ); } /** * @deprecated Use {@link org.apache.maven.model.io.ModelWriter}. */ @Deprecated public void writeOriginalModel( Writer writer ) throws IOException { MavenXpp3Writer pomWriter = new MavenXpp3Writer(); pomWriter.write( writer, getOriginalModel() ); } @Deprecated public Artifact replaceWithActiveArtifact( Artifact pluginArtifact ) { return pluginArtifact; } /** * Gets the project building request from which this project instance was created. Warning: This is * an utility method that is meant to assist integrators of Maven, it must not be used by Maven plugins. * * @return The project building request or {@code null}. * @since 2.1 */ @Deprecated public ProjectBuildingRequest getProjectBuildingRequest() { return projectBuilderConfiguration; } /** * Sets the project building request from which this project instance was created. Warning: This is * an utility method that is meant to assist integrators of Maven, it must not be used by Maven plugins. * * @param projectBuildingRequest The project building request, may be {@code null}. * @since 2.1 */ // used by maven-dependency-tree @Deprecated public void setProjectBuildingRequest( ProjectBuildingRequest projectBuildingRequest ) { this.projectBuilderConfiguration = projectBuildingRequest; } } maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/project/MavenProjectHelper.java000066400000000000000000000055511317160430700316170ustar00rootroot00000000000000package org.apache.maven.project; /* * 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.File; import java.util.List; /** * Convenience interface for plugins to add or replace artifacts and resources on projects. */ public interface MavenProjectHelper { String ROLE = MavenProjectHelper.class.getName(); /** * See {@link #attachArtifact(MavenProject, String, String, java.io.File)}, but with type set to null. * @param project project reference. * @param artifactFile artifact file. * @param artifactClassifier artifact classifier. */ void attachArtifact( MavenProject project, File artifactFile, String artifactClassifier ); /** * * See {@link #attachArtifact(MavenProject, String, String, java.io.File)}, but with classifier set to null. * @param project project reference. * @param artifactType artifact type. * @param artifactFile artifact file. */ void attachArtifact( MavenProject project, String artifactType, File artifactFile ); /** * Add or replace an artifact to the current project. * @param project the project reference. * @param artifactType the type (e.g. jar) or null. * @param artifactClassifier the classifier or null. * @param artifactFile the file for the artifact. */ void attachArtifact( MavenProject project, String artifactType, String artifactClassifier, File artifactFile ); /** * Add a resource directory to the project. * @param project project reference. * @param resourceDirectory directory. * @param includes include patterns. * @param excludes exclude patterns. */ void addResource( MavenProject project, String resourceDirectory, List includes, List excludes ); /** * Add a test resource directory to the project. * @param project project reference. * @param resourceDirectory directory. * @param includes include patterns. * @param excludes exclude patterns. */ void addTestResource( MavenProject project, String resourceDirectory, List includes, List excludes ); } maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/project/ProjectBuilder.java000066400000000000000000000113061317160430700307720ustar00rootroot00000000000000package org.apache.maven.project; /* * 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.File; import java.util.List; import org.apache.maven.artifact.Artifact; import org.apache.maven.model.building.ModelSource; /** * Builds in-memory descriptions of projects. */ public interface ProjectBuilder { /** * Builds a project descriptor from the specified POM file. * * @param projectFile The POM file to build the project from, must not be {@code null}. * @param request The project building request that holds further parameters, must not be {@code null}. * @return The result of the project building, never {@code null}. * @throws ProjectBuildingException If the project descriptor could not be successfully built. */ ProjectBuildingResult build( File projectFile, ProjectBuildingRequest request ) throws ProjectBuildingException; /** * Builds a project descriptor for the specified artifact. * * @param projectArtifact The POM artifact to build the project from, must not be {@code null}. * @param request The project building request that holds further parameters, must not be {@code null}. * @return The result of the project building, never {@code null}. * @throws ProjectBuildingException If the project descriptor could not be successfully built. */ ProjectBuildingResult build( Artifact projectArtifact, ProjectBuildingRequest request ) throws ProjectBuildingException; /** * Builds a project descriptor for the specified artifact. * * @param projectArtifact The POM artifact to build the project from, must not be {@code null}. * @param allowStubModel A flag controlling the case of a missing POM artifact. If {@code true} and the specified * POM artifact does not exist, a simple stub model will be returned. If {@code false}, an exception will * be thrown. * @param request The project building request that holds further parameters, must not be {@code null}. * @return The result of the project building, never {@code null}. * @throws ProjectBuildingException If the project descriptor could not be successfully built. */ ProjectBuildingResult build( Artifact projectArtifact, boolean allowStubModel, ProjectBuildingRequest request ) throws ProjectBuildingException; /** * Builds a project descriptor for the specified model source. * * @param modelSource The source of the model to built the project descriptor from, must not be {@code null}. * @param request The project building request that holds further parameters, must not be {@code null}. * @return The result of the project building, never {@code null}. * @throws ProjectBuildingException If the project descriptor could not be successfully built. * * @see org.apache.maven.model.building.ModelSource2 */ ProjectBuildingResult build( ModelSource modelSource, ProjectBuildingRequest request ) throws ProjectBuildingException; /** * Builds the projects for the specified POM files and optionally their children. * * @param pomFiles The POM files to build, must not be {@code null}. * @param recursive {@code true} to recursively build sub modules referenced by the POM files, {@code false} to * build only the specified POM files. * @param request The project builder configuration that provides further parameters, must not be {@code null}. * @return The results of the project builder where each result corresponds to one project that was built, never * {@code null}. * @throws ProjectBuildingException If an error was encountered during building of any project. * {@link ProjectBuildingException#getResults()} provides access to the details of the problems. */ List build( List pomFiles, boolean recursive, ProjectBuildingRequest request ) throws ProjectBuildingException; } maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/project/ProjectBuildingException.java000066400000000000000000000102431317160430700330170ustar00rootroot00000000000000package org.apache.maven.project; /* * 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 org.apache.maven.model.building.ModelProblem; import org.apache.maven.model.building.ModelProblemUtils; import java.io.File; import java.io.PrintWriter; import java.io.StringWriter; import java.util.List; /** * @author Jason van Zyl */ public class ProjectBuildingException extends Exception { private final String projectId; private File pomFile; private List results; public ProjectBuildingException( String projectId, String message, Throwable cause ) { super( createMessage( message, projectId, null ), cause ); this.projectId = projectId; } /** * @param projectId * @param message * @param pomFile pom file location */ public ProjectBuildingException( String projectId, String message, File pomFile ) { super( createMessage( message, projectId, pomFile ) ); this.projectId = projectId; this.pomFile = pomFile; } /** * @param projectId * @param message * @param pomFile pom file location * @param cause */ protected ProjectBuildingException( String projectId, String message, File pomFile, Throwable cause ) { super( createMessage( message, projectId, pomFile ), cause ); this.projectId = projectId; this.pomFile = pomFile; } public ProjectBuildingException( List results ) { super( createMessage( results ) ); this.projectId = ""; this.results = results; } public File getPomFile() { return pomFile; } /** * @deprecated use {@link #getPomFile()} */ public String getPomLocation() { if ( getPomFile() != null ) { return getPomFile().getAbsolutePath(); } else { return "null"; } } public String getProjectId() { return projectId; } public List getResults() { return results; } private static String createMessage( String message, String projectId, File pomFile ) { StringBuilder buffer = new StringBuilder( 256 ); buffer.append( message ); buffer.append( " for project " ).append( projectId ); if ( pomFile != null ) { buffer.append( " at " ).append( pomFile.getAbsolutePath() ); } return buffer.toString(); } private static String createMessage( List results ) { StringWriter buffer = new StringWriter( 1024 ); PrintWriter writer = new PrintWriter( buffer ); writer.println( "Some problems were encountered while processing the POMs:" ); try { for ( ProjectBuildingResult result : results ) { for ( ModelProblem problem : result.getProblems() ) { writer.print( "[" ); writer.print( problem.getSeverity() ); writer.print( "] " ); writer.print( problem.getMessage() ); writer.print( " @ " ); writer.println( ModelProblemUtils.formatLocation( problem, result.getProjectId() ) ); } } } finally { writer.close(); } return buffer.toString(); } } maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/project/ProjectBuildingHelper.java000066400000000000000000000075551317160430700323140ustar00rootroot00000000000000package org.apache.maven.project; /* * 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.util.List; import org.apache.maven.artifact.InvalidRepositoryException; import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.model.Model; import org.apache.maven.model.Repository; import org.apache.maven.plugin.PluginManagerException; import org.apache.maven.plugin.PluginResolutionException; import org.apache.maven.plugin.version.PluginVersionResolutionException; /** * Assists the project builder. Warning: This is an internal utility interface that is only public for * technical reasons, it is not part of the public API. In particular, this interface can be changed or deleted without * prior notice. * * @author Benjamin Bentmann */ public interface ProjectBuildingHelper { /** * Creates the effective artifact repositories from the specified POM repositories. * * @param pomRepositories The POM repositories to create the artifact repositories from, must not be {@code null}. * @param externalRepositories The external (and already mirrored) repositories to merge into the result list, may * be {@code null}. * @param request The project building request holding further settings like repository settings, must not be * {@code null}. * @return The effective artifact repositories, never {@code null}. * @throws InvalidRepositoryException */ List createArtifactRepositories( List pomRepositories, List externalRepositories, ProjectBuildingRequest request ) throws InvalidRepositoryException; /** * Creates the project realm that hosts the build extensions of the specified model. * * @param project The project to create the project realm for, must not be {@code null} * @param model The model to create the project realm for, must not be {@code null} * @param request The project building request holding further settings like repository settings, must not be * {@code null}. * @return The record with the project realm and extension artifact filter, never {@code null}. * @throws PluginResolutionException If any build extension could not be resolved. */ ProjectRealmCache.CacheRecord createProjectRealm( MavenProject project, Model model, ProjectBuildingRequest request ) throws PluginResolutionException, PluginVersionResolutionException, PluginManagerException; /** * Updates the context class loader such that the container will search the project realm when the model builder * injects the lifecycle bindings from the packaging in the next step. The context class loader is to be reset by * the project builder when the project is fully assembled. * * @param project The project whose class realm should be selected, must not be {@code null}. */ void selectProjectRealm( MavenProject project ); } maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/project/ProjectBuildingRequest.java000066400000000000000000000157521317160430700325230ustar00rootroot00000000000000package org.apache.maven.project; /* * 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.util.Date; import java.util.List; import java.util.Properties; import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.model.Profile; import org.eclipse.aether.RepositorySystemSession; public interface ProjectBuildingRequest { ProjectBuildingRequest setLocalRepository( ArtifactRepository localRepository ); ArtifactRepository getLocalRepository(); ProjectBuildingRequest setRemoteRepositories( List remoteRepositories ); List getRemoteRepositories(); ProjectBuildingRequest setPluginArtifactRepositories( List pluginArtifactRepositories ); List getPluginArtifactRepositories(); /** * Sets the system properties to use for interpolation and profile activation. The system properties are collected * from the runtime environment like {@link System#getProperties()} and environment variables. * * @param systemProperties The system properties, may be {@code null}. * @return This request, never {@code null}. */ ProjectBuildingRequest setSystemProperties( Properties systemProperties ); /** * Gets the system properties to use for interpolation and profile activation. The system properties are collected * from the runtime environment like {@link System#getProperties()} and environment variables. * * @return The system properties, never {@code null}. */ Properties getSystemProperties(); /** * Sets the user properties to use for interpolation and profile activation. The user properties have been * configured directly by the user on his discretion, e.g. via the {@code -Dkey=value} parameter on the command * line. * * @param userProperties The user properties, may be {@code null}. * @return This request, never {@code null}. */ ProjectBuildingRequest setUserProperties( Properties userProperties ); /** * Gets the user properties to use for interpolation and profile activation. The user properties have been * configured directly by the user on his discretion, e.g. via the {@code -Dkey=value} parameter on the command * line. * * @return The user properties, never {@code null}. */ Properties getUserProperties(); void setProject( MavenProject mavenProject ); MavenProject getProject(); ProjectBuildingRequest setProcessPlugins( boolean processPlugins ); boolean isProcessPlugins(); ProjectBuildingRequest setResolveDependencies( boolean resolveDependencies ); boolean isResolveDependencies(); /** * Controls the level of validation to perform on processed models. By default, models are validated in strict mode. * * @param validationLevel The level of validation to perform on processed models, e.g. * {@link org.apache.maven.model.building.ModelBuildingRequest#VALIDATION_LEVEL_STRICT}. * @return This configuration, never {@code null}. */ ProjectBuildingRequest setValidationLevel( int validationLevel ); /** * Gets the level of validation to perform on processed models. * * @return The level of validation to perform on processed models. */ int getValidationLevel(); // Profiles /** * Set any active profiles that the {@link ProjectBuilder} should consider while constructing * a {@link MavenProject}. */ void setActiveProfileIds( List activeProfileIds ); List getActiveProfileIds(); void setInactiveProfileIds( List inactiveProfileIds ); List getInactiveProfileIds(); /** * Add a {@link org.apache.maven.model.Profile} that has come from an external source. This may be from a custom * configuration like the MavenCLI settings.xml file, or from a custom dialog in an IDE integration like M2Eclipse. * * @param profile */ void addProfile( Profile profile ); void setProfiles( List profiles ); List getProfiles(); /** * Gets the start time of the build. * * @return The start time of the build or {@code null} if unknown. */ Date getBuildStartTime(); /** * Sets the start time of the build. * * @param buildStartTime The start time of the build, may be {@code null}. */ void setBuildStartTime( Date buildStartTime ); RepositorySystemSession getRepositorySession(); ProjectBuildingRequest setRepositorySession( RepositorySystemSession repositorySession ); /** * Sets the merge mode used to combine repositories declared in the POM with the repositories specified in this * request. * * @param mode The repository merge mode, must not be {@code null}. * @return This request for chaining, never {@code null}. * @see #setRemoteRepositories(List) */ ProjectBuildingRequest setRepositoryMerging( RepositoryMerging mode ); /** * Gets the merge mode used to combine repositories declared in the POM with the repositories specified in this * request * * @return The merge mode, never {@code null}. */ RepositoryMerging getRepositoryMerging(); /** * @since 3.2.2 * @deprecated This got added when implementing MNG-2199 and is no longer used. * Commit 6cf9320942c34bc68205425ab696b1712ace9ba4 updated the way 'MavenProject' objects are initialized. */ @Deprecated boolean isResolveVersionRanges(); /** * @since 3.2.2 * @deprecated This got added when implementing MNG-2199 and is no longer used. * Commit 6cf9320942c34bc68205425ab696b1712ace9ba4 updated the way 'MavenProject' objects are initialized. */ @Deprecated ProjectBuildingRequest setResolveVersionRanges( boolean value ); /** * The possible merge modes for combining remote repositories. */ enum RepositoryMerging { /** * The repositories declared in the POM have precedence over the repositories specified in the request. */ POM_DOMINANT, /** * The repositories specified in the request have precedence over the repositories declared in the POM. */ REQUEST_DOMINANT, } } maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/project/ProjectBuildingResult.java000066400000000000000000000047111317160430700323420ustar00rootroot00000000000000package org.apache.maven.project; /* * 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.File; import java.util.List; import org.apache.maven.model.building.ModelProblem; /** * Collects the output of the project builder. * * @author Benjamin Bentmann */ public interface ProjectBuildingResult { /** * Gets the identifier of the project that could not be built. The general format of the identifier is {@code * ::} but some of these coordinates may still be unknown at the point the exception * is thrown so this information is merely meant to assist the user. * * @return The identifier of the project or an empty string if not known, never {@code null}. */ String getProjectId(); /** * Gets the POM file from which the project was built. * * @return The POM file or {@code null} if unknown. */ File getPomFile(); /** * Gets the project that was built. * * @return The project that was built or {@code null} if an error occurred and this result accompanies a * {@link ProjectBuildingException}. */ MavenProject getProject(); /** * Gets the problems that were encountered during the project building. * * @return The problems that were encountered during the project building, can be empty but never {@code null}. */ List getProblems(); /** * Gets the result of the dependency resolution for the project. * * @return The result of the dependency resolution for the project or {@code null} if the project dependencies were * not requested. */ DependencyResolutionResult getDependencyResolutionResult(); } maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/project/ProjectDependenciesResolver.java000066400000000000000000000026411317160430700335160ustar00rootroot00000000000000package org.apache.maven.project; /* * 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. */ /** * Resolves the transitive dependencies of a project. * * @author Benjamin Bentmann */ public interface ProjectDependenciesResolver { /** * Resolves the transitive dependencies of a project. * * @param request The resolution request holding the parameters, must not be {@code null}. * @return The resolution result, never {@code null}. * @throws DependencyResolutionException If any project dependency could not be resolved. */ DependencyResolutionResult resolve( DependencyResolutionRequest request ) throws DependencyResolutionException; } maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/project/ProjectModelResolver.java000066400000000000000000000276041317160430700321760ustar00rootroot00000000000000package org.apache.maven.project; /* * 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.File; import java.util.ArrayList; import java.util.Collections; import java.util.HashSet; import java.util.List; import java.util.Set; import com.google.common.base.Predicate; import com.google.common.collect.Iterables; import org.apache.maven.model.Dependency; import org.apache.maven.model.Parent; import org.apache.maven.model.Repository; import org.apache.maven.model.building.FileModelSource; import org.apache.maven.model.building.ModelSource; import org.apache.maven.model.resolution.InvalidRepositoryException; import org.apache.maven.model.resolution.ModelResolver; import org.apache.maven.model.resolution.UnresolvableModelException; import org.apache.maven.repository.internal.ArtifactDescriptorUtils; import org.eclipse.aether.RepositorySystem; import org.eclipse.aether.RepositorySystemSession; import org.eclipse.aether.RequestTrace; import org.eclipse.aether.artifact.Artifact; import org.eclipse.aether.artifact.DefaultArtifact; import org.eclipse.aether.impl.RemoteRepositoryManager; import org.eclipse.aether.repository.RemoteRepository; import org.eclipse.aether.resolution.ArtifactRequest; import org.eclipse.aether.resolution.ArtifactResolutionException; import org.eclipse.aether.resolution.VersionRangeRequest; import org.eclipse.aether.resolution.VersionRangeResolutionException; import org.eclipse.aether.resolution.VersionRangeResult; /** * A model resolver to assist building of projects. This resolver gives priority to those repositories that have been * declared in the POM. * * @author Benjamin Bentmann */ public class ProjectModelResolver implements ModelResolver { private final RepositorySystemSession session; private final RequestTrace trace; private final String context = "project"; private List repositories; private List pomRepositories; private final List externalRepositories; private final RepositorySystem resolver; private final RemoteRepositoryManager remoteRepositoryManager; private final Set repositoryIds; private final ReactorModelPool modelPool; private final ProjectBuildingRequest.RepositoryMerging repositoryMerging; public ProjectModelResolver( RepositorySystemSession session, RequestTrace trace, RepositorySystem resolver, RemoteRepositoryManager remoteRepositoryManager, List repositories, ProjectBuildingRequest.RepositoryMerging repositoryMerging, ReactorModelPool modelPool ) { this.session = session; this.trace = trace; this.resolver = resolver; this.remoteRepositoryManager = remoteRepositoryManager; this.pomRepositories = new ArrayList<>(); List externalRepositories = new ArrayList<>(); externalRepositories.addAll( repositories ); this.externalRepositories = Collections.unmodifiableList( externalRepositories ); this.repositories = new ArrayList<>(); this.repositories.addAll( externalRepositories ); this.repositoryMerging = repositoryMerging; this.repositoryIds = new HashSet<>(); this.modelPool = modelPool; } private ProjectModelResolver( ProjectModelResolver original ) { this.session = original.session; this.trace = original.trace; this.resolver = original.resolver; this.remoteRepositoryManager = original.remoteRepositoryManager; this.pomRepositories = new ArrayList<>( original.pomRepositories ); this.externalRepositories = original.externalRepositories; this.repositories = new ArrayList<>( original.repositories ); this.repositoryMerging = original.repositoryMerging; this.repositoryIds = new HashSet<>( original.repositoryIds ); this.modelPool = original.modelPool; } public void addRepository( Repository repository ) throws InvalidRepositoryException { addRepository( repository, false ); } @Override public void addRepository( final Repository repository, boolean replace ) throws InvalidRepositoryException { if ( !repositoryIds.add( repository.getId() ) ) { if ( !replace ) { return; } // Remove any previous repository with this Id removeMatchingRepository( repositories, repository.getId() ); removeMatchingRepository( pomRepositories, repository.getId() ); } List newRepositories = Collections.singletonList( ArtifactDescriptorUtils.toRemoteRepository( repository ) ); if ( ProjectBuildingRequest.RepositoryMerging.REQUEST_DOMINANT.equals( repositoryMerging ) ) { repositories = remoteRepositoryManager.aggregateRepositories( session, repositories, newRepositories, true ); } else { pomRepositories = remoteRepositoryManager.aggregateRepositories( session, pomRepositories, newRepositories, true ); repositories = remoteRepositoryManager.aggregateRepositories( session, pomRepositories, externalRepositories, false ); } } private static void removeMatchingRepository( Iterable repositories, final String id ) { Iterables.removeIf( repositories, new Predicate() { @Override public boolean apply( RemoteRepository remoteRepository ) { return remoteRepository.getId().equals( id ); } } ); } public ModelResolver newCopy() { return new ProjectModelResolver( this ); } public ModelSource resolveModel( String groupId, String artifactId, String version ) throws UnresolvableModelException { File pomFile = null; if ( modelPool != null ) { pomFile = modelPool.get( groupId, artifactId, version ); } if ( pomFile == null ) { Artifact pomArtifact = new DefaultArtifact( groupId, artifactId, "", "pom", version ); try { ArtifactRequest request = new ArtifactRequest( pomArtifact, repositories, context ); request.setTrace( trace ); pomArtifact = resolver.resolveArtifact( session, request ).getArtifact(); } catch ( ArtifactResolutionException e ) { throw new UnresolvableModelException( e.getMessage(), groupId, artifactId, version, e ); } pomFile = pomArtifact.getFile(); } return new FileModelSource( pomFile ); } @Override public ModelSource resolveModel( final Parent parent ) throws UnresolvableModelException { try { final Artifact artifact = new DefaultArtifact( parent.getGroupId(), parent.getArtifactId(), "", "pom", parent.getVersion() ); final VersionRangeRequest versionRangeRequest = new VersionRangeRequest( artifact, repositories, context ); versionRangeRequest.setTrace( trace ); final VersionRangeResult versionRangeResult = resolver.resolveVersionRange( session, versionRangeRequest ); if ( versionRangeResult.getHighestVersion() == null ) { throw new UnresolvableModelException( String.format( "No versions matched the requested parent version range '%s'", parent.getVersion() ), parent.getGroupId(), parent.getArtifactId(), parent.getVersion() ); } if ( versionRangeResult.getVersionConstraint() != null && versionRangeResult.getVersionConstraint().getRange() != null && versionRangeResult.getVersionConstraint().getRange().getUpperBound() == null ) { // Message below is checked for in the MNG-2199 core IT. throw new UnresolvableModelException( String.format( "The requested parent version range '%s' does not specify an upper bound", parent.getVersion() ), parent.getGroupId(), parent.getArtifactId(), parent.getVersion() ); } parent.setVersion( versionRangeResult.getHighestVersion().toString() ); return resolveModel( parent.getGroupId(), parent.getArtifactId(), parent.getVersion() ); } catch ( final VersionRangeResolutionException e ) { throw new UnresolvableModelException( e.getMessage(), parent.getGroupId(), parent.getArtifactId(), parent.getVersion(), e ); } } @Override public ModelSource resolveModel( final Dependency dependency ) throws UnresolvableModelException { try { final Artifact artifact = new DefaultArtifact( dependency.getGroupId(), dependency.getArtifactId(), "", "pom", dependency.getVersion() ); final VersionRangeRequest versionRangeRequest = new VersionRangeRequest( artifact, repositories, context ); versionRangeRequest.setTrace( trace ); final VersionRangeResult versionRangeResult = resolver.resolveVersionRange( session, versionRangeRequest ); if ( versionRangeResult.getHighestVersion() == null ) { throw new UnresolvableModelException( String.format( "No versions matched the requested dependency version range '%s'", dependency.getVersion() ), dependency.getGroupId(), dependency.getArtifactId(), dependency.getVersion() ); } if ( versionRangeResult.getVersionConstraint() != null && versionRangeResult.getVersionConstraint().getRange() != null && versionRangeResult.getVersionConstraint().getRange().getUpperBound() == null ) { // Message below is checked for in the MNG-4463 core IT. throw new UnresolvableModelException( String.format( "The requested dependency version range '%s' does not specify an upper bound", dependency.getVersion() ), dependency.getGroupId(), dependency.getArtifactId(), dependency.getVersion() ); } dependency.setVersion( versionRangeResult.getHighestVersion().toString() ); return resolveModel( dependency.getGroupId(), dependency.getArtifactId(), dependency.getVersion() ); } catch ( VersionRangeResolutionException e ) { throw new UnresolvableModelException( e.getMessage(), dependency.getGroupId(), dependency.getArtifactId(), dependency.getVersion(), e ); } } } maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/project/ProjectRealmCache.java000066400000000000000000000047661317160430700314040ustar00rootroot00000000000000package org.apache.maven.project; /* * 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.util.List; import org.codehaus.plexus.classworlds.realm.ClassRealm; import org.eclipse.aether.graph.DependencyFilter; /** * Caches project class realms. Warning: This is an internal utility interface that is only public for * technical reasons, it is not part of the public API. In particular, this interface can be changed or deleted without * prior notice. * * @author Igor Fedorenko * @author Benjamin Bentmann */ public interface ProjectRealmCache { /** * A cache key. */ interface Key { // marker interface for cache keys } static class CacheRecord { public final ClassRealm realm; public final DependencyFilter extensionArtifactFilter; public CacheRecord( ClassRealm realm, DependencyFilter extensionArtifactFilter ) { this.realm = realm; this.extensionArtifactFilter = extensionArtifactFilter; } } Key createKey( List extensionRealms ); CacheRecord get( Key key ); CacheRecord put( Key key, ClassRealm projectRealm, DependencyFilter extensionArtifactFilter ); void flush(); /** * Registers the specified cache record for usage with the given project. Integrators can use the information * collected from this method in combination with a custom cache implementation to dispose unused records from the * cache. * * @param project The project that employs the plugin realm, must not be {@code null}. * @param record The cache record being used for the project, must not be {@code null}. */ void register( MavenProject project, Key key, CacheRecord record ); } maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/project/ProjectSorter.java000066400000000000000000000241301317160430700306610ustar00rootroot00000000000000package org.apache.maven.project; /* * 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.util.ArrayList; import java.util.Collection; import java.util.Collections; import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.Map; import org.apache.maven.artifact.ArtifactUtils; import org.apache.maven.model.Dependency; import org.apache.maven.model.Extension; import org.apache.maven.model.Parent; import org.apache.maven.model.Plugin; import org.codehaus.plexus.util.StringUtils; import org.codehaus.plexus.util.dag.CycleDetectedException; import org.codehaus.plexus.util.dag.DAG; import org.codehaus.plexus.util.dag.TopologicalSorter; import org.codehaus.plexus.util.dag.Vertex; public class ProjectSorter { private DAG dag; private List sortedProjects; private Map projectMap; private MavenProject topLevelProject; /** * Sort a list of projects. *
    *
  • collect all the vertices for the projects that we want to build.
  • *
  • iterate through the deps of each project and if that dep is within * the set of projects we want to build then add an edge, otherwise throw * the edge away because that dependency is not within the set of projects * we are trying to build. we assume a closed set.
  • *
  • do a topo sort on the graph that remains.
  • *
* @throws DuplicateProjectException if any projects are duplicated by id */ // MAVENAPI FIXME: the DAG used is NOT only used to represent the dependency relation, // but also for , , . We need multiple DAG's // since a DAG can only handle 1 type of relationship properly. // Usecase: This is detected as a cycle: // org.apache.maven:maven-plugin-api -(PARENT)-> // org.apache.maven:maven -(inherited REPORTING)-> // org.apache.maven.plugins:maven-checkstyle-plugin -(DEPENDENCY)-> // org.apache.maven:maven-plugin-api // In this case, both the verify and the report goals are called // in a different lifecycle. Though the compiler-plugin has a valid usecase, although // that seems to work fine. We need to take versions and lifecycle into account. public ProjectSorter( Collection projects ) throws CycleDetectedException, DuplicateProjectException { dag = new DAG(); // groupId:artifactId:version -> project projectMap = new HashMap<>( projects.size() * 2 ); // groupId:artifactId -> (version -> vertex) Map> vertexMap = new HashMap<>( projects.size() * 2 ); for ( MavenProject project : projects ) { String projectId = getId( project ); MavenProject conflictingProject = projectMap.put( projectId, project ); if ( conflictingProject != null ) { throw new DuplicateProjectException( projectId, conflictingProject.getFile(), project.getFile(), "Project '" + projectId + "' is duplicated in the reactor" ); } String projectKey = ArtifactUtils.versionlessKey( project.getGroupId(), project.getArtifactId() ); Map vertices = vertexMap.get( projectKey ); if ( vertices == null ) { vertices = new HashMap<>( 2, 1 ); vertexMap.put( projectKey, vertices ); } vertices.put( project.getVersion(), dag.addVertex( projectId ) ); } for ( Vertex projectVertex : dag.getVerticies() ) { String projectId = projectVertex.getLabel(); MavenProject project = projectMap.get( projectId ); for ( Dependency dependency : project.getDependencies() ) { addEdge( projectMap, vertexMap, project, projectVertex, dependency.getGroupId(), dependency.getArtifactId(), dependency.getVersion(), false, false ); } Parent parent = project.getModel().getParent(); if ( parent != null ) { // Parent is added as an edge, but must not cause a cycle - so we remove any other edges it has // in conflict addEdge( projectMap, vertexMap, null, projectVertex, parent.getGroupId(), parent.getArtifactId(), parent.getVersion(), true, false ); } List buildPlugins = project.getBuildPlugins(); if ( buildPlugins != null ) { for ( Plugin plugin : buildPlugins ) { addEdge( projectMap, vertexMap, project, projectVertex, plugin.getGroupId(), plugin.getArtifactId(), plugin.getVersion(), false, true ); for ( Dependency dependency : plugin.getDependencies() ) { addEdge( projectMap, vertexMap, project, projectVertex, dependency.getGroupId(), dependency.getArtifactId(), dependency.getVersion(), false, true ); } } } List buildExtensions = project.getBuildExtensions(); if ( buildExtensions != null ) { for ( Extension extension : buildExtensions ) { addEdge( projectMap, vertexMap, project, projectVertex, extension.getGroupId(), extension.getArtifactId(), extension.getVersion(), false, true ); } } } List sortedProjects = new ArrayList<>( projects.size() ); List sortedProjectLabels = TopologicalSorter.sort( dag ); for ( String id : sortedProjectLabels ) { sortedProjects.add( projectMap.get( id ) ); } this.sortedProjects = Collections.unmodifiableList( sortedProjects ); } private void addEdge( Map projectMap, Map> vertexMap, MavenProject project, Vertex projectVertex, String groupId, String artifactId, String version, boolean force, boolean safe ) throws CycleDetectedException { String projectKey = ArtifactUtils.versionlessKey( groupId, artifactId ); Map vertices = vertexMap.get( projectKey ); if ( vertices != null ) { if ( isSpecificVersion( version ) ) { Vertex vertex = vertices.get( version ); if ( vertex != null ) { addEdge( projectVertex, vertex, project, projectMap, force, safe ); } } else { for ( Vertex vertex : vertices.values() ) { addEdge( projectVertex, vertex, project, projectMap, force, safe ); } } } } private void addEdge( Vertex fromVertex, Vertex toVertex, MavenProject fromProject, Map projectMap, boolean force, boolean safe ) throws CycleDetectedException { if ( fromVertex.equals( toVertex ) ) { return; } if ( fromProject != null ) { MavenProject toProject = projectMap.get( toVertex.getLabel() ); fromProject.addProjectReference( toProject ); } if ( force && toVertex.getChildren().contains( fromVertex ) ) { dag.removeEdge( toVertex, fromVertex ); } try { dag.addEdge( fromVertex, toVertex ); } catch ( CycleDetectedException e ) { if ( !safe ) { throw e; } } } private boolean isSpecificVersion( String version ) { return !( StringUtils.isEmpty( version ) || version.startsWith( "[" ) || version.startsWith( "(" ) ); } // TODO !![jc; 28-jul-2005] check this; if we're using '-r' and there are aggregator tasks, this will result in weirdness. public MavenProject getTopLevelProject() { if ( topLevelProject == null ) { for ( Iterator i = sortedProjects.iterator(); i.hasNext() && ( topLevelProject == null ); ) { MavenProject project = i.next(); if ( project.isExecutionRoot() ) { topLevelProject = project; } } } return topLevelProject; } public List getSortedProjects() { return sortedProjects; } public boolean hasMultipleProjects() { return sortedProjects.size() > 1; } public List getDependents( String id ) { return dag.getParentLabels( id ); } public List getDependencies( String id ) { return dag.getChildLabels( id ); } public static String getId( MavenProject project ) { return ArtifactUtils.key( project.getGroupId(), project.getArtifactId(), project.getVersion() ); } public DAG getDAG() { return dag; } public Map getProjectMap() { return projectMap; } } maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/project/ReactorModelCache.java000066400000000000000000000057361317160430700313730ustar00rootroot00000000000000package org.apache.maven.project; /* * 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.util.HashMap; import java.util.Map; import org.apache.maven.model.building.ModelCache; /** * A simple model cache used to accelerate model building during a reactor build. * * @author Benjamin Bentmann */ class ReactorModelCache implements ModelCache { private final Map models = new HashMap<>( 256 ); public Object get( String groupId, String artifactId, String version, String tag ) { return models.get( new CacheKey( groupId, artifactId, version, tag ) ); } public void put( String groupId, String artifactId, String version, String tag, Object data ) { models.put( new CacheKey( groupId, artifactId, version, tag ), data ); } private static final class CacheKey { private final String groupId; private final String artifactId; private final String version; private final String tag; private final int hashCode; public CacheKey( String groupId, String artifactId, String version, String tag ) { this.groupId = ( groupId != null ) ? groupId : ""; this.artifactId = ( artifactId != null ) ? artifactId : ""; this.version = ( version != null ) ? version : ""; this.tag = ( tag != null ) ? tag : ""; int hash = 17; hash = hash * 31 + this.groupId.hashCode(); hash = hash * 31 + this.artifactId.hashCode(); hash = hash * 31 + this.version.hashCode(); hash = hash * 31 + this.tag.hashCode(); hashCode = hash; } @Override public boolean equals( Object obj ) { if ( this == obj ) { return true; } if ( !( obj instanceof CacheKey ) ) { return false; } CacheKey that = (CacheKey) obj; return artifactId.equals( that.artifactId ) && groupId.equals( that.groupId ) && version.equals( that.version ) && tag.equals( that.tag ); } @Override public int hashCode() { return hashCode; } } } maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/project/ReactorModelPool.java000066400000000000000000000061101317160430700312640ustar00rootroot00000000000000package org.apache.maven.project; /* * 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.File; import java.util.HashMap; import java.util.Map; /** * Holds all POM files that are known to the reactor. This allows the project builder to resolve imported POMs from the * reactor when building another project's effective model. * * @author Benjamin Bentmann */ class ReactorModelPool { private final Map pomFiles = new HashMap<>(); public File get( String groupId, String artifactId, String version ) { return pomFiles.get( new CacheKey( groupId, artifactId, version ) ); } public void put( String groupId, String artifactId, String version, File pomFile ) { pomFiles.put( new CacheKey( groupId, artifactId, version ), pomFile ); } private static final class CacheKey { private final String groupId; private final String artifactId; private final String version; private final int hashCode; public CacheKey( String groupId, String artifactId, String version ) { this.groupId = ( groupId != null ) ? groupId : ""; this.artifactId = ( artifactId != null ) ? artifactId : ""; this.version = ( version != null ) ? version : ""; int hash = 17; hash = hash * 31 + this.groupId.hashCode(); hash = hash * 31 + this.artifactId.hashCode(); hash = hash * 31 + this.version.hashCode(); hashCode = hash; } @Override public boolean equals( Object obj ) { if ( this == obj ) { return true; } if ( !( obj instanceof CacheKey ) ) { return false; } CacheKey that = (CacheKey) obj; return artifactId.equals( that.artifactId ) && groupId.equals( that.groupId ) && version.equals( that.version ); } @Override public int hashCode() { return hashCode; } @Override public String toString() { StringBuilder buffer = new StringBuilder( 96 ); buffer.append( groupId ).append( ':' ).append( artifactId ).append( ':' ).append( version ); return buffer.toString(); } } } maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/project/RepositorySessionDecorator.java000066400000000000000000000026041317160430700334440ustar00rootroot00000000000000package org.apache.maven.project; /* * 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 org.eclipse.aether.RepositorySystemSession; /** * Component interface that allows per-project customization of Aether repository system sessions. * * Note: This interface is part of work in progress and can be changed or removed without notice. * @since 3.2.4 */ public interface RepositorySessionDecorator { /** * Returns possibly {@code null} Aether repository system session to be used to resolve project dependencies. */ RepositorySystemSession decorate( MavenProject project, RepositorySystemSession session ); } maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/project/artifact/000077500000000000000000000000001317160430700270065ustar00rootroot00000000000000ActiveProjectArtifact.java000066400000000000000000000233571317160430700340240ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/project/artifactpackage org.apache.maven.project.artifact; /* * 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 org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.handler.ArtifactHandler; import org.apache.maven.artifact.metadata.ArtifactMetadata; import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.resolver.filter.ArtifactFilter; import org.apache.maven.artifact.versioning.ArtifactVersion; import org.apache.maven.artifact.versioning.OverConstrainedVersionException; import org.apache.maven.artifact.versioning.VersionRange; import org.apache.maven.project.MavenProject; import java.io.File; import java.util.Collection; import java.util.List; /** * Wraps an active project instance to be able to receive updates from its artifact without affecting the original * attributes of this artifact. * * @author Brett Porter * TODO I think this exposes a design flaw in that the immutable and mutable parts of an artifact are in one class and * should be split. ie scope, file, etc depend on the context of use, whereas everything else is immutable. */ @Deprecated public class ActiveProjectArtifact implements Artifact { private final Artifact artifact; private final MavenProject project; public ActiveProjectArtifact( MavenProject project, Artifact artifact ) { this.artifact = artifact; this.project = project; artifact.setFile( project.getArtifact().getFile() ); artifact.setResolved( true ); } /** {@inheritDoc} */ public File getFile() { // we need to get the latest file for the project, not the artifact that was created at one point in time return project.getArtifact().getFile(); } /** {@inheritDoc} */ public String getGroupId() { return artifact.getGroupId(); } /** {@inheritDoc} */ public String getArtifactId() { return artifact.getArtifactId(); } /** {@inheritDoc} */ public String getVersion() { return artifact.getVersion(); } /** {@inheritDoc} */ public void setVersion( String version ) { artifact.setVersion( version ); } /** {@inheritDoc} */ public String getScope() { return artifact.getScope(); } /** {@inheritDoc} */ public String getType() { return artifact.getType(); } /** {@inheritDoc} */ public String getClassifier() { return artifact.getClassifier(); } /** {@inheritDoc} */ public boolean hasClassifier() { return artifact.hasClassifier(); } /** {@inheritDoc} */ public void setFile( File destination ) { artifact.setFile( destination ); project.getArtifact().setFile( destination ); } /** {@inheritDoc} */ public String getBaseVersion() { return artifact.getBaseVersion(); } /** {@inheritDoc} */ public void setBaseVersion( String baseVersion ) { artifact.setBaseVersion( baseVersion ); } /** {@inheritDoc} */ public String getId() { return artifact.getId(); } /** {@inheritDoc} */ public String getDependencyConflictId() { return artifact.getDependencyConflictId(); } /** {@inheritDoc} */ public void addMetadata( ArtifactMetadata metadata ) { artifact.addMetadata( metadata ); } /** {@inheritDoc} */ public Collection getMetadataList() { return artifact.getMetadataList(); } /** {@inheritDoc} */ public void setRepository( ArtifactRepository remoteRepository ) { artifact.setRepository( remoteRepository ); } /** {@inheritDoc} */ public ArtifactRepository getRepository() { return artifact.getRepository(); } /** {@inheritDoc} */ public void updateVersion( String version, ArtifactRepository localRepository ) { artifact.updateVersion( version, localRepository ); } /** {@inheritDoc} */ public String getDownloadUrl() { return artifact.getDownloadUrl(); } /** {@inheritDoc} */ public void setDownloadUrl( String downloadUrl ) { artifact.setDownloadUrl( downloadUrl ); } /** {@inheritDoc} */ public ArtifactFilter getDependencyFilter() { return artifact.getDependencyFilter(); } /** {@inheritDoc} */ public void setDependencyFilter( ArtifactFilter artifactFilter ) { artifact.setDependencyFilter( artifactFilter ); } /** {@inheritDoc} */ public ArtifactHandler getArtifactHandler() { return artifact.getArtifactHandler(); } /** {@inheritDoc} */ public List getDependencyTrail() { return artifact.getDependencyTrail(); } /** {@inheritDoc} */ public void setDependencyTrail( List dependencyTrail ) { artifact.setDependencyTrail( dependencyTrail ); } /** {@inheritDoc} */ public void setScope( String scope ) { artifact.setScope( scope ); } /** {@inheritDoc} */ public VersionRange getVersionRange() { return artifact.getVersionRange(); } /** {@inheritDoc} */ public void setVersionRange( VersionRange newRange ) { artifact.setVersionRange( newRange ); } /** {@inheritDoc} */ public void selectVersion( String version ) { artifact.selectVersion( version ); } /** {@inheritDoc} */ public void setGroupId( String groupId ) { artifact.setGroupId( groupId ); } /** {@inheritDoc} */ public void setArtifactId( String artifactId ) { artifact.setArtifactId( artifactId ); } /** {@inheritDoc} */ public boolean isSnapshot() { return artifact.isSnapshot(); } /** {@inheritDoc} */ public int compareTo( Artifact a ) { return artifact.compareTo( a ); } /** {@inheritDoc} */ public void setResolved( boolean resolved ) { artifact.setResolved( resolved ); } /** {@inheritDoc} */ public boolean isResolved() { return artifact.isResolved(); } /** {@inheritDoc} */ public void setResolvedVersion( String version ) { artifact.setResolvedVersion( version ); } /** {@inheritDoc} */ public void setArtifactHandler( ArtifactHandler handler ) { artifact.setArtifactHandler( handler ); } /** {@inheritDoc} */ public String toString() { return "active project artifact:\n\tartifact = " + artifact + ";\n\tproject: " + project; } /** {@inheritDoc} */ public boolean isRelease() { return artifact.isRelease(); } /** {@inheritDoc} */ public void setRelease( boolean release ) { artifact.setRelease( release ); } /** {@inheritDoc} */ public List getAvailableVersions() { return artifact.getAvailableVersions(); } /** {@inheritDoc} */ public void setAvailableVersions( List versions ) { artifact.setAvailableVersions( versions ); } /** {@inheritDoc} */ public boolean isOptional() { return artifact.isOptional(); } /** {@inheritDoc} */ public ArtifactVersion getSelectedVersion() throws OverConstrainedVersionException { return artifact.getSelectedVersion(); } /** {@inheritDoc} */ public boolean isSelectedVersionKnown() throws OverConstrainedVersionException { return artifact.isSelectedVersionKnown(); } /** {@inheritDoc} */ public void setOptional( boolean optional ) { artifact.setOptional( optional ); } /** {@inheritDoc} */ public int hashCode() { int result = 17; result = 37 * result + getGroupId().hashCode(); result = 37 * result + getArtifactId().hashCode(); result = 37 * result + getType().hashCode(); if ( getVersion() != null ) { result = 37 * result + getVersion().hashCode(); } result = 37 * result + ( getClassifier() != null ? getClassifier().hashCode() : 0 ); return result; } /** {@inheritDoc} */ public boolean equals( Object o ) { if ( o == this ) { return true; } if ( !( o instanceof Artifact ) ) { return false; } Artifact a = (Artifact) o; if ( !a.getGroupId().equals( getGroupId() ) ) { return false; } else if ( !a.getArtifactId().equals( getArtifactId() ) ) { return false; } else if ( !a.getVersion().equals( getVersion() ) ) { return false; } else if ( !a.getType().equals( getType() ) ) { return false; } else if ( a.getClassifier() == null ? getClassifier() != null : !a.getClassifier().equals( getClassifier() ) ) { return false; } return true; } } ArtifactWithDependencies.java000066400000000000000000000020371317160430700344740ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/project/artifactpackage org.apache.maven.project.artifact; /* * 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.util.List; import org.apache.maven.model.Dependency; public interface ArtifactWithDependencies { List getDependencies(); List getManagedDependencies(); } maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/project/artifact/AttachedArtifact.java000066400000000000000000000142141317160430700330460ustar00rootroot00000000000000package org.apache.maven.project.artifact; /* * 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 org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.DefaultArtifact; import org.apache.maven.artifact.InvalidArtifactRTException; import org.apache.maven.artifact.handler.ArtifactHandler; import org.apache.maven.artifact.metadata.ArtifactMetadata; import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.versioning.ArtifactVersion; import org.apache.maven.artifact.versioning.VersionRange; import java.util.Collection; import java.util.Collections; import java.util.List; /** *Warning: This is an internal utility class that is only public for technical reasons, it is not part * of the public API. In particular, this class can be changed or deleted without prior notice. Use * {@link org.apache.maven.project.MavenProjectHelper#attachArtifact} instead. */ @Deprecated public class AttachedArtifact extends DefaultArtifact { private final Artifact parent; public AttachedArtifact( Artifact parent, String type, String classifier, ArtifactHandler artifactHandler ) { super( parent.getGroupId(), parent.getArtifactId(), parent.getVersionRange(), parent.getScope(), type, classifier, artifactHandler, parent.isOptional() ); setDependencyTrail( Collections.singletonList( parent.getId() ) ); this.parent = parent; if ( getId().equals( parent.getId() ) ) { throw new InvalidArtifactRTException( parent.getGroupId(), parent.getArtifactId(), parent.getVersion(), parent.getType(), "An attached artifact must have a different ID" + " than its corresponding main artifact." ); } } public AttachedArtifact( Artifact parent, String type, ArtifactHandler artifactHandler ) { this( parent, type, null, artifactHandler ); } public void setArtifactId( String artifactId ) { throw new UnsupportedOperationException( "Cannot change the artifactId for an attached artifact." + " It is derived from the main artifact." ); } public List getAvailableVersions() { return parent.getAvailableVersions(); } public void setAvailableVersions( List availableVersions ) { throw new UnsupportedOperationException( "Cannot change the version information for an attached artifact." + " It is derived from the main artifact." ); } public String getBaseVersion() { return parent.getBaseVersion(); } public void setBaseVersion( String baseVersion ) { throw new UnsupportedOperationException( "Cannot change the version information for an attached artifact." + " It is derived from the main artifact." ); } public String getDownloadUrl() { return parent.getDownloadUrl(); } public void setDownloadUrl( String downloadUrl ) { throw new UnsupportedOperationException( "Cannot change the download information for an attached artifact." + " It is derived from the main artifact." ); } public void setGroupId( String groupId ) { throw new UnsupportedOperationException( "Cannot change the groupId for an attached artifact." + " It is derived from the main artifact." ); } public ArtifactRepository getRepository() { return parent.getRepository(); } public void setRepository( ArtifactRepository repository ) { throw new UnsupportedOperationException( "Cannot change the repository information for an attached artifact." + " It is derived from the main artifact." ); } public String getScope() { return parent.getScope(); } public void setScope( String scope ) { throw new UnsupportedOperationException( "Cannot change the scoping information for an attached artifact." + " It is derived from the main artifact." ); } public String getVersion() { return parent.getVersion(); } public void setVersion( String version ) { throw new UnsupportedOperationException( "Cannot change the version information for an attached artifact." + " It is derived from the main artifact." ); } public VersionRange getVersionRange() { return parent.getVersionRange(); } public void setVersionRange( VersionRange range ) { throw new UnsupportedOperationException( "Cannot change the version information for an attached artifact." + " It is derived from the main artifact." ); } public boolean isRelease() { return parent.isRelease(); } public void setRelease( boolean release ) { throw new UnsupportedOperationException( "Cannot change the version information for an attached artifact." + " It is derived from the main artifact." ); } public boolean isSnapshot() { return parent.isSnapshot(); } public void addMetadata( ArtifactMetadata metadata ) { // ignore. The parent artifact will handle metadata. // we must fail silently here to avoid problems with the artifact transformers. } public Collection getMetadataList() { return Collections.emptyList(); } } DefaultMavenMetadataCache.java000066400000000000000000000300601317160430700345310ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/project/artifactpackage org.apache.maven.project.artifact; /* * 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.File; import java.util.ArrayList; import java.util.Iterator; import java.util.LinkedHashMap; import java.util.LinkedHashSet; import java.util.List; import java.util.Map; import java.util.Set; import java.util.concurrent.ConcurrentHashMap; import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.ArtifactUtils; import org.apache.maven.artifact.metadata.ResolutionGroup; import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.repository.ArtifactRepositoryPolicy; import org.codehaus.plexus.component.annotations.Component; @Component( role = MavenMetadataCache.class ) public class DefaultMavenMetadataCache implements MavenMetadataCache { protected final Map cache = new ConcurrentHashMap<>(); public static class CacheKey { private final Artifact artifact; private final long pomHash; private final boolean resolveManagedVersions; private final List repositories = new ArrayList<>(); private final int hashCode; public CacheKey( Artifact artifact, boolean resolveManagedVersions, ArtifactRepository localRepository, List remoteRepositories ) { File file = artifact.getFile(); this.artifact = ArtifactUtils.copyArtifact( artifact ); if ( "pom".equals( artifact.getType() ) && file != null ) { pomHash = file.getPath().hashCode() + file.lastModified(); } else { pomHash = 0; } this.resolveManagedVersions = resolveManagedVersions; this.repositories.add( localRepository ); this.repositories.addAll( remoteRepositories ); int hash = 17; hash = hash * 31 + artifactHashCode( artifact ); hash = hash * 31 + ( resolveManagedVersions ? 1 : 2 ); hash = hash * 31 + repositoriesHashCode( repositories ); this.hashCode = hash; } @Override public int hashCode() { return hashCode; } @Override public boolean equals( Object o ) { if ( o == this ) { return true; } if ( !( o instanceof CacheKey ) ) { return false; } CacheKey other = (CacheKey) o; return pomHash == other.pomHash && artifactEquals( artifact, other.artifact ) && resolveManagedVersions == other.resolveManagedVersions && repositoriesEquals( repositories, other.repositories ); } } private static int artifactHashCode( Artifact a ) { int result = 17; result = 31 * result + a.getGroupId().hashCode(); result = 31 * result + a.getArtifactId().hashCode(); result = 31 * result + a.getType().hashCode(); if ( a.getVersion() != null ) { result = 31 * result + a.getVersion().hashCode(); } result = 31 * result + ( a.getClassifier() != null ? a.getClassifier().hashCode() : 0 ); result = 31 * result + ( a.getScope() != null ? a.getScope().hashCode() : 0 ); result = 31 * result + ( a.getDependencyFilter() != null ? a.getDependencyFilter().hashCode() : 0 ); result = 31 * result + ( a.isOptional() ? 1 : 0 ); return result; } private static boolean artifactEquals( Artifact a1, Artifact a2 ) { if ( a1 == a2 ) { return true; } return eq( a1.getGroupId(), a2.getGroupId() ) && eq( a1.getArtifactId(), a2.getArtifactId() ) && eq( a1.getType(), a2.getType() ) && eq( a1.getVersion(), a2.getVersion() ) && eq( a1.getClassifier(), a2.getClassifier() ) && eq( a1.getScope(), a2.getScope() ) && eq( a1.getDependencyFilter(), a2.getDependencyFilter() ) && a1.isOptional() == a2.isOptional(); } private static int repositoryHashCode( ArtifactRepository repository ) { int result = 17; result = 31 * result + ( repository.getId() != null ? repository.getId().hashCode() : 0 ); return result; } private static int repositoriesHashCode( List repositories ) { int result = 17; for ( ArtifactRepository repository : repositories ) { result = 31 * result + repositoryHashCode( repository ); } return result; } private static boolean repositoryEquals( ArtifactRepository r1, ArtifactRepository r2 ) { if ( r1 == r2 ) { return true; } return eq( r1.getId(), r2.getId() ) && eq( r1.getUrl(), r2.getUrl() ) && repositoryPolicyEquals( r1.getReleases(), r2.getReleases() ) && repositoryPolicyEquals( r1.getSnapshots(), r2.getSnapshots() ); } private static boolean repositoryPolicyEquals( ArtifactRepositoryPolicy p1, ArtifactRepositoryPolicy p2 ) { if ( p1 == p2 ) { return true; } return p1.isEnabled() == p2.isEnabled() && eq( p1.getUpdatePolicy(), p2.getUpdatePolicy() ); } private static boolean repositoriesEquals( List r1, List r2 ) { if ( r1.size() != r2.size() ) { return false; } for ( Iterator it1 = r1.iterator(), it2 = r2.iterator(); it1.hasNext(); ) { if ( !repositoryEquals( it1.next(), it2.next() ) ) { return false; } } return true; } private static boolean eq( T s1, T s2 ) { return s1 != null ? s1.equals( s2 ) : s2 == null; } public class CacheRecord { private Artifact pomArtifact; private Artifact relocatedArtifact; private List artifacts; private Map managedVersions; private List remoteRepositories; private long length; private long timestamp; CacheRecord( Artifact pomArtifact, Artifact relocatedArtifact, Set artifacts, Map managedVersions, List remoteRepositories ) { this.pomArtifact = ArtifactUtils.copyArtifact( pomArtifact ); this.relocatedArtifact = ArtifactUtils.copyArtifactSafe( relocatedArtifact ); this.artifacts = ArtifactUtils.copyArtifacts( artifacts, new ArrayList() ); this.remoteRepositories = new ArrayList<>( remoteRepositories ); this.managedVersions = managedVersions; if ( managedVersions != null ) { this.managedVersions = ArtifactUtils.copyArtifacts( managedVersions, new LinkedHashMap() ); } File pomFile = pomArtifact.getFile(); if ( pomFile != null && pomFile.canRead() ) { this.length = pomFile.length(); this.timestamp = pomFile.lastModified(); } else { this.length = -1; this.timestamp = -1; } } public Artifact getArtifact() { return pomArtifact; } public Artifact getRelocatedArtifact() { return relocatedArtifact; } public List getArtifacts() { return artifacts; } public Map getManagedVersions() { return managedVersions; } public List getRemoteRepositories() { return remoteRepositories; } public boolean isStale() { File pomFile = pomArtifact.getFile(); if ( pomFile != null ) { if ( pomFile.canRead() ) { return length != pomFile.length() || timestamp != pomFile.lastModified(); } else { // if the POM didn't exist, retry if any repo is configured to always update boolean snapshot = pomArtifact.isSnapshot(); for ( ArtifactRepository repository : remoteRepositories ) { ArtifactRepositoryPolicy policy = snapshot ? repository.getSnapshots() : repository.getReleases(); if ( ArtifactRepositoryPolicy.UPDATE_POLICY_ALWAYS.equals( policy.getUpdatePolicy() ) ) { return true; } } } } return length != -1 || timestamp != -1; } } public ResolutionGroup get( Artifact artifact, boolean resolveManagedVersions, ArtifactRepository localRepository, List remoteRepositories ) { CacheKey cacheKey = newCacheKey( artifact, resolveManagedVersions, localRepository, remoteRepositories ); CacheRecord cacheRecord = cache.get( cacheKey ); if ( cacheRecord != null && !cacheRecord.isStale() ) { Artifact pomArtifact = ArtifactUtils.copyArtifact( cacheRecord.getArtifact() ); Artifact relocatedArtifact = ArtifactUtils.copyArtifactSafe( cacheRecord.getRelocatedArtifact() ); Set artifacts = ArtifactUtils.copyArtifacts( cacheRecord.getArtifacts(), new LinkedHashSet() ); Map managedVersions = cacheRecord.getManagedVersions(); if ( managedVersions != null ) { managedVersions = ArtifactUtils.copyArtifacts( managedVersions, new LinkedHashMap() ); } return new ResolutionGroup( pomArtifact, relocatedArtifact, artifacts, managedVersions, cacheRecord.getRemoteRepositories() ); } cache.remove( cacheKey ); return null; } public void put( Artifact artifact, boolean resolveManagedVersions, ArtifactRepository localRepository, List remoteRepositories, ResolutionGroup result ) { put( newCacheKey( artifact, resolveManagedVersions, localRepository, remoteRepositories ), result ); } protected CacheKey newCacheKey( Artifact artifact, boolean resolveManagedVersions, ArtifactRepository localRepository, List remoteRepositories ) { return new CacheKey( artifact, resolveManagedVersions, localRepository, remoteRepositories ); } protected void put( CacheKey cacheKey, ResolutionGroup result ) { CacheRecord cacheRecord = new CacheRecord( result.getPomArtifact(), result.getRelocatedArtifact(), result.getArtifacts(), result.getManagedVersions(), result.getResolutionRepositories() ); cache.put( cacheKey, cacheRecord ); } public void flush() { cache.clear(); } } DefaultMetadataSource.java000066400000000000000000000027151317160430700340050ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/project/artifactpackage org.apache.maven.project.artifact; /* * 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 org.apache.maven.artifact.metadata.ArtifactMetadataSource; import org.codehaus.plexus.component.annotations.Component; /** * This realizes the metadata source via the default hint to provide backward-compat with Maven 2.x whose Plexus version * registered component descriptors twice: once keyed by role+roleHint and once keyed by role only. This effectively * made the metadata source available with its original role hint ("maven") as well as the default hint. * * @author Benjamin Bentmann */ @Component( role = ArtifactMetadataSource.class ) public class DefaultMetadataSource extends MavenMetadataSource { } InvalidDependencyVersionException.java000066400000000000000000000037051317160430700364110ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/project/artifactpackage org.apache.maven.project.artifact; /* * 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.File; import org.apache.maven.artifact.ArtifactUtils; import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException; import org.apache.maven.model.Dependency; import org.apache.maven.project.InvalidProjectVersionException; /** * Thrown if a dependency has an invalid version. * * @author Brett Porter */ public class InvalidDependencyVersionException extends InvalidProjectVersionException { private Dependency dependency; public InvalidDependencyVersionException( String projectId, Dependency dependency, File pomFile, InvalidVersionSpecificationException cause ) { super( projectId, formatLocationInPom( dependency ), dependency.getVersion(), pomFile, cause ); this.dependency = dependency; } private static String formatLocationInPom( Dependency dependency ) { return "Dependency: " + ArtifactUtils.versionlessKey( dependency.getGroupId(), dependency.getArtifactId() ); } public Dependency getDependency() { return dependency; } } maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/project/artifact/MavenMetadataCache.java000066400000000000000000000027021317160430700333050ustar00rootroot00000000000000package org.apache.maven.project.artifact; /* * 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.util.List; import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.metadata.ResolutionGroup; public interface MavenMetadataCache { ResolutionGroup get( Artifact artifact, boolean resolveManagedVersions, ArtifactRepository localRepository, List remoteRepositories ); void put( Artifact artifact, boolean resolveManagedVersions, ArtifactRepository localRepository, List remoteRepositories, ResolutionGroup result ); void flush(); } MavenMetadataSource.java000066400000000000000000000727341317160430700334770ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/project/artifactpackage org.apache.maven.project.artifact; /* * 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.File; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; import java.util.Collections; import java.util.HashMap; import java.util.LinkedHashMap; import java.util.LinkedHashSet; import java.util.List; import java.util.Map; import java.util.Properties; import java.util.Set; import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.factory.ArtifactFactory; import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException; import org.apache.maven.artifact.metadata.ArtifactMetadataSource; import org.apache.maven.artifact.metadata.ResolutionGroup; import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.repository.metadata.ArtifactRepositoryMetadata; import org.apache.maven.artifact.repository.metadata.Metadata; import org.apache.maven.artifact.repository.metadata.RepositoryMetadata; import org.apache.maven.artifact.repository.metadata.RepositoryMetadataManager; import org.apache.maven.artifact.repository.metadata.RepositoryMetadataResolutionException; import org.apache.maven.artifact.resolver.ArtifactResolutionException; import org.apache.maven.artifact.resolver.MultipleArtifactsNotFoundException; import org.apache.maven.artifact.resolver.filter.AndArtifactFilter; import org.apache.maven.artifact.resolver.filter.ArtifactFilter; import org.apache.maven.artifact.resolver.filter.ExcludesArtifactFilter; import org.apache.maven.artifact.versioning.ArtifactVersion; import org.apache.maven.artifact.versioning.DefaultArtifactVersion; import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException; import org.apache.maven.artifact.versioning.VersionRange; import org.apache.maven.model.Dependency; import org.apache.maven.model.DependencyManagement; import org.apache.maven.model.DistributionManagement; import org.apache.maven.model.Exclusion; import org.apache.maven.model.Relocation; import org.apache.maven.model.building.ModelBuildingException; import org.apache.maven.model.building.ModelBuildingRequest; import org.apache.maven.model.building.ModelProblem; import org.apache.maven.model.resolution.UnresolvableModelException; import org.apache.maven.plugin.LegacySupport; import org.apache.maven.project.DefaultProjectBuildingRequest; import org.apache.maven.project.MavenProject; import org.apache.maven.project.ProjectBuilder; import org.apache.maven.project.ProjectBuildingException; import org.apache.maven.project.ProjectBuildingRequest; import org.apache.maven.properties.internal.EnvironmentUtils; import org.apache.maven.properties.internal.SystemProperties; import org.apache.maven.repository.legacy.metadata.DefaultMetadataResolutionRequest; import org.apache.maven.repository.legacy.metadata.MetadataResolutionRequest; import org.codehaus.plexus.PlexusContainer; import org.codehaus.plexus.component.annotations.Component; import org.codehaus.plexus.component.annotations.Requirement; import org.codehaus.plexus.component.repository.exception.ComponentLookupException; import org.codehaus.plexus.logging.Logger; import org.eclipse.aether.RepositorySystemSession; import org.eclipse.aether.repository.RepositoryPolicy; import org.eclipse.aether.transfer.ArtifactNotFoundException; /** * @author Jason van Zyl */ @Component( role = ArtifactMetadataSource.class, hint = "maven" ) public class MavenMetadataSource implements ArtifactMetadataSource { @Requirement private RepositoryMetadataManager repositoryMetadataManager; @Requirement private ArtifactFactory repositorySystem; //TODO This prevents a cycle in the composition which shows us another problem we need to deal with. //@Requirement private ProjectBuilder projectBuilder; @Requirement private PlexusContainer container; @Requirement private Logger logger; @Requirement private MavenMetadataCache cache; @Requirement private LegacySupport legacySupport; private void injectSession( MetadataResolutionRequest request ) { RepositorySystemSession session = legacySupport.getRepositorySession(); if ( session != null ) { request.setOffline( session.isOffline() ); request.setForceUpdate( RepositoryPolicy.UPDATE_POLICY_ALWAYS.equals( session.getUpdatePolicy() ) ); } } public ResolutionGroup retrieve( Artifact artifact, ArtifactRepository localRepository, List remoteRepositories ) throws ArtifactMetadataRetrievalException { return retrieve( artifact, localRepository, remoteRepositories, false ); } public ResolutionGroup retrieve( Artifact artifact, ArtifactRepository localRepository, List remoteRepositories, boolean resolveManagedVersions ) throws ArtifactMetadataRetrievalException { MetadataResolutionRequest request = new DefaultMetadataResolutionRequest(); injectSession( request ); request.setArtifact( artifact ); request.setLocalRepository( localRepository ); request.setRemoteRepositories( remoteRepositories ); request.setResolveManagedVersions( resolveManagedVersions ); return retrieve( request ); } public ResolutionGroup retrieve( MetadataResolutionRequest request ) throws ArtifactMetadataRetrievalException { Artifact artifact = request.getArtifact(); // // If we have a system scoped artifact then we do not want any searching in local or remote repositories // and we want artifact resolution to only return the system scoped artifact itself. // if ( artifact.getScope() != null && artifact.getScope().equals( Artifact.SCOPE_SYSTEM ) ) { return new ResolutionGroup( null, null, null ); } ResolutionGroup cached = cache.get( artifact, request.isResolveManagedVersions(), request.getLocalRepository(), request.getRemoteRepositories() ); if ( cached != null // if the POM has no file, we cached a missing artifact, only return the cached data if no update forced && ( !request.isForceUpdate() || hasFile( cached.getPomArtifact() ) ) ) { return cached; } List dependencies; List managedDependencies = null; List pomRepositories = null; Artifact pomArtifact; Artifact relocatedArtifact = null; //TODO Not even sure this is really required as the project will be cached in the builder, we'll see this // is currently the biggest hotspot if ( artifact instanceof ArtifactWithDependencies ) { pomArtifact = artifact; dependencies = ( (ArtifactWithDependencies) artifact ).getDependencies(); managedDependencies = ( (ArtifactWithDependencies) artifact ).getManagedDependencies(); } else { ProjectRelocation rel = retrieveRelocatedProject( artifact, request ); if ( rel == null ) { return null; } pomArtifact = rel.pomArtifact; relocatedArtifact = rel.relocatedArtifact; if ( rel.project == null ) { // When this happens we have a Maven 1.x POM, or some invalid POM. // It should have never found its way into Maven 2.x repository but it did. dependencies = Collections.emptyList(); } else { dependencies = rel.project.getDependencies(); DependencyManagement depMgmt = rel.project.getDependencyManagement(); managedDependencies = ( depMgmt != null ) ? depMgmt.getDependencies() : null; pomRepositories = rel.project.getRemoteArtifactRepositories(); } } Set artifacts = Collections.emptySet(); if ( !artifact.getArtifactHandler().isIncludesDependencies() ) { artifacts = new LinkedHashSet<>(); for ( Dependency dependency : dependencies ) { Artifact dependencyArtifact = createDependencyArtifact( dependency, artifact, pomArtifact ); if ( dependencyArtifact != null ) { artifacts.add( dependencyArtifact ); } } } Map managedVersions = null; if ( managedDependencies != null && request.isResolveManagedVersions() ) { managedVersions = new HashMap<>(); for ( Dependency managedDependency : managedDependencies ) { Artifact managedArtifact = createDependencyArtifact( managedDependency, null, pomArtifact ); managedVersions.put( managedDependency.getManagementKey(), managedArtifact ); } } List aggregatedRepositories = aggregateRepositories( request.getRemoteRepositories(), pomRepositories ); ResolutionGroup result = new ResolutionGroup( pomArtifact, relocatedArtifact, artifacts, managedVersions, aggregatedRepositories ); cache.put( artifact, request.isResolveManagedVersions(), request.getLocalRepository(), request.getRemoteRepositories(), result ); return result; } private boolean hasFile( Artifact artifact ) { return artifact != null && artifact.getFile() != null && artifact.getFile().exists(); } private List aggregateRepositories( List requestRepositories, List pomRepositories ) { List repositories = requestRepositories; if ( pomRepositories != null && !pomRepositories.isEmpty() ) { Map repos = new LinkedHashMap<>(); for ( ArtifactRepository repo : requestRepositories ) { if ( !repos.containsKey( repo.getId() ) ) { repos.put( repo.getId(), repo ); } } for ( ArtifactRepository repo : pomRepositories ) { if ( !repos.containsKey( repo.getId() ) ) { repos.put( repo.getId(), repo ); } } repositories = new ArrayList<>( repos.values() ); } return repositories; } private Artifact createDependencyArtifact( Dependency dependency, Artifact owner, Artifact pom ) throws ArtifactMetadataRetrievalException { try { String inheritedScope = ( owner != null ) ? owner.getScope() : null; ArtifactFilter inheritedFilter = ( owner != null ) ? owner.getDependencyFilter() : null; return createDependencyArtifact( repositorySystem, dependency, inheritedScope, inheritedFilter ); } catch ( InvalidVersionSpecificationException e ) { throw new ArtifactMetadataRetrievalException( "Invalid version for dependency " + dependency.getManagementKey() + ": " + e.getMessage(), e, pom ); } } private static Artifact createDependencyArtifact( ArtifactFactory factory, Dependency dependency, String inheritedScope, ArtifactFilter inheritedFilter ) throws InvalidVersionSpecificationException { String effectiveScope = getEffectiveScope( dependency.getScope(), inheritedScope ); if ( effectiveScope == null ) { return null; } VersionRange versionRange = VersionRange.createFromVersionSpec( dependency.getVersion() ); Artifact dependencyArtifact = factory.createDependencyArtifact( dependency.getGroupId(), dependency.getArtifactId(), versionRange, dependency.getType(), dependency.getClassifier(), effectiveScope, dependency.isOptional() ); ArtifactFilter dependencyFilter = inheritedFilter; if ( dependencyFilter != null && !dependencyFilter.include( dependencyArtifact ) ) { return null; } if ( Artifact.SCOPE_SYSTEM.equals( effectiveScope ) ) { dependencyArtifact.setFile( new File( dependency.getSystemPath() ) ); } dependencyArtifact.setDependencyFilter( createDependencyFilter( dependency, dependencyFilter ) ); return dependencyArtifact; } private static String getEffectiveScope( String originalScope, String inheritedScope ) { String effectiveScope = Artifact.SCOPE_RUNTIME; if ( originalScope == null ) { originalScope = Artifact.SCOPE_COMPILE; } if ( inheritedScope == null ) { // direct dependency retains its scope effectiveScope = originalScope; } else if ( Artifact.SCOPE_TEST.equals( originalScope ) || Artifact.SCOPE_PROVIDED.equals( originalScope ) ) { // test and provided are not transitive, so exclude them effectiveScope = null; } else if ( Artifact.SCOPE_SYSTEM.equals( originalScope ) ) { // system scope come through unchanged... effectiveScope = Artifact.SCOPE_SYSTEM; } else if ( Artifact.SCOPE_COMPILE.equals( originalScope ) && Artifact.SCOPE_COMPILE.equals( inheritedScope ) ) { // added to retain compile scope. Remove if you want compile inherited as runtime effectiveScope = Artifact.SCOPE_COMPILE; } else if ( Artifact.SCOPE_TEST.equals( inheritedScope ) ) { effectiveScope = Artifact.SCOPE_TEST; } else if ( Artifact.SCOPE_PROVIDED.equals( inheritedScope ) ) { effectiveScope = Artifact.SCOPE_PROVIDED; } return effectiveScope; } private static ArtifactFilter createDependencyFilter( Dependency dependency, ArtifactFilter inheritedFilter ) { ArtifactFilter effectiveFilter = inheritedFilter; if ( !dependency.getExclusions().isEmpty() ) { List exclusions = new ArrayList<>(); for ( Exclusion e : dependency.getExclusions() ) { exclusions.add( e.getGroupId() + ':' + e.getArtifactId() ); } effectiveFilter = new ExcludesArtifactFilter( exclusions ); if ( inheritedFilter != null ) { effectiveFilter = new AndArtifactFilter( Arrays.asList( inheritedFilter, effectiveFilter ) ); } } return effectiveFilter; } public List retrieveAvailableVersions( Artifact artifact, ArtifactRepository localRepository, List remoteRepositories ) throws ArtifactMetadataRetrievalException { MetadataResolutionRequest request = new DefaultMetadataResolutionRequest(); injectSession( request ); request.setArtifact( artifact ); request.setLocalRepository( localRepository ); request.setRemoteRepositories( remoteRepositories ); return retrieveAvailableVersions( request ); } public List retrieveAvailableVersions( MetadataResolutionRequest request ) throws ArtifactMetadataRetrievalException { RepositoryMetadata metadata = new ArtifactRepositoryMetadata( request.getArtifact() ); try { repositoryMetadataManager.resolve( metadata, request ); } catch ( RepositoryMetadataResolutionException e ) { throw new ArtifactMetadataRetrievalException( e.getMessage(), e, request.getArtifact() ); } List availableVersions = request.getLocalRepository().findVersions( request.getArtifact() ); return retrieveAvailableVersionsFromMetadata( metadata.getMetadata(), availableVersions ); } public List retrieveAvailableVersionsFromDeploymentRepository( Artifact artifact, ArtifactRepository localRepository, ArtifactRepository deploymentRepository ) throws ArtifactMetadataRetrievalException { RepositoryMetadata metadata = new ArtifactRepositoryMetadata( artifact ); try { repositoryMetadataManager.resolveAlways( metadata, localRepository, deploymentRepository ); } catch ( RepositoryMetadataResolutionException e ) { throw new ArtifactMetadataRetrievalException( e.getMessage(), e, artifact ); } List availableVersions = localRepository.findVersions( artifact ); return retrieveAvailableVersionsFromMetadata( metadata.getMetadata(), availableVersions ); } private List retrieveAvailableVersionsFromMetadata( Metadata repoMetadata, List availableVersions ) { Collection versions = new LinkedHashSet<>(); if ( ( repoMetadata != null ) && ( repoMetadata.getVersioning() != null ) ) { versions.addAll( repoMetadata.getVersioning().getVersions() ); } versions.addAll( availableVersions ); List artifactVersions = new ArrayList<>( versions.size() ); for ( String version : versions ) { artifactVersions.add( new DefaultArtifactVersion( version ) ); } return artifactVersions; } // USED BY MAVEN ASSEMBLY PLUGIN @Deprecated public static Set createArtifacts( ArtifactFactory artifactFactory, List dependencies, String inheritedScope, ArtifactFilter dependencyFilter, MavenProject project ) throws InvalidDependencyVersionException { Set artifacts = new LinkedHashSet<>(); for ( Dependency d : dependencies ) { Artifact dependencyArtifact; try { dependencyArtifact = createDependencyArtifact( artifactFactory, d, inheritedScope, dependencyFilter ); } catch ( InvalidVersionSpecificationException e ) { throw new InvalidDependencyVersionException( project.getId(), d, project.getFile(), e ); } if ( dependencyArtifact != null ) { artifacts.add( dependencyArtifact ); } } return artifacts; } private ProjectBuilder getProjectBuilder() { if ( projectBuilder != null ) { return projectBuilder; } try { projectBuilder = container.lookup( ProjectBuilder.class ); } catch ( ComponentLookupException e ) { // Won't happen } return projectBuilder; } private ProjectRelocation retrieveRelocatedProject( Artifact artifact, MetadataResolutionRequest repositoryRequest ) throws ArtifactMetadataRetrievalException { MavenProject project; Artifact pomArtifact; Artifact relocatedArtifact = null; boolean done = false; do { project = null; pomArtifact = repositorySystem.createProjectArtifact( artifact.getGroupId(), artifact.getArtifactId(), artifact.getVersion(), artifact.getScope() ); if ( "pom".equals( artifact.getType() ) ) { pomArtifact.setFile( artifact.getFile() ); } if ( Artifact.SCOPE_SYSTEM.equals( artifact.getScope() ) ) { done = true; } else { try { ProjectBuildingRequest configuration = new DefaultProjectBuildingRequest(); configuration.setLocalRepository( repositoryRequest.getLocalRepository() ); configuration.setRemoteRepositories( repositoryRequest.getRemoteRepositories() ); configuration.setValidationLevel( ModelBuildingRequest.VALIDATION_LEVEL_MINIMAL ); configuration.setProcessPlugins( false ); configuration.setRepositoryMerging( ProjectBuildingRequest.RepositoryMerging.REQUEST_DOMINANT ); configuration.setSystemProperties( getSystemProperties() ); configuration.setRepositorySession( legacySupport.getRepositorySession() ); project = getProjectBuilder().build( pomArtifact, configuration ).getProject(); } catch ( ProjectBuildingException e ) { ModelProblem missingParentPom = hasMissingParentPom( e ); if ( missingParentPom != null ) { throw new ArtifactMetadataRetrievalException( "Failed to process POM for " + artifact.getId() + ": " + missingParentPom.getMessage(), missingParentPom.getException(), artifact ); } String message; if ( isMissingPom( e ) ) { message = "Missing POM for " + artifact.getId(); } else if ( isNonTransferrablePom( e ) ) { throw new ArtifactMetadataRetrievalException( "Failed to retrieve POM for " + artifact.getId() + ": " + e.getCause().getMessage(), e.getCause(), artifact ); } else { message = "Invalid POM for " + artifact.getId() + ", transitive dependencies (if any) will not be available" + ", enable debug logging for more details"; } if ( logger.isDebugEnabled() ) { message += ": " + e.getMessage(); } logger.warn( message ); } if ( project != null ) { Relocation relocation = null; DistributionManagement distMgmt = project.getDistributionManagement(); if ( distMgmt != null ) { relocation = distMgmt.getRelocation(); artifact.setDownloadUrl( distMgmt.getDownloadUrl() ); pomArtifact.setDownloadUrl( distMgmt.getDownloadUrl() ); } if ( relocation != null ) { if ( relocation.getGroupId() != null ) { artifact.setGroupId( relocation.getGroupId() ); relocatedArtifact = artifact; project.setGroupId( relocation.getGroupId() ); } if ( relocation.getArtifactId() != null ) { artifact.setArtifactId( relocation.getArtifactId() ); relocatedArtifact = artifact; project.setArtifactId( relocation.getArtifactId() ); } if ( relocation.getVersion() != null ) { // note: see MNG-3454. This causes a problem, but fixing it may break more. artifact.setVersionRange( VersionRange.createFromVersion( relocation.getVersion() ) ); relocatedArtifact = artifact; project.setVersion( relocation.getVersion() ); } if ( artifact.getDependencyFilter() != null && !artifact.getDependencyFilter().include( artifact ) ) { return null; } // MNG-2861: the artifact data has changed. If the available versions where previously // retrieved, we need to update it. // TODO shouldn't the versions be merged across relocations? List available = artifact.getAvailableVersions(); if ( available != null && !available.isEmpty() ) { MetadataResolutionRequest metadataRequest = new DefaultMetadataResolutionRequest( repositoryRequest ); metadataRequest.setArtifact( artifact ); available = retrieveAvailableVersions( metadataRequest ); artifact.setAvailableVersions( available ); } String message = "\n This artifact has been relocated to " + artifact.getGroupId() + ":" + artifact.getArtifactId() + ":" + artifact.getVersion() + ".\n"; if ( relocation.getMessage() != null ) { message += " " + relocation.getMessage() + "\n"; } if ( artifact.getDependencyTrail() != null && artifact.getDependencyTrail().size() == 1 ) { logger.warn( "While downloading " + pomArtifact.getGroupId() + ":" + pomArtifact.getArtifactId() + ":" + pomArtifact.getVersion() + message + "\n" ); } else { logger.debug( "While downloading " + pomArtifact.getGroupId() + ":" + pomArtifact.getArtifactId() + ":" + pomArtifact.getVersion() + message + "\n" ); } } else { done = true; } } else { done = true; } } } while ( !done ); ProjectRelocation rel = new ProjectRelocation(); rel.project = project; rel.pomArtifact = pomArtifact; rel.relocatedArtifact = relocatedArtifact; return rel; } private ModelProblem hasMissingParentPom( ProjectBuildingException e ) { if ( e.getCause() instanceof ModelBuildingException ) { ModelBuildingException mbe = (ModelBuildingException) e.getCause(); for ( ModelProblem problem : mbe.getProblems() ) { if ( problem.getException() instanceof UnresolvableModelException ) { return problem; } } } return null; } private boolean isMissingPom( Exception e ) { if ( e.getCause() instanceof MultipleArtifactsNotFoundException ) { return true; } return e.getCause() instanceof org.eclipse.aether.resolution.ArtifactResolutionException && e.getCause().getCause() instanceof ArtifactNotFoundException; } private boolean isNonTransferrablePom( Exception e ) { if ( e.getCause() instanceof ArtifactResolutionException ) { return true; } return e.getCause() instanceof org.eclipse.aether.resolution.ArtifactResolutionException && !( e.getCause().getCause() instanceof ArtifactNotFoundException ); } private Properties getSystemProperties() { Properties props = new Properties(); EnvironmentUtils.addEnvVars( props ); SystemProperties.addSystemProperties( props ); return props; } private static final class ProjectRelocation { private MavenProject project; private Artifact pomArtifact; private Artifact relocatedArtifact; } } maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/project/artifact/PluginArtifact.java000066400000000000000000000047161317160430700325750ustar00rootroot00000000000000package org.apache.maven.project.artifact; /* * 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.util.Collections; import java.util.List; import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.DefaultArtifact; import org.apache.maven.artifact.handler.ArtifactHandler; import org.apache.maven.model.Dependency; import org.apache.maven.model.Plugin; public class PluginArtifact extends DefaultArtifact implements ArtifactWithDependencies { private Plugin plugin; public PluginArtifact( Plugin plugin, Artifact pluginArtifact ) { super( plugin.getGroupId(), plugin.getArtifactId(), plugin.getVersion(), null, "maven-plugin", null, new PluginArtifactHandler() ); this.plugin = plugin; setFile( pluginArtifact.getFile() ); setResolved( true ); } public List getDependencies() { return plugin.getDependencies(); } public List getManagedDependencies() { return Collections.emptyList(); } static class PluginArtifactHandler implements ArtifactHandler { public String getClassifier() { return null; } public String getDirectory() { return null; } public String getExtension() { return "jar"; } public String getLanguage() { return "none"; } public String getPackaging() { return "maven-plugin"; } public boolean isAddedToClasspath() { return true; } public boolean isIncludesDependencies() { return false; } } } maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/project/artifact/ProjectArtifact.java000066400000000000000000000052201317160430700327340ustar00rootroot00000000000000package org.apache.maven.project.artifact; /* * 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.util.Collections; import java.util.List; import org.apache.maven.artifact.DefaultArtifact; import org.apache.maven.artifact.handler.ArtifactHandler; import org.apache.maven.model.Dependency; import org.apache.maven.model.DependencyManagement; import org.apache.maven.project.MavenProject; public class ProjectArtifact extends DefaultArtifact implements ArtifactWithDependencies { private MavenProject project; public ProjectArtifact( MavenProject project ) { super( project.getGroupId(), project.getArtifactId(), project.getVersion(), null, "pom", null, new PomArtifactHandler() ); this.project = project; setFile( project.getFile() ); setResolved( true ); } public MavenProject getProject() { return project; } public List getDependencies() { return project.getDependencies(); } public List getManagedDependencies() { DependencyManagement depMgmt = project.getDependencyManagement(); return ( depMgmt != null ) ? depMgmt.getDependencies() : Collections.emptyList(); } static class PomArtifactHandler implements ArtifactHandler { public String getClassifier() { return null; } public String getDirectory() { return null; } public String getExtension() { return "pom"; } public String getLanguage() { return "none"; } public String getPackaging() { return "pom"; } public boolean isAddedToClasspath() { return false; } public boolean isIncludesDependencies() { return false; } } } ProjectArtifactMetadata.java000066400000000000000000000100231317160430700343130ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/project/artifactpackage org.apache.maven.project.artifact; /* * 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.File; import java.io.IOException; import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.metadata.AbstractArtifactMetadata; import org.apache.maven.artifact.metadata.ArtifactMetadata; import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.repository.metadata.RepositoryMetadataStoreException; import org.codehaus.plexus.util.FileUtils; /** * Attach a POM to an artifact. * * @author Brett Porter */ public class ProjectArtifactMetadata extends AbstractArtifactMetadata { private final File file; public ProjectArtifactMetadata( Artifact artifact ) { this( artifact, null ); } public ProjectArtifactMetadata( Artifact artifact, File file ) { super( artifact ); this.file = file; } public File getFile() { return file; } public String getRemoteFilename() { return getFilename(); } public String getLocalFilename( ArtifactRepository repository ) { return getFilename(); } private String getFilename() { return getArtifactId() + "-" + artifact.getVersion() + ".pom"; } public void storeInLocalRepository( ArtifactRepository localRepository, ArtifactRepository remoteRepository ) throws RepositoryMetadataStoreException { File destination = new File( localRepository.getBasedir(), localRepository.pathOfLocalRepositoryMetadata( this, remoteRepository ) ); // ---------------------------------------------------------------------------- // I'm fully aware that the file could just be moved using File.rename but // there are bugs in various JVM that have problems doing this across // different filesystem. So we'll incur the small hit to actually copy // here and be safe. jvz. // ---------------------------------------------------------------------------- try { FileUtils.copyFile( file, destination ); } catch ( IOException e ) { throw new RepositoryMetadataStoreException( "Error copying POM to the local repository.", e ); } } public String toString() { return "project information for " + artifact.getArtifactId() + " " + artifact.getVersion(); } public boolean storedInArtifactVersionDirectory() { return true; } public String getBaseVersion() { return artifact.getBaseVersion(); } public Object getKey() { return "project " + artifact.getGroupId() + ":" + artifact.getArtifactId(); } public void merge( ArtifactMetadata metadata ) { ProjectArtifactMetadata m = (ProjectArtifactMetadata) metadata; if ( !m.file.equals( file ) ) { throw new IllegalStateException( "Cannot add two different pieces of metadata for: " + getKey() ); } } public void merge( org.apache.maven.repository.legacy.metadata.ArtifactMetadata metadata ) { this.merge( (ArtifactMetadata) metadata ); } } maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/project/path/000077500000000000000000000000001317160430700261455ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/project/path/PathTranslator.java000066400000000000000000000024241317160430700317600ustar00rootroot00000000000000package org.apache.maven.project.path; /* * 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.File; import org.apache.maven.model.Model; /** * @author Jason van Zyl */ @Deprecated public interface PathTranslator { String ROLE = PathTranslator.class.getName(); void alignToBaseDirectory( Model model, File basedir ); String alignToBaseDirectory( String path, File basedir ); void unalignFromBaseDirectory( Model model, File basedir ); String unalignFromBaseDirectory( String directory, File basedir ); } maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/properties/000077500000000000000000000000001317160430700257375ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/properties/internal/000077500000000000000000000000001317160430700275535ustar00rootroot00000000000000EnvironmentUtils.java000066400000000000000000000047551317160430700336770ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/properties/internalpackage org.apache.maven.properties.internal; /* * 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.util.Locale; import java.util.Map; import java.util.Properties; import org.codehaus.plexus.util.Os; /** * Assists the project builder. Warning: This is an internal utility class that is only public for * technical reasons, it is not part of the public API. In particular, this class can be changed or deleted without * prior notice. * * @since 3.0 * @author Benjamin Bentmann */ public class EnvironmentUtils { private static Properties envVars; /** * Adds the environment variables in the form of properties whose keys are prefixed with {@code env.}, e.g. {@code * env.PATH}. Unlike native environment variables, properties are always case-sensitive. For the sake of * determinism, the environment variable names will be normalized to upper case on platforms with case-insensitive * variable lookup. * * @param props The properties to add the environment variables to, may be {@code null}. */ public static void addEnvVars( Properties props ) { if ( props != null ) { if ( envVars == null ) { Properties tmp = new Properties(); boolean caseSensitive = !Os.isFamily( Os.FAMILY_WINDOWS ); for ( Map.Entry entry : System.getenv().entrySet() ) { String key = "env." + ( caseSensitive ? entry.getKey() : entry.getKey().toUpperCase( Locale.ENGLISH ) ); tmp.setProperty( key, entry.getValue() ); } envVars = tmp; } props.putAll( envVars ); } } } SystemProperties.java000066400000000000000000000040041317160430700336760ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/properties/internalpackage org.apache.maven.properties.internal; /* * 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.util.Properties; /** * @since 3.2.3 */ public class SystemProperties { /** * Thread-safe System.properties copy implementation. */ public static void addSystemProperties( Properties props ) { props.putAll( getSystemProperties() ); } /** * Returns a copy of {@link System#getProperties()} in a thread-safe manner. * * @return {@link System#getProperties()} obtained in a thread-safe manner. */ public static Properties getSystemProperties() { return copyProperties( System.getProperties() ); } /** * Copies the given {@link Properties} object into a new {@link Properties} object, in a thread-safe manner. * @param properties Properties to copy. * @return Copy of the given properties. */ public static Properties copyProperties( Properties properties ) { final Properties copyProperties = new Properties(); // guard against modification/removal of keys in the given properties (MNG-5670, MNG-6053, MNG-6105) synchronized ( properties ) { copyProperties.putAll( properties ); } return copyProperties; } } maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/repository/000077500000000000000000000000001317160430700257625ustar00rootroot00000000000000ArtifactDoesNotExistException.java000066400000000000000000000022011317160430700344660ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/repositorypackage org.apache.maven.repository; /* * 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. */ public class ArtifactDoesNotExistException extends Exception { public ArtifactDoesNotExistException( final String message ) { super( message ); } public ArtifactDoesNotExistException( final String message, final Throwable cause ) { super( message, cause ); } } maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/repository/ArtifactTransferEvent.java000066400000000000000000000202141317160430700330700ustar00rootroot00000000000000package org.apache.maven.repository; /* * 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.File; import java.util.EventObject; /** * TransferEvent is used to notify TransferListeners about progress * in transfer of resources form/to the repository * * @author Michal Maczka */ public class ArtifactTransferEvent extends EventObject { /** * A transfer was attempted, but has not yet commenced. */ public static final int TRANSFER_INITIATED = 0; /** * A transfer was started. */ public static final int TRANSFER_STARTED = 1; /** * A transfer is completed. */ public static final int TRANSFER_COMPLETED = 2; /** * A transfer is in progress. */ public static final int TRANSFER_PROGRESS = 3; /** * An error occurred during transfer */ public static final int TRANSFER_ERROR = 4; /** * Indicates GET transfer (from the repository) */ public static final int REQUEST_GET = 5; /** * Indicates PUT transfer (to the repository) */ public static final int REQUEST_PUT = 6; private int eventType; private int requestType; private Exception exception; private File localFile; private ArtifactTransferResource artifact; private long transferredBytes; private byte[] dataBuffer; private int dataOffset; private int dataLength; public ArtifactTransferEvent( String wagon, final int eventType, final int requestType, ArtifactTransferResource artifact ) { super( wagon ); setEventType( eventType ); setRequestType( requestType ); this.artifact = artifact; } public ArtifactTransferEvent( String wagon, final Exception exception, final int requestType, ArtifactTransferResource artifact ) { this( wagon, TRANSFER_ERROR, requestType, artifact ); this.exception = exception; } public ArtifactTransferResource getResource() { return artifact; } /** * @return Returns the exception. */ public Exception getException() { return exception; } /** * Returns the request type. * * @return Returns the request type. The Request type is one of * TransferEvent.REQUEST_GET or TransferEvent.REQUEST_PUT */ public int getRequestType() { return requestType; } /** * Sets the request type * * @param requestType The requestType to set. * The Request type value should be either * TransferEvent.REQUEST_GET or TransferEvent.REQUEST_PUT. * @throws IllegalArgumentException when */ public void setRequestType( final int requestType ) { switch ( requestType ) { case REQUEST_PUT: break; case REQUEST_GET: break; default : throw new IllegalArgumentException( "Illegal request type: " + requestType ); } this.requestType = requestType; } /** * @return Returns the eventType. */ public int getEventType() { return eventType; } /** * @param eventType The eventType to set. */ public void setEventType( final int eventType ) { switch ( eventType ) { case TRANSFER_INITIATED: break; case TRANSFER_STARTED: break; case TRANSFER_COMPLETED: break; case TRANSFER_PROGRESS: break; case TRANSFER_ERROR: break; default : throw new IllegalArgumentException( "Illegal event type: " + eventType ); } this.eventType = eventType; } /** * @return Returns the local file. */ public File getLocalFile() { return localFile; } /** * @param localFile The local file to set. */ public void setLocalFile( File localFile ) { this.localFile = localFile; } public long getTransferredBytes() { return transferredBytes; } public void setTransferredBytes( long transferredBytes ) { this.transferredBytes = transferredBytes; } public byte[] getDataBuffer() { return dataBuffer; } public void setDataBuffer( byte[] dataBuffer ) { this.dataBuffer = dataBuffer; } public int getDataOffset() { return dataOffset; } public void setDataOffset( int dataOffset ) { this.dataOffset = dataOffset; } public int getDataLength() { return dataLength; } public void setDataLength( int dataLength ) { this.dataLength = dataLength; } public String toString() { StringBuilder sb = new StringBuilder( 64 ); sb.append( "TransferEvent[" ); switch ( this.getRequestType() ) { case REQUEST_GET: sb.append( "GET" ); break; case REQUEST_PUT: sb.append( "PUT" ); break; default: sb.append( this.getRequestType() ); break; } sb.append( '|' ); switch ( this.getEventType() ) { case TRANSFER_COMPLETED: sb.append( "COMPLETED" ); break; case TRANSFER_ERROR: sb.append( "ERROR" ); break; case TRANSFER_INITIATED: sb.append( "INITIATED" ); break; case TRANSFER_PROGRESS: sb.append( "PROGRESS" ); break; case TRANSFER_STARTED: sb.append( "STARTED" ); break; default: sb.append( this.getEventType() ); break; } sb.append( '|' ); sb.append( this.getLocalFile() ).append( '|' ); sb.append( ']' ); return sb.toString(); } public int hashCode() { final int prime = 31; int result = 1; result = prime * result + eventType; result = prime * result + ( ( exception == null ) ? 0 : exception.hashCode() ); result = prime * result + ( ( localFile == null ) ? 0 : localFile.hashCode() ); result = prime * result + requestType; return result; } public boolean equals( Object obj ) { if ( this == obj ) { return true; } if ( ( obj == null ) || ( getClass() != obj.getClass() ) ) { return false; } final ArtifactTransferEvent other = (ArtifactTransferEvent) obj; if ( eventType != other.eventType ) { return false; } if ( exception == null ) { if ( other.exception != null ) { return false; } } else if ( !exception.getClass().equals( other.exception.getClass() ) ) { return false; } if ( requestType != other.requestType ) { return false; } else if ( !source.equals( other.source ) ) { return false; } return true; } } ArtifactTransferFailedException.java000066400000000000000000000022101317160430700347670ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/repositorypackage org.apache.maven.repository; /* * 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. */ public class ArtifactTransferFailedException extends Exception { public ArtifactTransferFailedException( final String message ) { super( message ); } public ArtifactTransferFailedException( final String message, final Throwable cause ) { super( message, cause ); } } maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/repository/ArtifactTransferListener.java000066400000000000000000000023551317160430700336020ustar00rootroot00000000000000package org.apache.maven.repository; /* * 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. */ public interface ArtifactTransferListener { boolean isShowChecksumEvents(); void setShowChecksumEvents( boolean showChecksumEvents ); void transferInitiated( ArtifactTransferEvent transferEvent ); void transferStarted( ArtifactTransferEvent transferEvent ); void transferProgress( ArtifactTransferEvent transferEvent ); void transferCompleted( ArtifactTransferEvent transferEvent ); } maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/repository/ArtifactTransferResource.java000066400000000000000000000037551317160430700336110ustar00rootroot00000000000000package org.apache.maven.repository; /* * 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. */ /** * Describes a resource being uploaded or downloaded by the repository system. * * @author Benjamin Bentmann */ public interface ArtifactTransferResource { /** * The base URL of the repository, e.g. "http://repo1.maven.org/maven2/". Unless the URL is unknown, it will be * terminated by a trailing slash. * * @return The base URL of the repository or an empty string if unknown, never {@code null}. */ String getRepositoryUrl(); /** * The path of the artifact relative to the repository's base URL. * * @return The path of the artifact, never {@code null}. */ String getName(); /** * Gets the full URL of the artifact. * * @return The full URL of the artifact, never {@code null}. */ String getUrl(); /** * The size of the artifact in bytes. * * @return The of the artifact in bytes or a negative value if unknown. */ long getContentLength(); /** * Gets the timestamp when the transfer of this artifact was started. * * @return The timestamp when the transfer of this artifact was started. */ long getTransferStartTime(); } DelegatingLocalArtifactRepository.java000066400000000000000000000131141317160430700353420ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/repositorypackage org.apache.maven.repository; /* * 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.util.ArrayList; import java.util.Collection; import java.util.Collections; import java.util.LinkedHashSet; import java.util.List; import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.metadata.ArtifactMetadata; import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.repository.ArtifactRepositoryPolicy; import org.apache.maven.artifact.repository.MavenArtifactRepository; import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout; /** * Delegating local artifact repository chains the reactor, IDE workspace * and user local repository. */ @Deprecated public class DelegatingLocalArtifactRepository extends MavenArtifactRepository { private LocalArtifactRepository buildReactor; private LocalArtifactRepository ideWorkspace; private ArtifactRepository userLocalArtifactRepository; public DelegatingLocalArtifactRepository( ArtifactRepository artifactRepository ) { this.userLocalArtifactRepository = artifactRepository; } public void setBuildReactor( LocalArtifactRepository localRepository ) { this.buildReactor = localRepository; } public void setIdeWorkspace( LocalArtifactRepository localRepository ) { this.ideWorkspace = localRepository; } /** * @deprecated instead use {@link #getIdeWorkspace()} */ @Deprecated public LocalArtifactRepository getIdeWorspace() { return ideWorkspace; } public LocalArtifactRepository getIdeWorkspace() { return getIdeWorspace(); } @Override public Artifact find( Artifact artifact ) { if ( !artifact.isRelease() && buildReactor != null ) { artifact = buildReactor.find( artifact ); } if ( !artifact.isResolved() && ideWorkspace != null ) { artifact = ideWorkspace.find( artifact ); } if ( !artifact.isResolved() ) { artifact = userLocalArtifactRepository.find( artifact ); } return artifact; } @Override public List findVersions( Artifact artifact ) { Collection versions = new LinkedHashSet<>(); if ( buildReactor != null ) { versions.addAll( buildReactor.findVersions( artifact ) ); } if ( ideWorkspace != null ) { versions.addAll( ideWorkspace.findVersions( artifact ) ); } versions.addAll( userLocalArtifactRepository.findVersions( artifact ) ); return Collections.unmodifiableList( new ArrayList<>( versions ) ); } public String pathOfLocalRepositoryMetadata( ArtifactMetadata metadata, ArtifactRepository repository ) { return userLocalArtifactRepository.pathOfLocalRepositoryMetadata( metadata, repository ); } public String getId() { return userLocalArtifactRepository.getId(); } @Override public String pathOf( Artifact artifact ) { return userLocalArtifactRepository.pathOf( artifact ); } @Override public String getBasedir() { return ( userLocalArtifactRepository != null ) ? userLocalArtifactRepository.getBasedir() : null; } @Override public ArtifactRepositoryLayout getLayout() { return userLocalArtifactRepository.getLayout(); } @Override public ArtifactRepositoryPolicy getReleases() { return userLocalArtifactRepository.getReleases(); } @Override public ArtifactRepositoryPolicy getSnapshots() { return userLocalArtifactRepository.getSnapshots(); } @Override public String getKey() { return userLocalArtifactRepository.getKey(); } @Override public String getUrl() { return userLocalArtifactRepository.getUrl(); } @Override public int hashCode() { int hash = 17; hash = hash * 31 + ( buildReactor == null ? 0 : buildReactor.hashCode() ); hash = hash * 31 + ( ideWorkspace == null ? 0 : ideWorkspace.hashCode() ); hash = hash * 31 + ( userLocalArtifactRepository == null ? 0 : userLocalArtifactRepository.hashCode() ); return hash; } @Override public boolean equals( Object obj ) { if ( this == obj ) { return true; } if ( obj == null ) { return false; } if ( getClass() != obj.getClass() ) { return false; } DelegatingLocalArtifactRepository other = (DelegatingLocalArtifactRepository) obj; return eq( buildReactor, other.buildReactor ) && eq( ideWorkspace, other.ideWorkspace ) && eq( userLocalArtifactRepository, other.userLocalArtifactRepository ); } } maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/repository/LocalArtifactRepository.java000066400000000000000000000023001317160430700334300ustar00rootroot00000000000000package org.apache.maven.repository; /* * 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 org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.repository.MavenArtifactRepository; public abstract class LocalArtifactRepository extends MavenArtifactRepository { public static final String IDE_WORKSPACE = "ide-workspace"; public abstract Artifact find( Artifact artifact ); public abstract boolean hasLocalMetadata(); } LocalRepositoryNotAccessibleException.java000066400000000000000000000024461317160430700362240ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/repositorypackage org.apache.maven.repository; /* * 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; /** * Signals a failure to store files within the local repository. * * @author Benjamin Bentmann */ public class LocalRepositoryNotAccessibleException extends IOException { public LocalRepositoryNotAccessibleException( String message, Throwable cause ) { super( message ); initCause( cause ); } public LocalRepositoryNotAccessibleException( String message ) { super( message ); } } maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/repository/RepositorySystem.java000066400000000000000000000166631317160430700322250ustar00rootroot00000000000000package org.apache.maven.repository; /* * 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.File; import java.util.List; import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.InvalidRepositoryException; import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.repository.ArtifactRepositoryPolicy; import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout; import org.apache.maven.artifact.resolver.ArtifactResolutionRequest; import org.apache.maven.artifact.resolver.ArtifactResolutionResult; import org.apache.maven.model.Dependency; import org.apache.maven.model.Plugin; import org.apache.maven.model.Repository; import org.apache.maven.settings.Mirror; import org.apache.maven.settings.Server; import org.eclipse.aether.RepositorySystemSession; /** * @author Jason van Zyl * @since 3.0-alpha */ public interface RepositorySystem { String DEFAULT_LOCAL_REPO_ID = "local"; String userHome = System.getProperty( "user.home" ); File userMavenConfigurationHome = new File( userHome, ".m2" ); File defaultUserLocalRepository = new File( userMavenConfigurationHome, "repository" ); String DEFAULT_REMOTE_REPO_ID = "central"; String DEFAULT_REMOTE_REPO_URL = "https://repo.maven.apache.org/maven2"; Artifact createArtifact( String groupId, String artifactId, String version, String packaging ); Artifact createArtifact( String groupId, String artifactId, String version, String scope, String type ); Artifact createProjectArtifact( String groupId, String artifactId, String version ); Artifact createArtifactWithClassifier( String groupId, String artifactId, String version, String type, String classifier ); Artifact createPluginArtifact( Plugin plugin ); Artifact createDependencyArtifact( Dependency dependency ); ArtifactRepository buildArtifactRepository( Repository repository ) throws InvalidRepositoryException; ArtifactRepository createDefaultRemoteRepository() throws InvalidRepositoryException; ArtifactRepository createDefaultLocalRepository() throws InvalidRepositoryException; ArtifactRepository createLocalRepository( File localRepository ) throws InvalidRepositoryException; ArtifactRepository createArtifactRepository( String id, String url, ArtifactRepositoryLayout repositoryLayout, ArtifactRepositoryPolicy snapshots, ArtifactRepositoryPolicy releases ); /** * Calculates the effective repositories for the given input repositories which are assumed to be already mirrored * (if applicable). This process will essentially remove duplicate repositories by merging them into one equivalent * repository. It is worth to point out that merging does not simply choose one of the input repositories and * discards the others but actually combines their possibly different policies. * * @param repositories The original repositories, may be {@code null}. * @return The effective repositories or {@code null} if the input was {@code null}. */ List getEffectiveRepositories( List repositories ); /** * Determines the mirror for the specified repository. * * @param repository The repository to determine the mirror for, must not be {@code null}. * @param mirrors The available mirrors, may be {@code null}. * @return The mirror specification for the repository or {@code null} if no mirror matched. */ Mirror getMirror( ArtifactRepository repository, List mirrors ); /** * Injects the mirroring information into the specified repositories. For each repository that is matched by a * mirror, its URL and ID will be updated to match the values from the mirror specification. Repositories without a * matching mirror will pass through unchanged. Note: This method must be called before * {@link #injectAuthentication(List, List)} or the repositories will end up with the wrong credentials. * * @param repositories The repositories into which to inject the mirror information, may be {@code null}. * @param mirrors The available mirrors, may be {@code null}. */ void injectMirror( List repositories, List mirrors ); /** * Injects the proxy information into the specified repositories. For each repository that is matched by a proxy, * its proxy data will be set accordingly. Repositories without a matching proxy will have their proxy cleared. * Note: This method must be called after {@link #injectMirror(List, List)} or the repositories will end up * with the wrong proxies. * * @param repositories The repositories into which to inject the proxy information, may be {@code null}. * @param proxies The available proxies, may be {@code null}. */ void injectProxy( List repositories, List proxies ); /** * Injects the authentication information into the specified repositories. For each repository that is matched by a * server, its credentials will be updated to match the values from the server specification. Repositories without a * matching server will have their credentials cleared. Note: This method must be called after * {@link #injectMirror(List, List)} or the repositories will end up with the wrong credentials. * * @param repositories The repositories into which to inject the authentication information, may be {@code null}. * @param servers The available servers, may be {@code null}. */ void injectAuthentication( List repositories, List servers ); void injectMirror( RepositorySystemSession session, List repositories ); void injectProxy( RepositorySystemSession session, List repositories ); void injectAuthentication( RepositorySystemSession session, List repositories ); ArtifactResolutionResult resolve( ArtifactResolutionRequest request ); // Install // Deploy // Map types of artifacts // // Raw file transfers // void publish( ArtifactRepository repository, File source, String remotePath, ArtifactTransferListener transferListener ) throws ArtifactTransferFailedException; void retrieve( ArtifactRepository repository, File destination, String remotePath, ArtifactTransferListener transferListener ) throws ArtifactTransferFailedException, ArtifactDoesNotExistException; } maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/repository/legacy/000077500000000000000000000000001317160430700272265ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/repository/legacy/metadata/000077500000000000000000000000001317160430700310065ustar00rootroot00000000000000AbstractArtifactMetadata.java000066400000000000000000000036001317160430700364530ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/repository/legacy/metadatapackage org.apache.maven.repository.legacy.metadata; /* * 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 org.apache.maven.artifact.Artifact; /** * Common elements of artifact metadata. * * @author Brett Porter */ public abstract class AbstractArtifactMetadata implements ArtifactMetadata { protected Artifact artifact; protected AbstractArtifactMetadata( Artifact artifact ) { this.artifact = artifact; } public boolean storedInGroupDirectory() { return false; } public String getGroupId() { return artifact.getGroupId(); } public String getArtifactId() { return artifact.getArtifactId(); } public String extendedToString() { StringBuilder buffer = new StringBuilder( 256 ); buffer.append( "\nArtifact Metadata\n--------------------------" ); buffer.append( "\nGroupId: " ).append( getGroupId() ); buffer.append( "\nArtifactId: " ).append( getArtifactId() ); buffer.append( "\nMetadata Type: " ).append( getClass().getName() ); return buffer.toString(); } } ArtifactMetadataRetrievalException.java000066400000000000000000000043131317160430700405260ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/repository/legacy/metadatapackage org.apache.maven.repository.legacy.metadata; /* * 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 org.apache.maven.artifact.Artifact; /** * Error while retrieving repository metadata from the repository. * * @author Jason van Zyl */ public class ArtifactMetadataRetrievalException extends Exception { private Artifact artifact; /** @deprecated use {@link #ArtifactMetadataRetrievalException(String, Throwable, Artifact)} */ @Deprecated public ArtifactMetadataRetrievalException( String message ) { this( message, null, null ); } /** @deprecated use {@link #ArtifactMetadataRetrievalException(String, Throwable, Artifact)} */ @Deprecated public ArtifactMetadataRetrievalException( Throwable cause ) { this( null, cause, null ); } /** @deprecated use {@link #ArtifactMetadataRetrievalException(String, Throwable, Artifact)} */ @Deprecated public ArtifactMetadataRetrievalException( String message, Throwable cause ) { this( message, cause, null ); } public ArtifactMetadataRetrievalException( String message, Throwable cause, Artifact artifact ) { super( message, cause ); this.artifact = artifact; } public Artifact getArtifact() { return artifact; } } ArtifactMetadataSource.java000066400000000000000000000074531317160430700361620ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/repository/legacy/metadatapackage org.apache.maven.repository.legacy.metadata; /* * 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.util.List; import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.versioning.ArtifactVersion; /** * Provides some metadata operations, like querying the remote repository for a list of versions available for an * artifact. * * @author Jason van Zyl */ public interface ArtifactMetadataSource { ResolutionGroup retrieve( MetadataResolutionRequest request ) throws ArtifactMetadataRetrievalException; ResolutionGroup retrieve( Artifact artifact, ArtifactRepository localRepository, List remoteRepositories ) throws ArtifactMetadataRetrievalException; /** * Get a list of available versions for an artifact in the remote repository * * @param artifact artifact we are interested in. Only groupid and artifactId * are needed, for instance the following code will work * artifactFactory.createProjectArtifact( "org.apache.maven", "maven", "" ) * @param localRepository local repository * @param remoteRepositories remote repositories, {@link List} $lt; {@link ArtifactRepository} > * @return {@link List} $lt; {@link ArtifactVersion} > * @throws ArtifactMetadataRetrievalException * in case of error while retrieving repository metadata from the repository. */ List retrieveAvailableVersions( Artifact artifact, ArtifactRepository localRepository, List remoteRepositories ) throws ArtifactMetadataRetrievalException; /** * Get a list of available versions for an artifact in the remote deployment repository. This ignores any update * policy checks and mirrors and always retrieves the latest information from the given repository. * * @param artifact artifact we are interested in. Only groupid and artifactId are * needed, for instance the following code will work * artifactFactory.createProjectArtifact( "org.apache.maven", "maven", "" ) * @param localRepository local repository * @param remoteRepository remote repository * @return {@link List} $lt; {@link ArtifactVersion} > * @throws ArtifactMetadataRetrievalException * in case of error while retrieving repository metadata from the repository. */ List retrieveAvailableVersionsFromDeploymentRepository( Artifact artifact, ArtifactRepository localRepository, ArtifactRepository remoteRepository ) throws ArtifactMetadataRetrievalException; }DefaultMetadataResolutionRequest.java000066400000000000000000000071641317160430700402640ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/repository/legacy/metadatapackage org.apache.maven.repository.legacy.metadata; /* * 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.util.List; import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.repository.DefaultRepositoryRequest; import org.apache.maven.artifact.repository.RepositoryRequest; import org.apache.maven.artifact.resolver.ArtifactResolutionRequest; /** * Forms a request to retrieve artifact metadata. * * @author Benjamin Bentmann */ public class DefaultMetadataResolutionRequest implements MetadataResolutionRequest { private Artifact artifact; private boolean resolveManagedVersions; private RepositoryRequest repositoryRequest; public DefaultMetadataResolutionRequest() { repositoryRequest = new DefaultRepositoryRequest(); } public DefaultMetadataResolutionRequest( RepositoryRequest repositoryRequest ) { this.repositoryRequest = new DefaultRepositoryRequest( repositoryRequest ); } public DefaultMetadataResolutionRequest( ArtifactResolutionRequest resolutionRequest ) { this.repositoryRequest = new DefaultRepositoryRequest( resolutionRequest ); } public Artifact getArtifact() { return artifact; } public DefaultMetadataResolutionRequest setArtifact( Artifact artifact ) { this.artifact = artifact; return this; } public ArtifactRepository getLocalRepository() { return repositoryRequest.getLocalRepository(); } public DefaultMetadataResolutionRequest setLocalRepository( ArtifactRepository localRepository ) { repositoryRequest.setLocalRepository( localRepository ); return this; } public List getRemoteRepositories() { return repositoryRequest.getRemoteRepositories(); } public DefaultMetadataResolutionRequest setRemoteRepositories( List remoteRepositories ) { repositoryRequest.setRemoteRepositories( remoteRepositories ); return this; } public boolean isResolveManagedVersions() { return resolveManagedVersions; } public DefaultMetadataResolutionRequest setResolveManagedVersions( boolean resolveManagedVersions ) { this.resolveManagedVersions = resolveManagedVersions; return this; } public boolean isOffline() { return repositoryRequest.isOffline(); } public DefaultMetadataResolutionRequest setOffline( boolean offline ) { repositoryRequest.setOffline( offline ); return this; } public boolean isForceUpdate() { return repositoryRequest.isForceUpdate(); } public DefaultMetadataResolutionRequest setForceUpdate( boolean forceUpdate ) { repositoryRequest.setForceUpdate( forceUpdate ); return this; } } MetadataResolutionRequest.java000066400000000000000000000075001317160430700367510ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/repository/legacy/metadatapackage org.apache.maven.repository.legacy.metadata; /* * 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.util.List; import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.repository.RepositoryRequest; /** * Forms a request to retrieve artifact metadata. * * @author Benjamin Bentmann */ public interface MetadataResolutionRequest extends RepositoryRequest { /** * Indicates whether network access to remote repositories has been disabled. * * @return {@code true} if remote access has been disabled, {@code false} otherwise. */ boolean isOffline(); /** * Enables/disables network access to remote repositories. * * @param offline {@code true} to disable remote access, {@code false} to allow network access. * @return This request, never {@code null}. */ MetadataResolutionRequest setOffline( boolean offline ); /** * Gets the artifact to resolve metadata for. * * @return The artifact to resolve metadata for or {@code null} if not set. */ Artifact getArtifact(); /** * Sets the artifact for which to resolve metadata. * * @param artifact The artifact for which to resolve metadata. * @return This request, never {@code null}. */ MetadataResolutionRequest setArtifact( Artifact artifact ); /** * Gets the local repository to use for the resolution. * * @return The local repository to use for the resolution or {@code null} if not set. */ ArtifactRepository getLocalRepository(); /** * Sets the local repository to use for the resolution. * * @param localRepository The local repository to use for the resolution. * @return This request, never {@code null}. */ MetadataResolutionRequest setLocalRepository( ArtifactRepository localRepository ); /** * Gets the remote repositories to use for the resolution. * * @return The remote repositories to use for the resolution, never {@code null}. */ List getRemoteRepositories(); /** * Sets the remote repositories to use for the resolution. * * @param remoteRepositories The remote repositories to use for the resolution. * @return This request, never {@code null}. */ MetadataResolutionRequest setRemoteRepositories( List remoteRepositories ); /** * Determines whether the managed version information should be retrieved. * * @return {@code true} if the dependency management information should be retrieved, {@code false} otherwise. */ boolean isResolveManagedVersions(); /** * Enables/disables resolution of the dependency management information. * * @param resolveManagedVersions {@code true} if the dependency management information should be retrieved, {@code * false} otherwise. * @return This request, never {@code null}. */ MetadataResolutionRequest setResolveManagedVersions( boolean resolveManagedVersions ); } ResolutionGroup.java000066400000000000000000000047111317160430700347550ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/repository/legacy/metadatapackage org.apache.maven.repository.legacy.metadata; /* * 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.util.List; import java.util.Map; import java.util.Set; import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.repository.ArtifactRepository; public class ResolutionGroup { private final Set artifacts; private final List resolutionRepositories; private final Artifact pomArtifact; private final Artifact relocatedArtifact; private final Map managedVersions; public ResolutionGroup( Artifact pomArtifact, Set artifacts, List resolutionRepositories ) { this( pomArtifact, null, artifacts, null, resolutionRepositories ); } public ResolutionGroup( Artifact pomArtifact, Artifact relocatedArtifact, Set artifacts, Map managedVersions, List resolutionRepositories ) { this.pomArtifact = pomArtifact; this.relocatedArtifact = relocatedArtifact; this.artifacts = artifacts; this.managedVersions = managedVersions; this.resolutionRepositories = resolutionRepositories; } public Artifact getPomArtifact() { return pomArtifact; } public Artifact getRelocatedArtifact() { return relocatedArtifact; } public Set getArtifacts() { return artifacts; } public List getResolutionRepositories() { return resolutionRepositories; } public Map getManagedVersions() { return managedVersions; } } maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/rtinfo/000077500000000000000000000000001317160430700250445ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/rtinfo/RuntimeInformation.java000066400000000000000000000036401317160430700315430ustar00rootroot00000000000000package org.apache.maven.rtinfo; /* * 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. */ /** * Provides information about the current Maven runtime. * * @since 3.0.2 */ public interface RuntimeInformation { /** * Retrieves the current Maven version, for example "3.0.2". * * @return The current Maven version or an empty string if unknown, never {@code null}. */ String getMavenVersion(); /** * Checks whether the current Maven runtime matches the specified version range. A version range can either use the * usual mathematical syntax "[2.0.10,2.1.0),[3.0,)" or use a single version "2.2.1". The latter is a short form for * "[2.2.1,)", i.e. denotes the minimum version required. * * @param versionRange The version range to match the current Maven runtime against, must not be {@code null}. * @return {@code true} if the current Maven runtime matches the specified version range, {@code false} otherwise. * @throws IllegalArgumentException If the specified version range is {@code null}, empty or otherwise not a valid * version specification. */ boolean isMavenVersion( String versionRange ); } maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/rtinfo/internal/000077500000000000000000000000001317160430700266605ustar00rootroot00000000000000DefaultRuntimeInformation.java000066400000000000000000000104351317160430700346050ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/rtinfo/internalpackage org.apache.maven.rtinfo.internal; /* * 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 org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.Validate; import org.apache.maven.rtinfo.RuntimeInformation; import org.codehaus.plexus.component.annotations.Component; import org.codehaus.plexus.component.annotations.Requirement; import org.codehaus.plexus.logging.Logger; import org.eclipse.aether.util.version.GenericVersionScheme; import org.eclipse.aether.version.InvalidVersionSpecificationException; import org.eclipse.aether.version.Version; import org.eclipse.aether.version.VersionConstraint; import org.eclipse.aether.version.VersionScheme; import java.io.IOException; import java.io.InputStream; import java.util.Properties; /** * Provides information about the current Maven runtime. */ @Component( role = RuntimeInformation.class ) public class DefaultRuntimeInformation implements RuntimeInformation { @Requirement private Logger logger; private String mavenVersion; public String getMavenVersion() { if ( mavenVersion == null ) { Properties props = new Properties(); String resource = "META-INF/maven/org.apache.maven/maven-core/pom.properties"; try ( InputStream is = DefaultRuntimeInformation.class.getResourceAsStream( "/" + resource ) ) { if ( is != null ) { props.load( is ); } else { logger.warn( "Could not locate " + resource + " on classpath, Maven runtime information not available" ); } } catch ( IOException e ) { String msg = "Could not parse " + resource + ", Maven runtime information not available"; if ( logger.isDebugEnabled() ) { logger.warn( msg, e ); } else { logger.warn( msg ); } } String version = props.getProperty( "version", "" ).trim(); if ( !version.startsWith( "${" ) ) { mavenVersion = version; } else { mavenVersion = ""; } } return mavenVersion; } public boolean isMavenVersion( String versionRange ) { VersionScheme versionScheme = new GenericVersionScheme(); Validate.notBlank( versionRange, "versionRange can neither be null, empty nor blank" ); VersionConstraint constraint; try { constraint = versionScheme.parseVersionConstraint( versionRange ); } catch ( InvalidVersionSpecificationException e ) { throw new IllegalArgumentException( e.getMessage(), e ); } Version current; try { String mavenVersion = getMavenVersion(); Validate.validState( StringUtils.isNotEmpty( mavenVersion ), "Could not determine current Maven version" ); current = versionScheme.parseVersion( mavenVersion ); } catch ( InvalidVersionSpecificationException e ) { throw new IllegalStateException( "Could not parse current Maven version: " + e.getMessage(), e ); } if ( constraint.getRange() == null ) { return constraint.getVersion().compareTo( current ) <= 0; } return constraint.containsVersion( current ); } } maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/session/000077500000000000000000000000001317160430700252265ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/session/scope/000077500000000000000000000000001317160430700263375ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/session/scope/internal/000077500000000000000000000000001317160430700301535ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/session/scope/internal/SessionScope.java000066400000000000000000000111771317160430700334420ustar00rootroot00000000000000package org.apache.maven.session.scope.internal; /* * 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.util.Collections; import java.util.LinkedList; import java.util.Map; import com.google.common.collect.ImmutableMap; import com.google.common.collect.Maps; import com.google.inject.Key; import com.google.inject.OutOfScopeException; import com.google.inject.Provider; import com.google.inject.Scope; import com.google.inject.util.Providers; public class SessionScope implements Scope { /** * @since 3.3.0 */ public static class Memento { final Map, Provider> seeded; Memento( final Map, Provider> seeded ) { this.seeded = ImmutableMap.copyOf( seeded ); } } private static final Provider SEEDED_KEY_PROVIDER = new Provider() { public Object get() { throw new IllegalStateException(); } }; private static final class ScopeState { public final Map, Provider> seeded = Maps.newHashMap(); public final Map, Object> provided = Maps.newHashMap(); } private final ThreadLocal> values = new ThreadLocal<>(); public void enter() { LinkedList stack = values.get(); if ( stack == null ) { stack = new LinkedList<>(); values.set( stack ); } stack.addFirst( new ScopeState() ); } /** * @since 3.3.0 */ public void enter( Memento memento ) { enter(); getScopeState().seeded.putAll( memento.seeded ); } private ScopeState getScopeState() { LinkedList stack = values.get(); if ( stack == null || stack.isEmpty() ) { throw new IllegalStateException(); } return stack.getFirst(); } public void exit() { final LinkedList stack = values.get(); if ( stack == null || stack.isEmpty() ) { throw new IllegalStateException(); } stack.removeFirst(); if ( stack.isEmpty() ) { values.remove(); } } /** * @since 3.3.0 */ public Memento memento() { LinkedList stack = values.get(); return new Memento( stack != null ? stack.getFirst().seeded : Collections., Provider>emptyMap() ); } public void seed( Class clazz, Provider value ) { getScopeState().seeded.put( Key.get( clazz ), value ); } public void seed( Class clazz, final T value ) { getScopeState().seeded.put( Key.get( clazz ), Providers.of( value ) ); } public Provider scope( final Key key, final Provider unscoped ) { return new Provider() { @SuppressWarnings( "unchecked" ) public T get() { LinkedList stack = values.get(); if ( stack == null || stack.isEmpty() ) { throw new OutOfScopeException( "Cannot access " + key + " outside of a scoping block" ); } ScopeState state = stack.getFirst(); Provider seeded = state.seeded.get( key ); if ( seeded != null ) { return (T) seeded.get(); } T provided = (T) state.provided.get( key ); if ( provided == null && unscoped != null ) { provided = unscoped.get(); state.provided.put( key, provided ); } return provided; } }; } @SuppressWarnings( { "unchecked" } ) public static Provider seededKeyProvider() { return (Provider) SEEDED_KEY_PROVIDER; } } SessionScopeModule.java000066400000000000000000000035641317160430700345320ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/session/scope/internalpackage org.apache.maven.session.scope.internal; /* * 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 javax.inject.Inject; import javax.inject.Named; import org.apache.maven.SessionScoped; import org.apache.maven.execution.MavenSession; import org.codehaus.plexus.PlexusContainer; import org.codehaus.plexus.component.repository.exception.ComponentLookupException; import com.google.inject.AbstractModule; @Named public class SessionScopeModule extends AbstractModule { private final SessionScope scope; @Inject public SessionScopeModule() { this( new SessionScope() ); } public SessionScopeModule( PlexusContainer container ) throws ComponentLookupException { this( container.lookup( SessionScope.class ) ); } private SessionScopeModule( SessionScope scope ) { this.scope = scope; } @Override protected void configure() { bindScope( SessionScoped.class, scope ); bind( SessionScope.class ).toInstance( scope ); bind( MavenSession.class ).toProvider( SessionScope.seededKeyProvider() ).in( scope ); } } maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/settings/000077500000000000000000000000001317160430700254035ustar00rootroot00000000000000DefaultMavenSettingsBuilder.java000066400000000000000000000146261317160430700336030ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/settingspackage org.apache.maven.settings; /* * 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.File; import java.io.IOException; import org.apache.maven.execution.MavenExecutionRequest; import org.apache.maven.properties.internal.SystemProperties; import org.apache.maven.settings.building.DefaultSettingsBuildingRequest; import org.apache.maven.settings.building.SettingsBuilder; import org.apache.maven.settings.building.SettingsBuildingException; import org.apache.maven.settings.building.SettingsBuildingRequest; import org.codehaus.plexus.component.annotations.Component; import org.codehaus.plexus.component.annotations.Requirement; import org.codehaus.plexus.logging.AbstractLogEnabled; import org.codehaus.plexus.util.StringUtils; import org.codehaus.plexus.util.xml.pull.XmlPullParserException; /** * @author jdcasey */ @Component( role = MavenSettingsBuilder.class ) public class DefaultMavenSettingsBuilder extends AbstractLogEnabled implements MavenSettingsBuilder { @Requirement private SettingsBuilder settingsBuilder; public Settings buildSettings() throws IOException, XmlPullParserException { File userSettingsFile = getFile( "${user.home}/.m2/settings.xml", "user.home", MavenSettingsBuilder.ALT_USER_SETTINGS_XML_LOCATION ); return buildSettings( userSettingsFile ); } public Settings buildSettings( boolean useCachedSettings ) throws IOException, XmlPullParserException { return buildSettings(); } public Settings buildSettings( File userSettingsFile ) throws IOException, XmlPullParserException { File globalSettingsFile = getFile( "${maven.conf}/settings.xml", "maven.conf", MavenSettingsBuilder.ALT_GLOBAL_SETTINGS_XML_LOCATION ); SettingsBuildingRequest request = new DefaultSettingsBuildingRequest(); request.setUserSettingsFile( userSettingsFile ); request.setGlobalSettingsFile( globalSettingsFile ); request.setSystemProperties( SystemProperties.getSystemProperties() ); return build( request ); } public Settings buildSettings( File userSettingsFile, boolean useCachedSettings ) throws IOException, XmlPullParserException { return buildSettings( userSettingsFile ); } private Settings build( SettingsBuildingRequest request ) throws IOException, XmlPullParserException { try { return settingsBuilder.build( request ).getEffectiveSettings(); } catch ( SettingsBuildingException e ) { throw (IOException) new IOException( e.getMessage() ).initCause( e ); } } /** @since 2.1 */ public Settings buildSettings( MavenExecutionRequest request ) throws IOException, XmlPullParserException { SettingsBuildingRequest settingsRequest = new DefaultSettingsBuildingRequest(); settingsRequest.setUserSettingsFile( request.getUserSettingsFile() ); settingsRequest.setGlobalSettingsFile( request.getGlobalSettingsFile() ); settingsRequest.setUserProperties( request.getUserProperties() ); settingsRequest.setSystemProperties( request.getSystemProperties() ); return build( settingsRequest ); } private File getFile( String pathPattern, String basedirSysProp, String altLocationSysProp ) { // ------------------------------------------------------------------------------------- // Alright, here's the justification for all the regexp wizardry below... // // Continuum and other server-like apps may need to locate the user-level and // global-level settings somewhere other than ${user.home} and ${maven.home}, // respectively. Using a simple replacement of these patterns will allow them // to specify the absolute path to these files in a customized components.xml // file. Ideally, we'd do full pattern-evaluation against the sysprops, but this // is a first step. There are several replacements below, in order to normalize // the path character before we operate on the string as a regex input, and // in order to avoid surprises with the File construction... // ------------------------------------------------------------------------------------- String path = System.getProperty( altLocationSysProp ); if ( StringUtils.isEmpty( path ) ) { // TODO This replacing shouldn't be necessary as user.home should be in the // context of the container and thus the value would be interpolated by Plexus String basedir = System.getProperty( basedirSysProp ); if ( basedir == null ) { basedir = System.getProperty( "user.dir" ); } basedir = basedir.replaceAll( "\\\\", "/" ); basedir = basedir.replaceAll( "\\$", "\\\\\\$" ); path = pathPattern.replaceAll( "\\$\\{" + basedirSysProp + "\\}", basedir ); path = path.replaceAll( "\\\\", "/" ); // --------------------------------------------------------------------------------- // I'm not sure if this last regexp was really intended to disallow the usage of // network paths as user.home directory. Unfortunately it did. I removed it and // have not detected any problems yet. // --------------------------------------------------------------------------------- // path = path.replaceAll( "//", "/" ); return new File( path ).getAbsoluteFile(); } else { return new File( path ).getAbsoluteFile(); } } } maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/settings/MavenSettingsBuilder.java000066400000000000000000000055121317160430700323470ustar00rootroot00000000000000package org.apache.maven.settings; /* * 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.File; import java.io.IOException; import org.apache.maven.execution.MavenExecutionRequest; import org.codehaus.plexus.util.xml.pull.XmlPullParserException; /** * @author jdcasey * @author Jason van Zyl */ @Deprecated public interface MavenSettingsBuilder { String ROLE = MavenSettingsBuilder.class.getName(); String ALT_USER_SETTINGS_XML_LOCATION = "org.apache.maven.user-settings"; String ALT_GLOBAL_SETTINGS_XML_LOCATION = "org.apache.maven.global-settings"; String ALT_LOCAL_REPOSITORY_LOCATION = "maven.repo.local"; Settings buildSettings( MavenExecutionRequest request ) throws IOException, XmlPullParserException; /** * @return a Settings object from the user settings file. * @throws IOException if any * @throws XmlPullParserException if any */ Settings buildSettings() throws IOException, XmlPullParserException; /** * @param useCachedSettings if true, doesn't reload the user settings * @return a Settings object from the user settings file. * @throws IOException if any * @throws XmlPullParserException if any */ Settings buildSettings( boolean useCachedSettings ) throws IOException, XmlPullParserException; /** * @param userSettingsFile a given user settings file * @return a Settings object from the user settings file. * @throws IOException if any * @throws XmlPullParserException if any */ Settings buildSettings( File userSettingsFile ) throws IOException, XmlPullParserException; /** * @param userSettingsFile a given user settings file * @param useCachedSettings if true, doesn't reload the user settings * @return a Settings object from the user settings file. * @throws IOException if any * @throws XmlPullParserException if any */ Settings buildSettings( File userSettingsFile, boolean useCachedSettings ) throws IOException, XmlPullParserException; } SettingsConfigurationException.java000066400000000000000000000034441317160430700344030ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/settingspackage org.apache.maven.settings; /* * 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. */ /** * If there was an error in the settings file. * * @author Brett Porter */ public class SettingsConfigurationException extends Exception { private int lineNumber; private int columnNumber; public SettingsConfigurationException( String message ) { super( message ); } public SettingsConfigurationException( String message, Throwable cause ) { super( message, cause ); } public SettingsConfigurationException( String message, Throwable cause, int lineNumber, int columnNumber ) { super( message + ( lineNumber > 0 ? "\n Line: " + lineNumber : "" ) + ( columnNumber > 0 ? "\n Column: " + columnNumber : "" ), cause ); this.lineNumber = lineNumber; this.columnNumber = columnNumber; } public int getColumnNumber() { return columnNumber; } public int getLineNumber() { return lineNumber; } } maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/settings/SettingsUtils.java000066400000000000000000000245371317160430700311020ustar00rootroot00000000000000package org.apache.maven.settings; /* * 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 org.apache.maven.model.ActivationFile; import org.apache.maven.settings.merge.MavenSettingsMerger; import java.util.List; /** * Several convenience methods to handle settings * * @author Vincent Siveton */ public final class SettingsUtils { private SettingsUtils() { // don't allow construction. } /** * @param dominant * @param recessive * @param recessiveSourceLevel */ public static void merge( Settings dominant, Settings recessive, String recessiveSourceLevel ) { new MavenSettingsMerger().merge( dominant, recessive, recessiveSourceLevel ); } /** * @param modelProfile * @return a profile */ public static Profile convertToSettingsProfile( org.apache.maven.model.Profile modelProfile ) { Profile profile = new Profile(); profile.setId( modelProfile.getId() ); org.apache.maven.model.Activation modelActivation = modelProfile.getActivation(); if ( modelActivation != null ) { Activation activation = new Activation(); activation.setActiveByDefault( modelActivation.isActiveByDefault() ); activation.setJdk( modelActivation.getJdk() ); org.apache.maven.model.ActivationProperty modelProp = modelActivation.getProperty(); if ( modelProp != null ) { ActivationProperty prop = new ActivationProperty(); prop.setName( modelProp.getName() ); prop.setValue( modelProp.getValue() ); activation.setProperty( prop ); } org.apache.maven.model.ActivationOS modelOs = modelActivation.getOs(); if ( modelOs != null ) { ActivationOS os = new ActivationOS(); os.setArch( modelOs.getArch() ); os.setFamily( modelOs.getFamily() ); os.setName( modelOs.getName() ); os.setVersion( modelOs.getVersion() ); activation.setOs( os ); } ActivationFile modelFile = modelActivation.getFile(); if ( modelFile != null ) { org.apache.maven.settings.ActivationFile file = new org.apache.maven.settings.ActivationFile(); file.setExists( modelFile.getExists() ); file.setMissing( modelFile.getMissing() ); activation.setFile( file ); } profile.setActivation( activation ); } profile.setProperties( modelProfile.getProperties() ); List repos = modelProfile.getRepositories(); if ( repos != null ) { for ( org.apache.maven.model.Repository repo : repos ) { profile.addRepository( convertToSettingsRepository( repo ) ); } } List pluginRepos = modelProfile.getPluginRepositories(); if ( pluginRepos != null ) { for ( org.apache.maven.model.Repository pluginRepo : pluginRepos ) { profile.addPluginRepository( convertToSettingsRepository( pluginRepo ) ); } } return profile; } /** * @param settingsProfile * @return a profile */ public static org.apache.maven.model.Profile convertFromSettingsProfile( Profile settingsProfile ) { org.apache.maven.model.Profile profile = new org.apache.maven.model.Profile(); profile.setId( settingsProfile.getId() ); profile.setSource( "settings.xml" ); Activation settingsActivation = settingsProfile.getActivation(); if ( settingsActivation != null ) { org.apache.maven.model.Activation activation = new org.apache.maven.model.Activation(); activation.setActiveByDefault( settingsActivation.isActiveByDefault() ); activation.setJdk( settingsActivation.getJdk() ); ActivationProperty settingsProp = settingsActivation.getProperty(); if ( settingsProp != null ) { org.apache.maven.model.ActivationProperty prop = new org.apache.maven.model.ActivationProperty(); prop.setName( settingsProp.getName() ); prop.setValue( settingsProp.getValue() ); activation.setProperty( prop ); } ActivationOS settingsOs = settingsActivation.getOs(); if ( settingsOs != null ) { org.apache.maven.model.ActivationOS os = new org.apache.maven.model.ActivationOS(); os.setArch( settingsOs.getArch() ); os.setFamily( settingsOs.getFamily() ); os.setName( settingsOs.getName() ); os.setVersion( settingsOs.getVersion() ); activation.setOs( os ); } org.apache.maven.settings.ActivationFile settingsFile = settingsActivation.getFile(); if ( settingsFile != null ) { ActivationFile file = new ActivationFile(); file.setExists( settingsFile.getExists() ); file.setMissing( settingsFile.getMissing() ); activation.setFile( file ); } profile.setActivation( activation ); } profile.setProperties( settingsProfile.getProperties() ); List repos = settingsProfile.getRepositories(); if ( repos != null ) { for ( Repository repo : repos ) { profile.addRepository( convertFromSettingsRepository( repo ) ); } } List pluginRepos = settingsProfile.getPluginRepositories(); if ( pluginRepos != null ) { for ( Repository pluginRepo : pluginRepos ) { profile.addPluginRepository( convertFromSettingsRepository( pluginRepo ) ); } } return profile; } /** * @param settingsRepo * @return a repository */ private static org.apache.maven.model.Repository convertFromSettingsRepository( Repository settingsRepo ) { org.apache.maven.model.Repository repo = new org.apache.maven.model.Repository(); repo.setId( settingsRepo.getId() ); repo.setLayout( settingsRepo.getLayout() ); repo.setName( settingsRepo.getName() ); repo.setUrl( settingsRepo.getUrl() ); if ( settingsRepo.getSnapshots() != null ) { repo.setSnapshots( convertRepositoryPolicy( settingsRepo.getSnapshots() ) ); } if ( settingsRepo.getReleases() != null ) { repo.setReleases( convertRepositoryPolicy( settingsRepo.getReleases() ) ); } return repo; } /** * @param settingsPolicy * @return a RepositoryPolicy */ private static org.apache.maven.model.RepositoryPolicy convertRepositoryPolicy( RepositoryPolicy settingsPolicy ) { org.apache.maven.model.RepositoryPolicy policy = new org.apache.maven.model.RepositoryPolicy(); policy.setEnabled( settingsPolicy.isEnabled() ); policy.setUpdatePolicy( settingsPolicy.getUpdatePolicy() ); policy.setChecksumPolicy( settingsPolicy.getChecksumPolicy() ); return policy; } /** * @param modelRepo * @return a repository */ private static Repository convertToSettingsRepository( org.apache.maven.model.Repository modelRepo ) { Repository repo = new Repository(); repo.setId( modelRepo.getId() ); repo.setLayout( modelRepo.getLayout() ); repo.setName( modelRepo.getName() ); repo.setUrl( modelRepo.getUrl() ); if ( modelRepo.getSnapshots() != null ) { repo.setSnapshots( convertRepositoryPolicy( modelRepo.getSnapshots() ) ); } if ( modelRepo.getReleases() != null ) { repo.setReleases( convertRepositoryPolicy( modelRepo.getReleases() ) ); } return repo; } /** * @param modelPolicy * @return a RepositoryPolicy */ private static RepositoryPolicy convertRepositoryPolicy( org.apache.maven.model.RepositoryPolicy modelPolicy ) { RepositoryPolicy policy = new RepositoryPolicy(); policy.setEnabled( modelPolicy.isEnabled() ); policy.setUpdatePolicy( modelPolicy.getUpdatePolicy() ); policy.setChecksumPolicy( modelPolicy.getChecksumPolicy() ); return policy; } /** * @param settings could be null * @return a new instance of settings or null if settings was null. */ public static Settings copySettings( Settings settings ) { if ( settings == null ) { return null; } Settings clone = new Settings(); clone.setActiveProfiles( settings.getActiveProfiles() ); clone.setInteractiveMode( settings.isInteractiveMode() ); clone.setLocalRepository( settings.getLocalRepository() ); clone.setMirrors( settings.getMirrors() ); clone.setModelEncoding( settings.getModelEncoding() ); clone.setOffline( settings.isOffline() ); clone.setPluginGroups( settings.getPluginGroups() ); clone.setProfiles( settings.getProfiles() ); clone.setProxies( settings.getProxies() ); clone.setServers( settings.getServers() ); clone.setSourceLevel( settings.getSourceLevel() ); clone.setUsePluginRegistry( settings.isUsePluginRegistry() ); return clone; } } maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/toolchain/000077500000000000000000000000001317160430700255235ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/toolchain/DefaultToolchain.java000066400000000000000000000120631317160430700316150ustar00rootroot00000000000000package org.apache.maven.toolchain; /* * 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.util.HashMap; import java.util.Iterator; import java.util.Map; import java.util.Properties; import org.apache.maven.toolchain.model.ToolchainModel; import org.codehaus.plexus.logging.Logger; /** * Default abstract toolchain implementation, to be used as base class for any toolchain implementation * to avoid rewriting usual code. * * @author mkleint * @since 2.0.9 */ public abstract class DefaultToolchain // should have been AbstractToolchain... implements Toolchain, ToolchainPrivate { private String type; private Map provides = new HashMap<>(); public static final String KEY_TYPE = "type"; //NOI18N private ToolchainModel model; private Logger logger; /** * * @param model the model, must not be {@code null} * @param logger the logger, must not be {@code null} */ protected DefaultToolchain( ToolchainModel model, Logger logger ) { this.model = model; this.logger = logger; } /** * * @param model the model, must not be {@code null} * @param type the type * @param logger the logger, must not be {@code null} */ protected DefaultToolchain( ToolchainModel model, String type, Logger logger ) { this( model, logger ); this.type = type; } @Override public final String getType() { return type != null ? type : model.getType(); } @Override public final ToolchainModel getModel() { return model; } public final void addProvideToken( String type, RequirementMatcher matcher ) { provides.put( type, matcher ); } @Override public boolean matchesRequirements( Map requirements ) { for ( Map.Entry requirement : requirements.entrySet() ) { String key = requirement.getKey(); RequirementMatcher matcher = provides.get( key ); if ( matcher == null ) { getLog().debug( "Toolchain " + this + " is missing required property: " + key ); return false; } if ( !matcher.matches( requirement.getValue() ) ) { getLog().debug( "Toolchain " + this + " doesn't match required property: " + key ); return false; } } return true; } protected Logger getLog() { return logger; } @Override public boolean equals( Object obj ) { if ( obj == null ) { return false; } if ( this == obj ) { return true; } if ( !( obj instanceof DefaultToolchain ) ) { return false; } DefaultToolchain other = (DefaultToolchain) obj; if ( type == null ? other.type != null : !type.equals( other.type ) ) { return false; } Properties thisProvides = this.getModel().getProvides(); Properties otherProvides = other.getModel().getProvides(); if ( thisProvides == null ? otherProvides != null : !thisProvides.equals( otherProvides ) ) { return false; } return true; } @Override public int hashCode() { int hashCode = ( type == null ) ? 0 : type.hashCode(); if ( this.getModel().getProvides() != null ) { hashCode = 31 * hashCode + this.getModel().getProvides().hashCode(); } return hashCode; } @Override public String toString() { StringBuilder builder = new StringBuilder(); builder.append( "type:" ).append( getType() ); builder.append( '{' ); Iterator> providesIter = provides.entrySet().iterator(); while ( providesIter.hasNext() ) { Map.Entry provideEntry = providesIter.next(); builder.append( provideEntry.getKey() ).append( " = " ).append( provideEntry.getValue() ); if ( providesIter.hasNext() ) { builder.append( ';' ); } } builder.append( '}' ); return builder.toString(); } } maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/toolchain/DefaultToolchainManager.java000066400000000000000000000110061317160430700331040ustar00rootroot00000000000000package org.apache.maven.toolchain; /* * 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.util.ArrayList; import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; import org.apache.maven.execution.MavenSession; import org.apache.maven.plugin.descriptor.PluginDescriptor; import org.apache.maven.project.MavenProject; import org.apache.maven.toolchain.model.ToolchainModel; import org.codehaus.plexus.component.annotations.Component; import org.codehaus.plexus.component.annotations.Requirement; import org.codehaus.plexus.logging.Logger; /** * @author mkleint */ @Component( role = ToolchainManager.class ) public class DefaultToolchainManager implements ToolchainManager { @Requirement Logger logger; @Requirement( role = ToolchainFactory.class ) Map factories; @Override public Toolchain getToolchainFromBuildContext( String type, MavenSession session ) { Map context = retrieveContext( session ); ToolchainModel model = (ToolchainModel) context.get( getStorageKey( type ) ); if ( model != null ) { List toolchains = selectToolchains( Collections.singletonList( model ), type, null ); if ( !toolchains.isEmpty() ) { return toolchains.get( 0 ); } } return null; } @Override public List getToolchains( MavenSession session, String type, Map requirements ) { List models = session.getRequest().getToolchains().get( type ); return selectToolchains( models, type, requirements ); } private List selectToolchains( List models, String type, Map requirements ) { List toolchains = new ArrayList<>(); if ( models != null ) { ToolchainFactory fact = factories.get( type ); if ( fact == null ) { logger.error( "Missing toolchain factory for type: " + type + ". Possibly caused by misconfigured project." ); } else { for ( ToolchainModel model : models ) { try { ToolchainPrivate toolchain = fact.createToolchain( model ); if ( requirements == null || toolchain.matchesRequirements( requirements ) ) { toolchains.add( toolchain ); } } catch ( MisconfiguredToolchainException ex ) { logger.error( "Misconfigured toolchain.", ex ); } } } } return toolchains; } Map retrieveContext( MavenSession session ) { Map context = null; if ( session != null ) { PluginDescriptor desc = new PluginDescriptor(); desc.setGroupId( PluginDescriptor.getDefaultPluginGroupId() ); desc.setArtifactId( PluginDescriptor.getDefaultPluginArtifactId( "toolchains" ) ); MavenProject current = session.getCurrentProject(); if ( current != null ) { //TODO why is this using the context context = session.getPluginContext( desc, current ); } } return ( context != null ) ? context : new HashMap(); } public static final String getStorageKey( String type ) { return "toolchain-" + type; // NOI18N } } DefaultToolchainManagerPrivate.java000066400000000000000000000052501317160430700343640ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/toolchainpackage org.apache.maven.toolchain; /* * 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.util.ArrayList; import java.util.List; import java.util.Map; import org.apache.maven.execution.MavenSession; import org.apache.maven.toolchain.model.ToolchainModel; import org.codehaus.plexus.component.annotations.Component; /** * @author mkleint * @author Robert Scholte */ @Component( role = ToolchainManagerPrivate.class ) public class DefaultToolchainManagerPrivate extends DefaultToolchainManager implements ToolchainManagerPrivate { @Override public ToolchainPrivate[] getToolchainsForType( String type, MavenSession context ) throws MisconfiguredToolchainException { List toRet = new ArrayList<>(); ToolchainFactory fact = factories.get( type ); if ( fact == null ) { logger.error( "Missing toolchain factory for type: " + type + ". Possibly caused by misconfigured project." ); } else { List availableToolchains = context.getRequest().getToolchains().get( type ); if ( availableToolchains != null ) { for ( ToolchainModel toolchainModel : availableToolchains ) { toRet.add( fact.createToolchain( toolchainModel ) ); } } // add default toolchain ToolchainPrivate tool = fact.createDefaultToolchain(); if ( tool != null ) { toRet.add( tool ); } } return toRet.toArray( new ToolchainPrivate[toRet.size()] ); } @Override public void storeToolchainToBuildContext( ToolchainPrivate toolchain, MavenSession session ) { Map context = retrieveContext( session ); context.put( getStorageKey( toolchain.getType() ), toolchain.getModel() ); } } maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/toolchain/DefaultToolchainsBuilder.java000066400000000000000000000045731317160430700333160ustar00rootroot00000000000000package org.apache.maven.toolchain; /* * 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 org.apache.maven.toolchain.model.PersistedToolchains; import org.apache.maven.toolchain.model.io.xpp3.MavenToolchainsXpp3Reader; import org.codehaus.plexus.component.annotations.Component; import org.codehaus.plexus.component.annotations.Requirement; import org.codehaus.plexus.logging.Logger; import org.codehaus.plexus.util.ReaderFactory; import java.io.File; import java.io.Reader; /** * @author Benjamin Bentmann * @deprecated instead use {@link org.apache.maven.toolchain.building.DefaultToolchainsBuilder} */ @Deprecated @Component( role = ToolchainsBuilder.class, hint = "default" ) public class DefaultToolchainsBuilder implements ToolchainsBuilder { @Requirement private Logger logger; public PersistedToolchains build( File userToolchainsFile ) throws MisconfiguredToolchainException { PersistedToolchains toolchains = null; if ( userToolchainsFile != null && userToolchainsFile.isFile() ) { try ( Reader in = ReaderFactory.newXmlReader( userToolchainsFile ) ) { toolchains = new MavenToolchainsXpp3Reader().read( in ); } catch ( Exception e ) { throw new MisconfiguredToolchainException( "Cannot read toolchains file at " + userToolchainsFile.getAbsolutePath(), e ); } } else if ( userToolchainsFile != null ) { logger.debug( "Toolchains configuration was not found at " + userToolchainsFile ); } return toolchains; } } MisconfiguredToolchainException.java000066400000000000000000000022171317160430700346270ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/toolchainpackage org.apache.maven.toolchain; /* * 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 mkleint */ public class MisconfiguredToolchainException extends Exception { public MisconfiguredToolchainException( String message ) { super( message ); } public MisconfiguredToolchainException( String message, Throwable orig ) { super( message, orig ); } }maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/toolchain/RequirementMatcher.java000066400000000000000000000016761317160430700322040ustar00rootroot00000000000000package org.apache.maven.toolchain; /* * 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 mkleint */ public interface RequirementMatcher { boolean matches( String requirement ); }maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/toolchain/RequirementMatcherFactory.java000066400000000000000000000057721317160430700335350ustar00rootroot00000000000000package org.apache.maven.toolchain; /* * 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 org.apache.maven.artifact.versioning.DefaultArtifactVersion; import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException; import org.apache.maven.artifact.versioning.VersionRange; /** * * @author mkleint */ public final class RequirementMatcherFactory { private RequirementMatcherFactory() { } public static RequirementMatcher createExactMatcher( String provideValue ) { return new ExactMatcher( provideValue ); } public static RequirementMatcher createVersionMatcher( String provideValue ) { return new VersionMatcher( provideValue ); } private static final class ExactMatcher implements RequirementMatcher { private String provides; private ExactMatcher( String provides ) { this.provides = provides; } @Override public boolean matches( String requirement ) { return provides.equalsIgnoreCase( requirement ); } @Override public String toString() { return provides; } } private static final class VersionMatcher implements RequirementMatcher { DefaultArtifactVersion version; private VersionMatcher( String version ) { this.version = new DefaultArtifactVersion( version ); } @Override public boolean matches( String requirement ) { try { VersionRange range = VersionRange.createFromVersionSpec( requirement ); if ( range.hasRestrictions() ) { return range.containsVersion( version ); } else { return range.getRecommendedVersion().compareTo( version ) == 0; } } catch ( InvalidVersionSpecificationException ex ) { //TODO error reporting ex.printStackTrace(); return false; } } @Override public String toString() { return version.toString(); } } }maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/toolchain/Toolchain.java000066400000000000000000000025061317160430700303110ustar00rootroot00000000000000package org.apache.maven.toolchain; /* * 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. */ /** * Toolchain interface. * * @author Milos Kleint * @author Jason van Zyl * @since 2.0.9 */ public interface Toolchain { /** * get the type of toolchain. * * @return the toolchain type */ String getType(); /** * Gets the platform tool executable. * * @param toolName the tool platform independent tool name. * @return file representing the tool executable, or null if the tool can not be found */ String findTool( String toolName ); }maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/toolchain/ToolchainFactory.java000066400000000000000000000026271317160430700316450ustar00rootroot00000000000000package org.apache.maven.toolchain; /* * 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 org.apache.maven.toolchain.model.ToolchainModel; /** * Internal toolchain factory, to prepare toolchains instances. * * @author mkleint * @since 2.0.9 */ public interface ToolchainFactory { /** * Create instance of toolchain. **/ ToolchainPrivate createToolchain( ToolchainModel model ) throws MisconfiguredToolchainException; /** * Returns the default instance of the particular type of toolchain, can return null * if not applicable. * TODO keep around?? **/ ToolchainPrivate createDefaultToolchain(); }maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/toolchain/ToolchainManager.java000066400000000000000000000044751317160430700316130ustar00rootroot00000000000000package org.apache.maven.toolchain; /* * 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.util.List; import java.util.Map; import org.apache.maven.execution.MavenSession; /** * Public API for a toolchain-aware plugin to get expected toolchain instance. * * @author mkleint * @author Robert Scholte * @since 2.0.9 */ public interface ToolchainManager { // NOTE: Some plugins like Surefire access this field directly! @Deprecated String ROLE = ToolchainManager.class.getName(); /** * Retrieve toolchain of specified type from build context. It is expected that * maven-toolchains-plugin contains the configuration to select the appropriate * toolchain and is executed at the beginning of the build. * * @param type the type, must not be {@code null} * @param context the Maven session, must not be {@code null} * @return the toolchain selected by maven-toolchains-plugin */ Toolchain getToolchainFromBuildContext( String type, MavenSession context ); /** * Select all toolchains available in user settings matching the type and requirements, * independently from maven-toolchains-plugin. * * @param session the Maven session, must not be {@code null} * @param type the type, must not be {@code null} * @param requirements the requirements, may be {@code null} * @return the matching toolchains, never {@code null} * @since 3.3.0 */ List getToolchains( MavenSession session, String type, Map requirements ); } maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/toolchain/ToolchainManagerPrivate.java000066400000000000000000000042301317160430700331330ustar00rootroot00000000000000package org.apache.maven.toolchain; /* * 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 org.apache.maven.execution.MavenSession; /** * Component for use by the maven-toolchains-plugin only. * It provides API:
    *
  1. to retrieve every toolchains available in user settings,
  2. *
  3. to store chosen toolchain into build context for later use by toolchain-aware plugins.
  4. *
* * @author mkleint * @since 2.0.9 * @see ToolchainManager#getToolchainFromBuildContext(String, MavenSession) */ public interface ToolchainManagerPrivate { /** * Retrieves every toolchains of given type available in user settings. * * @param type the type, must not be {@code null} * @param context the Maven session, must not be {@code null} * @since 3.0 (addition of the MavenSession parameter) */ ToolchainPrivate[] getToolchainsForType( String type, MavenSession context ) throws MisconfiguredToolchainException; /** * Stores the toolchain into build context for later use by toolchain-aware plugins. * * @param toolchain the toolchain to store, must not be {@code null} * @param context the Maven session, must not be {@code null} * @since 2.0.9 * @see ToolchainManager#getToolchainFromBuildContext(String, MavenSession) */ void storeToolchainToBuildContext( ToolchainPrivate toolchain, MavenSession context ); } maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/toolchain/ToolchainPrivate.java000066400000000000000000000030431317160430700316410ustar00rootroot00000000000000package org.apache.maven.toolchain; /* * 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.util.Map; import org.apache.maven.toolchain.model.ToolchainModel; /** * a private contract between the toolchains plugin and the components. * @author mkleint */ public interface ToolchainPrivate extends Toolchain { /** * Let the toolchain decide if it matches requirements defined * in the toolchain plugin configuration. * @param requirements Map<String, String> key value pair, may not be {@code null} * @return {@code true} if the requirements match, otherwise {@code false} */ boolean matchesRequirements( Map requirements ); /** * * @return the original model wrapped by this interface */ ToolchainModel getModel(); }maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/toolchain/ToolchainsBuilder.java000066400000000000000000000033541317160430700320050ustar00rootroot00000000000000package org.apache.maven.toolchain; /* * 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.File; import org.apache.maven.toolchain.model.PersistedToolchains; /** * Builds the toolchains model from a previously configured filesystem path to the toolchains file. * Note: This is an internal component whose interface can change without prior notice. * * @author Benjamin Bentmann */ public interface ToolchainsBuilder { /** * Builds the toolchains model from the configured toolchain files. * * @param userToolchainsFile The path to the toolchains file, may be null to disable parsing. * @return The toolchains model or null if no toolchain file was configured or the configured file does * not exist. * @throws MisconfiguredToolchainException If the toolchain file exists but cannot be parsed. */ PersistedToolchains build( File userToolchainsFile ) throws MisconfiguredToolchainException; } maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/toolchain/building/000077500000000000000000000000001317160430700273205ustar00rootroot00000000000000DefaultToolchainsBuilder.java000066400000000000000000000112001317160430700350150ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/toolchain/buildingpackage org.apache.maven.toolchain.building; /* * 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.util.Collections; import java.util.List; import java.util.Map; import javax.inject.Inject; import javax.inject.Named; import javax.inject.Singleton; import org.apache.maven.building.Problem; import org.apache.maven.building.ProblemCollector; import org.apache.maven.building.ProblemCollectorFactory; import org.apache.maven.building.Source; import org.apache.maven.toolchain.io.ToolchainsParseException; import org.apache.maven.toolchain.io.ToolchainsReader; import org.apache.maven.toolchain.merge.MavenToolchainMerger; import org.apache.maven.toolchain.model.PersistedToolchains; import org.apache.maven.toolchain.model.TrackableBase; /** * * @author Robert Scholte * @since 3.3.0 */ @Named @Singleton public class DefaultToolchainsBuilder implements ToolchainsBuilder { private MavenToolchainMerger toolchainsMerger = new MavenToolchainMerger(); @Inject private ToolchainsReader toolchainsReader; @Override public ToolchainsBuildingResult build( ToolchainsBuildingRequest request ) throws ToolchainsBuildingException { ProblemCollector problems = ProblemCollectorFactory.newInstance( null ); PersistedToolchains globalToolchains = readToolchains( request.getGlobalToolchainsSource(), request, problems ); PersistedToolchains userToolchains = readToolchains( request.getUserToolchainsSource(), request, problems ); toolchainsMerger.merge( userToolchains, globalToolchains, TrackableBase.GLOBAL_LEVEL ); problems.setSource( "" ); if ( hasErrors( problems.getProblems() ) ) { throw new ToolchainsBuildingException( problems.getProblems() ); } return new DefaultToolchainsBuildingResult( userToolchains, problems.getProblems() ); } private PersistedToolchains readToolchains( Source toolchainsSource, ToolchainsBuildingRequest request, ProblemCollector problems ) { if ( toolchainsSource == null ) { return new PersistedToolchains(); } PersistedToolchains toolchains; try { Map options = Collections.singletonMap( ToolchainsReader.IS_STRICT, Boolean.TRUE ); try { toolchains = toolchainsReader.read( toolchainsSource.getInputStream(), options ); } catch ( ToolchainsParseException e ) { options = Collections.singletonMap( ToolchainsReader.IS_STRICT, Boolean.FALSE ); toolchains = toolchainsReader.read( toolchainsSource.getInputStream(), options ); problems.add( Problem.Severity.WARNING, e.getMessage(), e.getLineNumber(), e.getColumnNumber(), e ); } } catch ( ToolchainsParseException e ) { problems.add( Problem.Severity.FATAL, "Non-parseable toolchains " + toolchainsSource.getLocation() + ": " + e.getMessage(), e.getLineNumber(), e.getColumnNumber(), e ); return new PersistedToolchains(); } catch ( IOException e ) { problems.add( Problem.Severity.FATAL, "Non-readable toolchains " + toolchainsSource.getLocation() + ": " + e.getMessage(), -1, -1, e ); return new PersistedToolchains(); } return toolchains; } private boolean hasErrors( List problems ) { if ( problems != null ) { for ( Problem problem : problems ) { if ( Problem.Severity.ERROR.compareTo( problem.getSeverity() ) >= 0 ) { return true; } } } return false; } } DefaultToolchainsBuildingRequest.java000066400000000000000000000034411317160430700365450ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/toolchain/buildingpackage org.apache.maven.toolchain.building; /* * 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 org.apache.maven.building.Source; /** * Collects toolchains that control building of effective toolchains. * * @author Robert Scholte * @since 3.3.0 */ public class DefaultToolchainsBuildingRequest implements ToolchainsBuildingRequest { private Source globalToolchainsSource; private Source userToolchainsSource; @Override public Source getGlobalToolchainsSource() { return globalToolchainsSource; } @Override public ToolchainsBuildingRequest setGlobalToolchainsSource( Source globalToolchainsSource ) { this.globalToolchainsSource = globalToolchainsSource; return this; } @Override public Source getUserToolchainsSource() { return userToolchainsSource; } @Override public ToolchainsBuildingRequest setUserToolchainsSource( Source userToolchainsSource ) { this.userToolchainsSource = userToolchainsSource; return this; } } DefaultToolchainsBuildingResult.java000066400000000000000000000037721317160430700364020ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/toolchain/buildingpackage org.apache.maven.toolchain.building; /* * 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.util.ArrayList; import java.util.List; import org.apache.maven.building.Problem; import org.apache.maven.toolchain.model.PersistedToolchains; /** * Holds the result of the merged toolchains and holds the problems during this build, if any. * * @author Robert Scholte * @since 3.3.0 */ public class DefaultToolchainsBuildingResult implements ToolchainsBuildingResult { private PersistedToolchains effectiveToolchains; private List problems; /** * Default constructor * * @param effectiveToolchains the merged toolchains, may not be {@code null} * @param problems the problems while building the effectiveToolchains, if any. */ public DefaultToolchainsBuildingResult( PersistedToolchains effectiveToolchains, List problems ) { this.effectiveToolchains = effectiveToolchains; this.problems = ( problems != null ) ? problems : new ArrayList(); } @Override public PersistedToolchains getEffectiveToolchains() { return effectiveToolchains; } @Override public List getProblems() { return problems; } } ToolchainsBuilder.java000066400000000000000000000027721317160430700335260ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/toolchain/buildingpackage org.apache.maven.toolchain.building; /* * 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. */ /** * Builds the effective toolchains from a user toolchains file and/or a global toolchains file. * * @author Robert Scholte * @since 3.3.0 */ public interface ToolchainsBuilder { /** * Builds the effective toolchains of the specified toolchains files. * * @param request The toolchains building request that holds the parameters, must not be {@code null}. * @return The result of the toolchains building, never {@code null}. * @throws ToolchainsBuildingException If the effective toolchains could not be built. */ ToolchainsBuildingResult build( ToolchainsBuildingRequest request ) throws ToolchainsBuildingException; } ToolchainsBuildingException.java000066400000000000000000000052761317160430700355560ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/toolchain/buildingpackage org.apache.maven.toolchain.building; /* * 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.PrintWriter; import java.io.StringWriter; import java.util.ArrayList; import java.util.List; import org.apache.maven.building.Problem; /** * @author Robert Scholte * @since 3.3.0 */ public class ToolchainsBuildingException extends Exception { private final List problems; /** * Creates a new exception with the specified problems. * * @param problems The problems that causes this exception, must not be {@code null}. */ public ToolchainsBuildingException( List problems ) { super( toMessage( problems ) ); this.problems = new ArrayList<>(); if ( problems != null ) { this.problems.addAll( problems ); } } /** * Gets the problems that caused this exception. * * @return The problems that caused this exception, never {@code null}. */ public List getProblems() { return problems; } private static String toMessage( List problems ) { StringWriter buffer = new StringWriter( 1024 ); PrintWriter writer = new PrintWriter( buffer ); writer.print( problems.size() ); writer.print( ( problems.size() == 1 ) ? " problem was " : " problems were " ); writer.print( "encountered while building the effective toolchains" ); writer.println(); for ( Problem problem : problems ) { writer.print( "[" ); writer.print( problem.getSeverity() ); writer.print( "] " ); writer.print( problem.getMessage() ); String location = problem.getLocation(); if ( !location.isEmpty() ) { writer.print( " @ " ); writer.print( location ); } writer.println(); } return buffer.toString(); } } ToolchainsBuildingRequest.java000066400000000000000000000043151317160430700352410ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/toolchain/buildingpackage org.apache.maven.toolchain.building; /* * 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 org.apache.maven.building.Source; /** * Collects toolchains that control the building of effective toolchains. * * @author Robert Scholte * @since 3.3.0 */ public interface ToolchainsBuildingRequest { /** * Gets the global toolchains source. * * @return The global toolchains source or {@code null} if none. */ Source getGlobalToolchainsSource(); /** * Sets the global toolchains source. If both user toolchains and a global toolchains are given, the user toolchains * take precedence. * * @param globalToolchainsSource The global toolchains source, may be {@code null} to disable global toolchains. * @return This request, never {@code null}. */ ToolchainsBuildingRequest setGlobalToolchainsSource( Source globalToolchainsSource ); /** * Gets the user toolchains source. * * @return The user toolchains source or {@code null} if none. */ Source getUserToolchainsSource(); /** * Sets the user toolchains source. If both user toolchains and a global toolchains are given, the user toolchains * take precedence. * * @param userToolchainsSource The user toolchains source, may be {@code null} to disable user toolchains. * @return This request, never {@code null}. */ ToolchainsBuildingRequest setUserToolchainsSource( Source userToolchainsSource ); } ToolchainsBuildingResult.java000066400000000000000000000026651317160430700350750ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/toolchain/buildingpackage org.apache.maven.toolchain.building; /* * 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.util.List; import org.apache.maven.building.Problem; import org.apache.maven.toolchain.model.PersistedToolchains; /** * Collects the output of the toolchains builder. * * @author Robert Scholte * @since 3.3.0 */ public interface ToolchainsBuildingResult { /** * Gets the assembled toolchains. * * @return The assembled toolchains, never {@code null}. */ PersistedToolchains getEffectiveToolchains(); /** * Return a list of problems, if any. * * @return a list of problems, never {@code null}. */ List getProblems(); } maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/toolchain/io/000077500000000000000000000000001317160430700261325ustar00rootroot00000000000000DefaultToolchainsReader.java000066400000000000000000000057401317160430700334570ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/toolchain/iopackage org.apache.maven.toolchain.io; /* * 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.File; import java.io.IOException; import java.io.InputStream; import java.io.Reader; import java.util.Map; import javax.inject.Named; import javax.inject.Singleton; import org.apache.commons.lang3.Validate; import org.apache.maven.toolchain.model.PersistedToolchains; import org.apache.maven.toolchain.model.io.xpp3.MavenToolchainsXpp3Reader; import org.codehaus.plexus.util.ReaderFactory; import org.codehaus.plexus.util.xml.pull.XmlPullParserException; /** * Handles deserialization of toolchains from the default textual format. * * @author Robert Scholte * @since 3.3.0 */ @Named @Singleton public class DefaultToolchainsReader implements ToolchainsReader { @Override public PersistedToolchains read( File input, Map options ) throws IOException { Validate.notNull( input, "input cannot be null" ); return read( ReaderFactory.newXmlReader( input ), options ); } @Override public PersistedToolchains read( Reader input, Map options ) throws IOException { Validate.notNull( input, "input cannot be null" ); try ( final Reader in = input ) { return new MavenToolchainsXpp3Reader().read( in, isStrict( options ) ); } catch ( XmlPullParserException e ) { throw new ToolchainsParseException( e.getMessage(), e.getLineNumber(), e.getColumnNumber(), e ); } } @Override public PersistedToolchains read( InputStream input, Map options ) throws IOException { Validate.notNull( input, "input cannot be null" ); try ( final InputStream in = input ) { return new MavenToolchainsXpp3Reader().read( in, isStrict( options ) ); } catch ( XmlPullParserException e ) { throw new ToolchainsParseException( e.getMessage(), e.getLineNumber(), e.getColumnNumber(), e ); } } private boolean isStrict( Map options ) { Object value = ( options != null ) ? options.get( IS_STRICT ) : null; return value == null || Boolean.parseBoolean( value.toString() ); } } ToolchainsParseException.java000066400000000000000000000060741317160430700337020ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/toolchain/iopackage org.apache.maven.toolchain.io; /* * 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; /** * Signals a failure to parse the toolchains due to invalid syntax (e.g. non-wellformed XML or unknown elements). * * @author Robert Scholte * @since 3.3.0 */ public class ToolchainsParseException extends IOException { /** * The one-based index of the line containing the error. */ private final int lineNumber; /** * The one-based index of the column containing the error. */ private final int columnNumber; /** * Creates a new parser exception with the specified details. * * @param message The error message, may be {@code null}. * @param lineNumber The one-based index of the line containing the error or {@code -1} if unknown. * @param columnNumber The one-based index of the column containing the error or {@code -1} if unknown. */ public ToolchainsParseException( String message, int lineNumber, int columnNumber ) { super( message ); this.lineNumber = lineNumber; this.columnNumber = columnNumber; } /** * Creates a new parser exception with the specified details. * * @param message The error message, may be {@code null}. * @param lineNumber The one-based index of the line containing the error or {@code -1} if unknown. * @param columnNumber The one-based index of the column containing the error or {@code -1} if unknown. * @param cause The nested cause of this error, may be {@code null}. */ public ToolchainsParseException( String message, int lineNumber, int columnNumber, Throwable cause ) { super( message ); initCause( cause ); this.lineNumber = lineNumber; this.columnNumber = columnNumber; } /** * Gets the one-based index of the line containing the error. * * @return The one-based index of the line containing the error or a non-positive value if unknown. */ public int getLineNumber() { return lineNumber; } /** * Gets the one-based index of the column containing the error. * * @return The one-based index of the column containing the error or non-positive value if unknown. */ public int getColumnNumber() { return columnNumber; } } maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/toolchain/io/ToolchainsReader.java000066400000000000000000000067131317160430700322320ustar00rootroot00000000000000package org.apache.maven.toolchain.io; /* * 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.File; import java.io.IOException; import java.io.InputStream; import java.io.Reader; import java.util.Map; import org.apache.maven.toolchain.model.PersistedToolchains; /** * Handles deserialization of toolchains from some kind of textual format like XML. * * @author Robert Scholte * @since 3.3.0 */ public interface ToolchainsReader { /** * The key for the option to enable strict parsing. This option is of type {@link Boolean} and defaults to {@code * true}. If {@code false}, unknown elements will be ignored instead of causing a failure. */ String IS_STRICT = "org.apache.maven.toolchains.io.isStrict"; /** * Reads the toolchains from the specified file. * * @param input The file to deserialize the toolchains from, must not be {@code null}. * @param options The options to use for deserialization, may be {@code null} to use the default values. * @return The deserialized toolchains, never {@code null}. * @throws IOException If the toolchains could not be deserialized. * @throws ToolchainsParseException If the input format could not be parsed. */ PersistedToolchains read( File input, Map options ) throws IOException, ToolchainsParseException; /** * Reads the toolchains from the specified character reader. The reader will be automatically closed before the * method returns. * * @param input The reader to deserialize the toolchains from, must not be {@code null}. * @param options The options to use for deserialization, may be {@code null} to use the default values. * @return The deserialized toolchains, never {@code null}. * @throws IOException If the toolchains could not be deserialized. * @throws ToolchainsParseException If the input format could not be parsed. */ PersistedToolchains read( Reader input, Map options ) throws IOException, ToolchainsParseException; /** * Reads the toolchains from the specified byte stream. The stream will be automatically closed before the method * returns. * * @param input The stream to deserialize the toolchains from, must not be {@code null}. * @param options The options to use for deserialization, may be {@code null} to use the default values. * @return The deserialized toolchains, never {@code null}. * @throws IOException If the toolchains could not be deserialized. * @throws ToolchainsParseException If the input format could not be parsed. */ PersistedToolchains read( InputStream input, Map options ) throws IOException, ToolchainsParseException; } maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/toolchain/java/000077500000000000000000000000001317160430700264445ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/toolchain/java/DefaultJavaToolChain.java000066400000000000000000000035251317160430700333030ustar00rootroot00000000000000package org.apache.maven.toolchain.java; /* * 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 org.apache.maven.toolchain.model.ToolchainModel; import org.codehaus.plexus.logging.Logger; /** * Provides backwards compatibility with Maven 3.2.3 and earlier. Clients that do not require compatibility with Maven * 3.2.3 and earlier are encouraged to use {@link JavaToolchainImpl}. * Note: This is an internal component whose interface can change without prior notice. * * @deprecated clients that do not require compatibility with Maven 3.2.3 and earlier should link to * {@link JavaToolchainImpl} instead. */ public class DefaultJavaToolChain extends JavaToolchainImpl { public static final String KEY_JAVAHOME = JavaToolchainImpl.KEY_JAVAHOME; public DefaultJavaToolChain( ToolchainModel model, Logger logger ) { super( model, logger ); } @Override public String getJavaHome() { return super.getJavaHome(); } @Override public void setJavaHome( String javaHome ) { super.setJavaHome( javaHome ); } }maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/toolchain/java/JavaToolchain.java000066400000000000000000000042571317160430700320410ustar00rootroot00000000000000package org.apache.maven.toolchain.java; /* * 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 org.apache.maven.toolchain.Toolchain; /** * JDK toolchain interface. * * @author Jason van Zyl * @author Milos Kleint * @since 2.0.9, renamed from JavaToolChain in 3.2.4 */ public interface JavaToolchain extends Toolchain { // /** // * Returns a list of {@link java.io.File}s which represents the bootstrap libraries for the // * runtime environment. The Bootstrap libraries include libraries in JRE's // * extension directory, if there are any. // * // * @return List // */ // List getBootstrapLibraries(); // // /** // * Returns a list of {@link java.io.File}s which represent the libraries recognized by // * default by the platform. Usually it corresponds to contents of CLASSPATH // * environment variable. // * // * @return List // */ // List getStandardLibraries(); // // /** // * Returns a {@link java.io.File}s which represent the locations of the source of the JDK, // * or an empty collection when the location is not set or is invalid. // * // * @return List // */ // List getSourceDirectories(); // // /** // * Returns a {@link java.io.File}s which represent the locations of the Javadoc for this platform, // * or empty collection if the location is not set or invalid // * // * @return List // */ // List getJavadocFolders(); } maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/toolchain/java/JavaToolchainFactory.java000066400000000000000000000103031317160430700333560ustar00rootroot00000000000000package org.apache.maven.toolchain.java; /* * 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.File; import java.util.Map.Entry; import java.util.Properties; import org.apache.maven.toolchain.MisconfiguredToolchainException; import org.apache.maven.toolchain.RequirementMatcher; import org.apache.maven.toolchain.RequirementMatcherFactory; import org.apache.maven.toolchain.ToolchainFactory; import org.apache.maven.toolchain.ToolchainPrivate; import org.apache.maven.toolchain.model.ToolchainModel; import org.codehaus.plexus.component.annotations.Component; import org.codehaus.plexus.component.annotations.Requirement; import org.codehaus.plexus.logging.Logger; import org.codehaus.plexus.util.FileUtils; import org.codehaus.plexus.util.xml.Xpp3Dom; /** * JDK toolchain factory. * This is a ToolchainFactory Plexus component registered with * jdk hint. * * @author mkleint * @since 2.0.9, renamed from DefaultJavaToolchainFactory in 3.2.4 */ @Component( role = ToolchainFactory.class, hint = "jdk" ) public class JavaToolchainFactory implements ToolchainFactory { @Requirement private Logger logger; public ToolchainPrivate createToolchain( ToolchainModel model ) throws MisconfiguredToolchainException { if ( model == null ) { return null; } // use DefaultJavaToolChain for compatibility with maven 3.2.3 and earlier @SuppressWarnings( "deprecation" ) JavaToolchainImpl jtc = new DefaultJavaToolChain( model, logger ); // populate the provides section Properties provides = model.getProvides(); for ( Entry provide : provides.entrySet() ) { String key = (String) provide.getKey(); String value = (String) provide.getValue(); if ( value == null ) { throw new MisconfiguredToolchainException( "Provides token '" + key + "' doesn't have any value configured." ); } RequirementMatcher matcher; if ( "version".equals( key ) ) { matcher = RequirementMatcherFactory.createVersionMatcher( value ); } else { matcher = RequirementMatcherFactory.createExactMatcher( value ); } jtc.addProvideToken( key, matcher ); } // populate the configuration section Xpp3Dom dom = (Xpp3Dom) model.getConfiguration(); Xpp3Dom javahome = dom.getChild( JavaToolchainImpl.KEY_JAVAHOME ); if ( javahome == null ) { throw new MisconfiguredToolchainException( "Java toolchain without the " + JavaToolchainImpl.KEY_JAVAHOME + " configuration element." ); } File normal = new File( FileUtils.normalize( javahome.getValue() ) ); if ( normal.exists() ) { jtc.setJavaHome( FileUtils.normalize( javahome.getValue() ) ); } else { throw new MisconfiguredToolchainException( "Non-existing JDK home configuration at " + normal.getAbsolutePath() ); } return jtc; } public ToolchainPrivate createDefaultToolchain() { //not sure it's necessary to provide a default toolchain here. //only version can be eventually supplied, and return null; } protected Logger getLogger() { return logger; } }maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/toolchain/java/JavaToolchainImpl.java000066400000000000000000000046341317160430700326620ustar00rootroot00000000000000package org.apache.maven.toolchain.java; /* * 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.File; import org.apache.maven.toolchain.DefaultToolchain; import org.apache.maven.toolchain.model.ToolchainModel; import org.codehaus.plexus.logging.Logger; import org.codehaus.plexus.util.FileUtils; import org.codehaus.plexus.util.Os; /** * JDK toolchain implementation. * * @author Milos Kleint * @since 2.0.9, renamed from DefaultJavaToolChain in 3.2.4 */ class JavaToolchainImpl extends DefaultToolchain implements JavaToolchain { private String javaHome; public static final String KEY_JAVAHOME = "jdkHome"; //NOI18N public JavaToolchainImpl( ToolchainModel model, Logger logger ) { super( model, "jdk", logger ); } public String getJavaHome() { return javaHome; } public void setJavaHome( String javaHome ) { this.javaHome = javaHome; } public String toString() { return "JDK[" + getJavaHome() + "]"; } public String findTool( String toolName ) { File toRet = findTool( toolName, new File( FileUtils.normalize( getJavaHome() ) ) ); if ( toRet != null ) { return toRet.getAbsolutePath(); } return null; } private static File findTool( String toolName, File installFolder ) { File bin = new File( installFolder, "bin" ); //NOI18N if ( bin.exists() ) { File tool = new File( bin, toolName + ( Os.isFamily( "windows" ) ? ".exe" : "" ) ); // NOI18N if ( tool.exists() ) { return tool; } } return null; } }maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/toolchain/merge/000077500000000000000000000000001317160430700266225ustar00rootroot00000000000000MavenToolchainMerger.java000066400000000000000000000062601317160430700334630ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/main/java/org/apache/maven/toolchain/mergepackage org.apache.maven.toolchain.merge; /* * 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.util.LinkedHashMap; import java.util.List; import java.util.Map; import org.apache.maven.toolchain.model.PersistedToolchains; import org.apache.maven.toolchain.model.ToolchainModel; import org.codehaus.plexus.util.xml.Xpp3Dom; /** * * @author Robert Scholte * @since 3.2.4 */ public class MavenToolchainMerger { public void merge( PersistedToolchains dominant, PersistedToolchains recessive, String recessiveSourceLevel ) { if ( dominant == null || recessive == null ) { return; } recessive.setSourceLevel( recessiveSourceLevel ); shallowMerge( dominant.getToolchains(), recessive.getToolchains(), recessiveSourceLevel ); } private void shallowMerge( List dominant, List recessive, String recessiveSourceLevel ) { Map merged = new LinkedHashMap<>(); for ( ToolchainModel dominantModel : dominant ) { Object key = getToolchainModelKey( dominantModel ); merged.put( key, dominantModel ); } for ( ToolchainModel recessiveModel : recessive ) { Object key = getToolchainModelKey( recessiveModel ); ToolchainModel dominantModel = merged.get( key ); if ( dominantModel == null ) { recessiveModel.setSourceLevel( recessiveSourceLevel ); dominant.add( recessiveModel ); } else { mergeToolchainModel_Configuration( dominantModel, recessiveModel ); } } } protected void mergeToolchainModel_Configuration( ToolchainModel target, ToolchainModel source ) { Xpp3Dom src = (Xpp3Dom) source.getConfiguration(); if ( src != null ) { Xpp3Dom tgt = (Xpp3Dom) target.getConfiguration(); if ( tgt == null ) { tgt = Xpp3Dom.mergeXpp3Dom( new Xpp3Dom( src ), tgt ); } else { tgt = Xpp3Dom.mergeXpp3Dom( tgt, src ); } target.setConfiguration( tgt ); } } protected Object getToolchainModelKey( ToolchainModel model ) { return model; } }maven-maven-3.5.2/maven-core/src/main/mdo/000077500000000000000000000000001317160430700202635ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/main/mdo/extension.mdo000066400000000000000000000052611317160430700230040ustar00rootroot00000000000000 extension ExtensionDescriptor META-INF/maven/extension.xml in an extension's jar artifact to precisely control parts of the extension and dependencies to expose.

Notice: this documentation is generated from a Modello model but the code executed is not generated from this descriptor. Please report if you find anything wrong.

]]>
package extension descriptor XML documentation (no java generation) ExtensionDescriptor 1.0.0 extension.xml file.]]> exportedPackages 1.0.0 String * Packages from the artifact that are exposed. exportedArtifacts 1.0.0 String * groupId:artifactId file.]]>
maven-maven-3.5.2/maven-core/src/main/mdo/toolchains.mdo000066400000000000000000000234701317160430700231350ustar00rootroot00000000000000 toolchains MavenToolchains This is a reference for the Maven Toolchains descriptor.

The default location for the toolchains file is ~/.m2/toolchains.xml

A Toolchain is a preconfigured object that Maven plugins can use for tool configuration retrieval (location and other information).

The toolchains-plugin can read available toolchains on the user's computer and match them against the toolchain requirements of the project (as configured in pom.xml): if match is found, the toolchain instance is made available to other Maven plugins.

With jdk toolchain, for example, instead of being stuck with the JDK used to run Maven, all plugins can use the same other JDK instance without hardcoding absolute paths into the pom.xml and without configuring every plugin that require path to JDK tools.

See the Guide to Using Toolchains for more information.

]]>
package org.apache.maven.toolchain.model TrackableBase 1.1.0+ common base class that contains code to track the source for this instance (USER|GLOBAL) 1.1.0+ PersistedToolchains TrackableBase <toolchains> element is the root of the descriptor. The following table lists all of the possible child elements. ]]> 1.0.0+ toolchains 1.0.0+ ToolchainModel * ToolchainModel TrackableBase 1.0.0+ Definition of a toolchain instance. type 1.0.0+
  • jdk for JDK Standard Toolchain,
  • other value for Custom Toolchain
  • ]]>
    String
    provides 1.0.0/1.0.99 DOM Toolchain identification information, which will be matched against project requirements.

    Actual content structure is completely open: each toolchain type will define its own format and semantics.

    In general, this is a properties format: <name>value</name> with predefined properties names.

    ]]>
    provides 1.1.0+ Properties String * Toolchain identification information, which will be matched against project requirements.

    For Maven 2.0.9 to 3.2.3, the actual content structure was completely open: each toolchain type would define its own format and semantics. In general, this was a properties format.

    Since Maven 3.2.4, the type for this field has been changed to Properties to match the de-facto format.

    Each toolchain defines its own properties names and semantics.

    ]]>
    configuration 1.0.0+ DOM Toolchain configuration information, like location or any information that is to be retrieved.

    Actual content structure is completely open: each toolchain type will define its own format and semantics.

    In general, this is a properties format: <name>value</name> with per-toolchain defined properties names.

    ]]>
    1.1.0+ Generated hashCode() and equals() based on identifier also calls its super, which breaks comparison
    maven-maven-3.5.2/maven-core/src/main/resources/000077500000000000000000000000001317160430700215165ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/main/resources/META-INF/000077500000000000000000000000001317160430700226565ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/main/resources/META-INF/maven/000077500000000000000000000000001317160430700237645ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/main/resources/META-INF/maven/extension.xml000066400000000000000000000246531317160430700265340ustar00rootroot00000000000000 org.apache.maven.* org.apache.maven.artifact org.apache.maven.classrealm org.apache.maven.cli org.apache.maven.configuration org.apache.maven.exception org.apache.maven.execution org.apache.maven.execution.scope org.apache.maven.lifecycle org.apache.maven.model org.apache.maven.monitor org.apache.maven.plugin org.apache.maven.profiles org.apache.maven.project org.apache.maven.reporting org.apache.maven.repository org.apache.maven.rtinfo org.apache.maven.settings org.apache.maven.toolchain org.apache.maven.usability org.apache.maven.wagon.* org.apache.maven.wagon.authentication org.apache.maven.wagon.authorization org.apache.maven.wagon.events org.apache.maven.wagon.observers org.apache.maven.wagon.proxy org.apache.maven.wagon.repository org.apache.maven.wagon.resource org.eclipse.aether.* org.eclipse.aether.artifact org.eclipse.aether.collection org.eclipse.aether.deployment org.eclipse.aether.graph org.eclipse.aether.impl org.eclipse.aether.internal.impl org.eclipse.aether.installation org.eclipse.aether.metadata org.eclipse.aether.repository org.eclipse.aether.resolution org.eclipse.aether.spi org.eclipse.aether.transfer org.eclipse.aether.version org.codehaus.plexus.classworlds org.codehaus.classworlds org.codehaus.plexus.util.xml.Xpp3Dom org.codehaus.plexus.util.xml.pull.XmlPullParser org.codehaus.plexus.util.xml.pull.XmlPullParserException org.codehaus.plexus.util.xml.pull.XmlSerializer org.codehaus.plexus.* org.codehaus.plexus.component org.codehaus.plexus.configuration org.codehaus.plexus.container org.codehaus.plexus.context org.codehaus.plexus.lifecycle org.codehaus.plexus.logging org.codehaus.plexus.personality javax.inject.* javax.enterprise.util.* javax.enterprise.inject.* javax.annotation.* org.slf4j.* org.slf4j.spi.* org.slf4j.helpers.* org.fusesource.jansi.* classworlds:classworlds org.codehaus.plexus:plexus-classworlds org.codehaus.plexus:plexus-component-api org.codehaus.plexus:plexus-container-default plexus:plexus-container-default org.sonatype.spice:spice-inject-plexus org.sonatype.sisu:sisu-inject-plexus org.eclipse.sisu:org.eclipse.sisu.plexus org.apache.maven:maven-artifact org.apache.maven:maven-aether-provider org.apache.maven:maven-resolver-provider org.apache.maven:maven-artifact-manager org.apache.maven:maven-compat org.apache.maven:maven-core org.apache.maven:maven-error-diagnostics org.apache.maven:maven-lifecycle org.apache.maven:maven-model org.apache.maven:maven-model-builder org.apache.maven:maven-monitor org.apache.maven:maven-plugin-api org.apache.maven:maven-plugin-descriptor org.apache.maven:maven-plugin-parameter-documenter org.apache.maven:maven-plugin-registry org.apache.maven:maven-profile org.apache.maven:maven-project org.apache.maven:maven-repository-metadata org.apache.maven:maven-settings org.apache.maven:maven-settings-builder org.apache.maven:maven-toolchain org.apache.maven.wagon:wagon-provider-api org.apache.maven.resolver:maven-resolver-api org.apache.maven.resolver:maven-resolver-spi org.apache.maven.resolver:maven-resolver-impl javax.inject:javax.inject javax.annotation:jsr250-api org.slf4j:slf4j-api org.fusesource.jansi:jansi org.sonatype.aether:aether-api org.sonatype.aether:aether-spi org.sonatype.aether:aether-impl org.eclipse.aether:aether-api org.eclipse.aether:aether-spi org.eclipse.aether:aether-impl maven-maven-3.5.2/maven-core/src/main/resources/META-INF/plexus/000077500000000000000000000000001317160430700241765ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/main/resources/META-INF/plexus/artifact-handlers.xml000066400000000000000000000137611317160430700303230ustar00rootroot00000000000000 org.apache.maven.artifact.handler.ArtifactHandler pom org.apache.maven.artifact.handler.DefaultArtifactHandler pom org.apache.maven.artifact.handler.ArtifactHandler jar org.apache.maven.artifact.handler.DefaultArtifactHandler jar java true org.apache.maven.artifact.handler.ArtifactHandler ejb org.apache.maven.artifact.handler.DefaultArtifactHandler ejb jar java true org.apache.maven.artifact.handler.ArtifactHandler ejb-client org.apache.maven.artifact.handler.DefaultArtifactHandler ejb-client jar ejb client java true org.apache.maven.artifact.handler.ArtifactHandler test-jar org.apache.maven.artifact.handler.DefaultArtifactHandler tests jar test-jar jar java true org.apache.maven.artifact.handler.ArtifactHandler maven-plugin org.apache.maven.artifact.handler.DefaultArtifactHandler maven-plugin jar java true org.apache.maven.artifact.handler.ArtifactHandler java-source org.apache.maven.artifact.handler.DefaultArtifactHandler sources java-source jar java false org.apache.maven.artifact.handler.ArtifactHandler javadoc org.apache.maven.artifact.handler.DefaultArtifactHandler javadoc javadoc jar java true org.apache.maven.artifact.handler.ArtifactHandler war org.apache.maven.artifact.handler.DefaultArtifactHandler war true java false org.apache.maven.artifact.handler.ArtifactHandler ear org.apache.maven.artifact.handler.DefaultArtifactHandler ear true java false org.apache.maven.artifact.handler.ArtifactHandler rar org.apache.maven.artifact.handler.DefaultArtifactHandler rar true java false maven-maven-3.5.2/maven-core/src/main/resources/META-INF/plexus/components.xml000066400000000000000000000114241317160430700271070ustar00rootroot00000000000000 org.apache.maven.lifecycle.Lifecycle org.apache.maven.lifecycle.Lifecycle default default validate initialize generate-sources process-sources generate-resources process-resources compile process-classes generate-test-sources process-test-sources generate-test-resources process-test-resources test-compile process-test-classes test prepare-package package pre-integration-test integration-test post-integration-test verify install deploy org.apache.maven.lifecycle.Lifecycle org.apache.maven.lifecycle.Lifecycle clean clean pre-clean clean post-clean org.apache.maven.plugins:maven-clean-plugin:2.5:clean org.apache.maven.lifecycle.Lifecycle org.apache.maven.lifecycle.Lifecycle site site pre-site site post-site site-deploy org.apache.maven.plugins:maven-site-plugin:3.3:site org.apache.maven.plugins:maven-site-plugin:3.3:deploy org.sonatype.plexus.components.sec.dispatcher.SecDispatcher maven org.sonatype.plexus.components.sec.dispatcher.DefaultSecDispatcher Maven Security dispatcher org.sonatype.plexus.components.cipher.PlexusCipher _cipher org.sonatype.plexus.components.sec.dispatcher.PasswordDecryptor _decryptors <_configuration-file>~/.m2/settings-security.xml maven-maven-3.5.2/maven-core/src/main/resources/META-INF/plexus/default-bindings.xml000066400000000000000000000260741317160430700301500ustar00rootroot00000000000000 org.apache.maven.lifecycle.mapping.LifecycleMapping pom org.apache.maven.lifecycle.mapping.DefaultLifecycleMapping default org.apache.maven.plugins:maven-install-plugin:2.4:install org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy org.apache.maven.lifecycle.mapping.LifecycleMapping jar org.apache.maven.lifecycle.mapping.DefaultLifecycleMapping default org.apache.maven.plugins:maven-resources-plugin:2.6:resources org.apache.maven.plugins:maven-compiler-plugin:3.1:compile org.apache.maven.plugins:maven-resources-plugin:2.6:testResources org.apache.maven.plugins:maven-compiler-plugin:3.1:testCompile org.apache.maven.plugins:maven-surefire-plugin:2.12.4:test org.apache.maven.plugins:maven-jar-plugin:2.4:jar org.apache.maven.plugins:maven-install-plugin:2.4:install org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy org.apache.maven.lifecycle.mapping.LifecycleMapping ejb org.apache.maven.lifecycle.mapping.DefaultLifecycleMapping default org.apache.maven.plugins:maven-resources-plugin:2.6:resources org.apache.maven.plugins:maven-compiler-plugin:3.1:compile org.apache.maven.plugins:maven-resources-plugin:2.6:testResources org.apache.maven.plugins:maven-compiler-plugin:3.1:testCompile org.apache.maven.plugins:maven-surefire-plugin:2.12.4:test org.apache.maven.plugins:maven-ejb-plugin:2.3:ejb org.apache.maven.plugins:maven-install-plugin:2.4:install org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy org.apache.maven.lifecycle.mapping.LifecycleMapping maven-plugin org.apache.maven.lifecycle.mapping.DefaultLifecycleMapping default org.apache.maven.plugins:maven-resources-plugin:2.6:resources org.apache.maven.plugins:maven-compiler-plugin:3.1:compile org.apache.maven.plugins:maven-plugin-plugin:3.2:descriptor org.apache.maven.plugins:maven-resources-plugin:2.6:testResources org.apache.maven.plugins:maven-compiler-plugin:3.1:testCompile org.apache.maven.plugins:maven-surefire-plugin:2.12.4:test org.apache.maven.plugins:maven-jar-plugin:2.4:jar, org.apache.maven.plugins:maven-plugin-plugin:3.2:addPluginArtifactMetadata org.apache.maven.plugins:maven-install-plugin:2.4:install org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy org.apache.maven.lifecycle.mapping.LifecycleMapping war org.apache.maven.lifecycle.mapping.DefaultLifecycleMapping default org.apache.maven.plugins:maven-resources-plugin:2.6:resources org.apache.maven.plugins:maven-compiler-plugin:3.1:compile org.apache.maven.plugins:maven-resources-plugin:2.6:testResources org.apache.maven.plugins:maven-compiler-plugin:3.1:testCompile org.apache.maven.plugins:maven-surefire-plugin:2.12.4:test org.apache.maven.plugins:maven-war-plugin:2.2:war org.apache.maven.plugins:maven-install-plugin:2.4:install org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy org.apache.maven.lifecycle.mapping.LifecycleMapping ear org.apache.maven.lifecycle.mapping.DefaultLifecycleMapping default org.apache.maven.plugins:maven-ear-plugin:2.8:generate-application-xml org.apache.maven.plugins:maven-resources-plugin:2.6:resources org.apache.maven.plugins:maven-ear-plugin:2.8:ear org.apache.maven.plugins:maven-install-plugin:2.4:install org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy org.apache.maven.lifecycle.mapping.LifecycleMapping rar org.apache.maven.lifecycle.mapping.DefaultLifecycleMapping default org.apache.maven.plugins:maven-resources-plugin:2.6:resources org.apache.maven.plugins:maven-compiler-plugin:3.1:compile org.apache.maven.plugins:maven-resources-plugin:2.6:testResources org.apache.maven.plugins:maven-compiler-plugin:3.1:testCompile org.apache.maven.plugins:maven-surefire-plugin:2.12.4:test org.apache.maven.plugins:maven-rar-plugin:2.2:rar org.apache.maven.plugins:maven-install-plugin:2.4:install org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy maven-maven-3.5.2/maven-core/src/main/resources/org/000077500000000000000000000000001317160430700223055ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/main/resources/org/apache/000077500000000000000000000000001317160430700235265ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/main/resources/org/apache/maven/000077500000000000000000000000001317160430700246345ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/main/resources/org/apache/maven/messages/000077500000000000000000000000001317160430700264435ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/main/resources/org/apache/maven/messages/build.properties000066400000000000000000000017231317160430700316630ustar00rootroot00000000000000# 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. buildNumber=${buildNumber} timestamp=${timestamp} version=${project.version} distributionId=${distributionId} distributionShortName=${distributionShortName} distributionName=${distributionName}maven-maven-3.5.2/maven-core/src/main/resources/org/apache/maven/project/000077500000000000000000000000001317160430700263025ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/main/resources/org/apache/maven/project/standalone.xml000066400000000000000000000020171317160430700311540ustar00rootroot00000000000000 4.0.0 org.apache.maven standalone-pom 1 pom Maven Stub Project (No POM) maven-maven-3.5.2/maven-core/src/site/000077500000000000000000000000001317160430700175245ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/site/apt/000077500000000000000000000000001317160430700203105ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/site/apt/artifact-handlers.apt000066400000000000000000000101461317160430700244130ustar00rootroot00000000000000~~ 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. --- Default Artifact Handlers Reference --- Hervé Boutemy --- 2013-08-02 --- Default Artifact Handlers Reference Some artifact handlers (see {{{../maven-artifact/apidocs/org/apache/maven/artifact/handler/ArtifactHandler.html} API}}) are configured by default in <<>>: *--------------------+------------+------------+---------------+-----------+---------------------+-----------------------+ || type || extension || packaging || classifier || language || added to classpath || includesDependencies || *--------------------+------------+------------+---------------+-----------+---------------------+-----------------------+ | <<>> | <= type> | <= type> | | none | | | *--------------------+------------+------------+---------------+-----------+---------------------+-----------------------+ | <<>> | <= type> | <= type> | | java | <<>> | | *--------------------+------------+------------+---------------+-----------+---------------------+-----------------------+ | <<>> | <<>> | <= type> | | java | <<>> | | *--------------------+------------+------------+---------------+-----------+---------------------+-----------------------+ | <<>> | <<>> | <= type> | | java | <<>> | | *--------------------+------------+------------+---------------+-----------+---------------------+-----------------------+ | <<>> | <= type> | <= type> | | java | | <<>> | *--------------------+------------+------------+---------------+-----------+---------------------+-----------------------+ | <<>> | <= type> | <= type> | | java | | <<>> | *--------------------+------------+------------+---------------+-----------+---------------------+-----------------------+ | <<>> | <= type> | <= type> | | java | | <<>> | *--------------------+------------+------------+---------------+-----------+---------------------+-----------------------+ | <<>> | <<>> | <= type> | <<>> | java | | | *--------------------+------------+------------+---------------+-----------+---------------------+-----------------------+ | <<>> | <<>> | <= type> | <<>> | java | <<>> | | *--------------------+------------+------------+---------------+-----------+---------------------+-----------------------+ | <<>> | <<>> | <<>> | <<>> | java | <<>> | | *--------------------+------------+------------+---------------+-----------+---------------------+-----------------------+ | <<>> | <<>> | <<>> | <<>> | java | <<>> | | *--------------------+------------+------------+---------------+-----------+---------------------+-----------------------+ maven-maven-3.5.2/maven-core/src/site/apt/configuration-management.apt000066400000000000000000000134531317160430700260050ustar00rootroot00000000000000~~ 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. ----- Maven configuration management ----- The Maven Team ----- Configuration levels in maven In maven configuration control happens on four differ levels: the site level, the group level, the project level, and the user level. On the site level you can configure maven for all users utilizing the local installation, the group level allows configuration management for all the projects that belong to the same group, the project level allows configuration management at the project level, and the user level allows users to override settings on the site level, group level and project level. * Site configuration At the site level all configuration is achieved by tweaking the the various files that are available in the ${maven.home}/site-configuration directory +-----+ ${maven.home} | +--- maven.properties +-----+ * Group configuration As far as properties go for an entire build the maven.properties could be placed at the top of the group but I'm not really sure how this might work. There could probably also be a directory for plugins.xml and maven.properties. * Project configuration At the project level all configuration is achieved by tweaking the POM. One of the differences between maven 1.x and 2.x is that all project parameterization occurs in the POM and not from properties files. For many of the more advanced features in Maven2 it is critical that POMs be available in the local repository. Features like transitive dependencies and the new parent specification mechanism. The problem we run into is that currently we have information about a project scattered across the project.xml and the various properties files. What needs to be done is to encapsulate all of this in the POM. Typically users parameterize the use of plugins, or have custom values like ${user.name} for use in elements like the . It would be idea if we could encapsulate everything we need about the project in the POM including plugin parameters and anything else. We once had a document that Vincent and I agreed upon and I was about to implement it and then I disappeared for 8 months so it never came to pass. So I guess it's important to figure out what people are using properties files for and see if we can't incorporate it all into the POM. Or if we do have properties file (something I would like to avoid) say they don't contribute in any meaningful way to information in the POM. For example a properties file could be used the specify $ so it can be interpolated in but you couldn't use a properties file to specify the version of your project say. Anyway, food for thought to begin with. - elements that are critical for pom dissemination - those that are used locally by the user like * User configuration User configuration which is utilized site wide are controlled with the ${user.home}/.m2/maven.properties. User configuration which is utilized at the project level are controlled with the ${project.home}/maven.properties file. Plugin configuration The configuration of plugins is of the same form as the maven {{{plugin-descriptors}plugin descriptors}} themselves: +-----+ xdoc 1.0 theme classic +-----+ Unified source directory Unified source directory structure that is analagous to the repository itself. This way locations of intermediary artifacts of a build would be in a known location. This would also help with developer setup i.e. getting new developers up and running. They could run a maven command and have all their source trees set up in the same way as their colleagues. here's what I do currently in the netbeans part of the mavenide project to find the relevant subprojects/sibling projects. I check if the user has defined the maven.multiproject.includes property in any of his properties files for the current project. if yes. then I'm able to find projects that can be offered to be opened together with the current project. problems with the current solution are: 1. information is duplicate. once in POM's dependencies and once in the maven.multiproject.includes property. 2. it works without problems only for projects with relative paths, e.g., from one CVS repository.. for projects from multiple SCM repositories it's harder to maintain the same relative links on all developer computers. not sure the unified source directory structure addresses this issue. Properties maven.user.config.dir (system,default=${user.home}/.m2) maven.home (system,user,default=${user.home}/m2) maven.repo.local (system,user,default=${maven.user.config.dir}/repository) We need to define what happens in the when things are not setup correctly o ~/.m2 directory does not exist o ~/.m2/maven.properties does not exist o if they once existed but now to do not exist o what the installer will take care of of what we can recover from maven-maven-3.5.2/maven-core/src/site/apt/core-extensions.apt.vm000066400000000000000000000021251317160430700245640ustar00rootroot00000000000000~~ 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. --- Maven Core Extensions Reference --- Hervé Boutemy --- 2016-06-25 --- Maven Core Extensions Reference Maven core provides default extensions as defined in <<>>: %{snippet|id=core-extension|file=${project.basedir}/src/main/resources/META-INF/maven/extension.xml} maven-maven-3.5.2/maven-core/src/site/apt/default-bindings.apt.vm000066400000000000000000000043511317160430700246610ustar00rootroot00000000000000~~ 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. --- Plugin Bindings for Default Lifecycle Reference --- Hervé Boutemy --- 2013-08-02 --- Plugin Bindings for <<>> Lifecycle Reference The {{{./lifecycles.html}<<>> lifecycle}} is defined without any plugin binding; plugin bindings are defined separately in <<>> because they are specific for each packaging: %{toc|fromDepth=2} * Plugin bindings for <<>> packaging %{snippet|id=pom-lifecycle|file=${project.basedir}/src/main/resources/META-INF/plexus/default-bindings.xml} * Plugin bindings for <<>> packaging %{snippet|id=jar-lifecycle|file=${project.basedir}/src/main/resources/META-INF/plexus/default-bindings.xml} * Plugin bindings for <<>> packaging %{snippet|id=ejb-lifecycle|file=${project.basedir}/src/main/resources/META-INF/plexus/default-bindings.xml} * Plugin bindings for <<>> packaging %{snippet|id=maven-plugin-lifecycle|file=${project.basedir}/src/main/resources/META-INF/plexus/default-bindings.xml} * Plugin bindings for <<>> packaging %{snippet|id=war-lifecycle|file=${project.basedir}/src/main/resources/META-INF/plexus/default-bindings.xml} * Plugin bindings for <<>> packaging %{snippet|id=ear-lifecycle|file=${project.basedir}/src/main/resources/META-INF/plexus/default-bindings.xml} * Plugin bindings for <<>> packaging %{snippet|id=rar-lifecycle|file=${project.basedir}/src/main/resources/META-INF/plexus/default-bindings.xml} maven-maven-3.5.2/maven-core/src/site/apt/getting-to-container-configured-mojos.apt000066400000000000000000000102331317160430700303260ustar00rootroot00000000000000~~ 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. --- Getting to Plexus-configured Mojos --- John Casey --- 29-April-2005 Abstract We're moving toward integrating mojos as first-class plexus components, while at the same time avoiding introducing required plexus dependencies into the mojo development model. In order to really achieve this, we need mojo configurations (which are provided both in terms of static expressions that are just looked up, and in terms of user-provided configuration from system properties or the POM). If these mojos are to be first-class components, the configuration from these various sources must be consolidated and injected using the container. Currently, mojo configuration is done externally to the container, in the DefaultPluginManager in the maven-core API. In order to get from here to there, we need to do several things to add capability to the default configuration of plexus. This document will detail those changes. Container Enhancements * ExpressionEvaluator Currently, the expression evaluator used to resolve configuration values is the DefaultExpressionEvaluator, which is a local variable within the implementation of the BasicComponentConfigurator. This ExpressionEvaluator simply returns the expression itself as the resolved value, which adds very little value to the container. Things like ${project.build.resources} are not resolved, and result in a type mismatch for the member injection. We need a replacement for DefaultExpressionEvaluator that is capable of traversing an object graph and extracting Object values, not just Strings. * ComponentConfigurator Currently, the container uses BasicComponentConfigurator, to configure components. This wouldn't be a problem, except for the local instance of DefaultExpressionEvaluator used within. See the above discussion for more on why this evaluator is bad. We need to provide either an alternative implementation under a different roleHint, or else replace the BasicComponentConfigurator. * Other We may need to define a new lifecycle/phase to contextualize a mojo right before it's used, and reset it's state afterward. Up to now, the approach of most plexus components has been to avoid instance state like the plague. With the current parameter passing model of mojos, this will not be possible, particularly when we move mojos to a singleton instantiation model, and then run a reactorized project...the successive calls may leave behind configuration artifacts from invocation to invocation. Maven Modifications * DefaultPluginManager s/getMojoConfiguration()/getConfiguration()/g That should re-enable usage of mojo configuration. Ideally, we won't need any of the code that references this method, since the container should provide some way of recontextualizing the mojo, and all we would need to do is inject POM configuration via the lookup method or something. * PluginDescriptorBuilder s/getMojoConfiguration()/getConfiguration()/g That should be all there is to it. * MojoDescriptor Remove set/getMojoConfiguration(..), as it will become obsolete. * MavenSession We may need to enable the context injection here, since this will be instantiated per-project. If we always inject the same context parameters, and are careful to inject nulls where things are missing, we should be able to minimize reconfiguration artifacts injected from basic parameters. maven-maven-3.5.2/maven-core/src/site/apt/index.apt000066400000000000000000000100461317160430700221260ustar00rootroot00000000000000~~ 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 ----- 2013-07-27 ----- Maven Core Maven Core classes managing the whole build process. * Reference Documentation * {{{./lifecycles.html}lifecycles}} and {{{./default-bindings.html}plugin bindings to <<>> lifecycle}}, * {{{./artifact-handlers.html}default artifact handlers}}, * {{{./extension.html}extension descriptor}} and {{{./core-extensions.html}core extensions}}, * {{{/guides/mini/guide-maven-classloading.html}classloader hierarchy}} done by <<>> component ({{{./apidocs/org/apache/maven/classrealm/ClassRealmManager.html}javadoc}}), with its <<>> implementation ({{{./xref/org/apache/maven/classrealm/DefaultClassRealmManager.html}source}}), using {{{https://codehaus-plexus.github.io/plexus-classworlds/}Plexus Classworlds}}, * Useful entry points * <<>> component ({{{./apidocs/org/apache/maven/Maven.html}javadoc}}), with its <<>> implementation ({{{./xref/org/apache/maven/DefaultMaven.html}source}}), to drive a full <<>> execution ({{{./apidocs/org/apache/maven/execution/MavenSession.html}javadoc}} * <<>> component ({{{./apidocs/org/apache/maven/project/ProjectBuilder.html}javadoc}}), with its <<>> implementation ({{{./xref/org/apache/maven/project/DefaultProjectBuilder.html}source}}), * <<>> component ({{{./apidocs/org/apache/maven/plugin/MavenPluginManager.html}javadoc}}), with its <<>> implementation ({{{./xref/org/apache/maven/plugin/internal/DefaultMavenPluginManager.html}source}}), * {{{./apidocs/org/apache/maven/plugin/PluginParameterExpressionEvaluator.html}PluginParameterExpressionEvaluator}}, used to evaluate plugin parameters values during Mojo configuration, * <<>> component ({{{./apidocs/org/apache/maven/exception/ExceptionHandler.html}javadoc}}), with its <<>> implementation ({{{./xref/org/apache/maven/exception/DefaultExceptionHandler.html}source}}), use to transform exception into useful end-user messages. * Toolchains * {{{./toolchains.html}Toolchains descriptor reference}}, * public API for toolchains-aware plugins: <<>> component ({{{./apidocs/org/apache/maven/toolchain/ToolchainManager.html}javadoc}}) with its <<>> implementation ({{{./xref/org/apache/maven/toolchain/DefaultToolchainManager.html}source}}), to get selected <<>> ({{{./apidocs/org/apache/maven/toolchain/Toolchain.html}javadoc}}) instance, * internal <<>> component ({{{./apidocs/org/apache/maven/toolchain/ToolchainManagerPrivate.html}javadoc}}) with its <<>> implementation ({{{./xref/org/apache/maven/toolchain/DefaultToolchainManagerPrivate.html}source}}), to manage toolchain selection, * internal JDK toolchain implementation: <<>> interface ({{{./apidocs/org/apache/maven/toolchain/java/JavaToolchain.html}javadoc}}), with its <<>> implementation ({{{./xref/org/apache/maven/toolchain/java/JavaToolchainImpl.html}source}}) and <<>> factory ({{{./xref/org/apache/maven/toolchain/java/JavaToolchainFactory.html}source}}). maven-maven-3.5.2/maven-core/src/site/apt/inheritance.apt000066400000000000000000000070431317160430700233130ustar00rootroot00000000000000~~ 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. ----- Inheritance in Maven ----- The Maven Team ----- Inheritance in Maven In order the understand how inheritance works in Maven there are a few notions that you must be familiar with: * The maven super model * how parent poms are processed * the order in which elements in the POM are overridden * minimum element-set for a valid project pom Maven super model Inheritance is recursive in Maven but there is a special model which is the implicit super parent in the lineage of models you may specify: all of the models that you specify are collected to produce a lineage and then the super model is place at the top of that lineage to provide default values. The super model is where we place all the values which we believe to be standard, values that can be shared and utilized across all your maven projects. +-----+ m0 <- m1 <- m2 +-----+ which is transformed into +-----+ super model <- m0 <- m1 <- m2 +-----+ +-----+ 4.0.0 +-----+ Extending the POM in the future In order to anticipate changes in the structure of the POM as new releases of maven occur, the maven inheritance model must be pinned against a particular modelVersion. This is required so that a change from modelVersion 4.0.0 to 4.1.0 doesn't cause compatibility problems with users who have not upgraded their projects. It also allows for a certain amount of legacy support into the future. Therefore, we should rename this file from pom.xml in the maven-core jarfile to pom-4.0.0.xml (and successive revisions to the base pom made to accommodate changes in the model will be named accordingly - 4.0.1, 4.0.2, ...). Minimum Element-Set for a Project POM In order to furnish a basic set of information which we need to distinguish one project from another, maven requires a minimum set of elements to be specified in each project's pom.xml. - [modelVersion] tells maven which version of the object model this project is compliant with (to support future legacy concerns) - [artifactId] tells maven what the artifact name is for this particular project. Each project should have a distinct artifactId. - [version] tells maven what release of this artifact we're trying to produce. The fact that a project has a distinct pom.xml should indicate a separate release cycle that is also distinct to that project, so a concrete version declaration is required. - [name] tells maven what the user-friendly name of this project is. The name element is similar to artifactId in that it is a unique descriptor for this and only this project, and therefore should be concretely defined. maven-maven-3.5.2/maven-core/src/site/apt/lifecycles.apt.vm000066400000000000000000000032171317160430700235640ustar00rootroot00000000000000~~ 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. ----- Lifecycles Reference ----- Hervé Boutemy ----- 2013-08-02 ----- Lifecycles Reference Maven defines 3 lifecycles in <<>>: %{toc|fromDepth=2} * <<>> Lifecycle <<>> lifecycle is defined <> any associated plugin. Plugin bindings for this lifecycle are {{{./default-bindings.html}defined separately for every packaging}}: %{snippet|id=lifecycle|file=${project.basedir}/src/main/resources/META-INF/plexus/components.xml} * <<>> Lifecycle <<>> lifecycle is defined directly with its plugin bindings. %{snippet|id=clean|file=${project.basedir}/src/main/resources/META-INF/plexus/components.xml} * <<>> Lifecycle <<>> lifecycle is defined directly with its plugin bindings. %{snippet|id=site|file=${project.basedir}/src/main/resources/META-INF/plexus/components.xml} maven-maven-3.5.2/maven-core/src/site/apt/offline-mode.apt000066400000000000000000000252171317160430700233710ustar00rootroot00000000000000~~ 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. --- Offline Mode Design --- John Casey --- 08-April-2005 --- Offline Mode Design * UPDATE: 18-April-2005 We cannot take the approach outlined below of detecting which remote repositories are "really" offline, since offline mode is more of a behavior, and this will lead to counter-intuitive results. A different feature may exist unimplemented, which is to detect when the network is down and provide better feedback for that case. However, when offline mode is declared, nothing earmarked as remote should be accessed, regardless of whether it is actually a physically local resource. NOTE: One side-effect of this design change is that all offline-mode code can be isolated to maven-core, maven-plugin-descriptor, and [possibly] maven-artifact. Usage of maven-wagon will be determined by an offline-aware manager. * Assumptions: What is Offline? For the purposes of determining the areas sensitive to offline status, it is definitely useful to define what the offline state really means. [[1]] This is obvious, but the network/internet is unavailable. [[2]] Localhost (127.0.0.1) may also be unavailable if the whole network stack is offline. [[3]] "Remote" repositories referenced using the file:// protocol may be available. However, if that file:// url references a file-share, as in the case of an NFS or SMB mount, that will be unavailable. So, offline mode has several implications, some of which may not be altogether obvious: * Localhost may be unavailable. Therefore, even locally installed server processes which work by conversing over a port may fail. * Not all "remote" repositories will fail. Specifically, if the remote repo uses the file:// protocol, and it doesn't refer to a shared filesystem, it will continue to be available. The question remaining is: Which level of offline mode will we support? It seems reasonable to assume that users will be able to tell when localhost is not active (in most cases, localhost should be available, even if the rest of the network is not). Therefore, let's concentrate on the state where no network exists, and leave the more extreme state to users to diagnose and correct as necessary. * Why is Offline Mode Important? Offline mode is essential for breaking the requirement that m2 operate in a network-connected environment. It means legitimizing a development environment in which there is no network connection, and providing a robust m2 service offering in such circumstances. Introduction of offline mode allows m2 to anticipate the inevitable network failures that accompany being physically disconnected from the network, and adjust it's behavior accordingly. It is more than simply understanding that m2 cannot go and check for the latest version of some snapshot artifact. If m2 is offline, SCM operations cannot succeed; no artifact downloads can take place, regardless of whether they are snapshot versions; artifact deployment cannot take place; certain types of tests cannot be setup, since the container used to run them cannot be reached or started. All of these operations will produce their own unique errors in the absence of a coordinated offline strategy. In addition, efforts to unite these failing behaviors behind a consistent user interface is much, much more difficult if the system can't tell whether it has access to the network required by these operations. Offline mode really means anticipating a lack of network connectivity, and as a result turning off certain services provided by m2 and providing a coherent way of predicting and reporting when network-related failures will take place. It means warning users that since the network is missing, certain features and operations will be unavailable, rather than simply waiting for those operations to fail, then trying to help users decipher the error messages they get as a result. * Implications for Resolution ** Dependency Resolution This one is obvious...we only have access to the repositories using the file:// protocol and living on a truly local filesystem when offline. ** Plugin Resolution This is similar to dependency resolution. Plugin repositories not using file:// or not residing on a local (not shared) filesystem will be unavailable. * Implications for Mojo Execution ** Deployment mojos The concept of deployment is dependent on the availability of a some remote repository. Just as above, if that repository is not using file:// (which is highly likely to be the case), or the repository is not on a local filesystem, deployment will fail when offline. ** Testing mojos This can be a problem if the tests are more than simple unit tests; that is, if they require configuration of a server process, and subsequent testing in-container. Since we're only going to concern ourselves with states where localhost is still active, we only need to worry about this case when the server container is <> installed on localhost. This allows the popular pattern of starting a server container in-JVM, running tests against it, and shutting it down. ** SCM mojos See below for discussion on SCM-related operations. Any mojo which carries out some analysis or other interaction with a SCM system will likely be unavailable when in offline mode. * Implications for Subsystems ** Maven-Wagon Parts of Wagon will continue to function normally. These include: * The file wagon, provided the referenced location is on a local filesystem. It is not possible to determine whether a file-based location will be available except on a case-by-case basis (or a root-url by root-url basis). We may want to move the offline sensitivity entirely to Maven-Artifact, below, so we can be smarter about testing filesystem-based repositories, etc. * If not otherwise specified, all other wagons are assumed to be remote-only, and are therefore sensitive to offline mode. ** Maven-Artifact This is wholly dependent on Maven-Wagon, above. We could possibly use a flag on a particular Wagon to see whether it supports offline mode, and then test to see if the file-based basedir for an artifact repository works...if it doesn't work, we can mark that repository offline... OTOH, all offline-mode checks can probably be run from Wagon-based APIs. ** Maven-SCM In all but trivial examples, SCM operations cannot complete without having access to the versioning server. Therefore, it is assumed that any SCM-related activity will be unavailable when m2 is in offline mode. ** Maven-Core We'll examine the different parts of maven-core on a case-by-case basis, below: *** DefaultLifecycleExecutor When binding goals to the project's configured lifecycle, each mojo descriptor should declare whether it requires online/offline status. This value should be a java.lang.Boolean, so it can implement 3VL (three value logic: yes, no, don't-care). The requiresOnline field in the mojo descriptor has the following semantics: [true] Online status is required for this mojo to function correctly. [false] <<(Default)>> Either status is acceptable for the mojo to execute. It doesn't care. The majority of mojos will leave the requiresOnline == false, since online/offline status will be irrelevant, provided they have access to their required artifacts and other classpath elements. In the case of required artifacts and other classpath elements, this is assumed by the mojo API to be in a correct state, and will be handled by the Wagon modifications. * Implementation Notes ** Accessibility of offline status Offline status should be indicated in the MavenSettings instance, since it can conceivably be set from either the settings.xml or the command-line. In the event the '-o' switch is the impetus for setting offline mode, this should result in modification of the active profile in the MavenSettings instance, just as definition of the active profile from the command-line should result in similar modification. This object is not meant to be static within the build process, but rather to be setup as an aggregation of all settings-related information passed into the system. ** Control over downloads Find the control point for m2 using maven-wagon. At this point, inject a offline status parameter which is used when retrieving the specific Wagon. If <<>>: * If the wagon is not bound to "file://", then ignore the request and print a debug message. * If the wagon is bound to "file://" then: Retrieve the file or base-url file to be "downloaded". * If the file (or more usefully, the base-url file) exists, proceed. * If the file (or base-url file) doesn't exist, assume that this location is part of a file-share. Ignore the request and print a debug message as above. ** Control over mojos in the lifecycle When binding a mojo to the project's lifecycle instance, check the mojo descriptor's requiredConnectivity field. * If <<<(offline == true) && (requiresOnline != true)>>>, bind the mojo to the lifecycle. In this case, the client is <>, and the mojo does not require online status. * If <<<(offline == false) && (requiresOnline == true)>>>, bind the mojo to the lifecycle. In this case, the client is <>, and the mojo either requires <> status, or else doesn't care. * Otherwise, don't bind the mojo. Log a debug message to indicate that it is sensitive the the online state of the application, and that this state is currently wrong for execution. <> Do we want to fail when we cannot bind a mojo to the lifecycle because of offline/online status? That would probably indicate that the user was trying to do something they cannot succeed at for now...so we probably should throw an exception in this case. maven-maven-3.5.2/maven-core/src/site/apt/plugin-execution-isolation.apt000066400000000000000000000044011317160430700263130ustar00rootroot00000000000000~~ 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. ----- Maven plugins ----- The Maven Team ----- Maven plugin execution isolation Maven2 takes advantage of Plexus' ability to execute a component using a ClassWorlds ClassRealm that is populated with the JAR containing the component in question and all of its dependencies. Using ClassWorlds notation for realms we have the following: +-----+ [plexus.core] ^ | [plexus.core.maven] ^ ^ | | [plugin0] [plugin1] +-----+ The <<>> realm contains the resources required to run any plexus application; The <<>> realm contains all of the resources required to run Maven. Each subsequent plugin realm contains the JAR plugin as well as its dependencies. The realms noted above are setup in a hierarchical structure where the resources in the parent realms are available but the <>. Plugins are guaranteed to be provided the resources found in <<>> and <<>> realms at run-time if required. Plugins can state compile-time dependencies on any of the resources found in the core realms listed above and these dependencies will be included in the plugin descriptor that is generated but when running within Maven these resources will be filtered out. In other words these resources will not be added the realm created for the plugins execution as they are provided in the parent realms. maven-maven-3.5.2/maven-core/src/site/resources/000077500000000000000000000000001317160430700215365ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/site/resources/design/000077500000000000000000000000001317160430700230075ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/site/resources/design/2.1-lifecycle-refactor-class-diagram.png000077500000000000000000001124101317160430700322640ustar00rootroot00000000000000PNG  IHDRRriCCPICC Profilex_Lo?e$R: %Jcw5vW33sͥ+ %R$JWW)re@\ޠqqf_So}o>k^}ù_g  R@sH G~R NA1| HbCz%P]r!l7dC" Pw qS h9 KA%ny d6CP.g7`g-zr歇ƷFU ƦZ0ԜO~؇4\P"?pv NKC1MVú6]c Ȋz@=-e@$d]H==M}:#fpSe v2=]sABP{2 ]&sFD!DEťF*ǐ8pа2I_(d{L$:^}s^}G]\N@V'ԏRBREbPB"11N\9D%EFNf\I TyGSi~[UgB:OCky]#y<z`UHT<ǯE2Pz\}cEUDƇ IDATxyxTdg Y;eNJA"uC֥X-`Q\ڟ.X\ŶP)TQ$" [XǙ3 $ܯ:L̜L΁yaP """"-)Õ VuE/"""^"㾄/7/"""ܰ X"Eݔ o EDDDB/"6p?0܃\ -(d f""""Rdn 둾  8A>/Hhvg@41;1%r bbb u9axX Z!v """"% n( ĝ͆?/QQQ׏_~o#h=cvZlԩffVZ5޽M4VZٜ9s dܹEGG`+WիW`'O63$zY= qƙ?nu]VJȰӧ[ݭ[nVN33k۶U^ƍg-[46nXLb 6̆ ߿%&&Ztt5h&Md]r%֯_?lƌffVvmZ_ÅW}}@ B#"""ֲO^uќ/dj׮# ,Y¦Mz3gl|INN>VZYZO<|ŋ{ˇ}&ӄB!HhgqќX6lHǎyذaC*l27nLٳgoܸ1ժU !!'OfyAԩS+Wg DGGsmQV-͛8x ~ ={6UT[ooѣtVZݻwuV*UD||,Æ cر\}՜wy.g+-ǀH9pf#it.qGZZݻ7/>;yy^>|EFFZjjjղk.;}t_wۿu؊+IHH+"kSRRB3̷y=1PB|qSx32Vب(jժcݻ2d-Z 223h *UTbԫWXRJu̙3sһwo֮]Çkr6ח}^pHh}+\ܧ P X!~+VÇӦMNTTi NMMe|gTR~8NIx<Á@*p8 Ni@F~(;u-%ֽ5/QFFEDDDB+{hN x /dByB#"""Zlu ٿK^DDD$tw+} """"/0I%3N """"edvC\Af/B#"""q+O~|/"""Z bTx/f)C=iM/x\|ʾ4pY^DDD$X7e_>̙h EDDDƒЖ#%(H-Q%Q'ԥx<__quW =/=H-U|KE"QopEp·-u E^DDD$θ/ 8 qº4[WZ+@3TRyg_ '}izH]iEDDDBNj[|ﶲޣ}J ?|ξC!a< 3iO%3>{ |!^^DDD$ܩ8&>v %EGcqB|p 5XWQqϦ_[O _CEDDDBmyiu[ݩޣ|) >pNݧq|Hx/YDٗhΐ/|EDDDB/{ON?|`x?S?8i@q@=/DUqa:ξuv)l4 """"Z~vi<{^8ۀ8! T'Hå[Zs¸-|Q`=-(Έ91/@<_:/"""""aZ`qY u"""""RA 6ԅg*""""r08Jɓhs>N9""""" x@REDDDDD 0q) tT < Ng𪈈C]gTJOٸxh[刈H^bqڰE'J%^Z`q!"OB#""""u30k|WµH>t-s7l9"""""?τ)gv.DDDDDD k`M,ZDDDDDq|n"N_y ] +|%2pax9[w$S~Pjs`S rQ.O"""""B24|pEC>\S"""" |"D u""""R~ Mp (RT"R47E7 A""""4M P.dR/ /"""IWa- /"""oC]H~jC]_kpi"?) x( ˡZ߭HfuRlg<Ol( PRx [x+x^B]FR.x [?uڲe .,^|EƌS/RzYj;wu)zXlY__g|`Gk0ff1VJz-ܹuŞ}YKJJ233k3f̰-[Z-_73T߿͚5ڵkgɶd33mر#ؕW^iff+V޽{[n433;qy睖h]ty晙Yzzs=vXv33)SXBB5l><33ۼy]z֬Y3:ulҾR}hB9H u"""… QF[oٳrvWٴil_ڇ~hqqq?-""۾}M0.331c%$$7lV-[XRR۶i&k۶=SffvUW~;۾}M4a̙v-؎;lVfMzk.T}v"""r+W䧟~/sμ ڵv矩]6_}o>L:uXz5*)))[|{;v￟k('f֨Q?Ox^nϏ?H5СY_bb"3gdܹ9>ӹF>EDD$֮]Kbb"|%;v`tԉW^y &0ydZԩST^իW3tPv|M RSSIIIuѸqc֯_ѣGV^z) ꫯHHH?fbΜ94mڔ_ߚ5kС~n?jo㦛n*_aX,4/"""!Ϟ={ؿ?gΜ/ > TR۷o' 55͛7c;̙ѣYv-\p*To8q,X@>}x… 9~xk l u"""9rZjeժUf͚ȑ#k53[bb5kjժeƍ4[|5lZnm;v$;w=SYE]dUV͛[޽m۶mffgY||%''[_M~R/(ЈHXYv-m۞_|1cXAQ%lo˖-,\0U>RW_ѥK_|O_}Uj׮͊+juklٲ W%e]wP!"""Frٲe6zh{I&6|p[z6lhf?߶>}X lԨQvi332e v36o<ܹܹ3vכW]/== ]vsi&m vWmʔ)` 6O?4\= _SZ||="""sζtRsffm6ҥkҤ-Y̺vj͚5G}c:u\`6m23iӦـ/?T[=C|rԩةSԺ{nKLL?RSS;1c޽{mѢEc)))?XTT]tEoͫ7sL[lǎ`Yy^ۻwթS^yۺu?خ]RJ^z˟^P!"""+UW?lf΅[t>}w}g[n͛ۢE,--죏>ro=lcf΅4ibwӦMmٲeOu]_?eرcZo*U ۻw%%%h"7o%&&Zjjjmd7lɒ%v zxbZy^mر6|KIIjժ^x\FDDDm͚5L8 6P~}7|C6m8pO<} 4`ӦMtЁ;K/uqq~ibbbU/v]vILLd̙̝;׿>...k֬}DDDO2l0bbb03RSS[.seȑTT)6כW]k~^[r?RF :t}>}bO۷(vBX+h) 7 jТ/i8W$"RD {f:uy <[o]vSOQ~}j֬ɚ5kK.o{xb&L@JJ )))lݺ}QfM~x ;:Yzu.]-Zкu#6W]͚5~/2fbΜ9ݻ/:pGۜ?>Of͚5_zÅ|pg4n6ݺu ߹sYZZ}VfMիn]֣GkڵkgW63?e?_YfVV-7nwmZjeFUڙ3gr۸qc[n9TTZliM6{׼^޽ֳ^f IDATo~uɓVZֻwovW?l֮];ffv7[bbܹKxO (g] .`iɶlE),8xI8@ Eq)lBzQFRRRTRiܸ1+W.R-+О={\2񤧧sQW8|J*Y^saUvxr,QKútyv~u-%,=>!V&""VДՀud 'BSB]Hy\q)- -l1D5Js|p< T u!""r΋3k7>"e|p]""r3M`O'k_^DŒW4KDD~`oqtq%8!?]p# IعHfs|pi)സͶrA)/#gk/U+Y.\\ ""R[.Z[ЙsEs K)P#,{'ٺ~1)QJH,pW Wjis߲ `]e^:?3oGg˪d` F-0gTCN΋QCA-xշa+̭p.<~g)+vK^DDx|+`?w[Z.F%B{.<C]H'QED$T#Ũ. Q A}B .01ԅA<%y0Eqߓ`:[9r7"""-j~1bǕGy.f@G: e"D,"<cC]HY7 }#ssR=P]28=76`> 0O93!-D v;D<Сq8;b ]%g_z-:p۷+`]К`%Nk}*_*%!N+'8}qnfW[)$z)S'{pPKBp.X[/""R$szz9< NWG}yʧ<k( {!22;ޣ*DxLo9#*)sڵZo!Cm%#..&ۆ 8q"M6y*yf&""R^4LGqzŹJ*miPR4jԈ[nTΝѣ0`@ж_^=MFϞ=ͳzz&RU V ՠŋtRlmUIKKcĉ4jԈ-Z0uT97πx;޽;`޼ytޝ%K3ЦMڶm<9?L<ٿ\uUl۶^z[z-z믿… ԩueСY; ѣϻkزe SL=s4oޜ*UЧO[߽{w|M O?M!T$h ?ǕH}3M_Lh~Wb98q"_yGz̙3'f/祗^{lذÇ3|YkҬY3Fm U_MϞ=R -[g0uqEQ~}.bf͚lѢEtԉ-Z;dΝ;+]6={dҥ@Kq0p6?l 807nlZ;wW_m]r%'ؤI?1c <4h5l[`͘1;w9Ң_~ٳg`mڴ}`#G43dk۶Y{`7|;ֿl޼̮zխ[ג,55վ[&M_oqqqֵkW3|VujҤj~-]vZ̙cկ_߮Z5jؑ#GlXժU-**ʞ{<9̷ou=߾;ԅFDDʣbgHMM5_`=]:uj9 99:wlʕ+mɓ,))ɢ^z֣Glܸqff`fQjժkÇڵk`33mZmܸqֲeKlƍvIPEDDXRJؘ1c,##ڴic+VQFYÆ -..6o\R㶺\!:B73倩W%''رcVV-kѢ߿o~cff۷o^y۱cv-Y:uK.13~üرcmf5f>d33۷o%$$XLLpB330a_؉'[o5֯_o]C}|Yٳy<۷oM>tɶlR؃o|ǀTDD)v)7WP6mjj2mƍE 7pUX!!:qfꩧ ۷`̙36sL[t۷n&??{lڴig`8qŸ?9ayRtiii޽3RJfǎip{tڕEw߱gBIHH&Ey@ZjHLLdL4 /.^xal߾Pu֭[iҤ tݿE 4n=F~w3gHW 66 K~}o_RayJbk`_htӠAϟ屚5kՇߦ]vtޝCrhѢ+Wowӌ9P(iN8k8}W\InݨQ| III׮];ߺ*TS4l0ךj֬ɶm8}4|)|ɓ'C”)SbѤѷo_^}UvͭJ߾}ȷd6n̙3;*>""R WS b |~ȑ#6tPPoކjZ*>dff۷:uYfo[3sc:t?~ `UX~`ӦM33|>ff}u~;KKK+r~)0ۃ;#gxX ^ѣ/$%%W̙3lݺ:uOFܹsٽ{w̌;wAƍgm6?,]p+==RV\Kρػw/M62W}Q>p p 8=¹ĴHyq7r)r_~ɾ}⋉cܹ9r$˸`8u۶mN:n®~5k4;w$>>4c vř=+&s޽{QFOHd;S`al,_>|Ç*'س@>&At7nK<@:9HlY\Z=6zO/}~8fW|] fxtON29:i=QDD1wo?_er'3OIuq?\ՅlӟODD xX3I*<炰< ހû+}EH~3'+;* MD}s\/"Rx}[ݟyay9xsG MY/"R<<箰<:cyJ߾f:K)cyMayuׁ\kBS^DxyMay݅&,֑REDG6$.xw)~ E^Dpopnvs. ~q?T:3ǐ9*[P):q ~[p.u V$[^!a2X ݗCXED gN`¹h+ɷkJ4)%dͷ.C+o~Xѭ-_?@)ZED[(Hfo(Gnt:>y``8±8ke0_tSߺn bD/rRB*rΓ8l*|w{ҷpڷd8A ΁=) w.DDEqgg)o ু)' MRyJMxqJ/`|N|Xgo] Жap_ + >4g&7Owp˷ n2CC@'_큡~5?)B]H 7mQs{50w{m-*/;K<<'W<&}iu)>̖t0ρ8jF w94O,:_Xa޷=umd3XLP>h7U1'3:_E4~6єs5ΙHPnT):<8!=q{n+Qה9\Lo5Yn=8{@m9ͷ9Qq8n7qBF|ڪN۱X>.$r;4HT]`:qiφwd^mdv3yEySdhW6&eA &;* ݮ7_sp "|& ~y1B㾈 #Nr ַP:υs0kLh)ỹ>ro:*`qGaG@h3$`עrF`=ֻ9?je 2H2<Lx<S, 8:n3 ҡR3ƙ+q|KඦD~|8_~B 0^:̾BH(Es8| Q)'j:9I~L(JO<>"n/J0 G`8p?0)/(|nҁp!t,7-l9Ős6>mcY$Y^3OMp[/PU T)=skB8:xA_/]'Tᴼg.N\)0g0x$RT%納9mqy\j!~Mܸ~HY<%"{QZB>=04"e$w $V _]LLu.]Z7nZjeff>y۽{EDDرc7MMNN:dffֶm }q>;tn"3Mq8~VO oKp/SS[ilRK<Ms4 e8s?38nCWd.rsڷD=#8pg}#Gk.8OwQQzz6 L8 *|rON:u?~|>DTaL 9mcE2[s6SsW3PyOɟ3+'W™3Wp |/آ-55վK͙֭36olݺu^z̮j1blm;v͛SO=e32[off'O8ҥem?v옍=5jdڵRSS&Nh6|pۺu=s֣G={uzas~ֱcGS]s5v33{ǭ[nGYN,%%%t?d>;bӖRr8)?{pN>!灮.BD /A㫇r[@KЏ{{6rHaÆŋ 'x֬YcM4BsIPEDDXRJܹe SL1 fC 1&OlffIIImճ=z`ƍ33{X]~euԱ o-""š4ib_Y׮];4VjUT;v'㖾}~!sHy38Yv٢~)NW3 s.@)Q~Q8H@楔:ۍƽJ^3f0c |MҨSN.E|rN|xY!gYd }`<9W^=bbb4h ??P x';QGƍV ۷//ի;'lN8AJ3{^۷o3f *5Eи7* R^Tړs-dY3mcjj%arK^ g^8\ p[`/]*VJ֭Yr%?#:̲BmAܹ͛ծyqy廭o;wl24h@Æ <OyF|'YZk׮ŋe=30"eQ5rNۘs58-LۨRB॰ hӚsN/K/%D_'::^z[_ujԨc=V 4q?OcǎQn]5jbo'P߾}5k*GfҤIlٲ%KR彬^TE-: LG&kpN#x0`.+4spǯ>XdKә>}:o&-Zޣf͚$&&r7yfƎK߾}  UVquѺubv=Bzؽ{7ժU+F?̧~J>}Xj=UV=U|ks/OF3p >$B i DJ0iD"`l UTTĂʥ^((]`cL&eI&<ə9ɜ}f͞}`+59J9S 0٠4϶gBcMp T7r8u6͑^\"W_}OKK+2Beeew^-}%{Qɘ34J] ְ-,䞹t#pMeTW3̬uTU24W%O!(P:;Z1)E*y.S@ pHGxuyN3@CvE.]R r (|9TYQ !: x x3/P} ً+~́4%9@Jr*{9$"8]ttoU0ˢDDnm6m7&**9sЮ];*UI?~<:SN%""ロ3euԡq :'r֬Yѣ$=gߧI&vmՋI&/rJ&OLBBdϞ=v:y>|8Zbԩono ډUgg0/OttɅ8XA_: `JHK.{iKoO+ ?GN~ 48+uARSSٱc]w={Ν;X~zFŽ @Ϟ=9|p/_N&Mxwo߾[ O>L2bos1w\ZlIǎ׿E˖-%KPNBBB:t(ю?SoqY~m֮]UW]\3|]wĉINN.wiʚ=ԚŴ% gj ୫k9={ `&i^~tLi?CNnA*M}/{^rl֭W_}ETTTlܸ>fQn\oܸ={:߽{7]?#WX???bbbM8x`ϯ~s=|G 4g}Llܹs;y$j7E/j.\… ;tp1rOxUVm]1^~)b;k(A=[i2c k |:)tüw0\_T_S/dέСʕ@oO7EQ6lp7n,0(޿?ΝZj3_d _5_u\ӧ7ozlذh>"ߴiիWw?z(;vyʙJ||<?wdddP^= _9|>#fΜرc8qEBBuqу *\|^u_Q'?`&r#jy´Z-Ђ}呈u3*d9sVE4{FFN*ʘNOk\U97n䦛nדơC eРA|[)+'Nd۶m;vDxg #$$=zd*UѣiԨ+VUΙ3gg^}Uiذ!5kddddpԩÌ3Z*qqq̛7CZZ?>>N5wZ_ʘ@vL`?V*; jN[Ȫ=fđsPܥBS\)))ԭ[MOOgϞ=ԯ_?_yQ6l@dd$v:vs=_'NDFF _?NΝΟ?ݻ]6UVXRRv |Qh4 Q,|JNK[Vg-Ϣ,_?p/&ML3ɳ8V^|fYh]+E&W"w={R^=ҥKIHHpPLٷo5jԸ%-JyxLG4m*`v7p>^N1y x瑆 X@[ߕQEquU'?ѣmۖ!CXɓ72H+lt1#Ռ;HwNq6RI E>LyrYNqAwek\U yr!4W;~f2ُ9ksq_ј1xR1և t8<`ơ@6שUys\9w`ߝgХ/?c:Bݘky(WpTio߾\c_۷z*WD{)ϟ/ݻwO:%{-% @Ξ=+""[n EuD[UyyvLj:@u.b~Mӿafr,*ua7EQmۖ'Nٳdee1i$5kFXXc:}GFF`fQ{U111ܹ31.]O1btEN8!2|mWJ3ߘΑXJ/,[m8ʗ]Uv ?\)+|ODDn&1b?^_G9y'de˖СCٮ];yO4I "YYY({ҥlذXƍ_ϋn'NȼyiӦ)"&5SN[Zj{׮]bEDdȐ!r]w9sEDeҥ""ҿy뭷D|믿^~|wRnxMQ*4̸N;]Ud`fL0-|L %ٴi]wӲeKFͲe˨Z*ÇJ*8p>~ڵkSvm^{5j֬IPPGiРoVYY333ٲe  rf?ݽ{7*Uv.˵i&<(#_Zl֭[ %887ҳgOLx{n"""s뭷:NNNf͚uȑnaƍ2mܸh"##kHMMeĉ)4>~_|=A;3LG' G]f7 *6q/|ﰰ0ryȐ+Wu]'/,^X%55ձ$&&Jzz>}Z233ĉ2{l}:޶mۤB ӥN:j*3gիr͚5Kz?C|}}%%%E|M[DDsβ`+f#""dɒ%G->>}ڱ_)uݻWjԨ!""III+""2qD +Jbbb! rm?p+0l:DRL uNpuY>oQ%&& [ohݞ9s&<ӰaCj֬I@@˒%KС6=zzjݻ7k?֯_OFFGAD1cUV%..сrUPGLzz:GQFTXe+xA9s]vqA~7͛ǽ͛kX`]v>Mח?{~o𻧔*{n.*u -{J/f]U6ÇȈ#f͚""aXDGGK ܹIƍ}a}YoQbcceΜ97zhi߾Ԯ][ZÇH\\#UN>-ÇZjIfͤgϞ111|r9pTRq̿K ?HݺuiӦҲeKW {ƍst}{kJժUe˖-""oH5-Tv` fvm U @"&meV,Eq;v1ˏ?.7ntfeeݻ o}o:kN,Y"gΜ?\kr9IKK:ի ݏ+ӦM;C233e߾}U {%@xE ¤^$[UB*a8|LE#hT@JDN/ǎ}tMr_|!< 0uw޾i$0#K<qyf{[PH)^}۷Oy5j̙3V¼[:ٺQ uxJV4fʫ0.woqT a:ä 3x; T^L?.ԧ sE,\ 6\fm6[ }n.*Y1QQ QNrwArIRcNy昴`uY)R(&->&p<N.À]hRJ)T iB |əWO5p}]J/̵ Rf0( `L.Y>*YwDR#݅PJ)O(0 3~:̯.waFKQߘR.RJ /bfxU&㟔Kہ@ T)K)_S>:39*(LHwD)RI wsYr:BUUC$RJRF`3h沨˧&u* mYv3wDRƆ_mRt|Ҩ)>ڹ8ο1uB)fD3RLEI4pXɗB{Oᇙkӽ)nŜz+\5C:ReOf,`~A X],oL&f>BASxn.RME `:wr@xxx 30e^ј,JV0-G]uhr.'ٵc@?`6 G @&&0yoļRh*>o o@iWBmakbNz`Jwaov)T.+JJ [ rCy/FAr w p ӊM19\+E<+]~~rwAJև"_)uexpsHEr7|;Yʳ> af-\B\rq<(K4uP IDAT1u: 8ޢ8E('RujN=L~~ nOc\CN`^"YZ7cPcYIf(c0e<,v^?&ZW; t\C&9uԇ_)U6xaƹ~?E޿|t>wwAJPa!o=(x+o 2rf:=xx3l&p8^3Օ%/bɻHOdߞ@_y'yN(PZR 3JL~edee/aKpZZiiiUy?,)#{yeғX-֗f%B߅(Uw~PJ)7;OäcFY?E]6SL!..O?ǏRjK*ԴiSLff& -"44ӧӽ{wrXfzAJJ [n޶Ɵ_OcxcߟSNc6mڵk'%%Xgʔ)Ԯ]߼kqKO^YYY3x\vEo? ҸqK.HNP\xTyv%' tmL"d/^Ν;5ks`ܹ$%%qaK5cʕmׯ_Oǎ cС]'NЮ];xFEHMMɓ 60vo]` ;.@DDǏ駟>ˋCc/^ӧ߈_4nܘqa:ۗz1f23s^~;F^SO<GoU뮻k:w>>>DDD8?s #FADEE1vXΞ5#r-A90/9'~~ ^d &,,5kvZ\9}4wu5jԠVZ >^߿˗s)6mD\\4iҤ4~xƏ+BǎILL$%%%Wϯ,~i9|cqo:uw!66۷;רQ#&Nk_sԩS.]0k,6]vͤIxYb`~lܸ1tЁ[X̙C~2eJױ"RKNLm n 2k֬|mذA8q,]T5k&=ZYf/?nݺ'v풤$ 0`IHH={VZn-~~~r9IKKʕ+K=DDo@#u@,Y"7o@&O,.{IkG}Ty///OEDdܸqȎ;_~@vp RF [oUi޼fU^~/tIW.v]BCCED_@J``dffʋ/(Ҷm[YL4Iۤ_~ED^zbۥvr F*r5a[n/K""RF @n+1^$܋>kgUOJ(EiӦԬYS $Æ h;v2f̘\W$66V2d*wqvίO?TRʼnf@VXqA7o.111bk_%DFFkX~i޼TREF%M4qKWס;wJ^={ʺuǯS 4HvTZUN<)?$>>>2cƌBcEԇvRVL|] 3r* EDԩSO? ?gyF^uw9sHe׮]2uT/t|0Κ5Kp|߿_/gv\+f9ʕ+E{РA""?;)UToQd߾}t ޽{;_o[n~?\Ed̙NG`"'NpݠAB+\kזp9{>}Zjg}VK9$*Z=Ea/b/DDDHJJv?#?zұcGv111%IIIӧ 3fp%lYsdرY`{[D|~.$֭[>2aIKKiӦʕ+%!!Andҥ^.\(|'""/xzqݻw>S>C'au~|049%9x /"t0?[5oo4jԈ_rJ|||۷cf͚P~}r]w:7nHZZ#GtZT*Up96mi߾=6 8v!ٲe NUVoPj֬ڵkYf mڴܹs dĈ 8չv+==Gg*UD@@ Ǎ5wޅ?U,t4TڴiΝ;oӑbkα.66\KAϭ_>5jpXu$99m2m46lP`\_+V ""$ojXqj*4h;űi&r}a۱9E/:מ={k#66ֱҧO\^NJ<ՇBi'Vyorr-KA# +W a֭[GWZ⫯J*SjU|||qliѢEΜ Qs7|ծ]ȝ#ٸR~ñ`"--{ u̟??3_?l0>̪U nݺE +n' P/^\~ _8rs}=9X)e˖-f4o?kU+_uUܨ(N:Ebbb/΂g9BXXX:ԩï`HH(|biW䧟~"##\匊ʵnΝ5ݻW_g9FtʫZjݻT*T}-缫X1XCy.iRY-:V+Oć~ȺuGGGlh"z?fΜ;Cݱl_"==qqa ֫{ f̘vڱ`zͲe˘9s&˖-vܮ]믿2n8شi tdԨQ6mڰpBٶm 3V^M`` > ;wvtdVb iy~]pX"M6eŊ:H#""/W_}t;W^Ӈgyɓ'ł BOnóRJ _b\B.|.a#hs].rbDI-Vo-YwUVJ0/?,UVʕ+KZZe;h"$""B6m*`-.:FN4wH) +׶"f`8Z.۷oot{3g_O?H|||NYeT\2sS.W۹s'ͣo߾[)V^Orr2͚5coJXv}&9{9_=M:(T180| f*5S]Y8^9K2w?fֿN0i<>[jRa|HxU~r :'=%<} p_WPl+TrJXuǀkLxb}(6 Rros@^y|>fܲ[&އO렲='<>[J)\pۆ@BuY"x6RK}(J)Ci5L)w?\sz9)嬼ԇBiRPn*uCѓ> Z%9H*Tu(Uyz'kBxz}(J)C'SQaÛz8K}(J)S?߫\,#mZ%yQC4WJܬ!r!.%7<9-yUF(_% R*? 2[Ue\,_&)Wc}(N䤔RZ>3q[+ ^3(iSyJ)[9C&Cً:IUl 9P=d/o0u>Z秧*c?VX}8EP^K+T4 8ɷ&T7{zSG\Dg8uY9Lr.{I~juԁNC1iRF&pnZcC"N9ʻI~Ƽuk.`8—P(=RʰatL``o}+x{ ĤDcZ7I Xc-isx+8OPX%w V]{r}(J)eXD *duz9xrb1󛀵K[+jvNpV<)`)1sV+ƓCWJV.5>c묑/r%h~^f? XNtw^gi9g _lC}(J)jɳ5Л-~y[Pp S-X \H+Hq^yݵy.ɳ8Z+CWJܼn;VKsSu1j]@LWm0FAz3ӭ8LU[\^)AuuTttz`:}´>+y5 Nss۝Gyz}(J)嚗6XRMK$ flzO*>@`\=R fuTw]iIكi_I)ZʏRJ)T⃙ v*fTw~@eK)RJ)U 1iL'1RJ)RX%fL1L K{K)RJ)U ?1LNRJ)R,Nk',RJ)Rhv30 3L7r)RJ)0X?A; RJ)*Zp 0 Ln gFTRJ)T)dZ\`r)RJ)&0X ~MY(RJ)T*݀C &ύRJ)RJC(#R`$PۍeRJ)RJC0H6˥RJ)*o>An,RJ)RaRlNcRnLJ)RJbtz}8 t \J)RJbhr5fEa+kPJ)RJUnLu3DRB/sRJ)R.x7/ۀ sG`Z]2*u V)RYAq;b@/' X:pCU$\V+R/m.CE3!`wz,-08sKqq?}pwSJ)Tciz(]DL{޴ LͶ+\&Uӭge/>:RJ)J%@ZܷYtJj?mCWPL&9,L}pK_*RJ)Jw+hɾT$Q2 r-W+RbًO DJ]_\RSSsD-gbϵLJ *\EiiiWx9a4L~H^1?RJwt ^ 4c l6)da*TP`𞘘fGw͛Ӻuk233iݺ5+W755EE>m۶l62fax衇.[yصk%sf̝wK%S옺a4+F[RJ)JƴaFzX=>>&$ڼy3֭cذa%sߟSNc6mڵk'%%{Sz_>}hӦ G^D] Գ,W+Rʒ7xcx6*̲eˈVZ 8$?өS'ybccپ};o6QQQ1x`6n端Jfh޼9ƍ#)) ˂ 8y$?2~׬\ݻw3rH֭[ǚ5kHOOw3""ɓ';;y$Æ #,,]oˉ'XhXe*f֮]u垷_sԩS.]0k,kf3ϐ @׮]7n?85_~=tTIDATz;vxbN>oF\\:qƌ7+رcՋ:uO0zhn\e֭Ǐ7ޠw}Hݺu%KK/$|'""rwnǏ,Hxx4o\DiFj֬) aÆHtt;V3f4o\T"F&M ;v쐯ZPtY*U$̘1CDDnKdd4jHر7α_~Er 7H5^DD/tIW.v]BCCEDdٹ"-Z@8 &M@n6ׯ2qDQ 7x$$$[z) !C̻W097dׅQ%RJ)&V{pf&@k7V@?KJJ1Bٶmu]/III""ҭ[7G}v6m:tHv%aaa'""`XD{WDDZn-!!!!cƌIJJ*v/"|\v.gϞӧOW_-(CDD/ٳg;L >\DDj֬)ݺu+/DDDHJJv?#OKKiӦʕ+%!!Andҥ~ȑ""g$..NDL_vmIIItiժrA?,<㒞.һwo9~x{{ U& 6t|LYh̜9SRRRO?@N1|g""pBǗ~A~GYlYǼqwɮ MUuj4^)RS(4{i&j*4h@*U/ ,,͛73qDN>#-ԩSt 8G}׳b :uD*UHLLⓞѣG*U^>99ЬY3ׯ_sZn͗_~oƱcxg,qM6<#|7lnn3rH88$Զm[6lHhh(͛Sp 7nݺ\;RwܹslٲSNѪU+BBBtYBBBS111Ջ^zEhh(y WFѻwo駟駟?_~PSaU0CJ^QRJ)g6y{V 7|Þ={K||<=z 3"/3~xN8AEDD >S̙-_,N@@ʿm6q%997|ӑ>p@9k#Zl7ӧOy sNF5\Á0aBg+HIIرc\uUǶlْkjժ*hpvNZZ{z+V0oC~;бcG xQFAǎ̤gϞ?~2vX/^י3gYf ?nĉLګ1yuQM) *'*xH+U+BDq" "u!…JBPQA(݉ b:6.&ILjNs|p_Nߟ^::wV3]H:'5ߒ#-RJ).֭+Iʹ[^yRJ)333eǎehh\~eǎ%I9x`OڵkKaÆr 7$ejj|+ngll>|?{8Y@)=G)v[n>+o}evvݺ>}Yj='n/{$)+Gw7X5k֔ݻw$'oݺwy%Ik#.\z%I ʻ[JY$'|륯?x`ټysYfM˦MK)j}رcn;wUVGv̛v9|ps(I޽{.fff|n{j?~vU>_%~]sc@5+lLru9^{$)7n,cccOc=VFGG˅^=288Xξb~1*Aٖ-[h(;= [ƹ1ҷ  sњtHK4yweٹsg/l߾=6l{266۷gxxT^|l۶m5?u;8=z4ov g˖-N=a`` Iv'&wsI~Lr,hx '?k7Gnϩ$#ɷss˿ҧoxH',\']``F_jM# T}&,v{Z @kA:9.ڋ?Jzz!8c"x*UK:9Nfu1tƊo4;t4Cs\<-UO΃'{ @uLgMzZ BW 4iyIjesX3@;֙hvp+ lwn6D_j3V8-qIy39C~vzDI~N;psd$W}VOI~[M}:cxz㢎:SIZI 0$I'γ} ~ظszU@ "2_?%Yމ{a~k`WzfY?!^:E^ ޞ{|u֫x:ZK=pUM*USmLXlVWxVA|+OU蛽4- V:.5}4͞h^aV!H'7_gY5:`k^}ù_g  R@sH G~R NA1| HbCz%P]r!l7dC" Pw qS h9 KA%ny d6CP.g7`g-zr歇ƷFU ƦZ0ԜO~؇4\P"?pv NKC1MVú6]c Ȋz@=-e@$d]H==M}:#fpSe v2=]sABP{2 ]&sFD!DEťF*ǐ8pа2I_(d{L$:^}s^}G]\N@V'ԏRBREbPB"11N\9D%EFNf\I TyGSi~[UgB:OCky]#y<z`UHT<ǯE2Pz\}cEUDƇ IDATxy|LW$HBb )xUkZRnZکjEy*RRX"%*% !Bܛ$3Idɤu_̝{ɜ7;g4`%]*<)sqQ:w4S1Xr<[:YX(wcT::ø n1㜯#ʏ XPXƂm-P\.1X q2J7Ä̬b!¶XKZDǀq2A9&Sq<k[X-z%""""|GgaBE3٤t uwuy,@Cƅd4ä`23+0ȔPcXy\%<k;X|%""""ppy/{'DTse=6LX1.ʎ´&~,OT>2`زXBa ["""""Gq$ߕ6go@ @#~BYh4HGv {NdEQv/i7Ļ3ҐfddÇpuu\-L!%%pttz9eY `@U* cm*:ϒ^)QYc8BqpzBҐ .~jK}j=8WYiwk9Ōky F|{Ν̜9NNNܹsT< AAAsh4R\94k {?~ ]O>ػwo14|;wTo֬4 j֬YKkz֭Q`ĉ{.`h48|ӤIl2ݾ}]v-Ozź37, +W4jJ*_ÇXsg FAŊq̘1EK)e Qq 32L|9Bip6AiJRЎG:KٶlRз#TL:. jk???L6 gc'NF̙3|aBPaڽ&ȎBҥ >C/_:u`ܹk̜93gĈ#_aРAԪU ~!:tP2E:ԩSee 2kvI&a]6fϞUVYhoqY̢t@XB=0sL ظq#Ǝ8Ř<ܻwQQQȲr14_o,|2{F=f?-+z|7(]="\q^x3gĻヒrݮ02ŝ( %-gEHGEE+HLL_ ؾ};7o5k"<< .DƍѤIL8 شiBCCqF@RRBCC1iҤ\NOOǤIPvm4h3fI&aҤI?>pmݻqY@߾}1fpx2e ԩʕ+j)GD>SXlBCCqi_>|hР>99C?6mq%KM6XnZl6m`ӦMn_L;v 88.]2*JݚCcǍɓ'c˖-prrRCBhh(˗v܉f͚N:ؼy3BCCpB/={0QWԬYbƍٳ'|}}1zhdffe;}Y;:u*zQطՔc- ;wƤI駟{ؿ!vó> ///DDD`ԨQxgϜ96m`ɒ%ݻ7ׯ'}^R%EFF_Q}N<: ;vT_+WгgOxxxM6jz%"""""+@1( j1Sڵk'޽{-YDBBB$&&F^~ejժEDd۶mҬY3}J||'|"5ƍ;#wIHH|""r] 9t萴kN|}}套^Ȼ+ܹsfC ;vo]tnZVX!""m˗%--M"""Oׯ/ӧOW{++;vKȟ)!!!n:9wȲedٲe)K.*ݓ_~YjԨ!kIrr̛7OBBB~͛KLL6~go0v⢠-[&dÆ s_|ZDD:v(O>2`1Ǐ 1cI=GF%!!!RjU/,^X-7<<\HLLLYt_9"""QQQҺukYxKx ywDә]'"reѣԨQCZn-wV3o-t޽H{Xk qf3qD QQQ2sLqtt???7o:uJN:/lRDD֮]+q&dРAr% ""e ի'M4S ܹo^ܹsEDSN@&L &LAVȑ#G""+ZVjժ%[2rHoTREڴi#Fݻ UκuԫWOE y ;vIff̞=[BCC%$$D<==EDd@/z2 ȳ>+)f3W/sm8j( +V777t钹mVYx(sl׮]ܾ}[DD;&$88XD狈ѣGL:UD@@PBԩSz쉤$<ؾ};uXnF FUb;v,7oHlذo>DFF^zHLLDpIcÆ ֭RRRdn3g`Ĉoq;ؼy3VX@>YOSLy V\ ;wC֭[Hߴ.22׮]C_>4 ^yZ ׇ/_C.]H 0,Zd2?-yYf ~m5 ӦMC5ЩS'yp?'N0ƌ[RJضm)fΟ?CB֭[/Џܿ?Ǝx$%%aͮtxgk.tW^3<ȑ#AAڽ)̅kx"٤I7Ċ+vZ|x饗/jo>ݻÇ3|}}ѲeKڵ ؽ{7гg\/P^=lڴ [nE5Faܹs1w\Y49MF _/vaoo3gЬY3r~' 22SO=kVZEDFFUVF5j?+V@Yꫯm6;qqq8~\*^y\~ek%rmٲ%ԩH޽ T,^?:jXL W{M6!,, +8`|7HLL4+:vO?ǏcFx|!n݊_~P{x,L:Ճ;N8͛ǧgdd`׮]޽;vލg;O޽oa˖-~h}˖-kɓ'%xWqFL2!!!sÛ+vb?S0j(|gXt)=zkת+b|-BqL;3eQ ޽{7o6n܈e˖}vQ= v,Y.+V pm:ѵkWlٲ+zDWկc/Xf&㛀)mLaXBm6̝;-իW./ ɉ ,X[lQz\Es ֕@ߔ{I3L+7Tb͢bbb...Xt)ŋ*W Xx><<wÇ{n[)93zkCE GRy<9vؽ{7,XNNN7۷o딄˗C%ysrww` qjLJZhԺ[xtuu-T= X˜1c{n[DŊs\׫WZV^9'SEf`oo?M4QgϞȑ#QN`ԩ*vbW&[F1g5E|%""""p(r2RXQhРzs?@KMMŠAзo_L0AM3ԛ)#GСC^on ;;;8::Y}!** tR9ʕ+j޽oAAAf;9嗘P0dw=Μ VPSn 쬾G>W%d 3Ç7[ּyj*̙3ovÇ\!u?W I!n O%7npTFŚ˗cʕ2dN֭v܉3f/2A-Ze`oooryXXn݊nnn1b:t&`ĉ|Wjh۶|^z~ ÇG&M5Q< oߎp:)ZjI&k6Zw}ԬYkve 4%r5EBժU]vF_|_~eui 6L]`ѢEhРv܉ "==+6m ___VZaӦMh޼9/ܼySx0KTłvwssC۶mzjԬYFJJ>ggg4jwuMNNOt:5 Lo;s۬Y3bxgc|XlY>t~!""""`379*_ƍðaرcf_Xr%_C",, ܹ֭3f`ڵ0`eS .]@`Μ9kaҤIFzۯ̙3F˰aðm6S2h ůvСC3g*V~!88SLQ~}HOOGvrZhÇO>V{=̞=gƚ5kРA|w&3w4m}|MtڵP+ pO_o[Шe˖F? ?111U_J*̙3ve 4%rOkܹs>|zΛ7wŒ%Ko իW> vvvXz5VѣGcUVZFc6V{=ddd`طo:7PŠS% Пׯ| wt{~oMpp0:uyq |%3oPzuaΜ9x«JC{'.\TY7y%^.]# 書x"{,X^^^x饗OwjdϞ=HLLm")) |:7"""ФIno㩧BDD:\8::bԨQ ui&|ǨYayA}N͛1h t cǎEBB̙YBZZ1axzzĉ?:m0dO?Ş={`gg0ٳx~Z w5kp5̛7O!ၷz Xbv܉> ݺuκk H41l0|gFuTڵk^xvvv8t>#AHJJ,XZ L0G>}p1̟?=/{Œ%KkS2NiӦΝ;DժU_aѢE>"""/GѣѵkW<& <Gw}d]v6l1dT^3gδ´{ISMZ}U3g]v1Cƍpww79/"NC5菵6m`۶mѣKx{{Ν;&OIIArr2 r""u*Ur ?-V'n޼;\r8p 6l؀Ǐٳ.+%%ꍢz8qBMƙjCEHHoVv ]JJ 4 ʗ/ 4jkƦMЧO|W[EKDpMh4T^1ciiiHLLD5<;CCCQV"սXƍ ]R Zn{mڴG}Gz?77>^^^f;n[T 6lO>ǏݻXr%:tsYd?R[p)Q!X:E+eiy;}5j)3f0Jd SN;M^UCv0 }gʷOzFζowqx{J[WI`3ؘڵ OFڵѷo"/kx-_~ڷo6mڔx=[DDDDDTŕ|W}pW  K~g2Gc=;KZ }i7gdy/;8x-[re,-zKDDDDDPuYKf֒ >}bo&U +a!J;f@KZe-J*mIqaq`v/i(uR$2 )GU`RJa˱[C*'A?Ci8x}e,[QX:CvBL#;a$X*ɯg XҖJr!‡YKjnsm SVR^ҔDc#ǔdsDvɖcl5v`|L(s/[x9ֶ9`[lzKDDDDDdΛራN2JA:mwr;L:BxJqIe8"?5.l5,%MOJR吝t/*jA62UȞ{ٚϱαc["""""*K|WI/ G* G*/[h XaSI:)xQY@rqaq`v)gҠ#KJ0L`˱fiAI)ǃ +Mϱ8ϱb["""""GqL; }"+ -e?( 1[ mkWBN2RXN|%: s'ƅ-ǁڽ<Ɖw&ߍr{(ǃWF>ucmKqc VDDDDDT@hiAߙ,Ȟ`aV;}e:%q}PI>)_N7X$@n J) u䎱r&mFT򺉯r<T5<&Jx99`{lzKDDDDDdɑ9Y`HEןNN_itN5ve14ggP `\K3 oWF2Np } ~/XS\XƂ-@q; >Ñ#҈~["9Ρ2?ifM–R^ҔoZ(3]3Lg-M%i֜ϱ8ϱb["""""*h&r. =[t+a!9Gv3aܡW4O [K{ISpDax^V8r$Sc!qs(s,cv #}ƣ5w2Ξ9)֮v 5e8:4/ĸ8D4e_ &&xϛnqk*- i q<k{X=x%""""(;1qB1Hv,LL<֙xl?-.l=,%-g<(kf[\:oXRXƂm-壤;\y,t e"eeE^sZrѲe!KX,J;cK'kc SYQnJu.D`qoFjZ@YtG6bceϱ`, [dzgHIINZk42۞DDDDDDDDDD7,A"ŋ#==@?~<Μ9?ӦM+CJ  GN:HTTm!֮cb-`@DDDDDTL%.]* 6 '|"""G-[Jll\R^|Ey%aaaeJNrҫW/9~|PN8!oε.55Ubccs=,yg8n*O?? OCXwm,Zm۶ѺE1zhggg5lg{Ƥ tz¡C0k,L<V2[F)]ԫW tCFFlق>}w5mׯ_W1,իFk\xhCStx1ydl޼"'''u}٩p(@DDDDDDDDD ve-N\~:o𻲔Zʱ3({ػw/ "7n.]ݻc׮]j~O? &T Djj*ZjI<Ƒ#GX8p~oX~=֭[oy/^Ę1cиqcԬY޸|Z7ٳ׮]N3Q_P uGGGuN4iѹBׁlPkW`,QUfG[2=d'MsJVe; MYT~}tՃׯ}m۶?q|իWG.]ၐܾ}stSLG郏>@۶muӦMÀ V/2nݪ~0`uڵk'D@@bt׼ޓ֭[nݺVoZxWѢE TR͛7Gpp0&NA.447n@ZZ y_XD8%c((] @unYe(2MD3$$$ݻws=+QQQ^:&&Fr=}s s]jjj̕8IKK+cbbƍ~}^_.III"fРAau֕sg""""""""""۠>)T2'khw?YeeW~mISqe lٲ6alb """""*#UȞ(=<ۀJDDD )) ɞ W˴?&IhnXDDDDDDDDDdL$=(p~{Q>!Oԇ&12-"""""""":&f<}r~|Q(S8 ;+{1c %9~c"kj """""*ӝMVATsp]!~gtʙh3wAv]k'""""""""*8=3"{ %iK3sNCdg6$3x7|* x"""""""""(]ʖssQ/%Ye8c>Sn5we d&C"xndTYII| x b """""*|ϟ%IwÅ+ aaq2;Ϙ k[j """""*8LrmD{^SP-k}} Id'Ǖ{Xc@= c]2k,DDDc^F3u """"""#lsSxw>9Z+7[ "peI~Û*7\eµt^k;8qȊ@dpWn: dOQff&>| *X*O޾u T\>DJ̾Vu0c,QigJ￯<\`;N}2>M9r6I\CK|wA3=;1ضmѣGh4-Z+PY[n֮]S?ŋ VZ-jժt{{yyԩS1a„޾~W̙3ӧ7i@ A}B%d0*ɑ[.BCwO9mVYԂ>xy*֮]+]t pႈ\|YM&q|Ѯp<6K8 6ᅬ#G… SN!,, xWq}={.8QF*SLI0}t/ … +V۱rJ|S~hڴ)f͚n߱cGĨ?ӈ5w޽m۶EJJ:;;;Zjɓ>>?ȱc$ @֮]+s{'r1 'Oӧf͚rIqww(jժ-"#ߣ;vLt:jJx Yz,[L'͛74Uk,ԪU p IDAT@QV-#888`„ >@e" NNNÇRSSQN\۸a֬YoaooNN2f 4H}ȑXh>ըQCUf޽P_\1/~lV%K`ܸqxѯ_?L4 p9{o&LcJ--#M,-#FJYӸq0mڴVDxbI5rxWL—rqqq0͛ deuey& TMдiS \|?Smf͚˗/رc|2Wܹs_8zh!qqqd{Fׯ+oFFtK.aΝɓW^HHH?0^F>|K,v5,f2dcm0rHZJő|7L.T5lعs'`jR]vطoܹGGGhٲ%4 MÇcʕHva˖-h4ȑ#ԩS޽;q5׸qcTX}[)7mڄ!C۷ǡC}رׇ7ƌGwm۪SX<[:An.D|)uaƌ[.kxxxmڴaPvm4mGƪU-Z@TTx ,euwwwlٲ6l@F "66VM9r$Lva߿?>C$%%a:t(6l;v'vvvܹ3/&֭[c~^~e߿uEPPZn]xܹHIIA@@:t耦MիWG.]Ν;cԩ6O>$.\jD}GUM-ԥDzQ. ( XqQEEaHuE)6Ե!kP" $273LBB$>23sLY}|N @ d z"@k+l5m>|&Md:um۶-[G}d;v찁رc駟Ç_e'OVZ]we'O7Zݺum=xK.~}]Veff?`vEŋm֭VZ5[tܹӆ b={43Ϟx 33W^~z={ըQkIIIVbEm־}{8q%$$`?ºy?ƁGI)}ٶvZsݖinȑ#cvm?s233+n,!!ǥ[RRΝ;$L~ׯ ro.첒! wBƂ,;3o[cBn!]x/y뽇┊)Ip~OUHi """""K\C%2Ny''3sԙ(M`/Npv8dX͡uug.+8Kex/x n)I&*/,e|e㌟C[yo,q@z̀Ce~r\ˁ8|sI`)Gzps20 +-(w+o""""""""g"03c `۟:!8>)l™~<23ǁq όwOyP)}C X E<X┻ʱl&wqt&t@ٟ  @# fApqQȱ' }KAH`Zぎ8!BGwxds.8%h^@- T|g."""""""rwԾ{[+pJ3w+I EJ  X.3nF9H  ^=t-~Ҧ6CcADDDDDw3BwDȪw EDDL3 """""KỈi^w$`h,HR.""""""""""Rw@D ݏ4reru-ADDDDDDD$ )|_/U݉Hw''vJRK" """""KegDD&i@N Mf0 """""KỈ#FOԹfƴiRE;=M^EDDDDDDD|(|R0dȐ:v3l09R½:+x\.>:rz)4DDDDD$`滈%\s=Gzz:>,\s O?4;vdZ˗sev+Bڵ\2r {,]h&NH۶mO9t\s &Ltԉ+8Sd=qjW*r R5Y[s 3ߦM6WrwB3"""""qYży駟ի,\[2j(mu]ܹs?ƌíŋILLz :T,Yºu޽;6m׏wyhnvL /EC icKGpBz׃s7T6<N~goeOҾ@N$ApppG:ڴi_G!==M*U -KH]DOЬY35kƬY/VԬYӡC.r|I9m'559sqF7nL˖-yOIJJk׮\}L5܃m,,_qWRjUXzwҥKK_> b#C޽ٶm[W\ロoKpp0U2,YBjj ﹪ EHHH.*[PZĶpիW'##jժ;?Yfy6i҄]vQbE6nȈ#ؾ};s\ѣG{ر#{>oذ!_5RWE`ٲeyfmO`֭nq\)|,Cw P*;#"Rnbu%66Z˗ӰaC1˗{ԨQ#O3!!;3w֭\.ʕ+G seҥ]͛5ߞ1h o;v"##ٿIkt-HTTׯ?6VZĉk%++zWƲk׮<7h߾=k֬aر;Cyoԯ_d9uLݺu[nڇb߾}sSiǎcvYAAPPPz_ۻw/ʕ#""5w@DDDDD0."fy*x N]qƨ| $:xo-p8|0ƍo$99VZhѢ֩_x{,k*T8vF3<mܹ3 4{-~+VsrrrϨX"ݺu3S[#**O?={wz-ڶmK˖-qݼޠw̝;K/s5לZh wؑz;wRvm^}j7**իi&ڴi875kFpp SDDDDDDD.@=Yp03m*^SGӫ~ǎֻwonKHH03_~:wlQQQv7mÆ ֨Q#R 6̶lb9rʕ+Feׯ /`ӦM~Yݺuvao?ze111CY֭mڵ>?''}Qkڴ^~e{/+jժe]w 7`G.pLؘ1csαuO?mn̮*m۶/ο/ݻ 8֭kݺu+VxOYfeÇ [j03tӧ͞=̖,Yb_|իWnKII)_}նi&[nr-6akԨn֭[W-3]vY͚5-;;t? , *Xvsα_|c͚5:ygO=EDDآE,))ɢ^zVn]mĈffpB.믿nkan۞x kڴ5i d-Z03ƌcffm;&&֮]kffz9sx͙3nBZ' IDATUA."""""rQ.L(ׯy׮z ojղ'ڦMn>}ÇmҤI֩S'۶m7|7m֬Y6ydkٲ=fffk֬9!_*Ul޼yomff=zk֮]k7|\.[vm_`vZ3۴iƍgfNާO[`w[jM6Znmo1116sL33kܸ5o^z%KKK;&|g͛7ӧ#}sVZEbb"kצE̚5>t>~SO=EС&}VVlٲ.]omoڵlٲutܙ3fp=x˵ 69s0x`Fw=o„ So믏9.**8<OXy'UGγ-N={γHe&))$ϪU^:aaa 0o|s>o߾7oXz5IIIޛ+VdƍjՊ:u0o<﹅ԩ]rE~~{A'~s>III|L8~p;ٷo)))L:z*%`; """""R|"993rxʕ+ӭ[7ϟ=>--5knxx8M4~]vy 4`Νnp$%%vA{ˎ;aΝ;Fvv6ݻwO>e33g=ƒ qF:tzsݺuivsu1f>ČÆ n޼7nܘ;/sfƎʕ+iٲ%gw9ϯ1w~PPP{9E\pgt6mxK=Y 6<""""""rYEdggdzyطo;wg߾}ԩSEqHpp0G)C[oW_1ydo{ӰaCիG}5\g}4LqtЁyѹsgv… [ٻw/ڵcÆ oߞ[o)SޕW^ܹsܹ3!!!,Y$Oڳgv)ӫW/ONrr21ADD+WfӇx˼l_?'!!!񉉉~;s\f;[S|С޶ʕ+zL>W^y͛/cƌ믧e˖;֭[{yIOO'&&.]GXXkצ{DDDp3z"H~?ر#qqqnݚuO袋شiLCƍOR; CcADDDDD F@EPhtzv2=sjv B5];#~S*@gggڵkv[ffn #Gxٽ{y^33̴=Tv6l43믿͛ݟh'fvv۶mN?رҼxٳRSS֦M,++,##_AkԨϷn{ƂDỀ2.ߖ,Ybz]wu_."[pM:5jdis│_y0auҥg!}⡱ """""K5E2sL{=>#ڴim.o*Ul2"""X|9is│ʨQ,!+Kaʊ_if\@0*@urn{4pR5N 3>}\pH Hw)@7 %Ͼxk׮Ǟsc]q"'"wryW_(x]D\ y`|~nݕ^ 9 ߃}~7|ǜgOy,""""""R=3=fS/7f8s}~/|SRIėoLY<jr $9쌈șw{0\fƩlmiw&}t6;3-pB1ugnEU9sFỈș+X܈(0-)8Y8m3Sx`+0hSח3ǻ7@wo73pGC͊%x݊mV qn< ~-kʙWx? 1)7Ja&g)UZpU$nnvowiᄜ76*sfk 3^87YΆ}=)+x,f Nٙ6);wDDDDDD ]$0W}N=o)>r+Ah g= P'_3N+_9-%wUyStbÆ 'unBBq HDDDDDD]DN odr8-,v~XMҶd5jtR~L>{$RwDDDDDD ]DN ' ޳?ǀg48}<-w߳>{@(k֬{)߄Hb"""""q)<.dG@zv89pn[Ym;^c̚5K2eΡC5k[lO>!**1c0sL,X /@=9>? /?8n/Lxx8_|7}vƎKժUׯ*K,a͚5X~Yf߁ҥ ={dժUsM70}t> {1Nn7sZ._YBỈB3g2q q4 5w4yٿa}Fn[m^˷w 8/ロ sL*Ux饗eȑ,]#FЫW/JΝ Fa r ==wO碋.> x׏9N:8XreXr%GױcG[/_󳳳stt>\.o߶m[qo>yox$$$Pvv6)))$&&}n9 ,V<俖3"""""H΢,.܅ CܟA>n }Kd{@ 7mڔgzxnINNUV3ΫVZ].;v;w>:t8%%]vQvc%99s=pw!1+W[n̟?ZZZ5k$&&ݻw{_/iҤI+!AQR;~U);TvFDt!BDsNիW`cǎRxGe'dhə8ec<=f┛ =5OOCC鄦%#;;ӭ[bۻwoΝKff&)))|'t:0o^~֭[goذ7ҨQ#*TpB秧3ydTBhh(7p-Z>(QQQX͛7ӨQ#o9^zcƍTR%OI'gy￟۷ٺu+uiԨ[n%33Ox:L/Y37|Է<,gm Y)(P."E*!`Y?|3pvOόw9Ao@XbDx_ouV֮] /ڵk =7((ƍy<%L2ի}f͚ԬY6| %44 k7n<ߪ!x^/>m_Sbwq`oPəMHR."RFC7p\.蓖\!gO aLOYVM6 y\.4(z}NZ?)_|KestFa8{1@7-={f/$e4]DDDDDTaf.cY2PgO|gQLMYigyTƁqX R<߾={˔}<n9vVߐGx[Fl""""""G3ED. 5+XNob22-C`T~ #g-Cpp}kCDDDDDD"""rCv@yw`|~ <%h<~O""""""rZ)|q(k֬{᧟~bٲeL6pUӹqL03Vexg9s&))) :s96mws ˗syQjUZI&ӿy;w.͚5#..oo}cޙ=z`…mۖƍ3m4y| m۶]v|G׋{~ac;6m7TbŊ|_ŕW^IժUc}K.K.~ 4={`f<#лwomVh֭]vek.xy饗 ċ/x)>N-@ d z"@kNB8x(}fX;==ݪTb-]Zliffh"_}'O?YLL͙3vmݺugyl…sve?/63~تWnwuo6m4kݺ%&&Z||̙3,22mVV-8qmڴn6ӧֲeK۰a-^*T`M4:ud۶m3gZ˖-;.{'N{g駟Ç_e'OVZÇ\c֭VZ5[tܹӆ b={43ϪUfg϶{\.u֬YcC+^x l֬Yo?njղoΘ1cM6m짟~ɓ'[PP:tknEEE㍁>37Z |C #G#JZAoѣGYΝmԨQbsε5j_enZli}رhcǎ53?m-W^y*Ud#F03+ֿ5ϵkժeck֬iq/ffZQ3e˖3,]DDDDD\2oՋe&LiӸѣ{/cSNTM .PN͛N֭3g =CÆ 6lsSf4h[zDFFΛoC=Di޼9SL̈RJDFFJjNsٲe {\r >Ν;S\<?~<:t/'sa\s5ޙk;cǎẎ~ݻi׮17nqqq1a?hݺ5=?cƌ)}t~rrrc`Æ ߟGtt4+W<ڴi_~% .jժߟiӦxbɓKɡE|W3+}Ĉ 5Vϯryq<塢IJJoΈHl2bbb;v}ĉ$22_$''NÆ IJJ"));wE]߶m[Dڷo}-5{x&%%Dbc?{wU}5aAzY UTHiQUU@[bZvVUXqKnRP$@D@EvHqLNBBL2||eկ~C9}᭷bΝeq}~k6SOSNp%K `>~oϞ=3Zjh޼yv :3g2sL׿?٣G۳m6^x?:W*}2?@޽37:N:eۗ5kжm[.\[x;.sOkwU*/˖-]fJظq!I$IKjR|Au2С?(,,K3Tx͛ӽ{ww^&ȠAʄ .c-:djVիի Ȍx 9nkVfs=ԩSiݺ5Tڝ;w楗^bŌ9;oڃ bժU+WM6f͚U9TfȐ!|e?M{./YcWU}!//o}nᛲAf͚2}c9W^y뮻xkrUWJEմ}$޲e ׯ}WQcΝlذ!nݺuo(v$I$2aÆϲzjBqm#F`֬YR)0a7tp;v9O;4Oή]!SOqI'yψ#x饗X~=-[駟裏&J1zh~avG}ĹKvh֬YM}墋.bʔ)p͚5\}|_W^ڵ+V+dYgϓҬY36o\G˄gŌ5d.r=Pw^}F /)))a̙{uΪ@eaFAAnm/ W^ٓ'|nμwq̝;C2x,O?tOΝ;Yvm'իWӌ32}WGϞ=ҥ -ʬ+,,䠃 'ՙi{~$I$eỤFo̘1\tE >ӺukZj=VXA>}ݻ7+V.'t3ƅ^waF*SN)?o~x 2.{/}\uUtԉC2|o:еkWO~~>#F/?ӧgy&ÇϜĉq1?qѭ[2߿?ÇO>p x㍙{'JJ8#x9ׯt^U>aÆjժ2s w7ydƎ1ÑGɵ^KV;v,K,aذa 2#<~?O\tE_~~eJK.sOTT*_ŋ3e$I$IRͤ&m &\JڤY󡤪muu/իûBqqqxGg^RR BAAnM6ˬ޽{?~~;vvܹ3l޼̺k׆wy'lݺvX6[.[aUcŊaa׮]0ZjSs ?BB~*VwӦM6mmۢE2fƍa۶m!v͛s6o֭[Wfݞ~㏇cf^;6<3UU5. $I$U |AӦM >h83j}/~ZlYaHS>t~6p]wi& ŋèQl(?wI$I9˲3b̙,]z뭌;6+mIR̛7gMUM@~~>\s 7nw|+_ꓪ7_k_Z*I$IjY h N@`vM_|6-6`P#rEu&08,h?xݎT*l7664J=64AV$IR+3|2RC`?U̾ I$)gYvF4> ~}A$IRjHUe#DwiE}~4Lv$I$2Ը=/r%* JK$IT/,;#IS*aЌk Zi\^VEǍOTSqJո|_7+wlk7>I$Ia$5>qqނehڤ__Z[7Gpo^Dmؽ&׵lN(J˝n$I$UƲ3Rq8Qj)C*/^r/PmIQqy@/WӑDc}:t~ +%XF$IT(嶮ǁmr_B%'dQ: !I4qifT<(Q+u9*?=.ӒZc'wI$IR2|rOs 18f)ǴN?NMT#e|:8k|`:8x۠wp?pp;#%)I$IR쌔;{Ylr_rQsY:/Q:jPCm)=vyCk|^5,g6'$זXEmP: Q`)Mεxu#%I$IST=ӁyD.b[:.V}ھ<$G/!homTҬMD%fDe#[[wI$IR8]mlK$z?.,SֻMq?OnDMVщ~E-D#[Q:=ITy`/I$IRl7@9:ԓ#}k;|OUZ>_;p">S]_Uj}pWRXXHxwȴi_e]Ɨevɓ:t('N:R)9~ХKo}=W^!JC1gկ2z e˖1iҤ ӧsG0ydOPXXH.]҆ xꩧx9SXh6mbر<׏}kH?xn Iu'$I %5Z <ӧ88oXd G}t}?ڵˌXx1%%% >q-$C8܏ 9~wy\z|v P&H4hVʼ^r%mڴL бcGZhy(,,+V0a P&xǪl6뀏ҏ{/0N/Ж)Y.u##`ҤI 2dߟÇӧON8nFyOoW\!C߿?ǏgС 8N:3h B}q'sQG PI2K$ 7f/?6JGO,}q9͛73sLN:j;zh\Y; IDAT^x/_NII 3gܫs6g}իWB;l[r%>l6Hq3t!("o H$IRe.Ѻٹs':u]v@Trn&6nHi<4P:8<˗/g…t=S`HW\qؾ}{7 *SDvܹNIRW(# ƶI/@vD{qߋC% 9WAi]BPƁy8<>%&,_$@0j۶mw&9bN:$:o?Lµ^ [oyWݻwyw^/">,W]uUf]֭9*}p}'QB)O_ƥcv][ Q0p=H3>o~$I;G 37YD@gfl>wU|ٙa{~2|hq,$%;**303ppfQޓO>C=uFZq}ƍwwܹFu]=7o^rh"ZX*U}́V5ѵ6&ez"}'((ߑ^0Vn#$IrXٝỠDB0=XB&u|_y I# ڳAK54\oMRfIy#ٔFǓ wP:>9Apnj(I$I9˲3Rv [)-XUu!иP>8,J/?"僧RI\~XBqm8x {Fv<>=Y"I$I:e.ey0שּq{]ϴQR]IKP\n}<:};#3 -y(]my $I$ISRvm/MTj^DvdG $8DK$GOPѤʼnSk$Ie.ߴl7@MJfDye]nd ϓxx͒$I ߥS%5~=~J?QC'mD)Y1.`{^ Sv(2. ~}A$IR2|rWl7@MҝnT S $IrỔ{> n3$I$I$Ք5ߥ 8|HTwYm$I$I3|;p40 ؐ~}p Nu'b$I$IRK." Kwi.P.H`?U̾ I$)gK0?3`Q"WrŴl7@bI$I9~m&*1spp?XFI$I$Ij{ Ivj*f_$I݆T*u} 5qwb>bI$I9]IS]$I$IRg[oE I$I$II$I$I$2wUiȑ< 2#T)S0p@ ~SO=Yf1tP^_M (I?_jCI%LJ=7gR5O/H$IR" NBM:8}}6sM-[ #G ,BΝΝ;ÛoBaΜ9ᨣ N7o^޽{xwB!#uQaΜ9aԩ!///lٲ)Wf@k  L AIЙ?48;;>Q9r?J$I$q砃s3 /r۷C%??|dx 2.ߟ>xzm(N/`+I$I$5xڣdӇoewؑ;={r!|2{y޾}{mV ҠT.JỔM짊$I$nrߖ-[2ϟg]f~#.]ʜ9sڵ+~zyy O@ҁLQ%&p'` | 4ON`Z!T1$IՠSQՏxեKo0lذ2Νѣڵ+˗/W_F3B<=ŋ.`{zJo6}x)eQ 3}8~I$I$I ##`ҤI 2 &pu1b?|=\nf6nܘ׊dIb8tߘX6]~!|ߓ# %I$I,Ќ|HkQYN@`v{_;]"#`Q(FiߡUVX;wҩS'ڵkW۶m?$??5kЭ[nC*A<hE'ڤD}-Q?H3%D]DA{\~&.A/q)iԀT}lC};5՟[ T1$IewUKݫަML(xAzﻈTb6̀;)[&adw)[gR5O/H$IYɓi۶mMTzK";jIi4JH$I$I2RnCƣ׋<׆ϣt'GA{\(q]v9Tvj*f_$I U;8^/]}㏓Jv[9眽:ץ^/~Zk\P==z[1}_WuҲeK֯__fIRr-{ug:qD: |8|A&OUW]U6W+?:?jؒ$I$IRCa>}d7oz5pM7|rFA޽k;v碋.ʬ{Gw}?q'MD^^tm֬Y7dzzZ[oQPPg>n/2hРZ;$I$Id?T0eON֭9skXr%_ywoJJJ2̞=)SJ8///:Txg}o}[x׿[n$Jꫯ2p2[L8{w8iӦo|[^Ϟ= xv ߟ~in/^ 'ԩSw}OJ֭yù{iժFb̙}⋌92sUV}_~gؽU6gΜpQGwy'̛7/t=;!N=pYgW_}5\|!JW_}5[.o>|vXٳg!Yf?̘1̲cǎlٲйsOիWqƅQFBC.]%\,X.0u԰pн{OBxC~~~={v3gN0`@xlo!kï~B} s %%%a |A8u]B+;v =PxB~~~B!s1 o3řg.p7B1bD4iRXvm>}zg}ªUL0yvpgaݺuk &M !/})=:̝;7a} ֭ ofh߾}8O<,X9_|1#,\0^g?9{OUvYtMSNr7:x≙m\rI4iRݻw3O>p-d^~3Ψ!D{^^^h޼yh޼yˆ#ºuB-[?Bn!|!(W9_BϘ1#3&L>=…^L^PP† 2>|x뮻L=>f| ׯ_5k/^lÛo5k>B>lüyB! 6ЦMf͚1,YiӦP ߥWW_]f'u뭷' n:3&s'{r饗a'˿*I$IRqU}b;v;gϞr!,_^{={ҭ[9^x?1 V昽zgs,Y>:ߟvڱfZ8vEEEfp뭷ңGz=V\Ye{c^z)K.eҥ|Ǽtҥ{ڶm… 9ԧ>C=Tf{Ϟ=3۷o֭[l3f 3gΤ~N;-mɒ%tAt)o߾YfiU/^LII Ç|.o+W`Od̘1y|^&4hk֬)3IjAAsL?Sn4hтye>+VddmOS>Cn~_3{lعs'6lȼwݺujՊ߿mQYA{eժUvitԉ!CK/e=ӌ9|.>#B|e~陛С^z)n7+O:27WO(8ӧ%%%r!ьwo;g 6-[??~홑qYg1~x<ݶMQ\\7 >qDF qѢEh KxU套^bќ{r-odȐ! 2[n=P.\ȁy_~Xt)7o}$I$IRVo֭aҥ!aÆ`PRR~aժU{yX"̟??ڵk !PPP vVU{ƢE2۸qcضm':^ҦMo]D5LCa۶mLZ;vsv<;6zرg88j.j?*Qn<3< Tf_nBaw0xݺu ׿2p e&\=Š+Š+L9>c渨_{5>`f̘Y?l0*V^Mnݸ;9,2ZafI$IY+TnfZy(⢋.<~5:%\ FV}\hPfI$IRbwUW%{滔߸桨l]vy慭[迫͛7u֕YzP\\}pgqv.I$IҞ2pYzi(~x[Ē *3. Pn>aڴiG ~xx8_BAAAXxq5jߟU5K$IR2](Tm N@`vM}"#`lbnR8|9,!5C{^ms碦s 5T?ɬYزe rJ&~ !Э[=NhgU}%I$)gY]Z2T/_R&\ܧM8ɐ=$}KmS݀U:*S8=$I$UƑBs仒(-1'*('G7v|=MVb?U̾ I$)g9]\L5SC4Ak`gEMܣ$I$I]Z3-Vt֔(-;^1> ~}A$IR2|XQ9 R[lH`?U̾ I$)gK+7KR54GDU%I$IWynĥgkmVD~3ʖa\&)yYy%*5K웗X8y͒$IǨT8K?O9Y%QMߤʖ;5))vkm Joz7>N^$I$,HKy9-jqPDŵtIUor&G&%KwJү˗*_+Z$I:e.U-9"3.=S[{r{$xT֪=l>cQvք$I$1wz3q@T=YAT7R!|\m`%07:T~"~^~$I$IuJgp700mGצ8xoNiI$I$)i|&%ē#kSqnxx͒$I %IIӲ59u'Ck$Ie.)l7@RxmU$I:e.)տqn$Y$Ir԰FݙH^%I$)gK CFl7DBl7@$Il1|rWG߀V"I;]I$IỔ[/ˀ7݁o 4Ik+'$I$ hH/0 o=^` P>x*0=D7WfMjfI$IYRvfmc& ("DgʯǪ5\Sɶ3>ad׀CpseEʏpO&Qp>Qzlin$I$U]ʮ"`+QB4=%W#ro걦cүhW>a?v+WUe jk*/I$IRb.e*`4h $*;sOz{SR֟Qn$ y4̛ @*WBtr'0X_{x͒$I ߥܰ%Ѥ!*p8Q8%յ;1Ȫ QMYe&$`>ЉGK%I$)g-k7CDu?~vI'=/ќ׳(I$IỔ> |D4ODײDs\ T^*:N$I$)H R"I PU_MK{OAym*|$I$NKgjTd0^{qzI`ߘx͒$I %IIN\( ȋJʏqw]D],I$I9]$eC@h !*_hFi8/v՗l>vR'GK$ITpU4. P@ ؞^[M;|SqszDA>8x͒$I %IIwfj{>==]ǏWC*4T=j[ Ke ~{ӧM\\5g* +;nݺc1ǎ3.Fm/oc>1Ƙ,vɓ'5<رc#|XuYYYKջwo}7ٳZj%IC=T0AU}\ Š`!N8o> >>nwv=zS5*;r2<ͭQ Ͽ y%:|p*|}m۶ҥKlhӦM۷;<|b'T㹽 @X@x%I_>쳀ٳw﮷~[i&x<ڰa$iʕ]Q2>}Z袋*ӽ{wk]wޭ#G7zheddrvkzճgO%$$hڵO I(;TeYPnO>D PVV~nݺ.\PSNU>}ԲeK <ǶkNz!͙3Gҥbcc%I&LЖ-[4z *99YEEE۷ϟ_etӽޫ-Zs}iJLLUJJ.]*IZxN=z(&&F$IcƌѢEԥK]s55 w1 Ј0*${%I:O0Ic W5wn~"?D5W|EĄLLZ'O4_z:LzMIIzM6c̒%K̷~[iӦ˗?:fΝ&??߿>Oj1^dee Wz|x4w̜ӝVoqެ?۷Դtk3fVZT8u޽[n]Qmڴ\}!=ٳR>}*=>66V]v#ɸ$~R9= -[|yGy~'|4z뭕3p>?O%lv jt=1SRz@_(sR]n$VVɑ֒Jj/:cjrI:.)ORBITF %-v_h[*SJVtT>J*NK*SgTM]sѸOa/X|fbRY#i[ ]}=wՏJeev^[Qy  F=.c(Ӳwʃw{*//S8PVZܝ F83;GGVy^3v~w\X{=+F[VVRY!3x# ,Y QzG8 wF_"&\͞tԣe ^oVx;zK!nO_hL c;P=X\  QvnQĭ%НhnۣOɚ8з%]{RV3_=P`f6EI(;'߈sD#ޝcr%8sD=  3׍ƅ~ }@Ģ P=z{CygHo;8*/3C4Qv]uU&syx#|j.8@J5&t#i͎iV6U1*м0*B}]@mcf}6EI(;PdIAٙ@FB? b1#| 1w~ w:1F_"&\&\@1#|p7#.)l Qv@ɒƃ3׍ƅ~ }@Ċwy17 ݔ)Sb dzrV @]0Rf? 1=PsQc̖p!֭[G=zkr]64CܳD,F#JJJ}YY$)**J*::Z'OO~zCԡC:uޮ FjaRXEEEzj׮bbb& WR999ݻw}Qy睒7r\UV2dyk W_I͛E\k֬\wuO$Iׂ |G}T.K_UV6;C_}vءŋWܳD,w~;cdщ'tWkUAAA\?==]Kg>>|X:uJ9[֯_֭[y5kH>>}Z6lPRR6lpVv*++ܹsuw+..Ncƌџ琝!y?O?UVV."`= @"|GCsκ'G:s%I7t}Q Suݍ7.SBBOcǎIχcƌQvvskWvӍ7=}t-]o"|GcM6MsX2e: (K/iժU_T ,++SIIJJJt-YDٳukܸqڲeɞ={t=;ƍa)S(%%E5ydJ hڴi9se]lHBJOOܹs5gԩSt]wi…ZdmVu=S5jj^W^ѷ~u)>>^ .Zv$͛5vX><6lؠm۶/W^yEU'&&F/rss駟J駟[n;wuP$w{OҫzJzG4w\efffڵKSNx5\c^xc1s5 .4ӭ[7i&~]v5͆ ̴i{9ӻwoc1F6r.][c{}/mf:vhJKK1ׯ1Ƙ/&--ͬ\L<cڵk̈́ LFF 1 45cOmLnn1Ƙ<e233ͶmLRR^z1ƘߦW^cƎkyy-[f&MT}-))1;w6'Noc1 <8r}S\nT=naaټy1cz!3vXcL?js?ԩ/o߾j5ߗVZÇ߿H2g!;wHllLs9G/}]|#F?4rJImݦ>}̙#Iҗ_~nݺ[n4h<$s4bbb>C߿_IIIj߾[޽uaC֭y6mt) zz쩜(77W%\RUt*::ZUj!Bjjl٢"[kgggk}Qnno߮xuYԮ];轐ǒ%KߏOoט-_\/VN4|mf݊8o=h\iϞ=8p=\\ҿϙ~>~.cuSeNeeeԩ[BB\.gB3z5qD|X7pbccoM0A{y^m'NԊ+TRRGLZ;(((ѣuV8qBڸq n222TVVӧO+##C]twx_^5ݻFW:n}1bk?35>V{YS^{ϟs9Ə+VTmذAcƌQϞ=ս{w6mѣG+##C.Kn[g?\aǏ+%%E>|~_ .@YYYgggj>R}w׮]:t `Po.ɚHvxuA{VRR?$ uIկ4tPuQ֐!Ct=hٲe9rݻ.7c ]~ӧt饗V{v)::Z?tu[nQ^ԯ_?>^W^y$뽙:u飖-[j5n}ݧ+11Q^W)))Zti:w+R]t~39rD%I\rz-%%%:vk4YniiiZtFB]ZlyZ|o[͚5K5`%$$H:_, 2Do> 0NDV&//cMwQlsС ǔ/};rmMf/_n ?P|sj'sxjԖ\{nxLYYYzj8T^-cKWvI_^eθovvv$SPP`zx sM7U{\4+5?Twݻw"鼼3nܸ3 DDa\$Jj)K i]]~*!阤$K*tJR2E@gY6Tgٲez]tWhkoܸoѭ(zܸqMv8xc뫯տ .v{м^-[7X,\.הhQª7u3%5T㏕B]y啺+j}oFG1F;w>ѮP bKbE>|G.ǣKDŕ='1QR;sx4^bp5ׯU0ƌw]z[lrirm w!Y"svn/Q0Ju;l9{}(Gjg ޣ}?#+bdwK8=/ F܌G:2Ⱦ-dR`;P=g(YfZܭT>DVna;eV6ETY=Fh8k5@? bUsvən{L'^%1w4vٙYCYvoגי'rp7P0xKr<}^'~yK$WIFß c8x=ZVHJ-dwLw D/%͓IHImԛc9=x;_@T&wǬp7͎]zJv27hZgXp7͊;GRw;|'o:gX 3|wzGpYPh>EzI?HZ${8&{@dIHD_%]-t8gַ-YVJlئP߁j+JIWaT&%k$˷xeW.=uǗ?^܈_m%#ZKzK4D(w ^w~DheRVwhL:*+sR2I% U*K8PʮQ@)^;~"$=(鯒&KI kbՍmRd6;P.|G= @"|" I}y JϰG^[!Dߔp߁p7Qy@d\.Wwnw;iI<ԷLW>eM'XI1/I;H*tJVYU˗Wn4eK<'*))Is^o4ijڻwo]x~i7N]vռyXW_իWkذaڵk:ǫ}4hn*IG9ӕ=رcձcGM@/VFFYgh-zd`/5  ?h/E*~JYrj%/$u]RR%/$+wZY̨O0tOƚ/l߾,YĴj۷l۶$%%c;wi׮YryMBBy嗍1Ƥɓ'L_Ҹ\.Y-bSm>jiLv͛Ν;MRRYf1ƘDsy{ѣG=zԬXt:tl۶ 0c̚5kLBBYnL~kf1fԨQ[o5;0C 1G1cƌ1?˫Zvw{{-d $-m zƷҷʺG)ЈC"|G=1Մk׮>|y'*7to{&..c3QQQxLnLII1ƘcǎUn~7lg}cLVVqɓ}Ge}رGl23i$gvMQQ1ƘBpBz5\c^xI8Q1AKo1bX"toD,j@K/B;v>mڴQQQo߮xuYԮ];Tzʎ?:(&&FԱcG%%%ը?OLLԟ'CJJ$%%}m{Ç_?X?$X{7|={UV8=C5j XՇm!,,  ĉ+vWmC:^W999^].<(cʳܚ /,,?/畤ʪmVK.UvvM6o߾:vx4ZŞPU/aE_$}FWgϞ޽~mIҦMW&''hÆ +W|vJGKRFFtiedd袋.OK&wݽ{Fѣ!%ۭٳgVϞ=kgWn?i,Yn"}@Ģ DO>D PVV~nݺ.\PSNU>}ԲeK <ǶkNz!͙3Gҥbcc%I&LЖ-[4z *99YEEE۷ϟ_etӽޫ-Zs}iJLLUJJ.]*IZxN=z(&&F$IcƌѢEԥK]s55襇hDpRRIK W3߹}j6 SńLLZ'O4_z:LzMIIzM6c̒%K̷~[iӦ˗?:fΝ&??߿>Oj1^dee Wz|x,`;P3vgkOZc۷o0iMEEE׀4fZJqqq޽{ǷnݺF۴i .СCz'ճgO:˥>}Tz|llvZy#a/X|{̷x}hP/zꥷ~[C +v뭷Vzɓ5t:_T]v^{:sn"}@ĢIEvXY%GZKj+ 댩}6r$icKʓ/P)I `^.YNHj!Ij'/l1d |)IUcb%]vT%55uSݎ*v\9# }@Ģ P={Ļ=BԷL·LkYce73xo)GI*UrJ$mw;r"};P5gwʃRYy@ݭ41x `޿HK|<GbY{e)qWrCv#\f@ Oa/X%g=JVKDIzw=jӲ*o5@? bUp;xw(/Qyf'xw;Јϼ Ь9'\s;8/P'%t3s Iy%wlku n3觰D,WA%*iY[Jj-:HZgL\.I!阬@aκ߈ {4]R&&h׹~*i09z:%A.!遤G!hf@wOa/X%)J#);j,FEc@? b5wj*cw=z"].p9(;Seg `C$IQQQ}Z)..VQQ^ڵkjw~أAq(;ԏYnPG]`G՝w)IZf\.iժ:}'!yhѢ{w諯Ҏ;x:_{Eԏp7#.®O>2ÇSNCrKg>~~tE)55U꫐!= @"|uv!?^۷נAuV7.SBBOcǎI1Z`막'￯m۶խު۷(`ۘ1c\?^xFW^yE3f̐$ZJ$)55U:tl2{1xӧOҥK6!w~ w:VL߿_ɓ+cN͝;W;v?.Iz饗j*/Qjj^x*=S5jܹSOx]\\SNn]wݥ jɒ%ڶm$);;[999?\sjΜ9?W~ׯ}мi%Y";P? w:ݫ?P ,9眣nA)))ZvN:\&MRΝ󟒬Qӄ t7k{Ѓ>XvmݺU&LД)S4vX͙3GU?A Ҝ9sԥKeeejϞ=ի>}(''GuxPgXN߯$o޿w:|g 8P{V\>ȑ#Gpޞ={*''G999u%=eeew}7`zuަM:uJ}ԩS'\.坱HÇ*õm6-ZH=[.Kd8p`@ oYf)99YׯWBB$kՌ34j(W-[T-j|^˥/XYYYuӀN+Y "KR8I%u,iTI.d}4wd߹;Jj廦XSqfΝ&??¶{Rc1yyyԩScJKK_|asVPP`?.77޽x<SVVfV^mZw͚5&--:--lڴc4_Rw|C/8`LzzYz8py7j}+dee}qƝqp!^׫+(IZJj-:HZW߯}͐tLqIy%J:%TRχLInP]h +W\Qs|7:r䈌1ܹzY.{FY4$Y"{E߁`]06{'r w!Y"{E߁`]4S "; !| ĢuDE$UqAp6ʸ5ܳD,jWDwX*c%[s#@*K՗sFA׷Aw~ w:8Cu:50 VR RRﱕLc+Ǻ;q=4ܳD,TDBc@0.st[VHB~zdx/SHx~6 ܳD,,7cѲF!w XzT⻎Ƿ;/e+\n&FVPjvwo<P4][h%)SJwlsN:dׂUy} _@#O{%eIzV6u4+ ꈾPMY?vHQV0nIVCp bgdh!zI%}.+&)E cPwnPG]ԗVa+eYe--|KY,5PdI$}"鯒&J*gg0U>oW![dIWWؿZ]vܒB|=^;YAUW% e {8ɚ>59q977NƱ,7ۨzn>QnFۣML1@"|ox9IGݪ:H҈mU=9gsqxL+S"`W$CVPY띒{Ms"|I?4VOd/JZVA4Yup7MF4#)_ևt/ *CVVPhY{e@`W+􆬑ѿ4l5okPV >$ilQ#ޝeW["I1B5h SI$mT ߝ{p}{d xJ_$#> lV}4F$pPxRErYV_;;wjԩ?F-IZz XM2EْwyGV$)==]3fb _t)Mjffzٶm_8;v۷:t`_m۶m6b7oedd$ۼyښ|C4v@[*Β$ t+g/Oy kF uw(x>)K%|R33oM:tZx޽}oۨQ|_~Z_rr-/ӧ#"" >M6Yhh9r̞x ?~\VVI|_k{n_ѣG믿n?]}վ|-^LLwUxI% 4NMs:-wVig*\r}|bbb۷+33S:pO}V ݫO?mZ)SE@^&\.歷[w*4;wy-[諯$k=zBC6;DZZ֮]Nn[oi]/իua^x߱,^sEVۧ>QiiiZf/tW {nݺi劈P~~ m۶)--M~dfw^_xԩzT^&IUtIJzLS?^^cfyϽ]R*xh; t6jAɓ'tQ-__#Gy睧D3洮=eرCrݺծ];I5}J#YF/Vffx 6L_|E2JMMU޽WAXXW7pz)ݻW3gԅ^(I;vkUHHƍm߾]QQQ%8#Н0̻J:%py7y޷J̯'/{RRgw*x jk,g!yQR< ýY4+l]QI$K*T(O@+8#ݒj\̔$c޽9sZegg+//O}Ҳe?YoL3f3{ztRرCW\!I j=oСC{I_:}-Ryxg{*FHETyxgښUw tjG@\.ףnô31 B13g rՐR3 p{C$y2U,sSsk`ys*..VQQnbbb^gy <.rJZlc/Z'wF;aIUL=sB?Vn{wT1{Н9ϟ:߿_.KW^yecSLҞ={ܹsԮ3gꫯҧ~s9@K3Δ1e~R©ǽ; Vݙrvs)ۭӧ޲aaaϕWTT 6]v?sL?_| ]r%0a֬Y9߁qW4}-^5wkwB"yug4LUNv?ڃw ` 4H s='IڼyFJ^yvm|233fأ>jffFxrrr7ް8;t萙 :>S5[={?"X>pв"U:6L"BVqo[ۤIlֱcGK;03\ ݻw=zW_'ŋ LY~kĉg'Nbڵ'xƏ;?++$Y~~/|ȰKMM ZyyEFFZvv؞={|m 3HXQ@#wVgmv)ia-uCFF>s=3bGt=Zx$irJMMՑJ0`o#4bĈJSHRyyymnGTT.2XB;v\={hݺuSTToL~קOeggk*//W.]|ǒrn'3;<^&}AmU;jΜ99KKKUZZ*I:z^{5G_|w\r\:uTu8qV^w}WW_}uciiiZf:$IztBvIJLLTBBVX!ڵK#GTBB:woW>33S+`7s)K"OQMcrrr좋.޽;rssmʕkYYYff_ʆ ff;묳lСks՗nQQQ֯_?4i &XTT 2?[=ĉ7n]veΜff~EFFZjj6mdf\}뭷,22҆n{=Ӿ|Κ-Zn@h ߁fT{m?'O-[ؑ#G;zhLYYYVRRRc} 8`;vR߾ؖ-[-l2|ϯ:{^h;BzȘ IDAT4}~ڌFm+4W\a{nꪫ-ZVKk,PIKQRΒkg'K:*阤|I %T*\G !ʕ+VmݻWGk׮ٳg] @UʕW^yZ{YoE4tI fr tN}@Ŵ31 Bw*.Rk FC;!&G _gAIDWےT#вtഔֲ-Ϸ%*b#6-\ mfI%yI7H: O. `S"@m Mu(WIiHJ%}M5 S63^WI7JGͦ%a.͆9$)"χUI $§ڬ pu>th n4#= `@?z@x1 `@?z4\pZEI t;MllcTrrpzU$ t#M~~$]n8=L;4h h߁ @۸q RoSrUnhi*--$%$$h۶m-vӕQfddwm5Nkmc;4矯%K4/K?~/6s +nM>]Œ5k(99ŮV\^z5?\?|qZ}-hn0a^{5]tE>|֭[{G ,IڶmFDq*(($k֬YڵW^yE;wC=?X?lkNN~ӟsUJJ>3߱5auU7p3'~>~/*Y8IJXI$]k8IkZŢKolg/۝wiaaav}٦MlK/٨Q{7,..:d <ϟo\peffڎ;o߾+-b_[#G٢EK.kSL̖-[fIII{͛o߾h"33KMM{233m̙bff]t;v^gmwﶌ d7o6muVۿuVZetꪫlƌcK,kZRRun[t#>vaǏ.]ؼyoiӦ5\cff> <ؾ+[|EFFww}Wg[_۽kgyƆZ}:t75\c?x>ppum;}Cpʄh ,%|_rp;~yYfYFFX^^T[pa}ذa?Wgqƙ'|OJJ#GV6o+Wإ^jݻw|337n?M4ɾk "33+,,ٳg5|/++3IVPP{[n'xƏ+e,??f̘aӦM졇wҥKs5mffֵkW+//Yf_+[=s `fmVXXhÆ ^{wl…-ZT5殻)SXnn}fV}/))]ڂ rssm޽oL^cwm8$&&JL ӣGuQRٳGSll>} qdffjĈwoI6m6lPi6l> 6??#ɳpyx=޽{ճgOEFFJ:t{L.W׿g >[n򽾄߱hYڝDGGri׮] /W{܃;vaTVVeffjӦMӠAm㡇Rvvt^sm=<<\?Ν.]THHH5}jHZՀ]iJS.++믿E]v@7XB'4ݵkFYĉoTf+Wjرeee*))I}]}Gڸqbbb4w\IҨQtR\.hz'ԳgO%%%i咤%Khž~'zw}%˥SNUjwZZ֬Y {=]~5i&_}#ݗ,YduYwϜ{n:*""BVr7|S:znFEEE)44҂˗/ѣG] Չ'jǎӠAT\\#F'?ҨQ*}kҤIJIIQAAյkZ{N4~xuM]t9zJ]vqg4c,*X ۲eoR3-jfVVVf;v\mQXqq8p'NرcjY\؎;A̴ҥ6f+//ݻw^Mm{=r}V\\\o*+))'Nټyoǎ/N:Ui]=33Rts-Xpm h4t123EGG=?t萞{9ӷ/44MrΫXDDw^mTTj:9.ɳ mMe$sܹsuw t3߱Vh/`(NH:TRSSæNZTuFǏvn'''L:5TRKyyymʢRsOSTӚc^K~Zz*)BR{IQ:JY{o1fEntT1I $J:)OpUu TEE0W9PH@[C@#|]nH])#| "Xw V&F4@7h$.m1InϪ[SpRԴJ߁b4}~v9a7wh6h  ˽/hfane$r}Jur͊Vu{w$)ֻuARIg"'\/tRRK*QE?;< tF"Og$yRI$'hwy˖Iz_ K眔TY_ cA4}~v<3;O"o'O*i*F; Ow ;Z)gJ ޝpXS΄z9L?llB/ӶRyr'@/T )_RcJ:݆=;-=s@q൜v.yFREHj/)Jb%ur\t*>: |QXmCw*.mq3 $T#T1 1X;;ǝ,vVT\R9y~u8#Ty;;fC^3gհ}U?@p&r*w79s;CTy~G;A2x;7h];-OPsgz'xwFRy?{0͊n"|_Q>=w@#w m3ݙ~W*qw'r\h.="iNM ԡCTs*)))Qxx\oGII"""캥 mhL-ЄS8 Z@7{Urr<6[;w\ǎuĉj7nܨuGO?&!!A۶mk|AlLb_֧~@7цe˖֬Y={6Y}hS8 Z|:u u:t&NX 6Ly߹sNkђm۶iJLLwܡ_sQ5l07?xƍ8M>^7x%IYYYկ_?͚5Knϟ4iG}TӧO7|S>8['?͛޽{+%%E[nV~Æ _B}U+oY+HRsYDE0A_3{Īػwo>+))QF<`999oX\\:t6mdve֥K7o}76m4kl͖b[n۷[m֭ffjseff̙3-%%m~zhVTTTa^z}'6o<ݻwl333fXLL-Y֮]kIIIꫯل lɶqFl.6n:|b_|Ev֭[?0{lǎ6i$KKKV~ҥb<ٳN:u͚5|A33/i{m4_z!;uu>lffZc^eeeo%%%ffvQs\qqqVZZjff6l}V+tR;sv[׮]RGl&Ɏ?9@7h$.V+ :٣~)66ַO>Ζ$Sg}$)##C;vP||5l0)''G111zAモ$ݻW={Tdd$Czr$Ҝ***]v~=zZju}'JHHP׮]%In?"IDAT1114hPר>L;wVxx$)..N|s`egg|2224bIÒ';v233}Ç7ڷo6oެ}$I:zo2۾:CCC\ݻw/$mѣ>컾q^w\ʪt>\o{ }srrC믿^W_}~F]&|OLLTBBVX!ɳ]4rjeGu)77WZj.˥m۶)--M]tw}7JOJJ%IK,ŋO9;w͛+KϞ=o_ UVV+WJ}#ݗ,YduYGUvvnEDD7lk@[={: 2DC=vU+w饗V^Էo_W_$M>]ӧO/,IOjʔ);wnfCz饗N6mGyDQQQnfwyj߾.ŋӽޫ[n8P$]{r\:~^Jǻt;C^xt(%%EfԩS d,ZUAAmٲ -{/"۷oﹳȩYqq8p!M+- {:lΝM6nhnJJJv[tttK.1cXyy޽ζ CreationDate 2007-03-15 15:23:17 -0400 Creator John.alt GraphDocumentVersion 5 GuidesLocked NO GuidesVisible YES ImageCounter 1 LinksVisible NO MagnetsVisible NO MasterSheets ActiveLayerIndex 0 AutoAdjust CanvasColor w 1 CanvasOrigin {0, 0} CanvasScale 1 ColumnAlign 1 ColumnSpacing 36 DisplayScale 1 in = 1 in GraphicsList GridInfo HPages 1 IsPalette NO KeepToScale Layers Lock NO Name Layer 1 Print YES View YES LayoutInfo Orientation 2 OutlineStyle Basic RowAlign 1 RowSpacing 36 SheetTitle Master 1 UniqueID 1 VPages 1 ModificationDate 2007-03-15 16:57:24 -0400 Modifier John.alt NotesVisible NO OriginVisible NO PageBreaks YES PrintInfo NSBottomMargin float 0 NSLeftMargin float 0 NSOrientation int 1 NSPaperSize size {792, 612} NSRightMargin float 0 NSTopMargin float 0 ReadOnly NO Sheets ActiveLayerIndex 0 AutoAdjust CanvasColor w 1 CanvasOrigin {0, 0} CanvasScale 1 ColumnAlign 1 ColumnSpacing 36 DisplayScale 1 in = 1 in GraphicsList Bounds {{607.473, 151.036}, {112, 28}} Class ShapedGraphic FitText YES FontInfo Color w 0 Font Helvetica Size 12 ID 86 Line ID 72 Position 0.31921392679214478 RotationType 0 Shape Rectangle Style shadow Draws NO stroke Draws NO Text Text {\rtf1\mac\ansicpg10000\cocoartf824\cocoasubrtf410 {\fonttbl\f0\fswiss\fcharset77 Helvetica-Oblique;} {\colortbl;\red255\green255\blue255;} \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\qc\pardirnatural \f0\i\fs24 \cf0 deprecated,\ marked for refactor} Bounds {{584.742, 252.673}, {104, 28}} Class ShapedGraphic FitText YES FontInfo Color w 0 Font Helvetica Size 12 ID 85 Line ID 84 Position 0.45520344376564026 RotationType 0 Shape Rectangle Style shadow Draws NO stroke Draws NO Text Text {\rtf1\mac\ansicpg10000\cocoartf824\cocoasubrtf410 {\fonttbl\f0\fswiss\fcharset77 Helvetica-Oblique;} {\colortbl;\red255\green255\blue255;} \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\qc\pardirnatural \f0\i\fs24 \cf0 if binding spec \ uses plugin prefix} Class LineGraphic Head ID 39 ID 84 Points {623.954, 304} {652.046, 222} Style stroke HeadArrow FilledArrow HopLines HopType 1 Pattern 1 TailArrow 0 Tail ID 51 Class LineGraphic Head ID 51 ID 83 Points {488, 317} {555, 317} Style stroke HeadArrow FilledArrow HopLines HopType 1 TailArrow 0 Tail ID 48 Class LineGraphic Head ID 54 ID 82 Points {453.532, 330} {575.468, 366} Style stroke HeadArrow FilledArrow HopLines HopType 1 TailArrow 0 Tail ID 48 Class LineGraphic Head ID 42 ID 81 Points {83.5916, 196} {84, 138} {256, 138} {466, 138} {656, 138} {671.008, 99} Style stroke HeadArrow FilledArrow HopLines HopType 1 TailArrow 0 Tail ID 33 Class LineGraphic Head ID 39 ID 80 Points {83.6857, 196} {84, 174} {256, 174} {466, 174} {598, 198.252} Style stroke HeadArrow FilledArrow HopLines HopType 1 TailArrow 0 Tail ID 33 Class LineGraphic Head ID 45 ID 66 Points {142, 221.044} {195, 231.956} Style stroke HeadArrow FilledArrow HopLines HopType 1 TailArrow 0 Tail ID 33 Class LineGraphic Head ID 48 ID 79 Points {106.976, 222} {237, 294} {331, 306.533} Style stroke HeadArrow FilledArrow HopLines HopType 1 TailArrow 0 Tail ID 33 Class LineGraphic Head ID 39 ID 78 Points {419.845, 304} {466, 246} {598, 220.362} Style stroke HeadArrow FilledArrow HopLines HopType 1 TailArrow 0 Tail ID 48 Class LineGraphic Head ID 39 ID 77 Points {254.456, 231} {256, 210} {466, 210} {598, 209.307} Style stroke HeadArrow FilledArrow HopLines HopType 1 TailArrow 0 Tail ID 45 Class LineGraphic Head ID 42 ID 72 Points {658.562, 196} {673.948, 99} Style stroke HeadArrow FilledArrow LineType 1 Pattern 1 TailArrow 0 Tail ID 39 Class LineGraphic Head ID 48 ID 71 Points {281.281, 257} {381.719, 304} Style stroke HeadArrow FilledArrow LineType 1 TailArrow 0 Tail ID 45 Class TableGroup Graphics Bounds {{524, 366}, {191, 14}} Class ShapedGraphic FitText Vertical Flow Resize ID 55 Shape Rectangle Style fill GradientAngle 304 GradientCenter {-0.294118, -0.264706} Text Text {\rtf1\mac\ansicpg10000\cocoartf824\cocoasubrtf410 {\fonttbl\f0\fswiss\fcharset77 Helvetica-Bold;} {\colortbl;\red255\green255\blue255;} \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\qc \f0\b\fs24 \cf0 LegacyLifecycleMappingParser} TextPlacement 0 Bounds {{524, 380}, {191, 12}} Class ShapedGraphic FitText Vertical Flow Resize ID 56 Shape Rectangle Style fill GradientAngle 304 GradientCenter {-0.294118, -0.264706} Text Align 0 TextPlacement 0 GridH 55 56 GroupConnect YES ID 54 Class TableGroup Graphics Bounds {{555, 304}, {129, 14}} Class ShapedGraphic FitText Vertical Flow Resize ID 52 Shape Rectangle Style fill GradientAngle 304 GradientCenter {-0.294118, -0.264706} Text Text {\rtf1\mac\ansicpg10000\cocoartf824\cocoasubrtf410 {\fonttbl\f0\fswiss\fcharset77 Helvetica-Bold;} {\colortbl;\red255\green255\blue255;} \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\qc \f0\b\fs24 \cf0 MojoBindingFactory} TextPlacement 0 Bounds {{555, 318}, {129, 12}} Class ShapedGraphic FitText Vertical Flow Resize ID 53 Shape Rectangle Style fill GradientAngle 304 GradientCenter {-0.294118, -0.264706} Text Align 0 TextPlacement 0 GridH 52 53 GroupConnect YES ID 51 Class TableGroup Graphics Bounds {{331, 304}, {157, 14}} Class ShapedGraphic FitText Vertical Flow Resize ID 49 Shape Rectangle Style fill GradientAngle 304 GradientCenter {-0.294118, -0.264706} Text Text {\rtf1\mac\ansicpg10000\cocoartf824\cocoasubrtf410 {\fonttbl\f0\fswiss\fcharset77 Helvetica-Bold;} {\colortbl;\red255\green255\blue255;} \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\qc \f0\b\fs24 \cf0 LifecycleBindingManager} TextPlacement 0 Bounds {{331, 318}, {157, 12}} Class ShapedGraphic FitText Vertical Flow Resize ID 50 Shape Rectangle Style fill GradientAngle 304 GradientCenter {-0.294118, -0.264706} Text Align 0 TextPlacement 0 GridH 49 50 GroupConnect YES ID 48 Class TableGroup Graphics Bounds {{195, 231}, {117, 14}} Class ShapedGraphic FitText Vertical Flow Resize ID 46 Shape Rectangle Style fill GradientAngle 304 GradientCenter {-0.294118, -0.264706} Text Text {\rtf1\mac\ansicpg10000\cocoartf824\cocoasubrtf410 {\fonttbl\f0\fswiss\fcharset77 Helvetica-Bold;} {\colortbl;\red255\green255\blue255;} \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\qc \f0\b\fs24 \cf0 BuildPlanner} TextPlacement 0 Bounds {{195, 245}, {117, 12}} Class ShapedGraphic FitText Vertical Flow Resize ID 47 Shape Rectangle Style fill GradientAngle 304 GradientCenter {-0.294118, -0.264706} Text Align 0 TextPlacement 0 GridH 46 47 GroupConnect YES ID 45 Class TableGroup Graphics Bounds {{617.51, 73}, {117, 14}} Class ShapedGraphic FitText Vertical Flow Resize ID 43 Shape Rectangle Style fill GradientAngle 304 GradientCenter {-0.294118, -0.264706} Text Text {\rtf1\mac\ansicpg10000\cocoartf824\cocoasubrtf410 {\fonttbl\f0\fswiss\fcharset77 Helvetica-Bold;} {\colortbl;\red255\green255\blue255;} \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\qc \f0\b\fs24 \cf0 PluginManager} TextPlacement 0 Bounds {{617.51, 87}, {117, 12}} Class ShapedGraphic FitText Vertical Flow Resize ID 44 Shape Rectangle Style fill GradientAngle 304 GradientCenter {-0.294118, -0.264706} Text Align 0 TextPlacement 0 GridH 43 44 GroupConnect YES ID 42 Class TableGroup Graphics Bounds {{598, 196}, {117, 14}} Class ShapedGraphic FitText Vertical Flow Resize ID 40 Shape Rectangle Style fill GradientAngle 304 GradientCenter {-0.294118, -0.264706} Text Text {\rtf1\mac\ansicpg10000\cocoartf824\cocoasubrtf410 {\fonttbl\f0\fswiss\fcharset77 Helvetica-Bold;} {\colortbl;\red255\green255\blue255;} \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\qc \f0\b\fs24 \cf0 PluginLoader} TextPlacement 0 Bounds {{598, 210}, {117, 12}} Class ShapedGraphic FitText Vertical Flow Resize ID 41 Shape Rectangle Style fill GradientAngle 304 GradientCenter {-0.294118, -0.264706} Text Align 0 TextPlacement 0 GridH 40 41 GroupConnect YES ID 39 Class TableGroup Graphics Bounds {{25, 196}, {117, 14}} Class ShapedGraphic FitText Vertical Flow Resize ID 34 Shape Rectangle Style fill GradientAngle 304 GradientCenter {-0.294118, -0.264706} Text Text {\rtf1\mac\ansicpg10000\cocoartf824\cocoasubrtf410 {\fonttbl\f0\fswiss\fcharset77 Helvetica-Bold;} {\colortbl;\red255\green255\blue255;} \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\qc \f0\b\fs24 \cf0 LifecycleExecutor} TextPlacement 0 Bounds {{25, 210}, {117, 12}} Class ShapedGraphic FitText Vertical Flow Resize ID 38 Shape Rectangle Style fill GradientAngle 304 GradientCenter {-0.294118, -0.264706} Text Align 0 TextPlacement 0 GridH 34 38 GroupConnect YES ID 33 GridInfo HPages 1 IsPalette NO KeepToScale Layers Lock NO Name Layer 1 Print YES View YES LayoutInfo ChildOrdering 0 HierarchicalOrientation 0 MasterSheet Master 1 Orientation 2 OutlineStyle Basic RowAlign 1 RowSpacing 36 SheetTitle Canvas 1 UniqueID 1 VPages 1 ActiveLayerIndex 0 AutoAdjust CanvasColor w 1 CanvasOrigin {0, 0} CanvasScale 1 ColumnAlign 1 ColumnSpacing 36 DisplayScale 1 in = 1 in GraphicsList Bounds {{521.5, 182.853}, {75, 14}} Class ShapedGraphic FitText YES Flow Resize FontInfo Color w 0 Font Helvetica Size 12 ID 126 Shape Rectangle Style shadow Draws NO stroke Draws NO Text Text {\rtf1\mac\ansicpg10000\cocoartf824\cocoasubrtf410 {\fonttbl\f0\fswiss\fcharset77 Helvetica;} {\colortbl;\red255\green255\blue255;} \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\qc\pardirnatural \f0\fs24 \cf0 loadPlugin()} Wrap NO Bounds {{437, 221.123}, {92, 14}} Class ShapedGraphic FitText YES ID 125 Line ID 124 Offset 18.181819915771484 Position 0.55852556228637695 RotationType 0 Shape Rectangle Style shadow Draws NO stroke Draws NO Text Align 0 Text {\rtf1\mac\ansicpg10000\cocoartf824\cocoasubrtf410 {\fonttbl\f0\fswiss\fcharset77 Helvetica;} {\colortbl;\red255\green255\blue255;} \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ql\qnatural \f0\fs24 \cf0 binding, project} AllowLabelDrop Class LineGraphic Head ID 123 ID 124 Points {398, 209.12} {550.5, 210.592} Style stroke HeadArrow FilledArrow HeadScale 1.4285709857940674 TailArrow StickArrow TailScale 1.5 Tail ID 79 Bounds {{550.5, 203.842}, {17, 27}} Class ShapedGraphic HFlip YES ID 123 Magnets {1, 0.5} {1, -0.5} {-1, 0.5} {-1, -0.5} {0.5, 1} {-0.5, 1} {0.5, -1} {-0.5, -1} Shape Rectangle Text Align 0 Bounds {{521.5, 114.705}, {75, 14}} Class ShapedGraphic FitText YES Flow Resize FontInfo Color w 0 Font Helvetica Size 12 ID 122 Shape Rectangle Style shadow Draws NO stroke Draws NO Text Text {\rtf1\mac\ansicpg10000\cocoartf824\cocoasubrtf410 {\fonttbl\f0\fswiss\fcharset77 Helvetica;} {\colortbl;\red255\green255\blue255;} \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\qc\pardirnatural \f0\fs24 \cf0 loadPlugin()} Wrap NO Bounds {{436.814, 155.115}, {92, 14}} Class ShapedGraphic FitText YES ID 121 Line ID 120 Offset 18.181819915771484 Position 0.55852556228637695 RotationType 0 Shape Rectangle Style shadow Draws NO stroke Draws NO Text Align 0 Text {\rtf1\mac\ansicpg10000\cocoartf824\cocoasubrtf410 {\fonttbl\f0\fswiss\fcharset77 Helvetica;} {\colortbl;\red255\green255\blue255;} \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ql\qnatural \f0\fs24 \cf0 binding, project} AllowLabelDrop Class LineGraphic Head ID 119 ID 120 Points {397.5, 143.273} {550.5, 144.455} Style stroke HeadArrow FilledArrow HeadScale 1.4285709857940674 TailArrow StickArrow TailScale 1.5 Tail ID 73 Info 4 Bounds {{550.5, 137.705}, {17, 27}} Class ShapedGraphic HFlip YES ID 119 Magnets {1, 0.5} {1, -0.5} {-1, 0.5} {-1, -0.5} {0.5, 1} {-0.5, 1} {0.5, -1} {-0.5, -1} Shape Rectangle Text Align 0 Bounds {{26, 636}, {131, 14}} Class ShapedGraphic FitText YES Flow Resize ID 118 Shape Rectangle Style shadow Draws NO stroke Draws NO Text Align 0 Text {\rtf1\mac\ansicpg10000\cocoartf824\cocoasubrtf410 {\fonttbl\f0\fswiss\fcharset77 Helvetica;} {\colortbl;\red255\green255\blue255;} \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ql\qnatural \f0\fs24 \cf0 foreach binding in plan} Wrap NO AllowLabelDrop Class LineGraphic Head ID 4 Info 5 ID 117 OrthogonalBarAutomatic OrthogonalBarPosition 19.371429443359375 Points {75.5, 478} {26, 482} {26, 575} {79.125, 616} Style stroke HeadArrow 0 HeadScale 0.86000001430511475 LineType 2 TailArrow FilledArrow TailScale 0.85714292526245117 Tail ID 4 Info 1 Bounds {{310.653, 581.444}, {179, 14}} Class ShapedGraphic FitText YES ID 116 Line ID 115 Offset 18.181819915771484 Position 0.52437615394592285 RotationType 0 Shape Rectangle Style shadow Draws NO stroke Draws NO Text Align 0 Text {\rtf1\mac\ansicpg10000\cocoartf824\cocoasubrtf410 {\fonttbl\f0\fswiss\fcharset77 Helvetica;} {\colortbl;\red255\green255\blue255;} \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ql\qnatural \f0\fs24 \cf0 mojoExecution, project, session} AllowLabelDrop Class LineGraphic Head ID 113 Info 2 ID 115 Points {90, 570} {681.5, 570.5} Style stroke HeadArrow FilledArrow HeadScale 1.4285709857940674 TailArrow StickArrow TailScale 1.5 Tail ID 4 Info 12 Bounds {{646.5, 539}, {87, 14}} Class ShapedGraphic FitText YES FontInfo Color w 0 Font Helvetica Size 12 ID 114 Line ID 111 Position 0.8310316801071167 RotationType 0 Shape Rectangle Style shadow Draws NO stroke Draws NO Text Text {\rtf1\mac\ansicpg10000\cocoartf824\cocoasubrtf410 {\fonttbl\f0\fswiss\fcharset77 Helvetica;} {\colortbl;\red255\green255\blue255;} \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\qc\pardirnatural \f0\fs24 \cf0 executeMojo()} Bounds {{681.5, 559}, {17, 46}} Class ShapedGraphic HFlip YES ID 113 Magnets {1, 0.5} {1, -0.5} {-1, 0.5} {-1, -0.5} {0.5, 1} {-0.5, 1} {0.5, -1} {-0.5, -1} Shape Rectangle Text Align 0 Class Group Graphics AllowLabelDrop Class LineGraphic ID 111 Points {690, 34.5} {690, 650} Style stroke HeadArrow 0 HeadScale 1.4285709857940674 Pattern 1 TailArrow 0 TailScale 0.5 Tail ID 112 Bounds {{636, 20}, {108, 14}} Class ShapedGraphic FitText Vertical Flow Resize ID 112 Shape Rectangle Text Text {\rtf1\mac\ansicpg10000\cocoartf824\cocoasubrtf410 {\fonttbl\f0\fswiss\fcharset77 Helvetica-Bold;} {\colortbl;\red255\green255\blue255;} \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\qc \f0\b\fs24 \cf0 \ul \ulc0 PluginManager} ID 110 Bounds {{287.086, 525.522}, {92, 14}} Class ShapedGraphic FitText YES ID 109 Line ID 108 Offset 18.181819915771484 Position 0.52776741981506348 RotationType 0 Shape Rectangle Style shadow Draws NO stroke Draws NO Text Align 0 Text {\rtf1\mac\ansicpg10000\cocoartf824\cocoasubrtf410 {\fonttbl\f0\fswiss\fcharset77 Helvetica;} {\colortbl;\red255\green255\blue255;} \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ql\qnatural \f0\fs24 \cf0 binding, project} AllowLabelDrop Class LineGraphic Head ID 106 Info 2 ID 108 Points {90, 515} {550.5, 513.75} Style stroke HeadArrow FilledArrow HeadScale 1.4285709857940674 TailArrow StickArrow TailScale 1.5 Tail ID 4 Info 3 Bounds {{521.5, 485}, {75, 14}} Class ShapedGraphic FitText YES Flow Resize FontInfo Color w 0 Font Helvetica Size 12 ID 107 Shape Rectangle Style shadow Draws NO stroke Draws NO Text Text {\rtf1\mac\ansicpg10000\cocoartf824\cocoasubrtf410 {\fonttbl\f0\fswiss\fcharset77 Helvetica;} {\colortbl;\red255\green255\blue255;} \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\qc\pardirnatural \f0\fs24 \cf0 loadPlugin()} Wrap NO Bounds {{550.5, 507}, {17, 27}} Class ShapedGraphic HFlip YES ID 106 Magnets {1, 0.5} {0.5, -0.25} {-1, 0.5} {-1, -0.5} {0.5, 1} {-0.5, 1} {0.5, -1} {-0.5, -1} Shape Rectangle Text Align 0 Bounds {{130.5, 275}, {33, 14}} Class ShapedGraphic FitText YES Flow Resize ID 105 Shape Rectangle Style shadow Draws NO stroke Draws NO Text Align 0 Text {\rtf1\mac\ansicpg10000\cocoartf824\cocoasubrtf410 {\fonttbl\f0\fswiss\fcharset77 Helvetica;} {\colortbl;\red255\green255\blue255;} \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ql\qnatural \f0\fs24 \cf0 plan} Wrap NO Class LineGraphic Head ID 4 ID 66 Points {205.5, 270} {86.375, 270} Style stroke HeadArrow FilledArrow HopLines HopType 1 TailArrow 0 Tail ID 19 Info 16 Bounds {{521.5, 302}, {75, 14}} Class ShapedGraphic FitText YES Flow Resize FontInfo Color w 0 Font Helvetica Size 12 ID 104 Shape Rectangle Style shadow Draws NO stroke Draws NO Text Text {\rtf1\mac\ansicpg10000\cocoartf824\cocoasubrtf410 {\fonttbl\f0\fswiss\fcharset77 Helvetica;} {\colortbl;\red255\green255\blue255;} \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\qc\pardirnatural \f0\fs24 \cf0 loadPlugin()} Wrap NO Bounds {{349.413, 453.786}, {92, 14}} Class ShapedGraphic FitText YES ID 103 Line ID 102 Offset 18.181819915771484 Position 0.52776741981506348 RotationType 0 Shape Rectangle Style shadow Draws NO stroke Draws NO Text Align 0 Text {\rtf1\mac\ansicpg10000\cocoartf824\cocoasubrtf410 {\fonttbl\f0\fswiss\fcharset77 Helvetica;} {\colortbl;\red255\green255\blue255;} \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ql\qnatural \f0\fs24 \cf0 binding, project} AllowLabelDrop Class LineGraphic Head ID 101 ID 102 Points {222, 443} {550.5, 442.25} Style stroke HeadArrow FilledArrow HeadScale 1.4285709857940674 TailArrow StickArrow TailScale 1.5 Tail ID 86 Bounds {{550.5, 422}, {17, 27}} Class ShapedGraphic HFlip YES ID 101 Magnets {1, 0.5} {0.5, -0.25} {-1, 0.5} {-1, -0.5} {0.5, 1} {-0.5, 1} {0.5, -1} {-0.5, -1} Shape Rectangle Text Align 0 Bounds {{521.5, 396.749}, {75, 14}} Class ShapedGraphic FitText YES FontInfo Color w 0 Font Helvetica Size 12 ID 100 Line ID 93 Position 0.59991699457168579 RotationType 0 Shape Rectangle Style shadow Draws NO stroke Draws NO Text Text {\rtf1\mac\ansicpg10000\cocoartf824\cocoasubrtf410 {\fonttbl\f0\fswiss\fcharset77 Helvetica;} {\colortbl;\red255\green255\blue255;} \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\qc\pardirnatural \f0\fs24 \cf0 loadPlugin()} Bounds {{349.564, 356.057}, {92, 14}} Class ShapedGraphic FitText YES ID 99 Line ID 98 Offset 18.181819915771484 Position 0.52776741981506348 RotationType 0 Shape Rectangle Style shadow Draws NO stroke Draws NO Text Align 0 Text {\rtf1\mac\ansicpg10000\cocoartf824\cocoasubrtf410 {\fonttbl\f0\fswiss\fcharset77 Helvetica;} {\colortbl;\red255\green255\blue255;} \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ql\qnatural \f0\fs24 \cf0 binding, project} AllowLabelDrop Class LineGraphic Head ID 95 ID 98 Points {222.5, 344.456} {550.5, 345.25} Style stroke HeadArrow FilledArrow HeadScale 1.4285709857940674 TailArrow StickArrow TailScale 1.5 Tail ID 83 Info 9 AllowLabelDrop Class LineGraphic Head ID 86 Info 3 ID 97 OrthogonalBarAutomatic OrthogonalBarPosition -1 Points {222.5, 254.5} {309.5, 254} {327, 344} {222.5, 454.079} Style stroke HeadArrow 0 HeadScale 0.86000001430511475 LineType 2 TailArrow StickArrow TailScale 0.85714292526245117 Tail ID 19 Info 15 AllowLabelDrop Class LineGraphic Head ID 83 Info 3 ID 96 OrthogonalBarAutomatic OrthogonalBarPosition -1 Points {222, 237} {295.5, 237} {295.5, 337} {222.5, 356.792} Style stroke HeadArrow 0 HeadScale 0.86000001430511475 LineType 2 TailArrow StickArrow TailScale 0.85714292526245117 Tail ID 19 Info 14 Bounds {{550.5, 325}, {17, 27}} Class ShapedGraphic HFlip YES ID 95 Magnets {1, 0.5} {1, -0.5} {-1, 0.5} {-1, -0.5} {0.5, 1} {-0.5, 1} {0.5, -1} {-0.5, -1} Shape Rectangle Text Align 0 Class Group Graphics AllowLabelDrop Class LineGraphic ID 93 Points {559, 34.5} {559, 650} Style stroke HeadArrow 0 HeadScale 1.4285709857940674 Pattern 1 TailArrow 0 TailScale 0.5 Tail ID 94 Bounds {{505, 20}, {108, 14}} Class ShapedGraphic FitText Vertical Flow Resize ID 94 Shape Rectangle Text Text {\rtf1\mac\ansicpg10000\cocoartf824\cocoasubrtf410 {\fonttbl\f0\fswiss\fcharset77 Helvetica-Bold;} {\colortbl;\red255\green255\blue255;} \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\qc \f0\b\fs24 \cf0 \ul \ulc0 PluginLoader} ID 92 AllowLabelDrop Class LineGraphic Head ID 19 Info 13 ID 91 OrthogonalBarAutomatic OrthogonalBarPosition -1 Points {222.5, 426.798} {321, 420} {301, 249} {222.5, 248.833} Style stroke HeadArrow 0 HeadScale 0.86000001430511475 LineType 2 TailArrow FilledArrow TailScale 0.85714292526245117 Tail ID 86 Info 4 AllowLabelDrop Class LineGraphic Head ID 19 Info 12 ID 10 OrthogonalBarAutomatic OrthogonalBarPosition -1 Points {222.5, 330.264} {288.5, 330} {288.5, 230} {222.5, 230} Style stroke HeadArrow 0 HeadScale 0.86000001430511475 LineType 2 TailArrow FilledArrow TailScale 0.85714292526245117 Tail ID 83 Info 4 Bounds {{132.5, 396.158}, {163, 14}} Class ShapedGraphic FitText YES Flow Resize FontInfo Color w 0 Font Helvetica Size 12 ID 87 Shape Rectangle Style shadow Draws NO stroke Draws NO Text Text {\rtf1\mac\ansicpg10000\cocoartf824\cocoasubrtf410 {\fonttbl\f0\fswiss\fcharset77 Helvetica;} {\colortbl;\red255\green255\blue255;} \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\qc\pardirnatural \f0\fs24 \cf0 addReportingPlanModifiers()} Wrap NO Bounds {{205.5, 413.158}, {17, 54.5618}} Class ShapedGraphic HFlip YES ID 86 Magnets {1, 0.5} {1, -0.5} {-1, 0.5} {-1, -0.5} {0.5, 1} {-0.5, 1} {0.5, -1} {-0.5, -1} {-0.529412, 0.0497093} Shape Rectangle Text Align 0 Bounds {{139.5, 297.124}, {149, 14}} Class ShapedGraphic FitText YES FontInfo Color w 0 Font Helvetica Size 12 ID 84 Line ID 17 Position 0.43805667757987976 RotationType 0 Shape Rectangle Style shadow Draws NO stroke Draws NO Text Text {\rtf1\mac\ansicpg10000\cocoartf824\cocoasubrtf410 {\fonttbl\f0\fswiss\fcharset77 Helvetica;} {\colortbl;\red255\green255\blue255;} \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\qc\pardirnatural \f0\fs24 \cf0 addForkedPlanModifiers()} Bounds {{205.5, 317}, {17, 53.056}} Class ShapedGraphic HFlip YES ID 83 Magnets {1, 0.5} {1, -0.5} {-1, 0.5} {-1, -0.5} {0.5, 1} {-0.5, 1} {0.5, -1} {-0.5, -1} {-0.529412, 0.0185184} Shape Rectangle Text Align 0 Bounds {{305.436, 220.259}, {47, 14}} Class ShapedGraphic FitText YES ID 82 Line ID 81 Offset 18.181819915771484 Position 0.67475664615631104 RotationType 0 Shape Rectangle Style shadow Draws NO stroke Draws NO Text Align 0 Text {\rtf1\mac\ansicpg10000\cocoartf824\cocoasubrtf410 {\fonttbl\f0\fswiss\fcharset77 Helvetica;} {\colortbl;\red255\green255\blue255;} \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ql\qnatural \f0\fs24 \cf0 project} AllowLabelDrop Class LineGraphic Head ID 79 Info 2 ID 81 Points {222, 209} {380.5, 209.115} Style stroke HeadArrow FilledArrow HeadScale 1.4285709857940674 TailArrow StickArrow TailScale 1.5 Tail ID 19 Info 3 Bounds {{311.5, 120.556}, {155, 14}} Class ShapedGraphic FitText YES Flow Resize FontInfo Color w 0 Font Helvetica Size 12 ID 80 Shape Rectangle Style shadow Draws NO stroke Draws NO Text Text {\rtf1\mac\ansicpg10000\cocoartf824\cocoasubrtf410 {\fonttbl\f0\fswiss\fcharset77 Helvetica;} {\colortbl;\red255\green255\blue255;} \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\qc\pardirnatural \f0\fs24 \cf0 getBindingsForPackaging()} Wrap NO Bounds {{380.5, 203.842}, {17, 21.0909}} Class ShapedGraphic HFlip YES ID 79 Magnets {1, 0.5} {1, -0.5} {-1, 0.5} {-1, -0.5} {0.5, 1} {-0.5, 1} {0.5, -1} {-0.5, -1} Shape Rectangle Text Align 0 Bounds {{260.247, 156.369}, {47, 14}} Class ShapedGraphic FitText YES ID 76 Line ID 75 Offset 18.181819915771484 Position 0.38291174173355103 RotationType 0 Shape Rectangle Style shadow Draws NO stroke Draws NO Text Align 0 Text {\rtf1\mac\ansicpg10000\cocoartf824\cocoasubrtf410 {\fonttbl\f0\fswiss\fcharset77 Helvetica;} {\colortbl;\red255\green255\blue255;} \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ql\qnatural \f0\fs24 \cf0 project} AllowLabelDrop Class LineGraphic ID 75 Points {222.5, 145.7} {382.054, 144.364} Style stroke HeadArrow FilledArrow HeadScale 1.4285709857940674 TailArrow StickArrow TailScale 1.5 Tail ID 19 Bounds {{309, 182.853}, {160, 14}} Class ShapedGraphic FitText YES FontInfo Color w 0 Font Helvetica Size 12 ID 74 Line ID 69 Position 0.25240078568458557 RotationType 0 Shape Rectangle Style shadow Draws NO stroke Draws NO Text Text {\rtf1\mac\ansicpg10000\cocoartf824\cocoasubrtf410 {\fonttbl\f0\fswiss\fcharset77 Helvetica;} {\colortbl;\red255\green255\blue255;} \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\qc\pardirnatural \f0\fs24 \cf0 getProjectCustomBindings()} Bounds {{380.5, 138}, {17, 21.0909}} Class ShapedGraphic HFlip YES ID 73 Magnets {1, 0.5} {1, -0.5} {-1, 0.5} {-1, -0.5} {0.5, 1} {-0.5, 1} {0.5, -1} {-0.5, -1} Shape Rectangle Text Align 0 Bounds {{259.56, 110.107}, {47, 14}} Class ShapedGraphic FitText YES ID 29 Line ID 7 Offset 18.181819915771484 Position 0.38198670744895935 RotationType 0 Shape Rectangle Style shadow Draws NO stroke Draws NO Text Align 0 Text {\rtf1\mac\ansicpg10000\cocoartf824\cocoasubrtf410 {\fonttbl\f0\fswiss\fcharset77 Helvetica;} {\colortbl;\red255\green255\blue255;} \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ql\qnatural \f0\fs24 \cf0 project} AllowLabelDrop Class LineGraphic Head ID 71 ID 7 Points {222.5, 99.6111} {380.5, 97.8182} Style stroke HeadArrow FilledArrow HeadScale 1.4285709857940674 TailArrow StickArrow TailScale 1.5 Tail ID 19 Info 10 Bounds {{329.5, 75.973}, {119, 14}} Class ShapedGraphic FitText YES FontInfo Color w 0 Font Helvetica Size 12 ID 72 Line ID 69 Position 0.078753873705863953 RotationType 0 Shape Rectangle Style shadow Draws NO stroke Draws NO Text Text {\rtf1\mac\ansicpg10000\cocoartf824\cocoasubrtf410 {\fonttbl\f0\fswiss\fcharset77 Helvetica;} {\colortbl;\red255\green255\blue255;} \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\qc\pardirnatural \f0\fs24 \cf0 getDefaultBindings()} Bounds {{380.5, 92.5454}, {17, 21.0909}} Class ShapedGraphic HFlip YES ID 71 Magnets {1, 0.5} {1, -0.5} {-1, 0.5} {-1, -0.5} {0.5, 1} {-0.5, 1} {0.5, -1} {-0.5, -1} Shape Rectangle Text Align 0 Class Group Graphics AllowLabelDrop Class LineGraphic ID 69 Points {389, 34.5} {389, 650} Style stroke HeadArrow 0 HeadScale 1.4285709857940674 Pattern 1 TailArrow 0 TailScale 0.5 Tail ID 70 Bounds {{313.5, 20}, {151, 14}} Class ShapedGraphic FitText Vertical Flow Resize ID 70 Shape Rectangle Text Text {\rtf1\mac\ansicpg10000\cocoartf824\cocoasubrtf410 {\fonttbl\f0\fswiss\fcharset77 Helvetica-Bold;} {\colortbl;\red255\green255\blue255;} \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\qc \f0\b\fs24 \cf0 \ul \ulc0 LifecycleBindingManager} ID 68 Bounds {{108.828, 81.9091}, {81, 14}} Class ShapedGraphic FitText YES ID 30 Line ID 6 Offset 10.909090042114258 Position 0.52006888389587402 RotationType 0 Shape Rectangle Style shadow Draws NO stroke Draws NO Text Align 0 Text {\rtf1\mac\ansicpg10000\cocoartf824\cocoasubrtf410 {\fonttbl\f0\fswiss\fcharset77 Helvetica;} {\colortbl;\red255\green255\blue255;} \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ql\qnatural \f0\fs24 \cf0 tasks, project} AllowLabelDrop Class LineGraphic ID 6 Points {89, 78} {205, 78} Style stroke HeadArrow StickArrow HeadScale 1.4285709857940674 TailArrow 0 TailScale 0.5 Bounds {{155, 53.596}, {118, 14}} Class ShapedGraphic FitText YES FontInfo Color w 0 Font Helvetica Size 12 ID 20 Line ID 17 Position 0.042397733777761459 RotationType 0 Shape Rectangle Style shadow Draws NO stroke Draws NO Text Text {\rtf1\mac\ansicpg10000\cocoartf824\cocoasubrtf410 {\fonttbl\f0\fswiss\fcharset77 Helvetica;} {\colortbl;\red255\green255\blue255;} \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\qc\pardirnatural \f0\fs24 \cf0 constructBuildPlan()} Bounds {{205.5, 74}, {17, 208}} Class ShapedGraphic HFlip YES ID 19 Magnets {1, 0.5} {1, -0.5} {-0.470589, 0.149038} {-0.5, -0.197115} {0.5, 1} {-0.5, 1} {0.5, -1} {-0.5, -1} {-0.5, -0.155288} {-0.5, -0.37687} {-0.5, -0.155288} {-0.5, 0.25} {-0.529412, 0.360577} {-0.470589, 0.283654} {-0.529412, 0.389423} {0.5, 0.442308} Shape Rectangle Text Align 0 Class Group Graphics AllowLabelDrop Class LineGraphic ID 17 Points {214, 34.5002} {214, 650} Style stroke HeadArrow 0 HeadScale 1.4285709857940674 Pattern 1 TailArrow 0 TailScale 0.5 Tail ID 18 Bounds {{160, 20.0002}, {108, 14}} Class ShapedGraphic FitText Vertical Flow Resize ID 18 Shape Rectangle Text Text {\rtf1\mac\ansicpg10000\cocoartf824\cocoasubrtf410 {\fonttbl\f0\fswiss\fcharset77 Helvetica-Bold;} {\colortbl;\red255\green255\blue255;} \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\qc \f0\b\fs24 \cf0 \ul \ulc0 BuildPlanner} ID 16 Bounds {{53.5, 46.7192}, {61, 14}} Class ShapedGraphic FitText YES FontInfo Color w 0 Font Helvetica Size 12 ID 5 Line ID 2 Position 0.031224979087710381 RotationType 0 Shape Rectangle Style shadow Draws NO stroke Draws NO Text Text {\rtf1\mac\ansicpg10000\cocoartf824\cocoasubrtf410 {\fonttbl\f0\fswiss\fcharset77 Helvetica;} {\colortbl;\red255\green255\blue255;} \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\qc\pardirnatural \f0\fs24 \cf0 execute()} Bounds {{75.5, 64}, {14.5, 552}} Class ShapedGraphic HFlip YES ID 4 Magnets {1, 0.5} {1, -0.5} {-0.5, 0.317029} {-1, -0.5} {0.5, 1} {-0.5, 1} {0.5, -1} {-0.5, -1} {-0.25, -0.126812} {-0.568965, 0.302536} {-0.637931, 0.400362} {-0.5, 0.416667} Shape Rectangle Text Align 0 Class Group Graphics AllowLabelDrop Class LineGraphic ID 2 Points {84, 34.5003} {84, 650} Style stroke HeadArrow 0 HeadScale 1.4285709857940674 Pattern 1 TailArrow 0 TailScale 0.5 Tail ID 3 Bounds {{26, 20.0002}, {116, 14}} Class ShapedGraphic FitText Vertical Flow Resize ID 3 Shape Rectangle Text Text {\rtf1\mac\ansicpg10000\cocoartf824\cocoasubrtf410 {\fonttbl\f0\fswiss\fcharset77 Helvetica-Bold;} {\colortbl;\red255\green255\blue255;} \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\qc \f0\b\fs24 \cf0 \ul \ulc0 LifecycleExecutor} ID 1 GridInfo HPages 2 IsPalette NO KeepToScale Layers Lock NO Name Layer 1 Print YES View YES LayoutInfo ChildOrdering 0 HierarchicalOrientation 0 MasterSheet Master 1 Orientation 2 OutlineStyle Basic RowAlign 1 RowSpacing 36 SheetTitle Canvas 2 UniqueID 2 VPages 2 SmartAlignmentGuidesActive YES SmartDistanceGuidesActive YES UseEntirePage WindowInfo CurrentSheet 0 DrawerOpen DrawerTab Outline DrawerWidth 209 FitInWindow Frame {{6, 123}, {956, 590}} ShowRuler ShowStatusBar VisibleRegion {{-94, 0}, {941, 476}} Zoom 1 maven-maven-3.5.2/maven-core/src/site/site.xml000066400000000000000000000032201317160430700212070ustar00rootroot00000000000000 maven-maven-3.5.2/maven-core/src/test/000077500000000000000000000000001317160430700175375ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/java/000077500000000000000000000000001317160430700204605ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/java/org/000077500000000000000000000000001317160430700212475ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/java/org/apache/000077500000000000000000000000001317160430700224705ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/java/org/apache/maven/000077500000000000000000000000001317160430700235765ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/java/org/apache/maven/AbstractCoreMavenComponentTestCase.java000066400000000000000000000311441317160430700333260ustar00rootroot00000000000000package org.apache.maven; /* * 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.File; import java.util.Arrays; import java.util.List; import java.util.Properties; import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.InvalidRepositoryException; import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.execution.DefaultMavenExecutionRequest; import org.apache.maven.execution.DefaultMavenExecutionResult; import org.apache.maven.execution.MavenExecutionRequest; import org.apache.maven.execution.MavenSession; import org.apache.maven.model.Build; import org.apache.maven.model.Dependency; import org.apache.maven.model.Exclusion; import org.apache.maven.model.Model; import org.apache.maven.model.Plugin; import org.apache.maven.model.Repository; import org.apache.maven.model.RepositoryPolicy; import org.apache.maven.project.DefaultProjectBuildingRequest; import org.apache.maven.project.MavenProject; import org.apache.maven.project.ProjectBuildingRequest; import org.apache.maven.repository.RepositorySystem; import org.apache.maven.repository.internal.MavenRepositorySystemUtils; import org.codehaus.plexus.ContainerConfiguration; import org.codehaus.plexus.PlexusConstants; import org.codehaus.plexus.PlexusTestCase; import org.codehaus.plexus.component.annotations.Requirement; import org.codehaus.plexus.util.FileUtils; import org.eclipse.aether.DefaultRepositorySystemSession; import org.eclipse.aether.internal.impl.SimpleLocalRepositoryManagerFactory; import org.eclipse.aether.repository.LocalRepository; public abstract class AbstractCoreMavenComponentTestCase extends PlexusTestCase { @Requirement protected RepositorySystem repositorySystem; @Requirement protected org.apache.maven.project.ProjectBuilder projectBuilder; protected void setUp() throws Exception { repositorySystem = lookup( RepositorySystem.class ); projectBuilder = lookup( org.apache.maven.project.ProjectBuilder.class ); } @Override protected void tearDown() throws Exception { repositorySystem = null; projectBuilder = null; super.tearDown(); } abstract protected String getProjectsDirectory(); protected File getProject( String name ) throws Exception { File source = new File( new File( getBasedir(), getProjectsDirectory() ), name ); File target = new File( new File( getBasedir(), "target" ), name ); FileUtils.copyDirectoryStructureIfModified( source, target ); return new File( target, "pom.xml" ); } /** * We need to customize the standard Plexus container with the plugin discovery listener which * is what looks for the META-INF/maven/plugin.xml resources that enter the system when a Maven * plugin is loaded. * * We also need to customize the Plexus container with a standard plugin discovery listener * which is the MavenPluginCollector. When a Maven plugin is discovered the MavenPluginCollector * collects the plugin descriptors which are found. */ protected void customizeContainerConfiguration( ContainerConfiguration containerConfiguration ) { containerConfiguration.setAutoWiring( true ).setClassPathScanning( PlexusConstants.SCANNING_INDEX ); } protected MavenExecutionRequest createMavenExecutionRequest( File pom ) throws Exception { MavenExecutionRequest request = new DefaultMavenExecutionRequest() .setPom( pom ) .setProjectPresent( true ) .setShowErrors( true ) .setPluginGroups( Arrays.asList( "org.apache.maven.plugins" ) ) .setLocalRepository( getLocalRepository() ) .setRemoteRepositories( getRemoteRepositories() ) .setPluginArtifactRepositories( getPluginArtifactRepositories() ) .setGoals( Arrays.asList( "package" ) ); return request; } // layer the creation of a project builder configuration with a request, but this will need to be // a Maven subclass because we don't want to couple maven to the project builder which we need to // separate. protected MavenSession createMavenSession( File pom ) throws Exception { return createMavenSession( pom, new Properties() ); } protected MavenSession createMavenSession( File pom, Properties executionProperties ) throws Exception { MavenExecutionRequest request = createMavenExecutionRequest( pom ); ProjectBuildingRequest configuration = new DefaultProjectBuildingRequest() .setLocalRepository( request.getLocalRepository() ) .setRemoteRepositories( request.getRemoteRepositories() ) .setPluginArtifactRepositories( request.getPluginArtifactRepositories() ) .setSystemProperties( executionProperties ); MavenProject project = null; if ( pom != null ) { project = projectBuilder.build( pom, configuration ).getProject(); } else { project = createStubMavenProject(); project.setRemoteArtifactRepositories( request.getRemoteRepositories() ); project.setPluginArtifactRepositories( request.getPluginArtifactRepositories() ); } initRepoSession( configuration ); MavenSession session = new MavenSession( getContainer(), configuration.getRepositorySession(), request, new DefaultMavenExecutionResult() ); session.setProjects( Arrays.asList( project ) ); session.setAllProjects( session.getProjects() ); return session; } protected void initRepoSession( ProjectBuildingRequest request ) throws Exception { File localRepoDir = new File( request.getLocalRepository().getBasedir() ); LocalRepository localRepo = new LocalRepository( localRepoDir ); DefaultRepositorySystemSession session = MavenRepositorySystemUtils.newSession(); session.setLocalRepositoryManager( new SimpleLocalRepositoryManagerFactory().newInstance( session, localRepo ) ); request.setRepositorySession( session ); } protected MavenProject createStubMavenProject() { Model model = new Model(); model.setGroupId( "org.apache.maven.test" ); model.setArtifactId( "maven-test" ); model.setVersion( "1.0" ); return new MavenProject( model ); } protected List getRemoteRepositories() throws InvalidRepositoryException { File repoDir = new File( getBasedir(), "src/test/remote-repo" ).getAbsoluteFile(); RepositoryPolicy policy = new RepositoryPolicy(); policy.setEnabled( true ); policy.setChecksumPolicy( "ignore" ); policy.setUpdatePolicy( "always" ); Repository repository = new Repository(); repository.setId( RepositorySystem.DEFAULT_REMOTE_REPO_ID ); repository.setUrl( "file://" + repoDir.toURI().getPath() ); repository.setReleases( policy ); repository.setSnapshots( policy ); return Arrays.asList( repositorySystem.buildArtifactRepository( repository ) ); } protected List getPluginArtifactRepositories() throws InvalidRepositoryException { return getRemoteRepositories(); } protected ArtifactRepository getLocalRepository() throws InvalidRepositoryException { File repoDir = new File( getBasedir(), "target/local-repo" ).getAbsoluteFile(); return repositorySystem.createLocalRepository( repoDir ); } protected class ProjectBuilder { private MavenProject project; public ProjectBuilder( MavenProject project ) { this.project = project; } public ProjectBuilder( String groupId, String artifactId, String version ) { Model model = new Model(); model.setModelVersion( "4.0.0" ); model.setGroupId( groupId ); model.setArtifactId( artifactId ); model.setVersion( version ); model.setBuild( new Build() ); project = new MavenProject( model ); } public ProjectBuilder setGroupId( String groupId ) { project.setGroupId( groupId ); return this; } public ProjectBuilder setArtifactId( String artifactId ) { project.setArtifactId( artifactId ); return this; } public ProjectBuilder setVersion( String version ) { project.setVersion( version ); return this; } // Dependencies // public ProjectBuilder addDependency( String groupId, String artifactId, String version, String scope ) { return addDependency( groupId, artifactId, version, scope, (Exclusion)null ); } public ProjectBuilder addDependency( String groupId, String artifactId, String version, String scope, Exclusion exclusion ) { return addDependency( groupId, artifactId, version, scope, null, exclusion ); } public ProjectBuilder addDependency( String groupId, String artifactId, String version, String scope, String systemPath ) { return addDependency( groupId, artifactId, version, scope, systemPath, null ); } public ProjectBuilder addDependency( String groupId, String artifactId, String version, String scope, String systemPath, Exclusion exclusion ) { Dependency d = new Dependency(); d.setGroupId( groupId ); d.setArtifactId( artifactId ); d.setVersion( version ); d.setScope( scope ); if ( systemPath != null && scope.equals( Artifact.SCOPE_SYSTEM ) ) { d.setSystemPath( systemPath ); } if ( exclusion != null ) { d.addExclusion( exclusion ); } project.getDependencies().add( d ); return this; } // Plugins // public ProjectBuilder addPlugin( Plugin plugin ) { project.getBuildPlugins().add( plugin ); return this; } public MavenProject get() { return project; } } protected class PluginBuilder { private Plugin plugin; public PluginBuilder( String groupId, String artifactId, String version ) { plugin = new Plugin(); plugin.setGroupId( groupId ); plugin.setArtifactId( artifactId ); plugin.setVersion( version ); } // Dependencies // public PluginBuilder addDependency( String groupId, String artifactId, String version, String scope, Exclusion exclusion ) { return addDependency( groupId, artifactId, version, scope, exclusion ); } public PluginBuilder addDependency( String groupId, String artifactId, String version, String scope, String systemPath ) { return addDependency( groupId, artifactId, version, scope, systemPath, null ); } public PluginBuilder addDependency( String groupId, String artifactId, String version, String scope, String systemPath, Exclusion exclusion ) { Dependency d = new Dependency(); d.setGroupId( groupId ); d.setArtifactId( artifactId ); d.setVersion( version ); d.setScope( scope ); if ( systemPath != null && scope.equals( Artifact.SCOPE_SYSTEM ) ) { d.setSystemPath( systemPath ); } if ( exclusion != null ) { d.addExclusion( exclusion ); } plugin.getDependencies().add( d ); return this; } public Plugin get() { return plugin; } } } maven-maven-3.5.2/maven-core/src/test/java/org/apache/maven/DefaultMavenTest.java000066400000000000000000000032001317160430700276470ustar00rootroot00000000000000package org.apache.maven; import org.apache.maven.execution.MavenExecutionRequest; import org.apache.maven.execution.MavenExecutionResult; import static java.util.Arrays.asList; /* * 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. */ public class DefaultMavenTest extends AbstractCoreMavenComponentTestCase{ public void testThatErrorDuringProjectDependencyGraphCreationAreStored() throws Exception { Maven maven = getContainer().lookup( Maven.class ); MavenExecutionRequest request = createMavenExecutionRequest( getProject( "cyclic-reference" ) ).setGoals( asList("validate") ); MavenExecutionResult result = maven.execute( request ); assertEquals( ProjectCycleException.class, result.getExceptions().get( 0 ).getClass() ); } @Override protected String getProjectsDirectory() { return "src/test/projects/default-maven"; } } maven-maven-3.5.2/maven-core/src/test/java/org/apache/maven/MavenLifecycleParticipantTest.java000066400000000000000000000144311317160430700323710ustar00rootroot00000000000000package org.apache.maven; /* * 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.File; import java.io.IOException; import java.util.ArrayList; import java.util.Arrays; import java.util.List; import org.apache.maven.artifact.Artifact; import org.apache.maven.execution.MavenExecutionRequest; import org.apache.maven.execution.MavenExecutionResult; import org.apache.maven.execution.MavenSession; import org.apache.maven.model.Dependency; import org.apache.maven.project.MavenProject; import org.codehaus.plexus.PlexusContainer; import org.codehaus.plexus.component.repository.ComponentDescriptor; public class MavenLifecycleParticipantTest extends AbstractCoreMavenComponentTestCase { private static final String INJECTED_ARTIFACT_ID = "injected"; public static class InjectDependencyLifecycleListener extends AbstractMavenLifecycleParticipant { @Override public void afterProjectsRead( MavenSession session ) { MavenProject project = session.getProjects().get( 0 ); Dependency dependency = new Dependency(); dependency.setArtifactId( INJECTED_ARTIFACT_ID ); dependency.setGroupId( "foo" ); dependency.setVersion( "1.2.3" ); dependency.setScope( "system" ); try { dependency.setSystemPath( new File( "src/test/projects/lifecycle-executor/project-with-additional-lifecycle-elements/pom.xml" ).getCanonicalPath() ); } catch ( IOException e ) { throw new RuntimeException( e ); } project.getModel().addDependency( dependency ); } @Override public void afterSessionStart( MavenSession session ) { session.getUserProperties().setProperty( "injected", "bar" ); } } public static class InjectReactorDependency extends AbstractMavenLifecycleParticipant { @Override public void afterProjectsRead( MavenSession session ) { injectReactorDependency( session.getProjects(), "module-a", "module-b" ); } private void injectReactorDependency( List projects, String moduleFrom, String moduleTo ) { for ( MavenProject project : projects ) { if ( moduleFrom.equals( project.getArtifactId() ) ) { Dependency dependency = new Dependency(); dependency.setArtifactId( moduleTo ); dependency.setGroupId( project.getGroupId() ); dependency.setVersion( project.getVersion() ); project.getModel().addDependency( dependency ); } } } } @Override protected void setupContainer() { super.setupContainer(); } @Override protected String getProjectsDirectory() { return "src/test/projects/lifecycle-listener"; } public void testDependencyInjection() throws Exception { PlexusContainer container = getContainer(); ComponentDescriptor cd = new ComponentDescriptor<>( InjectDependencyLifecycleListener.class, container.getContainerRealm() ); cd.setRoleClass( AbstractMavenLifecycleParticipant.class ); container.addComponentDescriptor( cd ); Maven maven = container.lookup( Maven.class ); File pom = getProject( "lifecycle-listener-dependency-injection" ); MavenExecutionRequest request = createMavenExecutionRequest( pom ); request.setGoals( Arrays.asList( "validate" ) ); MavenExecutionResult result = maven.execute( request ); assertFalse( result.getExceptions().toString(), result.hasExceptions() ); MavenProject project = result.getProject(); assertEquals( "bar", project.getProperties().getProperty( "foo" ) ); ArrayList artifacts = new ArrayList<>( project.getArtifacts() ); assertEquals( 1, artifacts.size() ); assertEquals( INJECTED_ARTIFACT_ID, artifacts.get( 0 ).getArtifactId() ); } public void testReactorDependencyInjection() throws Exception { List reactorOrder = getReactorOrder( "lifecycle-participant-reactor-dependency-injection", InjectReactorDependency.class ); assertEquals( Arrays.asList( "parent", "module-b", "module-a" ), reactorOrder ); } private List getReactorOrder( String testProject, Class participant ) throws Exception { PlexusContainer container = getContainer(); ComponentDescriptor cd = new ComponentDescriptor<>( participant, container.getContainerRealm() ); cd.setRoleClass( AbstractMavenLifecycleParticipant.class ); container.addComponentDescriptor( cd ); Maven maven = container.lookup( Maven.class ); File pom = getProject( testProject ); MavenExecutionRequest request = createMavenExecutionRequest( pom ); request.setGoals( Arrays.asList( "validate" ) ); MavenExecutionResult result = maven.execute( request ); assertFalse( result.getExceptions().toString(), result.hasExceptions() ); List order = new ArrayList<>(); for ( MavenProject project : result.getTopologicallySortedProjects() ) { order.add( project.getArtifactId() ); } return order; } } maven-maven-3.5.2/maven-core/src/test/java/org/apache/maven/MavenTest.java000066400000000000000000000043021317160430700263460ustar00rootroot00000000000000package org.apache.maven; /* * 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 org.apache.maven.exception.ExceptionHandler; import org.codehaus.plexus.component.annotations.Requirement; public class MavenTest extends AbstractCoreMavenComponentTestCase { @Requirement private Maven maven; @Requirement private ExceptionHandler exceptionHandler; protected void setUp() throws Exception { super.setUp(); maven = lookup( Maven.class ); exceptionHandler = lookup( ExceptionHandler.class ); } @Override protected void tearDown() throws Exception { maven = null; exceptionHandler = null; super.tearDown(); } protected String getProjectsDirectory() { return "src/test/projects/lifecycle-executor"; } public void testLifecycleExecutionUsingADefaultLifecyclePhase() throws Exception { /* File pom = getProject( "project-with-additional-lifecycle-elements" ); MavenExecutionRequest request = createMavenExecutionRequest( pom ); MavenExecutionResult result = maven.execute( request ); if ( result.hasExceptions() ) { ExceptionSummary es = exceptionHandler.handleException( result.getExceptions().get( 0 ) ); System.out.println( es.getMessage() ); es.getException().printStackTrace(); fail( "Maven did not execute correctly." ); } */ } } maven-maven-3.5.2/maven-core/src/test/java/org/apache/maven/ProjectDependenciesResolverTest.java000066400000000000000000000101671317160430700327450ustar00rootroot00000000000000package org.apache.maven; /* * 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.File; import java.util.Collections; import java.util.List; import java.util.Properties; import java.util.Set; import org.apache.maven.artifact.Artifact; import org.apache.maven.execution.MavenSession; import org.apache.maven.project.MavenProject; import org.codehaus.plexus.component.annotations.Requirement; public class ProjectDependenciesResolverTest extends AbstractCoreMavenComponentTestCase { @Requirement private ProjectDependenciesResolver resolver; protected void setUp() throws Exception { super.setUp(); resolver = lookup( ProjectDependenciesResolver.class ); } @Override protected void tearDown() throws Exception { resolver = null; super.tearDown(); } protected String getProjectsDirectory() { return "src/test/projects/project-dependencies-resolver"; } /* public void testExclusionsInDependencies() throws Exception { MavenSession session = createMavenSession( null ); MavenProject project = session.getCurrentProject(); Exclusion exclusion = new Exclusion(); exclusion.setGroupId( "org.apache.maven.its" ); exclusion.setArtifactId( "a" ); new ProjectBuilder( project ).addDependency( "org.apache.maven.its", "b", "0.1", Artifact.SCOPE_RUNTIME, exclusion ); Set artifactDependencies = resolver.resolve( project, Collections.singleton( Artifact.SCOPE_COMPILE ), session ); assertEquals( 0, artifactDependencies.size() ); artifactDependencies = resolver.resolve( project, Collections.singleton( Artifact.SCOPE_RUNTIME ), session ); assertEquals( 1, artifactDependencies.size() ); assertEquals( "b", artifactDependencies.iterator().next().getArtifactId() ); } */ public void testSystemScopeDependencies() throws Exception { MavenSession session = createMavenSession( null ); MavenProject project = session.getCurrentProject(); new ProjectBuilder( project ) .addDependency( "com.mycompany", "system-dependency", "1.0", Artifact.SCOPE_SYSTEM, new File( getBasedir(), "pom.xml" ).getAbsolutePath() ); Set artifactDependencies = resolver.resolve( project, Collections.singleton( Artifact.SCOPE_COMPILE ), session ); assertEquals( 1, artifactDependencies.size() ); } public void testSystemScopeDependencyIsPresentInTheCompileClasspathElements() throws Exception { File pom = getProject( "it0063" ); Properties eps = new Properties(); eps.setProperty( "jre.home", new File( pom.getParentFile(), "jdk/jre" ).getPath() ); MavenSession session = createMavenSession( pom, eps ); MavenProject project = session.getCurrentProject(); project.setArtifacts( resolver.resolve( project, Collections.singleton( Artifact.SCOPE_COMPILE ), session ) ); List elements = project.getCompileClasspathElements(); assertEquals( 2, elements.size() ); @SuppressWarnings( "deprecation" ) List artifacts = project.getCompileArtifacts(); assertEquals( 1, artifacts.size() ); assertTrue( artifacts.get( 0 ).getFile().getName().endsWith( "tools.jar" ) ); } } maven-maven-3.5.2/maven-core/src/test/java/org/apache/maven/artifact/000077500000000000000000000000001317160430700253735ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/java/org/apache/maven/artifact/handler/000077500000000000000000000000001317160430700270105ustar00rootroot00000000000000ArtifactHandlerTest.java000066400000000000000000000066221317160430700334750ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/java/org/apache/maven/artifact/handlerpackage org.apache.maven.artifact.handler; /* * 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.File; import java.util.List; import org.codehaus.plexus.PlexusTestCase; import org.codehaus.plexus.util.FileUtils; public class ArtifactHandlerTest extends PlexusTestCase { public void testAptConsistency() throws Exception { File apt = getTestFile( "src/site/apt/artifact-handlers.apt" ); @SuppressWarnings( "unchecked" ) List lines = FileUtils.loadFile( apt ); for ( String line : lines ) { if ( line.startsWith( "||" ) ) { String[] cols = line.split( "\\|\\|" ); String[] expected = new String[] { "", "type", "extension", "packaging", "classifier", "language", "added to classpath", "includesDependencies", "" }; int i = 0; for ( String col : cols ) { assertEquals( "Wrong column header", expected[i++], col.trim() ); } } else if ( line.startsWith( "|" ) ) { String[] cols = line.split( "\\|" ); String type = trimApt( cols[1] ); String extension = trimApt( cols[2], type ); String packaging = trimApt( cols[3], type ); String classifier = trimApt( cols[4] ); String language = trimApt( cols[5] ); String addedToClasspath = trimApt( cols[6] ); String includesDependencies = trimApt( cols[7] ); ArtifactHandler handler = lookup( ArtifactHandler.class, type ); assertEquals( type + " extension", handler.getExtension(), extension ); assertEquals( type + " packaging", handler.getPackaging(), packaging ); assertEquals( type + " classifier", handler.getClassifier(), classifier ); assertEquals( type + " language", handler.getLanguage(), language ); assertEquals( type + " addedToClasspath", handler.isAddedToClasspath() ? "true" : null, addedToClasspath ); assertEquals( type + " includesDependencies", handler.isIncludesDependencies() ? "true" : null, includesDependencies ); } } } private String trimApt( String content, String type ) { String value = trimApt( content ); return "= type".equals( value ) ? type : value; } private String trimApt( String content ) { content = content.replace( '<', ' ' ).replace( '>', ' ' ).trim(); return ( content.length() == 0 ) ? null : content; } } maven-maven-3.5.2/maven-core/src/test/java/org/apache/maven/configuration/000077500000000000000000000000001317160430700264455ustar00rootroot00000000000000DefaultBeanConfiguratorTest.java000066400000000000000000000102031317160430700346220ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/java/org/apache/maven/configurationpackage org.apache.maven.configuration; /* * 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.File; import java.io.IOException; import java.io.StringReader; import org.codehaus.plexus.PlexusTestCase; import org.codehaus.plexus.util.xml.Xpp3Dom; import org.codehaus.plexus.util.xml.Xpp3DomBuilder; import org.codehaus.plexus.util.xml.pull.XmlPullParserException; /** * @author Benjamin Bentmann */ public class DefaultBeanConfiguratorTest extends PlexusTestCase { private BeanConfigurator configurator; @Override protected void setUp() throws Exception { super.setUp(); configurator = lookup( BeanConfigurator.class ); } @Override protected void tearDown() throws Exception { configurator = null; super.tearDown(); } private Xpp3Dom toConfig( String xml ) { try { return Xpp3DomBuilder.build( new StringReader( "" + xml + "" ) ); } catch ( XmlPullParserException | IOException e ) { throw new IllegalArgumentException( e ); } } public void testMinimal() throws BeanConfigurationException { SomeBean bean = new SomeBean(); Xpp3Dom config = toConfig( "test" ); DefaultBeanConfigurationRequest request = new DefaultBeanConfigurationRequest(); request.setBean( bean ).setConfiguration( config ); configurator.configureBean( request ); assertEquals( new File( "test" ), bean.file ); } public void testPreAndPostProcessing() throws BeanConfigurationException { SomeBean bean = new SomeBean(); Xpp3Dom config = toConfig( "${test}" ); BeanConfigurationValuePreprocessor preprocessor = new BeanConfigurationValuePreprocessor() { public Object preprocessValue( String value, Class type ) throws BeanConfigurationException { if ( value != null && value.startsWith( "${" ) && value.endsWith( "}" ) ) { return value.substring( 2, value.length() - 1 ); } return value; } }; BeanConfigurationPathTranslator translator = new BeanConfigurationPathTranslator() { public File translatePath( File path ) { return new File( "base", path.getPath() ).getAbsoluteFile(); } }; DefaultBeanConfigurationRequest request = new DefaultBeanConfigurationRequest(); request.setBean( bean ).setConfiguration( config ); request.setValuePreprocessor( preprocessor ).setPathTranslator( translator ); configurator.configureBean( request ); assertEquals( new File( "base/test" ).getAbsoluteFile(), bean.file ); } public void testChildConfigurationElement() throws BeanConfigurationException { SomeBean bean = new SomeBean(); Xpp3Dom config = toConfig( "test" ); DefaultBeanConfigurationRequest request = new DefaultBeanConfigurationRequest(); request.setBean( bean ).setConfiguration( config, "wrapper" ); configurator.configureBean( request ); assertEquals( new File( "test" ), bean.file ); } static class SomeBean { File file; } } maven-maven-3.5.2/maven-core/src/test/java/org/apache/maven/exception/000077500000000000000000000000001317160430700255745ustar00rootroot00000000000000DefaultExceptionHandlerTest.java000066400000000000000000000043511317160430700337640ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/java/org/apache/maven/exceptionpackage org.apache.maven.exception; /* * 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.net.ConnectException; import org.apache.maven.plugin.MojoExecutionException; import junit.framework.TestCase; /** * @author Barrie Treloar */ public class DefaultExceptionHandlerTest extends TestCase { /** * Running Maven under JDK7 may cause connection issues because IPv6 is used by default. *

    * e.g running mvn site:run will cause Jetty to fail. *

    *

    * The resolution is to add -Djava.net.preferIPv4Stack=true to the command line as documented in * http://cwiki.apache.org/confluence/display/MAVEN/ConnectException *

    */ public void testJdk7ipv6() { ConnectException connEx = new ConnectException( "Connection refused: connect" ); IOException ioEx = new IOException( "Unable to establish loopback connection" ); ioEx.initCause( connEx ); MojoExecutionException mojoEx = new MojoExecutionException( "Error executing Jetty: Unable to establish loopback connection", ioEx ); ExceptionHandler exceptionHandler = new DefaultExceptionHandler(); ExceptionSummary exceptionSummary = exceptionHandler.handleException( mojoEx ); String expectedReference = "http://cwiki.apache.org/confluence/display/MAVEN/ConnectException"; assertEquals( expectedReference, exceptionSummary.getReference() ); } } maven-maven-3.5.2/maven-core/src/test/java/org/apache/maven/execution/000077500000000000000000000000001317160430700256015ustar00rootroot00000000000000DefaultMavenExecutionRequestPopulatorTest.java000066400000000000000000000041051317160430700367430ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/java/org/apache/maven/executionpackage org.apache.maven.execution; import java.util.List; import javax.inject.Inject; import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.settings.Profile; import org.apache.maven.settings.Repository; import org.apache.maven.settings.Settings; import org.eclipse.sisu.launch.InjectedTestCase; /* * 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. */ public class DefaultMavenExecutionRequestPopulatorTest extends InjectedTestCase { @Inject MavenExecutionRequestPopulator testee; public void testPluginRepositoryInjection() throws Exception { MavenExecutionRequest request = new DefaultMavenExecutionRequest(); Repository r = new Repository(); r.setId( "test" ); r.setUrl( "file:///test" ); Profile p = new Profile(); p.setId( "test" ); p.addPluginRepository( r ); Settings settings = new Settings(); settings.addProfile( p ); settings.addActiveProfile( p.getId() ); testee.populateFromSettings( request, settings ); List repositories = request.getPluginArtifactRepositories(); assertEquals( 1, repositories.size() ); assertEquals( r.getId(), repositories.get( 0 ).getId() ); assertEquals( r.getUrl(), repositories.get( 0 ).getUrl() ); } } maven-maven-3.5.2/maven-core/src/test/java/org/apache/maven/execution/DefaultMavenExecutionTest.java000066400000000000000000000032501317160430700335430ustar00rootroot00000000000000package org.apache.maven.execution; /* * 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 org.apache.maven.project.MavenProject; import java.util.List; import junit.framework.TestCase; /** * @author Benjamin Bentmann */ public class DefaultMavenExecutionTest extends TestCase { public void testCopyDefault() { MavenExecutionRequest original = new DefaultMavenExecutionRequest(); MavenExecutionRequest copy = DefaultMavenExecutionRequest.copy( original ); assertNotNull( copy ); assertNotSame( copy, original ); } public void testResultWithNullTopologicallySortedProjectsIsEmptyList() { MavenExecutionResult result = new DefaultMavenExecutionResult(); result.setTopologicallySortedProjects( null ); List projects = result.getTopologicallySortedProjects(); assertNotNull( projects ); assertTrue( projects.isEmpty() ); } } maven-maven-3.5.2/maven-core/src/test/java/org/apache/maven/execution/scope/000077500000000000000000000000001317160430700267125ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/java/org/apache/maven/execution/scope/internal/000077500000000000000000000000001317160430700305265ustar00rootroot00000000000000MojoExecutionScopeTest.java000066400000000000000000000100711317160430700357330ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/java/org/apache/maven/execution/scope/internal/* * Licensed to the Apache Software Foundation (ASF) under one or more contributor license * agreements. See the NOTICE file distributed with this work for additional information regarding * copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance with the License. You may obtain a * copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express * or implied. See the License for the specific language governing permissions and limitations under * the License. */ package org.apache.maven.execution.scope.internal; import java.util.concurrent.atomic.AtomicInteger; import org.apache.maven.execution.MojoExecutionEvent; import org.apache.maven.execution.scope.WeakMojoExecutionListener; import org.apache.maven.plugin.MojoExecutionException; import junit.framework.TestCase; import com.google.inject.Key; import com.google.inject.Provider; public class MojoExecutionScopeTest extends TestCase { public void testNestedEnter() throws Exception { MojoExecutionScope scope = new MojoExecutionScope(); scope.enter(); Object o1 = new Object(); scope.seed( Object.class, o1 ); assertSame( o1, scope.scope( Key.get( Object.class ), null ).get() ); scope.enter(); Object o2 = new Object(); scope.seed( Object.class, o2 ); assertSame( o2, scope.scope( Key.get( Object.class ), null ).get() ); scope.exit(); assertSame( o1, scope.scope( Key.get( Object.class ), null ).get() ); scope.exit(); try { scope.exit(); fail(); } catch ( IllegalStateException expected ) { } } public void testMultiKeyInstance() throws Exception { MojoExecutionScope scope = new MojoExecutionScope(); scope.enter(); final AtomicInteger beforeExecution = new AtomicInteger(); final AtomicInteger afterExecutionSuccess = new AtomicInteger(); final AtomicInteger afterExecutionFailure = new AtomicInteger(); final WeakMojoExecutionListener instance = new WeakMojoExecutionListener() { @Override public void beforeMojoExecution( MojoExecutionEvent event ) throws MojoExecutionException { beforeExecution.incrementAndGet(); } @Override public void afterMojoExecutionSuccess( MojoExecutionEvent event ) throws MojoExecutionException { afterExecutionSuccess.incrementAndGet(); } @Override public void afterExecutionFailure( MojoExecutionEvent event ) { afterExecutionFailure.incrementAndGet(); } }; assertSame( instance, scope.scope( Key.get( Object.class ), new Provider() { @Override public Object get() { return instance; } } ).get() ); assertSame( instance, scope.scope( Key.get( WeakMojoExecutionListener.class ), new Provider() { @Override public WeakMojoExecutionListener get() { return instance; } } ).get() ); final MojoExecutionEvent event = new MojoExecutionEvent( null, null, null, null ); scope.beforeMojoExecution( event ); scope.afterMojoExecutionSuccess( event ); scope.afterExecutionFailure( event ); assertEquals( 1, beforeExecution.get() ); assertEquals( 1, afterExecutionSuccess.get() ); assertEquals( 1, afterExecutionFailure.get() ); scope.exit(); } } maven-maven-3.5.2/maven-core/src/test/java/org/apache/maven/graph/000077500000000000000000000000001317160430700246775ustar00rootroot00000000000000DefaultProjectDependencyGraphTest.java000066400000000000000000000166621317160430700342320ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/java/org/apache/maven/graph/* * Licensed to the Apache Software Foundation (ASF) under one or more contributor license * agreements. See the NOTICE file distributed with this work for additional information regarding * copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance with the License. You may obtain a * copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express * or implied. See the License for the specific language governing permissions and limitations under * the License. */ package org.apache.maven.graph; import junit.framework.TestCase; import org.apache.maven.execution.ProjectDependencyGraph; import org.apache.maven.model.Dependency; import org.apache.maven.project.DuplicateProjectException; import org.apache.maven.project.MavenProject; import org.codehaus.plexus.util.dag.CycleDetectedException; import java.util.Arrays; import java.util.List; /** * @author Kristian Rosenvold */ public class DefaultProjectDependencyGraphTest extends TestCase { private final MavenProject aProject = createA(); private final MavenProject depender1 = createProject( Arrays.asList( toDependency( aProject ) ), "depender1" ); private final MavenProject depender2 = createProject( Arrays.asList( toDependency( aProject ) ), "depender2" ); private final MavenProject depender3 = createProject( Arrays.asList( toDependency( aProject ) ), "depender3" ); private final MavenProject depender4 = createProject( Arrays.asList( toDependency( aProject ), toDependency( depender3 ) ), "depender4" ); private final MavenProject transitiveOnly = createProject( Arrays.asList( toDependency( depender3 ) ), "depender5" ); public void testGetSortedProjects() throws DuplicateProjectException, CycleDetectedException { ProjectDependencyGraph graph = new DefaultProjectDependencyGraph( Arrays.asList( depender1, aProject ) ); final List sortedProjects = graph.getSortedProjects(); assertEquals( aProject, sortedProjects.get( 0 ) ); assertEquals( depender1, sortedProjects.get( 1 ) ); } public void testVerifyExpectedParentStructure() throws CycleDetectedException, DuplicateProjectException { // This test verifies the baseline structure used in subsequent tests. If this fails, the rest will fail. ProjectDependencyGraph graph = threeProjectsDependingOnASingle(); final List sortedProjects = graph.getSortedProjects(); assertEquals( aProject, sortedProjects.get( 0 ) ); assertEquals( depender1, sortedProjects.get( 1 ) ); assertEquals( depender2, sortedProjects.get( 2 ) ); assertEquals( depender3, sortedProjects.get( 3 ) ); } public void testVerifyThatDownstreamProjectsComeInSortedOrder() throws CycleDetectedException, DuplicateProjectException { final List downstreamProjects = threeProjectsDependingOnASingle().getDownstreamProjects( aProject, true ); assertEquals( depender1, downstreamProjects.get( 0 ) ); assertEquals( depender2, downstreamProjects.get( 1 ) ); assertEquals( depender3, downstreamProjects.get( 2 ) ); } public void testTransitivesInOrder() throws CycleDetectedException, DuplicateProjectException { final ProjectDependencyGraph graph = new DefaultProjectDependencyGraph( Arrays.asList( depender1, depender4, depender2, depender3, aProject ) ); final List downstreamProjects = graph.getDownstreamProjects( aProject, true ); assertEquals( depender1, downstreamProjects.get( 0 ) ); assertEquals( depender3, downstreamProjects.get( 1 ) ); assertEquals( depender4, downstreamProjects.get( 2 ) ); assertEquals( depender2, downstreamProjects.get( 3 ) ); } public void testNonTransitivesInOrder() throws CycleDetectedException, DuplicateProjectException { final ProjectDependencyGraph graph = new DefaultProjectDependencyGraph( Arrays.asList( depender1, depender4, depender2, depender3, aProject ) ); final List downstreamProjects = graph.getDownstreamProjects( aProject, false ); assertEquals( depender1, downstreamProjects.get( 0 ) ); assertEquals( depender3, downstreamProjects.get( 1 ) ); assertEquals( depender4, downstreamProjects.get( 2 ) ); assertEquals( depender2, downstreamProjects.get( 3 ) ); } public void testWithTransitiveOnly() throws CycleDetectedException, DuplicateProjectException { final ProjectDependencyGraph graph = new DefaultProjectDependencyGraph( Arrays.asList( depender1, transitiveOnly, depender2, depender3, aProject ) ); final List downstreamProjects = graph.getDownstreamProjects( aProject, true ); assertEquals( depender1, downstreamProjects.get( 0 ) ); assertEquals( depender3, downstreamProjects.get( 1 ) ); assertEquals( transitiveOnly, downstreamProjects.get( 2 ) ); assertEquals( depender2, downstreamProjects.get( 3 ) ); } public void testWithMissingTransitiveOnly() throws CycleDetectedException, DuplicateProjectException { final ProjectDependencyGraph graph = new DefaultProjectDependencyGraph( Arrays.asList( depender1, transitiveOnly, depender2, depender3, aProject ) ); final List downstreamProjects = graph.getDownstreamProjects( aProject, false ); assertEquals( depender1, downstreamProjects.get( 0 ) ); assertEquals( depender3, downstreamProjects.get( 1 ) ); assertEquals( depender2, downstreamProjects.get( 2 ) ); } public void testGetUpstreamProjects() throws CycleDetectedException, DuplicateProjectException { ProjectDependencyGraph graph = threeProjectsDependingOnASingle(); final List downstreamProjects = graph.getUpstreamProjects( depender1, true ); assertEquals( aProject, downstreamProjects.get( 0 ) ); } private ProjectDependencyGraph threeProjectsDependingOnASingle() throws CycleDetectedException, DuplicateProjectException { return new DefaultProjectDependencyGraph( Arrays.asList( depender1, depender2, depender3, aProject ) ); } private static MavenProject createA() { MavenProject result = new MavenProject(); result.setGroupId( "org.apache" ); result.setArtifactId( "A" ); result.setVersion( "1.2" ); return result; } static Dependency toDependency( MavenProject mavenProject ) { final Dependency dependency = new Dependency(); dependency.setArtifactId( mavenProject.getArtifactId() ); dependency.setGroupId( mavenProject.getGroupId() ); dependency.setVersion( mavenProject.getVersion() ); return dependency; } private static MavenProject createProject( List dependencies, String artifactId ) { MavenProject result = new MavenProject(); result.setGroupId( "org.apache" ); result.setArtifactId( artifactId ); result.setVersion( "1.2" ); result.setDependencies( dependencies ); return result; } }maven-maven-3.5.2/maven-core/src/test/java/org/apache/maven/lifecycle/000077500000000000000000000000001317160430700255355ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/java/org/apache/maven/lifecycle/DefaultLifecyclesTest.java000066400000000000000000000033451317160430700326340ustar00rootroot00000000000000/* * Licensed to the Apache Software Foundation (ASF) under one or more contributor license * agreements. See the NOTICE file distributed with this work for additional information regarding * copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance with the License. You may obtain a * copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express * or implied. See the License for the specific language governing permissions and limitations under * the License. */ package org.apache.maven.lifecycle; import org.codehaus.plexus.PlexusTestCase; import org.codehaus.plexus.component.annotations.Requirement; import java.util.List; /** * @author Kristian Rosenvold */ public class DefaultLifecyclesTest extends PlexusTestCase { @Requirement private DefaultLifecycles defaultLifeCycles; protected void setUp() throws Exception { super.setUp(); defaultLifeCycles = lookup( DefaultLifecycles.class ); } @Override protected void tearDown() throws Exception { defaultLifeCycles = null; super.tearDown(); } public void testLifecycle() throws Exception { final List cycles = defaultLifeCycles.getLifeCycles(); assertNotNull( cycles ); final Lifecycle lifecycle = cycles.get( 0 ); assertEquals( "default", lifecycle.getId() ); assertEquals( 23, lifecycle.getPhases().size() ); } }DelegatingMojoExecutionListener.java000066400000000000000000000044111317160430700346030ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/java/org/apache/maven/lifecyclepackage org.apache.maven.lifecycle; /* * 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.util.List; import java.util.concurrent.CopyOnWriteArrayList; import javax.inject.Named; import javax.inject.Singleton; import org.apache.maven.execution.MojoExecutionEvent; import org.apache.maven.execution.MojoExecutionListener; import org.apache.maven.plugin.MojoExecutionException; @Named @Singleton public class DelegatingMojoExecutionListener implements MojoExecutionListener { private final List listeners = new CopyOnWriteArrayList<>(); public void beforeMojoExecution( MojoExecutionEvent event ) throws MojoExecutionException { for ( MojoExecutionListener listener : listeners ) { listener.beforeMojoExecution( event ); } } public void afterMojoExecutionSuccess( MojoExecutionEvent event ) throws MojoExecutionException { for ( MojoExecutionListener listener : listeners ) { listener.afterMojoExecutionSuccess( event ); } } public void afterExecutionFailure( MojoExecutionEvent event ) { for ( MojoExecutionListener listener : listeners ) { listener.afterExecutionFailure( event ); } } public void addMojoExecutionListener( MojoExecutionListener listener ) { this.listeners.add( listener ); } public void removeMojoExecutionListener( MojoExecutionListener listener ) { this.listeners.remove( listener ); } } DelegatingProjectExecutionListener.java000066400000000000000000000050721317160430700353110ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/java/org/apache/maven/lifecyclepackage org.apache.maven.lifecycle; /* * 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.util.List; import java.util.concurrent.CopyOnWriteArrayList; import javax.inject.Named; import javax.inject.Singleton; import org.apache.maven.execution.ProjectExecutionEvent; import org.apache.maven.execution.ProjectExecutionListener; @Named @Singleton public class DelegatingProjectExecutionListener implements ProjectExecutionListener { private final List listeners = new CopyOnWriteArrayList<>(); public void beforeProjectExecution( ProjectExecutionEvent event ) throws LifecycleExecutionException { for ( ProjectExecutionListener listener : listeners ) { listener.beforeProjectExecution( event ); } } public void beforeProjectLifecycleExecution( ProjectExecutionEvent event ) throws LifecycleExecutionException { for ( ProjectExecutionListener listener : listeners ) { listener.beforeProjectLifecycleExecution( event ); } } public void afterProjectExecutionSuccess( ProjectExecutionEvent event ) throws LifecycleExecutionException { for ( ProjectExecutionListener listener : listeners ) { listener.afterProjectExecutionSuccess( event ); } } public void afterProjectExecutionFailure( ProjectExecutionEvent event ) { for ( ProjectExecutionListener listener : listeners ) { listener.afterProjectExecutionFailure( event ); } } public void addProjectExecutionListener( ProjectExecutionListener listener ) { this.listeners.add( listener ); } public void removeProjectExecutionListener( ProjectExecutionListener listener ) { this.listeners.remove( listener ); } } EmptyLifecyclePluginAnalyzer.java000066400000000000000000000050361317160430700341300ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/java/org/apache/maven/lifecyclepackage org.apache.maven.lifecycle; /* * 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.util.Collections; import java.util.LinkedHashSet; import java.util.Set; import org.apache.maven.model.Plugin; import org.apache.maven.model.PluginExecution; /** * @author Benjamin Bentmann */ public class EmptyLifecyclePluginAnalyzer implements LifeCyclePluginAnalyzer { public Set getPluginsBoundByDefaultToAllLifecycles( String packaging ) { Set plugins; // NOTE: The upper-case packaging name is intentional, that's a special hinting mode used for certain tests if ( "JAR".equals( packaging ) ) { plugins = new LinkedHashSet<>(); plugins.add( newPlugin( "maven-compiler-plugin", "compile", "testCompile" ) ); plugins.add( newPlugin( "maven-resources-plugin", "resources", "testResources" ) ); plugins.add( newPlugin( "maven-surefire-plugin", "test" ) ); plugins.add( newPlugin( "maven-jar-plugin", "jar" ) ); plugins.add( newPlugin( "maven-install-plugin", "install" ) ); plugins.add( newPlugin( "maven-deploy-plugin", "deploy" ) ); } else { plugins = Collections.emptySet(); } return plugins; } private Plugin newPlugin( String artifactId, String... goals ) { Plugin plugin = new Plugin(); plugin.setGroupId( "org.apache.maven.plugins" ); plugin.setArtifactId( artifactId ); for ( String goal : goals ) { PluginExecution pluginExecution = new PluginExecution(); pluginExecution.setId( "default-" + goal ); pluginExecution.addGoal( goal ); plugin.addExecution( pluginExecution ); } return plugin; } } LifecycleExecutorSubModulesTest.java000066400000000000000000000066121317160430700346070ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/java/org/apache/maven/lifecycle/* * Licensed to the Apache Software Foundation (ASF) under one or more contributor license * agreements. See the NOTICE file distributed with this work for additional information regarding * copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance with the License. You may obtain a * copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express * or implied. See the License for the specific language governing permissions and limitations under * the License. */ package org.apache.maven.lifecycle; import org.apache.maven.AbstractCoreMavenComponentTestCase; import org.apache.maven.exception.ExceptionHandler; import org.apache.maven.lifecycle.internal.LifecycleDependencyResolver; import org.apache.maven.lifecycle.internal.LifecycleExecutionPlanCalculator; import org.apache.maven.lifecycle.internal.LifecycleModuleBuilder; import org.apache.maven.lifecycle.internal.LifecycleTaskSegmentCalculator; import org.apache.maven.lifecycle.internal.MojoExecutor; import org.codehaus.plexus.component.annotations.Requirement; /** * Just asserts that it's able to create those components. Handy when plexus gets a nervous breakdown. * * @author Kristian Rosenvold */ public class LifecycleExecutorSubModulesTest extends AbstractCoreMavenComponentTestCase { @Requirement private DefaultLifecycles defaultLifeCycles; @Requirement private MojoExecutor mojoExecutor; @Requirement private LifecycleModuleBuilder lifeCycleBuilder; @Requirement private LifecycleDependencyResolver lifeCycleDependencyResolver; @Requirement private LifecycleExecutionPlanCalculator lifeCycleExecutionPlanCalculator; @Requirement private LifeCyclePluginAnalyzer lifeCyclePluginAnalyzer; @Requirement private LifecycleTaskSegmentCalculator lifeCycleTaskSegmentCalculator; protected void setUp() throws Exception { super.setUp(); defaultLifeCycles = lookup( DefaultLifecycles.class ); mojoExecutor = lookup( MojoExecutor.class ); lifeCycleBuilder = lookup( LifecycleModuleBuilder.class ); lifeCycleDependencyResolver = lookup( LifecycleDependencyResolver.class ); lifeCycleExecutionPlanCalculator = lookup( LifecycleExecutionPlanCalculator.class ); lifeCyclePluginAnalyzer = lookup( LifeCyclePluginAnalyzer.class ); lifeCycleTaskSegmentCalculator = lookup( LifecycleTaskSegmentCalculator.class ); lookup( ExceptionHandler.class ); } @Override protected void tearDown() throws Exception { defaultLifeCycles = null; super.tearDown(); } protected String getProjectsDirectory() { return "src/test/projects/lifecycle-executor"; } public void testCreation() throws Exception { assertNotNull( defaultLifeCycles ); assertNotNull( mojoExecutor ); assertNotNull( lifeCycleBuilder ); assertNotNull( lifeCycleDependencyResolver ); assertNotNull( lifeCycleExecutionPlanCalculator ); assertNotNull( lifeCyclePluginAnalyzer ); assertNotNull( lifeCycleTaskSegmentCalculator ); } }maven-maven-3.5.2/maven-core/src/test/java/org/apache/maven/lifecycle/LifecycleExecutorTest.java000066400000000000000000000637311317160430700326700ustar00rootroot00000000000000package org.apache.maven.lifecycle; /* * 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.File; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.List; import org.apache.maven.AbstractCoreMavenComponentTestCase; import org.apache.maven.exception.ExceptionHandler; import org.apache.maven.execution.MavenSession; import org.apache.maven.execution.MojoExecutionEvent; import org.apache.maven.execution.MojoExecutionListener; import org.apache.maven.execution.ProjectDependencyGraph; import org.apache.maven.execution.ProjectExecutionEvent; import org.apache.maven.execution.ProjectExecutionListener; import org.apache.maven.lifecycle.internal.DefaultLifecycleTaskSegmentCalculator; import org.apache.maven.lifecycle.internal.ExecutionPlanItem; import org.apache.maven.lifecycle.internal.LifecycleExecutionPlanCalculator; import org.apache.maven.lifecycle.internal.LifecycleTask; import org.apache.maven.lifecycle.internal.LifecycleTaskSegmentCalculator; import org.apache.maven.lifecycle.internal.MojoDescriptorCreator; import org.apache.maven.lifecycle.internal.TaskSegment; import org.apache.maven.model.Plugin; import org.apache.maven.plugin.MojoExecution; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoNotFoundException; import org.apache.maven.plugin.descriptor.MojoDescriptor; import org.apache.maven.project.MavenProject; import org.codehaus.plexus.component.annotations.Requirement; import org.codehaus.plexus.util.xml.Xpp3Dom; public class LifecycleExecutorTest extends AbstractCoreMavenComponentTestCase { @Requirement private DefaultLifecycleExecutor lifecycleExecutor; @Requirement private DefaultLifecycleTaskSegmentCalculator lifeCycleTaskSegmentCalculator; @Requirement private LifecycleExecutionPlanCalculator lifeCycleExecutionPlanCalculator; @Requirement private MojoDescriptorCreator mojoDescriptorCreator; protected void setUp() throws Exception { super.setUp(); lifecycleExecutor = (DefaultLifecycleExecutor) lookup( LifecycleExecutor.class ); lifeCycleTaskSegmentCalculator = (DefaultLifecycleTaskSegmentCalculator) lookup( LifecycleTaskSegmentCalculator.class ); lifeCycleExecutionPlanCalculator = lookup( LifecycleExecutionPlanCalculator.class ); mojoDescriptorCreator = lookup( MojoDescriptorCreator.class ); lookup( ExceptionHandler.class ); } @Override protected void tearDown() throws Exception { lifecycleExecutor = null; super.tearDown(); } protected String getProjectsDirectory() { return "src/test/projects/lifecycle-executor"; } // ----------------------------------------------------------------------------------------------- // Tests which exercise the lifecycle executor when it is dealing with default lifecycle phases. // ----------------------------------------------------------------------------------------------- public void testCalculationOfBuildPlanWithIndividualTaskWherePluginIsSpecifiedInThePom() throws Exception { // We are doing something like "mvn resources:resources" where no version is specified but this // project we are working on has the version specified in the POM so the version should come from there. File pom = getProject( "project-basic" ); MavenSession session = createMavenSession( pom ); assertEquals( "project-basic", session.getCurrentProject().getArtifactId() ); assertEquals( "1.0", session.getCurrentProject().getVersion() ); List executionPlan = getExecutions( calculateExecutionPlan( session, "resources:resources" ) ); assertEquals( 1, executionPlan.size() ); MojoExecution mojoExecution = executionPlan.get( 0 ); assertNotNull( mojoExecution ); assertEquals( "org.apache.maven.plugins", mojoExecution.getMojoDescriptor().getPluginDescriptor().getGroupId() ); assertEquals( "maven-resources-plugin", mojoExecution.getMojoDescriptor().getPluginDescriptor().getArtifactId() ); assertEquals( "0.1", mojoExecution.getMojoDescriptor().getPluginDescriptor().getVersion() ); } public void testCalculationOfBuildPlanWithIndividualTaskOfTheCleanLifecycle() throws Exception { // We are doing something like "mvn clean:clean" where no version is specified but this // project we are working on has the version specified in the POM so the version should come from there. File pom = getProject( "project-basic" ); MavenSession session = createMavenSession( pom ); assertEquals( "project-basic", session.getCurrentProject().getArtifactId() ); assertEquals( "1.0", session.getCurrentProject().getVersion() ); List executionPlan = getExecutions( calculateExecutionPlan( session, "clean" ) ); assertEquals( 1, executionPlan.size() ); MojoExecution mojoExecution = executionPlan.get( 0 ); assertNotNull( mojoExecution ); assertEquals( "org.apache.maven.plugins", mojoExecution.getMojoDescriptor().getPluginDescriptor().getGroupId() ); assertEquals( "maven-clean-plugin", mojoExecution.getMojoDescriptor().getPluginDescriptor().getArtifactId() ); assertEquals( "0.1", mojoExecution.getMojoDescriptor().getPluginDescriptor().getVersion() ); } public void testCalculationOfBuildPlanWithIndividualTaskOfTheCleanCleanGoal() throws Exception { // We are doing something like "mvn clean:clean" where no version is specified but this // project we are working on has the version specified in the POM so the version should come from there. File pom = getProject( "project-basic" ); MavenSession session = createMavenSession( pom ); assertEquals( "project-basic", session.getCurrentProject().getArtifactId() ); assertEquals( "1.0", session.getCurrentProject().getVersion() ); List executionPlan = getExecutions( calculateExecutionPlan( session, "clean:clean" ) ); assertEquals( 1, executionPlan.size() ); MojoExecution mojoExecution = executionPlan.get( 0 ); assertNotNull( mojoExecution ); assertEquals( "org.apache.maven.plugins", mojoExecution.getMojoDescriptor().getPluginDescriptor().getGroupId() ); assertEquals( "maven-clean-plugin", mojoExecution.getMojoDescriptor().getPluginDescriptor().getArtifactId() ); assertEquals( "0.1", mojoExecution.getMojoDescriptor().getPluginDescriptor().getVersion() ); } List getExecutions( MavenExecutionPlan mavenExecutionPlan ) { List result = new ArrayList<>(); for ( ExecutionPlanItem executionPlanItem : mavenExecutionPlan ) { result.add( executionPlanItem.getMojoExecution() ); } return result; } // We need to take in multiple lifecycles public void testCalculationOfBuildPlanTasksOfTheCleanLifecycleAndTheInstallLifecycle() throws Exception { File pom = getProject( "project-with-additional-lifecycle-elements" ); MavenSession session = createMavenSession( pom ); assertEquals( "project-with-additional-lifecycle-elements", session.getCurrentProject().getArtifactId() ); assertEquals( "1.0", session.getCurrentProject().getVersion() ); List executionPlan = getExecutions( calculateExecutionPlan( session, "clean", "install" ) ); //[01] clean:clean //[02] resources:resources //[03] compiler:compile //[04] it:generate-metadata //[05] resources:testResources //[06] compiler:testCompile //[07] it:generate-test-metadata //[08] surefire:test //[09] jar:jar //[10] install:install // assertEquals( 10, executionPlan.size() ); assertEquals( "clean:clean", executionPlan.get( 0 ).getMojoDescriptor().getFullGoalName() ); assertEquals( "resources:resources", executionPlan.get( 1 ).getMojoDescriptor().getFullGoalName() ); assertEquals( "compiler:compile", executionPlan.get( 2 ).getMojoDescriptor().getFullGoalName() ); assertEquals( "it:generate-metadata", executionPlan.get( 3 ).getMojoDescriptor().getFullGoalName() ); assertEquals( "resources:testResources", executionPlan.get( 4 ).getMojoDescriptor().getFullGoalName() ); assertEquals( "compiler:testCompile", executionPlan.get( 5 ).getMojoDescriptor().getFullGoalName() ); assertEquals( "it:generate-test-metadata", executionPlan.get( 6 ).getMojoDescriptor().getFullGoalName() ); assertEquals( "surefire:test", executionPlan.get( 7 ).getMojoDescriptor().getFullGoalName() ); assertEquals( "jar:jar", executionPlan.get( 8 ).getMojoDescriptor().getFullGoalName() ); assertEquals( "install:install", executionPlan.get( 9 ).getMojoDescriptor().getFullGoalName() ); } // We need to take in multiple lifecycles public void testCalculationOfBuildPlanWithMultipleExecutionsOfModello() throws Exception { File pom = getProject( "project-with-multiple-executions" ); MavenSession session = createMavenSession( pom ); assertEquals( "project-with-multiple-executions", session.getCurrentProject().getArtifactId() ); assertEquals( "1.0.1", session.getCurrentProject().getVersion() ); MavenExecutionPlan plan = calculateExecutionPlan( session, "clean", "install" ); List executions = getExecutions( plan ); //[01] clean:clean //[02] modello:xpp3-writer //[03] modello:java //[04] modello:xpp3-reader //[05] modello:xpp3-writer //[06] modello:java //[07] modello:xpp3-reader //[08] plugin:descriptor //[09] resources:resources //[10] compiler:compile //[11] resources:testResources //[12] compiler:testCompile //[13] surefire:test //[14] jar:jar //[15] plugin:addPluginArtifactMetadata //[16] install:install // assertEquals( 16, executions.size() ); assertEquals( "clean:clean", executions.get( 0 ).getMojoDescriptor().getFullGoalName() ); assertEquals( "it:xpp3-writer", executions.get( 1 ).getMojoDescriptor().getFullGoalName() ); assertEquals( "it:java", executions.get( 2 ).getMojoDescriptor().getFullGoalName() ); assertEquals( "it:xpp3-reader", executions.get( 3 ).getMojoDescriptor().getFullGoalName() ); assertEquals( "it:xpp3-writer", executions.get( 4 ).getMojoDescriptor().getFullGoalName() ); assertEquals( "it:java", executions.get( 5 ).getMojoDescriptor().getFullGoalName() ); assertEquals( "it:xpp3-reader", executions.get( 6 ).getMojoDescriptor().getFullGoalName() ); assertEquals( "resources:resources", executions.get( 7 ).getMojoDescriptor().getFullGoalName() ); assertEquals( "compiler:compile", executions.get( 8 ).getMojoDescriptor().getFullGoalName() ); assertEquals( "plugin:descriptor", executions.get( 9 ).getMojoDescriptor().getFullGoalName() ); assertEquals( "resources:testResources", executions.get( 10 ).getMojoDescriptor().getFullGoalName() ); assertEquals( "compiler:testCompile", executions.get( 11 ).getMojoDescriptor().getFullGoalName() ); assertEquals( "surefire:test", executions.get( 12 ).getMojoDescriptor().getFullGoalName() ); assertEquals( "jar:jar", executions.get( 13 ).getMojoDescriptor().getFullGoalName() ); assertEquals( "plugin:addPluginArtifactMetadata", executions.get( 14 ).getMojoDescriptor().getFullGoalName() ); assertEquals( "install:install", executions.get( 15 ).getMojoDescriptor().getFullGoalName() ); assertEquals( "src/main/mdo/remote-resources.mdo", new MojoExecutionXPathContainer( executions.get( 1 ) ).getValue( "configuration/models[1]/model" ) ); assertEquals( "src/main/mdo/supplemental-model.mdo", new MojoExecutionXPathContainer( executions.get( 4 ) ).getValue( "configuration/models[1]/model" ) ); } public void testLifecycleQueryingUsingADefaultLifecyclePhase() throws Exception { File pom = getProject( "project-with-additional-lifecycle-elements" ); MavenSession session = createMavenSession( pom ); assertEquals( "project-with-additional-lifecycle-elements", session.getCurrentProject().getArtifactId() ); assertEquals( "1.0", session.getCurrentProject().getVersion() ); List executionPlan = getExecutions( calculateExecutionPlan( session, "package" ) ); //[01] resources:resources //[02] compiler:compile //[03] it:generate-metadata //[04] resources:testResources //[05] compiler:testCompile //[06] plexus-component-metadata:generate-test-metadata //[07] surefire:test //[08] jar:jar // assertEquals( 8, executionPlan.size() ); assertEquals( "resources:resources", executionPlan.get( 0 ).getMojoDescriptor().getFullGoalName() ); assertEquals( "compiler:compile", executionPlan.get( 1 ).getMojoDescriptor().getFullGoalName() ); assertEquals( "it:generate-metadata", executionPlan.get( 2 ).getMojoDescriptor().getFullGoalName() ); assertEquals( "resources:testResources", executionPlan.get( 3 ).getMojoDescriptor().getFullGoalName() ); assertEquals( "compiler:testCompile", executionPlan.get( 4 ).getMojoDescriptor().getFullGoalName() ); assertEquals( "it:generate-test-metadata", executionPlan.get( 5 ).getMojoDescriptor().getFullGoalName() ); assertEquals( "surefire:test", executionPlan.get( 6 ).getMojoDescriptor().getFullGoalName() ); assertEquals( "jar:jar", executionPlan.get( 7 ).getMojoDescriptor().getFullGoalName() ); } public void testLifecyclePluginsRetrievalForDefaultLifecycle() throws Exception { List plugins = new ArrayList<>( lifecycleExecutor.getPluginsBoundByDefaultToAllLifecycles( "jar" ) ); assertEquals( 8, plugins.size() ); } public void testPluginConfigurationCreation() throws Exception { File pom = getProject( "project-with-additional-lifecycle-elements" ); MavenSession session = createMavenSession( pom ); MojoDescriptor mojoDescriptor = mojoDescriptorCreator.getMojoDescriptor( "org.apache.maven.its.plugins:maven-it-plugin:0.1:java", session, session.getCurrentProject() ); Xpp3Dom dom = MojoDescriptorCreator.convert( mojoDescriptor ); System.out.println( dom ); } MavenExecutionPlan calculateExecutionPlan( MavenSession session, String... tasks ) throws Exception { List taskSegments = lifeCycleTaskSegmentCalculator.calculateTaskSegments( session, Arrays.asList( tasks ) ); TaskSegment mergedSegment = new TaskSegment( false ); for ( TaskSegment taskSegment : taskSegments ) { mergedSegment.getTasks().addAll( taskSegment.getTasks() ); } return lifeCycleExecutionPlanCalculator.calculateExecutionPlan( session, session.getCurrentProject(), mergedSegment.getTasks() ); } public void testInvalidGoalName() throws Exception { File pom = getProject( "project-basic" ); MavenSession session = createMavenSession( pom ); try { getExecutions( calculateExecutionPlan( session, "resources:" ) ); fail( "expected a MojoNotFoundException" ); } catch ( MojoNotFoundException e ) { assertEquals( "", e.getGoal() ); } try { getExecutions( calculateExecutionPlan( session, "org.apache.maven.plugins:maven-resources-plugin:0.1:resources:toomany" ) ); fail( "expected a MojoNotFoundException" ); } catch ( MojoNotFoundException e ) { assertEquals( "resources:toomany", e.getGoal() ); } } public void testPluginPrefixRetrieval() throws Exception { File pom = getProject( "project-basic" ); MavenSession session = createMavenSession( pom ); Plugin plugin = mojoDescriptorCreator.findPluginForPrefix( "resources", session ); assertEquals( "org.apache.maven.plugins", plugin.getGroupId() ); assertEquals( "maven-resources-plugin", plugin.getArtifactId() ); } // Prefixes public void testFindingPluginPrefixforCleanClean() throws Exception { File pom = getProject( "project-basic" ); MavenSession session = createMavenSession( pom ); Plugin plugin = mojoDescriptorCreator.findPluginForPrefix( "clean", session ); assertNotNull( plugin ); } public void testSetupMojoExecution() throws Exception { File pom = getProject( "mojo-configuration" ); MavenSession session = createMavenSession( pom ); LifecycleTask task = new LifecycleTask( "generate-sources" ); MavenExecutionPlan executionPlan = lifeCycleExecutionPlanCalculator.calculateExecutionPlan( session, session.getCurrentProject(), Arrays.asList( (Object) task ), false ); MojoExecution execution = executionPlan.getMojoExecutions().get(0); assertEquals(execution.toString(), "maven-it-plugin", execution.getArtifactId()); assertNull(execution.getConfiguration()); lifeCycleExecutionPlanCalculator.setupMojoExecution( session, session.getCurrentProject(), execution ); assertNotNull(execution.getConfiguration()); assertEquals("1.0", execution.getConfiguration().getChild( "version" ).getAttribute( "default-value" )); } public void testExecutionListeners() throws Exception { final File pom = getProject( "project-basic" ); final MavenSession session = createMavenSession( pom ); session.setProjectDependencyGraph( new ProjectDependencyGraph() { public List getUpstreamProjects( MavenProject project, boolean transitive ) { return Collections.emptyList(); } public List getAllProjects() { return session.getAllProjects(); } public List getSortedProjects() { return Collections.singletonList( session.getCurrentProject() ); } public List getDownstreamProjects( MavenProject project, boolean transitive ) { return Collections.emptyList(); } public java.util.List getAllSortedProjects() { return Collections.emptyList(); } } ); final List log = new ArrayList<>(); MojoExecutionListener mojoListener = new MojoExecutionListener() { public void beforeMojoExecution( MojoExecutionEvent event ) throws MojoExecutionException { assertNotNull( event.getSession() ); assertNotNull( event.getProject() ); assertNotNull( event.getExecution() ); assertNotNull( event.getMojo() ); assertNull( event.getCause() ); log.add( "beforeMojoExecution " + event.getProject().getArtifactId() + ":" + event.getExecution().getExecutionId() ); } public void afterMojoExecutionSuccess( MojoExecutionEvent event ) throws MojoExecutionException { assertNotNull( event.getSession() ); assertNotNull( event.getProject() ); assertNotNull( event.getExecution() ); assertNotNull( event.getMojo() ); assertNull( event.getCause() ); log.add( "afterMojoExecutionSuccess " + event.getProject().getArtifactId() + ":" + event.getExecution().getExecutionId() ); } public void afterExecutionFailure( MojoExecutionEvent event ) { assertNotNull( event.getSession() ); assertNotNull( event.getProject() ); assertNotNull( event.getExecution() ); assertNotNull( event.getMojo() ); assertNotNull( event.getCause() ); log.add( "afterExecutionFailure " + event.getProject().getArtifactId() + ":" + event.getExecution().getExecutionId() ); } }; ProjectExecutionListener projectListener = new ProjectExecutionListener() { public void beforeProjectExecution( ProjectExecutionEvent event ) throws LifecycleExecutionException { assertNotNull( event.getSession() ); assertNotNull( event.getProject() ); assertNull( event.getExecutionPlan() ); assertNull( event.getCause() ); log.add( "beforeProjectExecution " + event.getProject().getArtifactId() ); } public void beforeProjectLifecycleExecution( ProjectExecutionEvent event ) throws LifecycleExecutionException { assertNotNull( event.getSession() ); assertNotNull( event.getProject() ); assertNotNull( event.getExecutionPlan() ); assertNull( event.getCause() ); log.add( "beforeProjectLifecycleExecution " + event.getProject().getArtifactId() ); } public void afterProjectExecutionSuccess( ProjectExecutionEvent event ) throws LifecycleExecutionException { assertNotNull( event.getSession() ); assertNotNull( event.getProject() ); assertNotNull( event.getExecutionPlan() ); assertNull( event.getCause() ); log.add( "afterProjectExecutionSuccess " + event.getProject().getArtifactId() ); } public void afterProjectExecutionFailure( ProjectExecutionEvent event ) { assertNotNull( event.getSession() ); assertNotNull( event.getProject() ); assertNull( event.getExecutionPlan() ); assertNotNull( event.getCause() ); log.add( "afterProjectExecutionFailure " + event.getProject().getArtifactId() ); } }; lookup( DelegatingProjectExecutionListener.class ).addProjectExecutionListener( projectListener ); lookup( DelegatingMojoExecutionListener.class ).addMojoExecutionListener( mojoListener ); try { lifecycleExecutor.execute( session ); } finally { lookup( DelegatingProjectExecutionListener.class ).removeProjectExecutionListener( projectListener ); lookup( DelegatingMojoExecutionListener.class ).removeMojoExecutionListener( mojoListener ); } List expectedLog = Arrays.asList( "beforeProjectExecution project-basic", // "beforeProjectLifecycleExecution project-basic", // "beforeMojoExecution project-basic:default-resources", // "afterMojoExecutionSuccess project-basic:default-resources", // "beforeMojoExecution project-basic:default-compile", // "afterMojoExecutionSuccess project-basic:default-compile", // "beforeMojoExecution project-basic:default-testResources", // "afterMojoExecutionSuccess project-basic:default-testResources", // "beforeMojoExecution project-basic:default-testCompile", // "afterMojoExecutionSuccess project-basic:default-testCompile", // "beforeMojoExecution project-basic:default-test", // "afterMojoExecutionSuccess project-basic:default-test", // "beforeMojoExecution project-basic:default-jar", // "afterMojoExecutionSuccess project-basic:default-jar", // "afterProjectExecutionSuccess project-basic" // ); assertEventLog( expectedLog, log ); } private static void assertEventLog( List expectedList, List actualList ) { assertEquals( toString( expectedList ), toString( actualList ) ); } private static String toString( List lines ) { StringBuilder sb = new StringBuilder(); for ( String line : lines ) { sb.append( line ).append( '\n' ); } return sb.toString(); } } maven-maven-3.5.2/maven-core/src/test/java/org/apache/maven/lifecycle/MavenExecutionPlanTest.java000066400000000000000000000053601317160430700330110ustar00rootroot00000000000000/* * Licensed to the Apache Software Foundation (ASF) under one or more contributor license * agreements. See the NOTICE file distributed with this work for additional information regarding * copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance with the License. You may obtain a * copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express * or implied. See the License for the specific language governing permissions and limitations under * the License. */ package org.apache.maven.lifecycle; import junit.framework.TestCase; import org.apache.maven.lifecycle.internal.ExecutionPlanItem; import org.apache.maven.lifecycle.internal.stub.LifecycleExecutionPlanCalculatorStub; import org.apache.maven.model.Plugin; import java.util.Set; /** * @author Kristian Rosenvold */ public class MavenExecutionPlanTest extends TestCase { public void testFindLastInPhase() throws Exception { MavenExecutionPlan plan = LifecycleExecutionPlanCalculatorStub.getProjectAExceutionPlan(); ExecutionPlanItem expected = plan.findLastInPhase( "package" ); ExecutionPlanItem beerPhase = plan.findLastInPhase( "BEER" ); // Beer comes straight after package in stub assertEquals( expected, beerPhase ); assertNotNull( expected ); } public void testThreadSafeMojos() throws Exception { MavenExecutionPlan plan = LifecycleExecutionPlanCalculatorStub.getProjectAExceutionPlan(); final Set unSafePlugins = plan.getNonThreadSafePlugins(); // There is only a single threadsafe plugin here... assertEquals( plan.size() - 1, unSafePlugins.size() ); } public void testFindLastWhenFirst() throws Exception { MavenExecutionPlan plan = LifecycleExecutionPlanCalculatorStub.getProjectAExceutionPlan(); ExecutionPlanItem beerPhase = plan.findLastInPhase( LifecycleExecutionPlanCalculatorStub.VALIDATE.getPhase() ); // Beer comes straight after package in stub assertNull( beerPhase ); } public void testFindLastInPhaseMisc() throws Exception { MavenExecutionPlan plan = LifecycleExecutionPlanCalculatorStub.getProjectAExceutionPlan(); assertNull( plan.findLastInPhase( "pacXkage" ) ); // Beer comes straight after package in stub, much like real life. assertNotNull( plan.findLastInPhase( LifecycleExecutionPlanCalculatorStub.INITIALIZE.getPhase() ) ); } } MojoExecutionXPathContainer.java000066400000000000000000000042771317160430700337330ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/java/org/apache/maven/lifecyclepackage org.apache.maven.lifecycle; /* * 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.util.Iterator; import org.apache.commons.jxpath.JXPathContext; import org.apache.commons.jxpath.JXPathNotFoundException; import org.apache.commons.jxpath.ri.JXPathContextReferenceImpl; import org.apache.maven.plugin.MojoExecution; import org.apache.maven.project.harness.Xpp3DomPointerFactory; public class MojoExecutionXPathContainer { private JXPathContext context; static { JXPathContextReferenceImpl.addNodePointerFactory( new Xpp3DomPointerFactory() ); } public MojoExecutionXPathContainer( MojoExecution mojoExecution ) throws IOException { context = JXPathContext.newContext( mojoExecution ); } public Iterator getIteratorForXPathExpression( String expression ) { return context.iterate( expression ); } public boolean containsXPathExpression( String expression ) { return context.getValue( expression ) != null; } public Object getValue( String expression ) { try { return context.getValue( expression ); } catch ( JXPathNotFoundException e ) { return null; } } public boolean xPathExpressionEqualsValue( String expression, String value ) { return context.getValue( expression ) != null && context.getValue( expression ).equals( value ); } } maven-maven-3.5.2/maven-core/src/test/java/org/apache/maven/lifecycle/internal/000077500000000000000000000000001317160430700273515ustar00rootroot00000000000000BuildListCalculatorTest.java000066400000000000000000000042441317160430700347060ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/java/org/apache/maven/lifecycle/internalpackage org.apache.maven.lifecycle.internal; /* * Licensed to the Apache Software Foundation (ASF) under one or more contributor license * agreements. See the NOTICE file distributed with this work for additional information regarding * copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance with the License. You may obtain a * copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express * or implied. See the License for the specific language governing permissions and limitations under * the License. */ import junit.framework.TestCase; import org.apache.maven.execution.MavenSession; import org.apache.maven.lifecycle.internal.stub.LifecycleTaskSegmentCalculatorStub; import org.apache.maven.lifecycle.internal.stub.ProjectDependencyGraphStub; import java.util.List; public class BuildListCalculatorTest extends TestCase { public void testCalculateProjectBuilds() throws Exception { LifecycleTaskSegmentCalculator lifecycleTaskSegmentCalculator = getTaskSegmentCalculator(); BuildListCalculator buildListCalculator = new BuildListCalculator(); final MavenSession session = ProjectDependencyGraphStub.getMavenSession(); List taskSegments = lifecycleTaskSegmentCalculator.calculateTaskSegments( session ); final ProjectBuildList buildList = buildListCalculator.calculateProjectBuilds( session, taskSegments ); final ProjectBuildList segments = buildList.getByTaskSegment( taskSegments.get( 0 ) ); assertEquals( "Stub data contains 3 segments", 3, taskSegments.size() ); assertEquals( "Stub data contains 6 items", 6, segments.size() ); final ProjectSegment build = segments.get( 0 ); assertNotNull( build ); } private static LifecycleTaskSegmentCalculator getTaskSegmentCalculator() { return new LifecycleTaskSegmentCalculatorStub(); } } BuilderCommonTest.java000066400000000000000000000051571317160430700335440ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/java/org/apache/maven/lifecycle/internalpackage org.apache.maven.lifecycle.internal; /* * Licensed to the Apache Software Foundation (ASF) under one or more contributor license * agreements. See the NOTICE file distributed with this work for additional information regarding * copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance with the License. You may obtain a * copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express * or implied. See the License for the specific language governing permissions and limitations under * the License. */ import junit.framework.TestCase; import org.apache.maven.artifact.Artifact; import org.apache.maven.execution.MavenSession; import org.apache.maven.lifecycle.MavenExecutionPlan; import org.apache.maven.lifecycle.internal.builder.BuilderCommon; import org.apache.maven.lifecycle.internal.stub.LifecycleExecutionPlanCalculatorStub; import org.apache.maven.lifecycle.internal.stub.LoggerStub; import org.apache.maven.lifecycle.internal.stub.ProjectDependencyGraphStub; import java.util.HashSet; /** * @author Kristian Rosenvold */ public class BuilderCommonTest extends TestCase { public void testResolveBuildPlan() throws Exception { MavenSession original = ProjectDependencyGraphStub.getMavenSession(); final TaskSegment taskSegment1 = new TaskSegment( false ); final MavenSession session1 = original.clone(); session1.setCurrentProject( ProjectDependencyGraphStub.A ); final BuilderCommon builderCommon = getBuilderCommon(); final MavenExecutionPlan plan = builderCommon.resolveBuildPlan( session1, ProjectDependencyGraphStub.A, taskSegment1, new HashSet() ); assertEquals( LifecycleExecutionPlanCalculatorStub.getProjectAExceutionPlan().size(), plan.size() ); } public void testHandleBuildError() throws Exception { } public void testAttachToThread() throws Exception { } public void testGetKey() throws Exception { } public static BuilderCommon getBuilderCommon() { final LifecycleDebugLogger logger = new LifecycleDebugLogger( new LoggerStub() ); return new BuilderCommon( logger, new LifecycleExecutionPlanCalculatorStub(), new LoggerStub() ); } } ConcurrencyDependencyGraphTest.java000066400000000000000000000107361317160430700362570ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/java/org/apache/maven/lifecycle/internalpackage org.apache.maven.lifecycle.internal; /* * 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 org.apache.maven.execution.MavenSession; import org.apache.maven.execution.ProjectDependencyGraph; import org.apache.maven.lifecycle.LifecycleNotFoundException; import org.apache.maven.lifecycle.LifecyclePhaseNotFoundException; import org.apache.maven.lifecycle.internal.builder.multithreaded.ConcurrencyDependencyGraph; import org.apache.maven.lifecycle.internal.stub.ProjectDependencyGraphStub; import org.apache.maven.plugin.InvalidPluginDescriptorException; import org.apache.maven.plugin.MojoNotFoundException; import org.apache.maven.plugin.PluginDescriptorParsingException; import org.apache.maven.plugin.PluginNotFoundException; import org.apache.maven.plugin.PluginResolutionException; import org.apache.maven.plugin.prefix.NoPluginFoundForPrefixException; import org.apache.maven.plugin.version.PluginVersionResolutionException; import org.apache.maven.project.MavenProject; import java.util.List; import static org.apache.maven.lifecycle.internal.stub.ProjectDependencyGraphStub.*; /** * @author Kristian Rosenvold */ public class ConcurrencyDependencyGraphTest extends junit.framework.TestCase { public void testConcurrencyGraphPrimaryVersion() throws InvalidPluginDescriptorException, PluginVersionResolutionException, PluginDescriptorParsingException, NoPluginFoundForPrefixException, MojoNotFoundException, PluginNotFoundException, PluginResolutionException, LifecyclePhaseNotFoundException, LifecycleNotFoundException { ProjectDependencyGraph dependencyGraph = new ProjectDependencyGraphStub(); final MavenSession session = ProjectDependencyGraphStub.getMavenSession(); ConcurrencyDependencyGraph graph = new ConcurrencyDependencyGraph( getProjectBuildList( session ), dependencyGraph ); final List projectBuilds = graph.getRootSchedulableBuilds(); assertEquals( 1, projectBuilds.size() ); assertEquals( A, projectBuilds.get( 0 ) ); final List subsequent = graph.markAsFinished( A ); assertEquals( 2, subsequent.size() ); assertEquals( ProjectDependencyGraphStub.B, subsequent.get( 0 ) ); assertEquals( C, subsequent.get( 1 ) ); final List bDescendants = graph.markAsFinished( B ); assertEquals( 1, bDescendants.size() ); assertEquals( Y, bDescendants.get( 0 ) ); final List cDescendants = graph.markAsFinished( C ); assertEquals( 2, cDescendants.size() ); assertEquals( X, cDescendants.get( 0 ) ); assertEquals( Z, cDescendants.get( 1 ) ); } public void testConcurrencyGraphDifferentCompletionOrder() throws InvalidPluginDescriptorException, PluginVersionResolutionException, PluginDescriptorParsingException, NoPluginFoundForPrefixException, MojoNotFoundException, PluginNotFoundException, PluginResolutionException, LifecyclePhaseNotFoundException, LifecycleNotFoundException { ProjectDependencyGraph dependencyGraph = new ProjectDependencyGraphStub(); final MavenSession session = ProjectDependencyGraphStub.getMavenSession(); ConcurrencyDependencyGraph graph = new ConcurrencyDependencyGraph( getProjectBuildList( session ), dependencyGraph ); graph.markAsFinished( A ); final List cDescendants = graph.markAsFinished( C ); assertEquals( 1, cDescendants.size() ); assertEquals( Z, cDescendants.get( 0 ) ); final List bDescendants = graph.markAsFinished( B ); assertEquals( 2, bDescendants.size() ); assertEquals( X, bDescendants.get( 0 ) ); assertEquals( Y, bDescendants.get( 1 ) ); } } LifecycleExecutionPlanCalculatorTest.java000066400000000000000000000077341317160430700374200ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/java/org/apache/maven/lifecycle/internalpackage org.apache.maven.lifecycle.internal; /* * 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 org.apache.maven.AbstractCoreMavenComponentTestCase; import org.apache.maven.execution.MavenSession; import org.apache.maven.lifecycle.MavenExecutionPlan; import org.apache.maven.lifecycle.internal.stub.BuildPluginManagerStub; import org.apache.maven.lifecycle.internal.stub.DefaultLifecyclesStub; import org.apache.maven.lifecycle.internal.stub.PluginPrefixResolverStub; import org.apache.maven.lifecycle.internal.stub.PluginVersionResolverStub; import org.apache.maven.lifecycle.internal.stub.ProjectDependencyGraphStub; /** * @author Kristian Rosenvold */ public class LifecycleExecutionPlanCalculatorTest extends AbstractCoreMavenComponentTestCase { public void testCalculateExecutionPlanWithGoalTasks() throws Exception { MojoDescriptorCreator mojoDescriptorCreator = createMojoDescriptorCreator(); LifecycleExecutionPlanCalculator lifecycleExecutionPlanCalculator = createExecutionPlaceCalculator( mojoDescriptorCreator ); final GoalTask goalTask1 = new GoalTask( "compiler:compile" ); final GoalTask goalTask2 = new GoalTask( "surefire:test" ); final TaskSegment taskSegment1 = new TaskSegment( false, goalTask1, goalTask2 ); final MavenSession session1 = ProjectDependencyGraphStub.getMavenSession( ProjectDependencyGraphStub.A ); MavenExecutionPlan executionPlan = lifecycleExecutionPlanCalculator.calculateExecutionPlan( session1, ProjectDependencyGraphStub.A, taskSegment1.getTasks() ); assertEquals( 2, executionPlan.size() ); final GoalTask goalTask3 = new GoalTask( "surefire:test" ); final TaskSegment taskSegment2 = new TaskSegment( false, goalTask1, goalTask2, goalTask3 ); MavenExecutionPlan executionPlan2 = lifecycleExecutionPlanCalculator.calculateExecutionPlan( session1, ProjectDependencyGraphStub.A, taskSegment2.getTasks() ); assertEquals( 3, executionPlan2.size() ); } // Maybe also make one with LifeCycleTasks public static LifecycleExecutionPlanCalculator createExecutionPlaceCalculator( MojoDescriptorCreator mojoDescriptorCreator ) { LifecyclePluginResolver lifecyclePluginResolver = new LifecyclePluginResolver( new PluginVersionResolverStub() ); return new DefaultLifecycleExecutionPlanCalculator( new BuildPluginManagerStub(), DefaultLifecyclesStub.createDefaultLifecycles(), mojoDescriptorCreator, lifecyclePluginResolver ); } public static MojoDescriptorCreator createMojoDescriptorCreator() { return new MojoDescriptorCreator( new PluginVersionResolverStub(), new BuildPluginManagerStub(), new PluginPrefixResolverStub(), new LifecyclePluginResolver( new PluginVersionResolverStub() ) ); } @Override protected String getProjectsDirectory() { return "src/test/projects/lifecycle-executor"; } } LifecycleTaskSegmentCalculatorImplTest.java000066400000000000000000000043531317160430700377030ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/java/org/apache/maven/lifecycle/internalpackage org.apache.maven.lifecycle.internal; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import junit.framework.TestCase; import org.apache.maven.execution.MavenSession; import org.apache.maven.lifecycle.internal.stub.LifecycleTaskSegmentCalculatorStub; import org.apache.maven.lifecycle.internal.stub.ProjectDependencyGraphStub; import java.util.List; /** * @author Kristian Rosenvold */ public class LifecycleTaskSegmentCalculatorImplTest extends TestCase { public void testCalculateProjectBuilds() throws Exception { LifecycleTaskSegmentCalculator lifecycleTaskSegmentCalculator = getTaskSegmentCalculator(); BuildListCalculator buildListCalculator = new BuildListCalculator(); final MavenSession session = ProjectDependencyGraphStub.getMavenSession(); List taskSegments = lifecycleTaskSegmentCalculator.calculateTaskSegments( session ); final ProjectBuildList buildList = buildListCalculator.calculateProjectBuilds( session, taskSegments ); final ProjectBuildList segments = buildList.getByTaskSegment( taskSegments.get( 0 ) ); assertEquals( "Stub data contains 3 segments", 3, taskSegments.size() ); assertEquals( "Stub data contains 6 items", 6, segments.size() ); final ProjectSegment build = segments.get( 0 ); assertNotNull( build ); } private static LifecycleTaskSegmentCalculator getTaskSegmentCalculator() { return new LifecycleTaskSegmentCalculatorStub(); } } PhaseRecorderTest.java000066400000000000000000000041131317160430700335220ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/java/org/apache/maven/lifecycle/internalpackage org.apache.maven.lifecycle.internal; /* * Licensed to the Apache Software Foundation (ASF) under one or more contributor license * agreements. See the NOTICE file distributed with this work for additional information regarding * copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance with the License. You may obtain a * copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express * or implied. See the License for the specific language governing permissions and limitations under * the License. */ import junit.framework.TestCase; import org.apache.maven.lifecycle.MavenExecutionPlan; import org.apache.maven.lifecycle.internal.stub.LifecycleExecutionPlanCalculatorStub; import org.apache.maven.lifecycle.internal.stub.ProjectDependencyGraphStub; import org.apache.maven.plugin.MojoExecution; import java.util.List; /** * @author Kristian Rosenvold */ public class PhaseRecorderTest extends TestCase { public void testObserveExecution() throws Exception { PhaseRecorder phaseRecorder = new PhaseRecorder( ProjectDependencyGraphStub.A); MavenExecutionPlan plan = LifecycleExecutionPlanCalculatorStub.getProjectAExceutionPlan(); final List executions = plan.getMojoExecutions(); final MojoExecution mojoExecution1 = executions.get( 0 ); final MojoExecution mojoExecution2 = executions.get( 1 ); phaseRecorder.observeExecution( mojoExecution1 ); assertTrue( ProjectDependencyGraphStub.A.hasLifecyclePhase( mojoExecution1.getLifecyclePhase() )); assertFalse( ProjectDependencyGraphStub.A.hasLifecyclePhase( mojoExecution2.getLifecyclePhase() )); assertFalse( phaseRecorder.isDifferentPhase( mojoExecution1)); assertTrue( phaseRecorder.isDifferentPhase( mojoExecution2)); } } ProjectBuildListTest.java000066400000000000000000000034041317160430700342200ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/java/org/apache/maven/lifecycle/internalpackage org.apache.maven.lifecycle.internal; /* * Licensed to the Apache Software Foundation (ASF) under one or more contributor license * agreements. See the NOTICE file distributed with this work for additional information regarding * copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance with the License. You may obtain a * copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express * or implied. See the License for the specific language governing permissions and limitations under * the License. */ import junit.framework.TestCase; import org.apache.maven.execution.MavenSession; import org.apache.maven.lifecycle.internal.stub.ProjectDependencyGraphStub; /** * @author Kristian Rosenvold */ public class ProjectBuildListTest extends TestCase { public void testGetByTaskSegment() throws Exception { final MavenSession session = ProjectDependencyGraphStub.getMavenSession(); ProjectBuildList projectBuildList = ProjectDependencyGraphStub.getProjectBuildList( session ); TaskSegment taskSegment = projectBuildList.get( 0 ).getTaskSegment(); assertTrue( "This test assumes there are at least 6 elements in projectBuilds", projectBuildList.size() >= 6 ); final ProjectBuildList byTaskSegment = projectBuildList.getByTaskSegment( taskSegment ); assertEquals( projectBuildList.size(), byTaskSegment.size() ); // TODO Make multiple segments on projectBuildList } } maven-maven-3.5.2/maven-core/src/test/java/org/apache/maven/lifecycle/internal/builder/000077500000000000000000000000001317160430700307775ustar00rootroot00000000000000multithreaded/000077500000000000000000000000001317160430700335535ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/java/org/apache/maven/lifecycle/internal/builderThreadOutputMuxerTest.java000066400000000000000000000155361317160430700407410ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/java/org/apache/maven/lifecycle/internal/builder/multithreadedpackage org.apache.maven.lifecycle.internal.builder.multithreaded; /* * Licensed to the Apache Software Foundation (ASF) under one or more contributor license * agreements. See the NOTICE file distributed with this work for additional information regarding * copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance with the License. You may obtain a * copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express * or implied. See the License for the specific language governing permissions and limitations under * the License. */ import junit.framework.TestCase; import org.apache.maven.execution.MavenSession; import org.apache.maven.lifecycle.LifecycleNotFoundException; import org.apache.maven.lifecycle.LifecyclePhaseNotFoundException; import org.apache.maven.lifecycle.internal.ProjectBuildList; import org.apache.maven.lifecycle.internal.ProjectSegment; import org.apache.maven.lifecycle.internal.builder.multithreaded.ThreadOutputMuxer; import org.apache.maven.lifecycle.internal.stub.ProjectDependencyGraphStub; import org.apache.maven.plugin.InvalidPluginDescriptorException; import org.apache.maven.plugin.MojoNotFoundException; import org.apache.maven.plugin.PluginDescriptorParsingException; import org.apache.maven.plugin.PluginNotFoundException; import org.apache.maven.plugin.PluginResolutionException; import org.apache.maven.plugin.prefix.NoPluginFoundForPrefixException; import org.apache.maven.plugin.version.PluginVersionResolutionException; import java.io.ByteArrayOutputStream; import java.io.PrintStream; import java.util.ArrayList; import java.util.Arrays; import java.util.Iterator; import java.util.List; import java.util.concurrent.Callable; import java.util.concurrent.CompletionService; import java.util.concurrent.ExecutorCompletionService; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.concurrent.Future; /** * @author Kristian Rosenvold */ public class ThreadOutputMuxerTest extends TestCase { final String paid = "Paid"; final String in = "In"; final String full = "Full"; public void testSingleThreaded() throws Exception { ProjectBuildList src = getProjectBuildList(); ProjectBuildList projectBuildList = new ProjectBuildList( Arrays.asList( src.get( 0 ), src.get( 1 ), src.get( 2 ) ) ); ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); PrintStream systemOut = new PrintStream( byteArrayOutputStream ); ThreadOutputMuxer threadOutputMuxer = new ThreadOutputMuxer( projectBuildList, systemOut ); threadOutputMuxer.associateThreadWithProjectSegment( projectBuildList.get( 0 ) ); System.out.print( paid ); // No, this does not print to system.out. It's part of the test assertEquals( paid.length(), byteArrayOutputStream.size() ); threadOutputMuxer.associateThreadWithProjectSegment( projectBuildList.get( 1 ) ); System.out.print( in ); // No, this does not print to system.out. It's part of the test assertEquals( paid.length(), byteArrayOutputStream.size() ); threadOutputMuxer.associateThreadWithProjectSegment( projectBuildList.get( 2 ) ); System.out.print( full ); // No, this does not print to system.out. It's part of the test assertEquals( paid.length(), byteArrayOutputStream.size() ); threadOutputMuxer.setThisModuleComplete( projectBuildList.get( 0 ) ); threadOutputMuxer.setThisModuleComplete( projectBuildList.get( 1 ) ); threadOutputMuxer.setThisModuleComplete( projectBuildList.get( 2 ) ); threadOutputMuxer.close(); assertEquals( ( paid + in + full ).length(), byteArrayOutputStream.size() ); } public void testMultiThreaded() throws Exception { ProjectBuildList projectBuildList = getProjectBuildList(); ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); PrintStream systemOut = new PrintStream( byteArrayOutputStream ); final ThreadOutputMuxer threadOutputMuxer = new ThreadOutputMuxer( projectBuildList, systemOut ); final List stringList = Arrays.asList( "Thinkin", "of", "a", "master", "plan", "Cuz", "ain’t", "nuthin", "but", "sweat", "inside", "my", "hand" ); Iterator lyrics = stringList.iterator(); ExecutorService executor = Executors.newFixedThreadPool( 10 ); CompletionService service = new ExecutorCompletionService<>( executor ); List> futures = new ArrayList<>(); for ( ProjectSegment projectBuild : projectBuildList ) { final Future buildFuture = service.submit( new Outputter( threadOutputMuxer, projectBuild, lyrics.next() ) ); futures.add( buildFuture ); } for ( Future future : futures ) { future.get(); } int expectedLength = 0; for ( int i = 0; i < projectBuildList.size(); i++ ) { expectedLength += stringList.get( i ).length(); } threadOutputMuxer.close(); final byte[] bytes = byteArrayOutputStream.toByteArray(); String result = new String( bytes ); assertEquals( result, expectedLength, bytes.length ); } class Outputter implements Callable { private final ThreadOutputMuxer threadOutputMuxer; private final ProjectSegment item; private final String response; Outputter( ThreadOutputMuxer threadOutputMuxer, ProjectSegment item, String response ) { this.threadOutputMuxer = threadOutputMuxer; this.item = item; this.response = response; } public ProjectSegment call() throws Exception { threadOutputMuxer.associateThreadWithProjectSegment( item ); System.out.print( response ); threadOutputMuxer.setThisModuleComplete( item ); return item; } } private ProjectBuildList getProjectBuildList() throws InvalidPluginDescriptorException, PluginVersionResolutionException, PluginDescriptorParsingException, NoPluginFoundForPrefixException, MojoNotFoundException, PluginNotFoundException, PluginResolutionException, LifecyclePhaseNotFoundException, LifecycleNotFoundException { final MavenSession session = ProjectDependencyGraphStub.getMavenSession(); return ProjectDependencyGraphStub.getProjectBuildList( session ); } } maven-maven-3.5.2/maven-core/src/test/java/org/apache/maven/lifecycle/internal/stub/000077500000000000000000000000001317160430700303265ustar00rootroot00000000000000AboutTheStubs.html000066400000000000000000000045661317160430700337040ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/java/org/apache/maven/lifecycle/internal/stub About these stubs

    Design

    These stubs can be thought of as hand-coded mock objects. They allow unit tests to test only specific aspects of a component while ignoring others. These stubs form an internally consistent data-set that is not expected to change. They are used to test the individual components in the lifecycle with data that has expected characteristics and can be asserted as desired. You can change/extend these stubs, and tests should not be breaking too much, since most tests assert using expected values from the stubs. Normally, when you try to use data from the stubs that have not been properly populated, you'll get a nullpointer in your test and you then have to identify which stub creates that specific piece of data. The most important stubs are: LifecycleExecutionPlanCalculatorStub ProjectDependencyGraphStub Since they define the primary structure of the project/build. The stubs define three top-level targets that are defined in LifecycleTaskSegmentCalculatorStub; clean, aggr and install. "aggr" is an aggregating task while clean and install are lifecyclephases. There will be three items in the task list for this dataset. The stubs also exist at different "levels", where one test might wire stubs into a specific live implementation. In the next test that same "live implementation" will be used in a stub version instead. Not all live services have stubs, but can be added as needed. BuildPluginManagerStub.java000066400000000000000000000040621317160430700354630ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/java/org/apache/maven/lifecycle/internal/stubpackage org.apache.maven.lifecycle.internal.stub; /* * 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.util.List; import org.apache.maven.execution.MavenSession; import org.apache.maven.model.Plugin; import org.apache.maven.plugin.BuildPluginManager; import org.apache.maven.plugin.MojoExecution; import org.apache.maven.plugin.descriptor.MojoDescriptor; import org.apache.maven.plugin.descriptor.PluginDescriptor; import org.codehaus.plexus.classworlds.realm.ClassRealm; import org.eclipse.aether.RepositorySystemSession; import org.eclipse.aether.repository.RemoteRepository; /** * @author Kristian Rosenvold */ public class BuildPluginManagerStub implements BuildPluginManager { public PluginDescriptor loadPlugin( Plugin plugin, List repositories, RepositorySystemSession session ) { return null; } public MojoDescriptor getMojoDescriptor( Plugin plugin, String goal, List repositories, RepositorySystemSession session ) { return MojoExecutorStub.createMojoDescriptor( plugin.getKey() ); } public ClassRealm getPluginRealm( MavenSession session, PluginDescriptor pluginDescriptor ) { return null; } public void executeMojo( MavenSession session, MojoExecution execution ) { } } CompletionServiceStub.java000066400000000000000000000053421317160430700354060ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/java/org/apache/maven/lifecycle/internal/stub/* * Licensed to the Apache Software Foundation (ASF) under one or more contributor license * agreements. See the NOTICE file distributed with this work for additional information regarding * copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance with the License. You may obtain a * copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express * or implied. See the License for the specific language governing permissions and limitations under * the License. */ package org.apache.maven.lifecycle.internal.stub; import org.apache.maven.lifecycle.internal.ProjectSegment; import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.concurrent.Callable; import java.util.concurrent.CompletionService; import java.util.concurrent.Future; import java.util.concurrent.FutureTask; import java.util.concurrent.TimeUnit; /** * @author Kristian Rosenvold */ public class CompletionServiceStub implements CompletionService { List> projectBuildFutureTasks = Collections.synchronizedList( new ArrayList>() ); final boolean finishImmediately; public int size() { return projectBuildFutureTasks.size(); } public CompletionServiceStub( boolean finishImmediately ) { this.finishImmediately = finishImmediately; } public Future submit( Callable task ) { FutureTask projectBuildFutureTask = new FutureTask<>( task ); projectBuildFutureTasks.add( projectBuildFutureTask ); if ( finishImmediately ) { projectBuildFutureTask.run(); } return projectBuildFutureTask; } public Future submit( Runnable task, ProjectSegment result ) { FutureTask projectBuildFutureTask = new FutureTask<>( task, result ); projectBuildFutureTasks.add( projectBuildFutureTask ); if ( finishImmediately ) { projectBuildFutureTask.run(); } return projectBuildFutureTask; } public Future take() throws InterruptedException { return null; } public Future poll() { return null; } public Future poll( long timeout, TimeUnit unit ) throws InterruptedException { return null; } } DefaultLifecyclesStub.java000066400000000000000000000050221317160430700353360ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/java/org/apache/maven/lifecycle/internal/stub/* * Licensed to the Apache Software Foundation (ASF) under one or more contributor license * agreements. See the NOTICE file distributed with this work for additional information regarding * copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance with the License. You may obtain a * copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express * or implied. See the License for the specific language governing permissions and limitations under * the License. */ package org.apache.maven.lifecycle.internal.stub; import org.apache.maven.lifecycle.DefaultLifecycles; import org.apache.maven.lifecycle.Lifecycle; import java.util.Arrays; import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.Map; import static org.apache.maven.lifecycle.internal.stub.LifecycleExecutionPlanCalculatorStub.*; /** * @author Kristian Rosenvold */ public class DefaultLifecyclesStub { public static DefaultLifecycles createDefaultLifecycles() { List stubDefaultCycle = Arrays.asList( VALIDATE.getPhase(), INITIALIZE.getPhase(), PROCESS_RESOURCES.getPhase(), COMPILE.getPhase(), TEST.getPhase(), PROCESS_TEST_RESOURCES.getPhase(), PACKAGE.getPhase(), "BEER", INSTALL.getPhase() ); // The two phases below are really for future expansion, some would say they lack a drink // The point being that they do not really have to match the "real" stuff, List stubCleanCycle = Arrays.asList( PRE_CLEAN.getPhase(), CLEAN.getPhase(), POST_CLEAN.getPhase() ); List stubSiteCycle = Arrays.asList( PRE_SITE.getPhase(), SITE.getPhase(), POST_SITE.getPhase(), SITE_DEPLOY.getPhase() ); @SuppressWarnings( "unchecked" ) Iterator> lcs = Arrays.asList( stubDefaultCycle, stubCleanCycle, stubSiteCycle ).iterator(); Map lifeCycles = new HashMap<>(); for ( String s : DefaultLifecycles.STANDARD_LIFECYCLES ) { final Lifecycle lifecycle = new Lifecycle( s, lcs.next(), null ); lifeCycles.put( s, lifecycle ); } return new DefaultLifecycles( lifeCycles, new LoggerStub() ); } }ExecutionEventCatapultStub.java000066400000000000000000000026201317160430700364130ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/java/org/apache/maven/lifecycle/internal/stubpackage org.apache.maven.lifecycle.internal.stub; /* * 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 org.apache.maven.execution.MavenSession; import org.apache.maven.execution.ExecutionEvent.Type; import org.apache.maven.lifecycle.internal.ExecutionEventCatapult; import org.apache.maven.plugin.MojoExecution; /** * @author Benjamin Bentmann */ public class ExecutionEventCatapultStub implements ExecutionEventCatapult { public void fire( Type eventType, MavenSession session, MojoExecution mojoExecution ) { } public void fire( Type eventType, MavenSession session, MojoExecution mojoExecution, Exception exception ) { } } LifeCyclePluginAnalyzerStub.java000066400000000000000000000051251317160430700364770ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/java/org/apache/maven/lifecycle/internal/stub/* * Licensed to the Apache Software Foundation (ASF) under one or more contributor license * agreements. See the NOTICE file distributed with this work for additional information regarding * copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance with the License. You may obtain a * copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express * or implied. See the License for the specific language governing permissions and limitations under * the License. */ package org.apache.maven.lifecycle.internal.stub; import org.apache.maven.lifecycle.LifeCyclePluginAnalyzer; import org.apache.maven.model.Plugin; import org.apache.maven.model.PluginExecution; import java.util.Collections; import java.util.LinkedHashSet; import java.util.Set; /** * @author Kristian Rosenvold */ public class LifeCyclePluginAnalyzerStub implements LifeCyclePluginAnalyzer { public Set getPluginsBoundByDefaultToAllLifecycles( String packaging ) { Set plugins; // NOTE: The upper-case packaging name is intentional, that's a special hinting mode used for certain tests if ( "JAR".equals( packaging ) ) { plugins = new LinkedHashSet<>(); plugins.add( newPlugin( "maven-compiler-plugin", "compile", "testCompile" ) ); plugins.add( newPlugin( "maven-resources-plugin", "resources", "testResources" ) ); plugins.add( newPlugin( "maven-surefire-plugin", "test" ) ); plugins.add( newPlugin( "maven-jar-plugin", "jar" ) ); plugins.add( newPlugin( "maven-install-plugin", "install" ) ); plugins.add( newPlugin( "maven-deploy-plugin", "deploy" ) ); } else { plugins = Collections.emptySet(); } return plugins; } private Plugin newPlugin( String artifactId, String... goals ) { Plugin plugin = new Plugin(); plugin.setGroupId( "org.apache.maven.plugins" ); plugin.setArtifactId( artifactId ); for ( String goal : goals ) { PluginExecution pluginExecution = new PluginExecution(); pluginExecution.setId( "default-" + goal ); pluginExecution.addGoal( goal ); plugin.addExecution( pluginExecution ); } return plugin; } } LifecycleExecutionPlanCalculatorStub.java000066400000000000000000000274221317160430700403670ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/java/org/apache/maven/lifecycle/internal/stub/* * Licensed to the Apache Software Foundation (ASF) under one or more contributor license * agreements. See the NOTICE file distributed with this work for additional information regarding * copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance with the License. You may obtain a * copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express * or implied. See the License for the specific language governing permissions and limitations under * the License. */ package org.apache.maven.lifecycle.internal.stub; import org.apache.maven.execution.MavenSession; import org.apache.maven.lifecycle.LifecycleNotFoundException; import org.apache.maven.lifecycle.LifecyclePhaseNotFoundException; import org.apache.maven.lifecycle.MavenExecutionPlan; import org.apache.maven.lifecycle.internal.ExecutionPlanItem; import org.apache.maven.lifecycle.internal.LifecycleExecutionPlanCalculator; import org.apache.maven.lifecycle.internal.ProjectBuildList; import org.apache.maven.lifecycle.internal.ProjectSegment; import org.apache.maven.model.Plugin; import org.apache.maven.plugin.InvalidPluginDescriptorException; import org.apache.maven.plugin.MojoExecution; import org.apache.maven.plugin.MojoNotFoundException; import org.apache.maven.plugin.PluginDescriptorParsingException; import org.apache.maven.plugin.PluginNotFoundException; import org.apache.maven.plugin.PluginResolutionException; import org.apache.maven.plugin.descriptor.MojoDescriptor; import org.apache.maven.plugin.descriptor.PluginDescriptor; import org.apache.maven.plugin.prefix.NoPluginFoundForPrefixException; import org.apache.maven.plugin.version.PluginVersionResolutionException; import org.apache.maven.project.MavenProject; import org.codehaus.plexus.util.xml.Xpp3Dom; import java.util.ArrayList; import java.util.Arrays; import java.util.HashSet; import java.util.List; import java.util.Set; /** * @author Kristian Rosenvold */ public class LifecycleExecutionPlanCalculatorStub implements LifecycleExecutionPlanCalculator { // clean public final static MojoDescriptor PRE_CLEAN = createMojoDescriptor( "pre-clean" ); public final static MojoDescriptor CLEAN = createMojoDescriptor( "clean" ); public final static MojoDescriptor POST_CLEAN = createMojoDescriptor( "post-clean" ); // default (or at least some of them) public final static MojoDescriptor VALIDATE = createMojoDescriptor( "validate" ); public final static MojoDescriptor INITIALIZE = createMojoDescriptor( "initialize" ); public final static MojoDescriptor TEST_COMPILE = createMojoDescriptor( "test-compile" ); public final static MojoDescriptor PROCESS_TEST_RESOURCES = createMojoDescriptor( "process-test-resources" ); public final static MojoDescriptor PROCESS_RESOURCES = createMojoDescriptor( "process-resources" ); public final static MojoDescriptor COMPILE = createMojoDescriptor( "compile", true ); public final static MojoDescriptor TEST = createMojoDescriptor( "test" ); public final static MojoDescriptor PACKAGE = createMojoDescriptor( "package" ); public final static MojoDescriptor INSTALL = createMojoDescriptor( "install" ); // site public final static MojoDescriptor PRE_SITE = createMojoDescriptor( "pre-site" ); public final static MojoDescriptor SITE = createMojoDescriptor( "site" ); public final static MojoDescriptor POST_SITE = createMojoDescriptor( "post-site" ); public final static MojoDescriptor SITE_DEPLOY = createMojoDescriptor( "site-deploy" ); /** * @deprecated instead use {@link #getNumberOfExecutions(ProjectBuildList)} */ @Deprecated public int getNumberOfExceutions( ProjectBuildList projectBuildList ) throws InvalidPluginDescriptorException, PluginVersionResolutionException, PluginDescriptorParsingException, NoPluginFoundForPrefixException, MojoNotFoundException, PluginNotFoundException, PluginResolutionException, LifecyclePhaseNotFoundException, LifecycleNotFoundException { int result = 0; for ( ProjectSegment projectBuild : projectBuildList ) { MavenExecutionPlan plan = calculateExecutionPlan( projectBuild.getSession(), projectBuild.getProject(), projectBuild.getTaskSegment().getTasks() ); result += plan.size(); } return result; } public int getNumberOfExecutions( ProjectBuildList projectBuildList ) throws InvalidPluginDescriptorException, PluginVersionResolutionException, PluginDescriptorParsingException, NoPluginFoundForPrefixException, MojoNotFoundException, PluginNotFoundException, PluginResolutionException, LifecyclePhaseNotFoundException, LifecycleNotFoundException { return getNumberOfExceutions( projectBuildList ); } public void calculateForkedExecutions( MojoExecution mojoExecution, MavenSession session ) throws MojoNotFoundException, PluginNotFoundException, PluginResolutionException, PluginDescriptorParsingException, NoPluginFoundForPrefixException, InvalidPluginDescriptorException, LifecyclePhaseNotFoundException, LifecycleNotFoundException, PluginVersionResolutionException { // Maybe do something ? } public MavenExecutionPlan calculateExecutionPlan( MavenSession session, MavenProject project, List tasks, boolean setup ) throws PluginNotFoundException, PluginResolutionException, LifecyclePhaseNotFoundException, PluginDescriptorParsingException, MojoNotFoundException, InvalidPluginDescriptorException, NoPluginFoundForPrefixException, LifecycleNotFoundException, PluginVersionResolutionException { if ( project.equals( ProjectDependencyGraphStub.A ) ) { return getProjectAExceutionPlan(); } if ( project.equals( ProjectDependencyGraphStub.B ) ) { return getProjectBExecutionPlan(); } // The remaining are basically "for future expansion" List me = new ArrayList<>(); me.add( createMojoExecution( "resources", "default-resources", PROCESS_RESOURCES ) ); me.add( createMojoExecution( "compile", "default-compile", COMPILE ) ); return createExecutionPlan( project, me ); } public MavenExecutionPlan calculateExecutionPlan( MavenSession session, MavenProject project, List tasks ) throws PluginNotFoundException, PluginResolutionException, LifecyclePhaseNotFoundException, PluginDescriptorParsingException, MojoNotFoundException, InvalidPluginDescriptorException, NoPluginFoundForPrefixException, LifecycleNotFoundException, PluginVersionResolutionException { return calculateExecutionPlan( session, project, tasks, true ); } public void setupMojoExecution( MavenSession session, MavenProject project, MojoExecution mojoExecution ) throws PluginNotFoundException, PluginResolutionException, PluginDescriptorParsingException, MojoNotFoundException, InvalidPluginDescriptorException, NoPluginFoundForPrefixException, LifecyclePhaseNotFoundException, LifecycleNotFoundException, PluginVersionResolutionException { } public static MavenExecutionPlan getProjectAExceutionPlan() throws PluginNotFoundException, PluginResolutionException, LifecyclePhaseNotFoundException, PluginDescriptorParsingException, MojoNotFoundException, InvalidPluginDescriptorException, NoPluginFoundForPrefixException, LifecycleNotFoundException, PluginVersionResolutionException { List me = new ArrayList<>(); me.add( createMojoExecution( "initialize", "default-initialize", INITIALIZE ) ); me.add( createMojoExecution( "resources", "default-resources", PROCESS_RESOURCES ) ); me.add( createMojoExecution( "compile", "default-compile", COMPILE ) ); me.add( createMojoExecution( "testResources", "default-testResources", PROCESS_TEST_RESOURCES ) ); me.add( createMojoExecution( "testCompile", "default-testCompile", TEST_COMPILE ) ); me.add( createMojoExecution( "test", "default-test", TEST ) ); me.add( createMojoExecution( "war", "default-war", PACKAGE ) ); me.add( createMojoExecution( "install", "default-install", INSTALL ) ); return createExecutionPlan( ProjectDependencyGraphStub.A.getExecutionProject(), me ); } public static MavenExecutionPlan getProjectBExecutionPlan() throws PluginNotFoundException, PluginResolutionException, LifecyclePhaseNotFoundException, PluginDescriptorParsingException, MojoNotFoundException, InvalidPluginDescriptorException, NoPluginFoundForPrefixException, LifecycleNotFoundException, PluginVersionResolutionException { List me = new ArrayList<>(); me.add( createMojoExecution( "enforce", "enforce-versions", VALIDATE ) ); me.add( createMojoExecution( "resources", "default-resources", PROCESS_RESOURCES ) ); me.add( createMojoExecution( "compile", "default-compile", COMPILE ) ); me.add( createMojoExecution( "testResources", "default-testResources", PROCESS_TEST_RESOURCES ) ); me.add( createMojoExecution( "testCompile", "default-testCompile", TEST_COMPILE ) ); me.add( createMojoExecution( "test", "default-test", TEST ) ); return createExecutionPlan( ProjectDependencyGraphStub.B.getExecutionProject(), me ); } private static MavenExecutionPlan createExecutionPlan( MavenProject project, List mojoExecutions ) throws InvalidPluginDescriptorException, PluginVersionResolutionException, PluginDescriptorParsingException, NoPluginFoundForPrefixException, MojoNotFoundException, PluginNotFoundException, PluginResolutionException, LifecyclePhaseNotFoundException, LifecycleNotFoundException { final List planItemList = ExecutionPlanItem.createExecutionPlanItems( project, mojoExecutions ); return new MavenExecutionPlan( planItemList, DefaultLifecyclesStub.createDefaultLifecycles() ); } private static MojoExecution createMojoExecution( String goal, String executionId, MojoDescriptor mojoDescriptor ) { final Plugin plugin = mojoDescriptor.getPluginDescriptor().getPlugin(); MojoExecution result = new MojoExecution( plugin, goal, executionId ); result.setConfiguration( new Xpp3Dom( executionId + "-" + goal ) ); result.setMojoDescriptor( mojoDescriptor ); result.setLifecyclePhase( mojoDescriptor.getPhase() ); return result; } public static MojoDescriptor createMojoDescriptor( String phaseName ) { return createMojoDescriptor( phaseName, false ); } public static MojoDescriptor createMojoDescriptor( String phaseName, boolean threadSafe ) { final MojoDescriptor mojoDescriptor = new MojoDescriptor(); mojoDescriptor.setPhase( phaseName ); final PluginDescriptor descriptor = new PluginDescriptor(); Plugin plugin = new Plugin(); plugin.setArtifactId( "org.apache.maven.test.MavenExecutionPlan" ); plugin.setGroupId( "stub-plugin-" + phaseName ); descriptor.setPlugin( plugin ); descriptor.setArtifactId( "artifact." + phaseName ); mojoDescriptor.setPluginDescriptor( descriptor ); mojoDescriptor.setThreadSafe( threadSafe ); return mojoDescriptor; } public static Set getScopes() { return new HashSet<>( Arrays.asList( "compile" ) ); } } LifecycleTaskSegmentCalculatorStub.java000066400000000000000000000065101317160430700400310ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/java/org/apache/maven/lifecycle/internal/stub/* * Licensed to the Apache Software Foundation (ASF) under one or more contributor license * agreements. See the NOTICE file distributed with this work for additional information regarding * copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance with the License. You may obtain a * copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express * or implied. See the License for the specific language governing permissions and limitations under * the License. */ package org.apache.maven.lifecycle.internal.stub; import org.apache.maven.execution.MavenSession; import org.apache.maven.lifecycle.internal.GoalTask; import org.apache.maven.lifecycle.internal.LifecycleTask; import org.apache.maven.lifecycle.internal.DefaultLifecycleTaskSegmentCalculator; import org.apache.maven.lifecycle.internal.TaskSegment; import org.apache.maven.plugin.InvalidPluginDescriptorException; import org.apache.maven.plugin.MojoNotFoundException; import org.apache.maven.plugin.PluginDescriptorParsingException; import org.apache.maven.plugin.PluginNotFoundException; import org.apache.maven.plugin.PluginResolutionException; import org.apache.maven.plugin.prefix.NoPluginFoundForPrefixException; import org.apache.maven.plugin.version.PluginVersionResolutionException; import java.util.ArrayList; import java.util.List; /** * @author Kristian Rosenvold */ public class LifecycleTaskSegmentCalculatorStub extends DefaultLifecycleTaskSegmentCalculator { public static final String clean = "clean"; public static final String aggr = "aggr"; public static final String install = "install"; public List calculateTaskSegments( MavenSession session, List tasks ) throws PluginNotFoundException, PluginResolutionException, PluginDescriptorParsingException, MojoNotFoundException, NoPluginFoundForPrefixException, InvalidPluginDescriptorException, PluginVersionResolutionException { List taskSegments = new ArrayList<>( tasks.size() ); TaskSegment currentSegment = null; for ( String task : tasks ) { if ( aggr.equals( task ) ) { boolean aggregating = true; if ( currentSegment == null || currentSegment.isAggregating() != aggregating ) { currentSegment = new TaskSegment( aggregating ); taskSegments.add( currentSegment ); } currentSegment.getTasks().add( new GoalTask( task ) ); } else { // lifecycle phase if ( currentSegment == null || currentSegment.isAggregating() ) { currentSegment = new TaskSegment( false ); taskSegments.add( currentSegment ); } currentSegment.getTasks().add( new LifecycleTask( task ) ); } } return taskSegments; } public boolean requiresProject( MavenSession session ) { return true; } } maven-maven-3.5.2/maven-core/src/test/java/org/apache/maven/lifecycle/internal/stub/LoggerStub.java000066400000000000000000000041711317160430700332510ustar00rootroot00000000000000/* * Licensed to the Apache Software Foundation (ASF) under one or more contributor license * agreements. See the NOTICE file distributed with this work for additional information regarding * copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance with the License. You may obtain a * copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express * or implied. See the License for the specific language governing permissions and limitations under * the License. */ package org.apache.maven.lifecycle.internal.stub; import org.codehaus.plexus.logging.Logger; /** * @author Kristian Rosenvold */ public class LoggerStub implements Logger { public void debug( String s ) { } public void debug( String s, Throwable throwable ) { } public boolean isDebugEnabled() { return true; } public void info( String s ) { } public void info( String s, Throwable throwable ) { } public boolean isInfoEnabled() { return true; } public void warn( String s ) { } public void warn( String s, Throwable throwable ) { } public boolean isWarnEnabled() { return true; } public void error( String s ) { } public void error( String s, Throwable throwable ) { } public boolean isErrorEnabled() { return true; } public void fatalError( String s ) { } public void fatalError( String s, Throwable throwable ) { } public boolean isFatalErrorEnabled() { return true; } public Logger getChildLogger( String s ) { return null; } public int getThreshold() { return 0; } public void setThreshold( int i ) { } public String getName() { return "StubLogger"; } } MojoExecutorStub.java000066400000000000000000000052561317160430700344030ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/java/org/apache/maven/lifecycle/internal/stub/* * Licensed to the Apache Software Foundation (ASF) under one or more contributor license * agreements. See the NOTICE file distributed with this work for additional information regarding * copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance with the License. You may obtain a * copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express * or implied. See the License for the specific language governing permissions and limitations under * the License. */ package org.apache.maven.lifecycle.internal.stub; import org.apache.maven.execution.MavenSession; import org.apache.maven.lifecycle.LifecycleExecutionException; import org.apache.maven.lifecycle.internal.DependencyContext; import org.apache.maven.lifecycle.internal.MojoExecutor; import org.apache.maven.lifecycle.internal.PhaseRecorder; import org.apache.maven.lifecycle.internal.ProjectIndex; import org.apache.maven.plugin.MojoExecution; import org.apache.maven.plugin.descriptor.MojoDescriptor; import org.apache.maven.plugin.descriptor.PluginDescriptor; import java.util.ArrayList; import java.util.Collections; import java.util.List; /** * @author Kristian Rosenvold */ public class MojoExecutorStub extends MojoExecutor { // This is being lazy instead of making interface public List executions = Collections.synchronizedList( new ArrayList() ); @Override public void execute( MavenSession session, MojoExecution mojoExecution, ProjectIndex projectIndex, DependencyContext dependencyContext, PhaseRecorder phaseRecorder ) throws LifecycleExecutionException { executions.add( mojoExecution ); } @Override public void execute( MavenSession session, List mojoExecutions, ProjectIndex projectIndex ) throws LifecycleExecutionException { for ( MojoExecution mojoExecution : mojoExecutions ) { executions.add( mojoExecution ); } } public static MojoDescriptor createMojoDescriptor( String mojoDescription ) { final PluginDescriptor descriptor = new PluginDescriptor(); descriptor.setArtifactId( mojoDescription ); final MojoDescriptor mojoDescriptor = new MojoDescriptor(); mojoDescriptor.setDescription( mojoDescription ); mojoDescriptor.setPluginDescriptor( descriptor ); return mojoDescriptor; } } PluginPrefixResolverStub.java000066400000000000000000000033561317160430700361150ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/java/org/apache/maven/lifecycle/internal/stub/* * Licensed to the Apache Software Foundation (ASF) under one or more contributor license * agreements. See the NOTICE file distributed with this work for additional information regarding * copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance with the License. You may obtain a * copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express * or implied. See the License for the specific language governing permissions and limitations under * the License. */ package org.apache.maven.lifecycle.internal.stub; import org.apache.maven.plugin.prefix.NoPluginFoundForPrefixException; import org.apache.maven.plugin.prefix.PluginPrefixRequest; import org.apache.maven.plugin.prefix.PluginPrefixResolver; import org.apache.maven.plugin.prefix.PluginPrefixResult; import org.eclipse.aether.repository.ArtifactRepository; /** * @author Kristian Rosenvold */ public class PluginPrefixResolverStub implements PluginPrefixResolver { public PluginPrefixResult resolve( PluginPrefixRequest request ) throws NoPluginFoundForPrefixException { return new PluginPrefixResult() { public String getGroupId() { return "com.foobar"; } public String getArtifactId() { return "bazbaz"; } public ArtifactRepository getRepository() { return null; } }; } } PluginVersionResolverStub.java000066400000000000000000000032171317160430700363010ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/java/org/apache/maven/lifecycle/internal/stub/* * Licensed to the Apache Software Foundation (ASF) under one or more contributor license * agreements. See the NOTICE file distributed with this work for additional information regarding * copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance with the License. You may obtain a * copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express * or implied. See the License for the specific language governing permissions and limitations under * the License. */ package org.apache.maven.lifecycle.internal.stub; import org.apache.maven.plugin.version.PluginVersionRequest; import org.apache.maven.plugin.version.PluginVersionResolutionException; import org.apache.maven.plugin.version.PluginVersionResolver; import org.apache.maven.plugin.version.PluginVersionResult; import org.eclipse.aether.repository.ArtifactRepository; /** * @author Kristian Rosenvold */ public class PluginVersionResolverStub implements PluginVersionResolver { public PluginVersionResult resolve( PluginVersionRequest request ) throws PluginVersionResolutionException { return new PluginVersionResult() { public String getVersion() { return "0.42"; } public ArtifactRepository getRepository() { return null; } }; } } ProjectDependenciesResolverStub.java000066400000000000000000000077411317160430700374200ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/java/org/apache/maven/lifecycle/internal/stub/* * Licensed to the Apache Software Foundation (ASF) under one or more contributor license * agreements. See the NOTICE file distributed with this work for additional information regarding * copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance with the License. You may obtain a * copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express * or implied. See the License for the specific language governing permissions and limitations under * the License. */ package org.apache.maven.lifecycle.internal.stub; import org.apache.maven.ProjectDependenciesResolver; import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.resolver.ArtifactNotFoundException; import org.apache.maven.artifact.resolver.ArtifactResolutionException; import org.apache.maven.execution.MavenSession; import org.apache.maven.project.DependencyResolutionException; import org.apache.maven.project.DependencyResolutionRequest; import org.apache.maven.project.DependencyResolutionResult; import org.apache.maven.project.MavenProject; import org.eclipse.aether.graph.DefaultDependencyNode; import org.eclipse.aether.graph.Dependency; import org.eclipse.aether.graph.DependencyNode; import java.util.Collection; import java.util.Collections; import java.util.HashSet; import java.util.List; import java.util.Set; /** * @author Kristian Rosenvold */ public class ProjectDependenciesResolverStub implements ProjectDependenciesResolver, org.apache.maven.project.ProjectDependenciesResolver { public Set resolve( MavenProject project, Collection scopesToResolve, MavenSession session ) throws ArtifactResolutionException, ArtifactNotFoundException { return new HashSet<>(); } public Set resolve( MavenProject project, Collection scopesToCollect, Collection scopesToResolve, MavenSession session ) throws ArtifactResolutionException, ArtifactNotFoundException { return new HashSet<>(); } public Set resolve( Collection projects, Collection scopes, MavenSession session ) throws ArtifactResolutionException, ArtifactNotFoundException { return new HashSet<>(); } public Set resolve( MavenProject project, Collection scopesToCollect, Collection scopesToResolve, MavenSession session, Set ignoreableArtifacts ) throws ArtifactResolutionException, ArtifactNotFoundException { return new HashSet<>(); } public DependencyResolutionResult resolve( DependencyResolutionRequest request ) throws DependencyResolutionException { return new DependencyResolutionResult() { public List getUnresolvedDependencies() { return Collections.emptyList(); } public List getResolvedDependencies() { return Collections.emptyList(); } public List getResolutionErrors( Dependency dependency ) { return Collections.emptyList(); } public DependencyNode getDependencyGraph() { return new DefaultDependencyNode( (Dependency) null ); } public List getDependencies() { return Collections.emptyList(); } public List getCollectionErrors() { return Collections.emptyList(); } }; } } ProjectDependencyGraphStub.java000066400000000000000000000216331317160430700363440ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/java/org/apache/maven/lifecycle/internal/stub/* * Licensed to the Apache Software Foundation (ASF) under one or more contributor license * agreements. See the NOTICE file distributed with this work for additional information regarding * copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance with the License. You may obtain a * copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express * or implied. See the License for the specific language governing permissions and limitations under * the License. */ package org.apache.maven.lifecycle.internal.stub; import org.apache.maven.execution.AbstractExecutionListener; import org.apache.maven.execution.DefaultMavenExecutionRequest; import org.apache.maven.execution.DefaultMavenExecutionResult; import org.apache.maven.execution.MavenExecutionRequest; import org.apache.maven.execution.MavenSession; import org.apache.maven.execution.ProjectDependencyGraph; import org.apache.maven.lifecycle.LifecycleNotFoundException; import org.apache.maven.lifecycle.LifecyclePhaseNotFoundException; import org.apache.maven.lifecycle.internal.GoalTask; import org.apache.maven.lifecycle.internal.ProjectBuildList; import org.apache.maven.lifecycle.internal.ProjectSegment; import org.apache.maven.lifecycle.internal.TaskSegment; import org.apache.maven.plugin.InvalidPluginDescriptorException; import org.apache.maven.plugin.MojoNotFoundException; import org.apache.maven.plugin.PluginDescriptorParsingException; import org.apache.maven.plugin.PluginNotFoundException; import org.apache.maven.plugin.PluginResolutionException; import org.apache.maven.plugin.prefix.NoPluginFoundForPrefixException; import org.apache.maven.plugin.version.PluginVersionResolutionException; import org.apache.maven.project.MavenProject; import java.util.ArrayList; import java.util.Arrays; import java.util.List; /** * A stub dependency graph that is custom made for testing concurrent build graph evaluations. *

    * Implements a graph as follows: * A has no dependencies * B depends on A * C depends on A * X depends on B & C * Y depends on B * Z depends on C *

    * * @author Kristian Rosenvold */ public class ProjectDependencyGraphStub implements ProjectDependencyGraph { public static final MavenProject A = new MavenProject(); public static final MavenProject B = new MavenProject(); public static final MavenProject C = new MavenProject(); public static final MavenProject X = new MavenProject(); public static final MavenProject Y = new MavenProject(); public static final MavenProject Z = new MavenProject(); public static final MavenProject UNKNOWN = new MavenProject(); static { A.setArtifactId( "A" ); B.setArtifactId( "B" ); C.setArtifactId( "C" ); X.setArtifactId( "X" ); Y.setArtifactId( "Y" ); Z.setArtifactId( "Z" ); } // This should probably be moved to a separate stub public static ProjectBuildList getProjectBuildList( MavenSession session ) throws InvalidPluginDescriptorException, PluginVersionResolutionException, PluginDescriptorParsingException, NoPluginFoundForPrefixException, MojoNotFoundException, PluginNotFoundException, PluginResolutionException, LifecyclePhaseNotFoundException, LifecycleNotFoundException { final List list = getProjectBuilds( session ); return new ProjectBuildList( list ); } public static List getProjectBuilds( MavenSession session ) throws InvalidPluginDescriptorException, PluginVersionResolutionException, PluginDescriptorParsingException, NoPluginFoundForPrefixException, PluginNotFoundException, MojoNotFoundException, PluginResolutionException, LifecyclePhaseNotFoundException, LifecycleNotFoundException { List projectBuilds = new ArrayList<>(); TaskSegment segment = createTaskSegment(); projectBuilds.add( createProjectBuild( A, session, segment ) ); projectBuilds.add( createProjectBuild( B, session, segment ) ); projectBuilds.add( createProjectBuild( C, session, segment ) ); projectBuilds.add( createProjectBuild( X, session, segment ) ); projectBuilds.add( createProjectBuild( Y, session, segment ) ); projectBuilds.add( createProjectBuild( Z, session, segment ) ); return projectBuilds; } private static ProjectSegment createProjectBuild( MavenProject project, MavenSession session, TaskSegment taskSegment ) throws InvalidPluginDescriptorException, PluginVersionResolutionException, PluginDescriptorParsingException, NoPluginFoundForPrefixException, MojoNotFoundException, PluginNotFoundException, PluginResolutionException, LifecyclePhaseNotFoundException, LifecycleNotFoundException { final MavenSession session1 = session.clone(); return new ProjectSegment( project, taskSegment, session1 ); } private static TaskSegment createTaskSegment() { TaskSegment result = new TaskSegment( false ); result.getTasks().add( new GoalTask( "t1" ) ); result.getTasks().add( new GoalTask( "t2" ) ); return result; } class Dependency { MavenProject dependant; MavenProject dependency; Dependency( MavenProject dependant, MavenProject dependency ) { this.dependant = dependant; this.dependency = dependency; } void addIfDownstream( MavenProject mavenProject, List result ) { if ( dependency == mavenProject ) { result.add( dependant ); } } void addIfUpstreamOf( MavenProject mavenProject, List result ) { if ( dependant == mavenProject ) { result.add( dependency ); // All projects are the statics from this class } } } private List getDependencies() { List dependencies = new ArrayList<>(); dependencies.add( new Dependency( B, A ) ); dependencies.add( new Dependency( C, A ) ); dependencies.add( new Dependency( X, B ) ); dependencies.add( new Dependency( X, C ) ); dependencies.add( new Dependency( Y, B ) ); dependencies.add( new Dependency( Z, C ) ); return dependencies; } public List getAllProjects() { return Arrays.asList( A, B, C, X, Y, Z, UNKNOWN ); } public List getSortedProjects() { return Arrays.asList( A, B, C, X, Y, Z ); // I'm not entirely sure about the order but this should do... } public List getDownstreamProjects( MavenProject project, boolean transitive ) { if ( transitive ) { throw new RuntimeException( "Not implemented yet" ); } List result = new ArrayList<>(); for ( Dependency dependency : getDependencies() ) { dependency.addIfDownstream( project, result ); } return result; } public List getUpstreamProjects( MavenProject project, boolean transitive ) { /* if ( transitive ) { throw new RuntimeException( "Not implemented yet" ); }*/ List result = new ArrayList<>(); final List dependencies = getDependencies(); for ( Dependency dependency : dependencies ) { dependency.addIfUpstreamOf( project, result ); } return result; } public static MavenSession getMavenSession( MavenProject mavenProject ) { final MavenSession session = getMavenSession(); session.setCurrentProject( mavenProject ); return session; } public static MavenSession getMavenSession() { final DefaultMavenExecutionResult defaultMavenExecutionResult = new DefaultMavenExecutionResult(); MavenExecutionRequest mavenExecutionRequest = new DefaultMavenExecutionRequest(); mavenExecutionRequest.setExecutionListener( new AbstractExecutionListener() ); mavenExecutionRequest.setGoals( Arrays.asList( "clean", "aggr", "install" ) ); mavenExecutionRequest.setDegreeOfConcurrency( 1 ); final MavenSession session = new MavenSession( null, null, mavenExecutionRequest, defaultMavenExecutionResult ); final ProjectDependencyGraphStub dependencyGraphStub = new ProjectDependencyGraphStub(); session.setProjectDependencyGraph( dependencyGraphStub ); session.setProjects( dependencyGraphStub.getSortedProjects() ); return session; } } ProjectDependencyGraphStubTest.java000066400000000000000000000045161317160430700372050ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/java/org/apache/maven/lifecycle/internal/stub/* * Licensed to the Apache Software Foundation (ASF) under one or more contributor license * agreements. See the NOTICE file distributed with this work for additional information regarding * copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance with the License. You may obtain a * copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express * or implied. See the License for the specific language governing permissions and limitations under * the License. */ package org.apache.maven.lifecycle.internal.stub; import junit.framework.TestCase; import org.apache.maven.project.MavenProject; import java.util.List; /** * Tests the stub. Yeah, I know. * * @author Kristian Rosenvold */ public class ProjectDependencyGraphStubTest extends TestCase { public void testADependencies() { ProjectDependencyGraphStub stub = new ProjectDependencyGraphStub(); final List mavenProjects = stub.getUpstreamProjects( ProjectDependencyGraphStub.A, false ); assertEquals( 0, mavenProjects.size() ); } public void testBDepenencies( ProjectDependencyGraphStub stub ) { final List bProjects = stub.getUpstreamProjects( ProjectDependencyGraphStub.B, false ); assertEquals( 1, bProjects.size() ); assertTrue( bProjects.contains( ProjectDependencyGraphStub.A ) ); } public void testCDepenencies( ProjectDependencyGraphStub stub ) { final List cProjects = stub.getUpstreamProjects( ProjectDependencyGraphStub.C, false ); assertEquals( 1, cProjects.size() ); assertTrue( cProjects.contains( ProjectDependencyGraphStub.C ) ); } public void testXDepenencies( ProjectDependencyGraphStub stub ) { final List cProjects = stub.getUpstreamProjects( ProjectDependencyGraphStub.X, false ); assertEquals( 2, cProjects.size() ); assertTrue( cProjects.contains( ProjectDependencyGraphStub.C ) ); assertTrue( cProjects.contains( ProjectDependencyGraphStub.B ) ); } } maven-maven-3.5.2/maven-core/src/test/java/org/apache/maven/lifecycle/mapping/000077500000000000000000000000001317160430700271705ustar00rootroot00000000000000LifecyclePhaseTest.java000066400000000000000000000045531317160430700335030ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/java/org/apache/maven/lifecycle/mappingpackage org.apache.maven.lifecycle.mapping; /* * 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.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; import java.util.Arrays; import java.util.List; import org.junit.Test; /** * @author atanasenko */ public class LifecyclePhaseTest { @Test public void testToString() { LifecyclePhase phase = new LifecyclePhase(); assertEquals( "", phase.toString() ); LifecycleMojo mojo1 = new LifecycleMojo(); mojo1.setGoal( "jar:jar" ); phase.setMojos( Arrays.asList( mojo1 ) ); assertEquals( "jar:jar", phase.toString() ); LifecycleMojo mojo2 = new LifecycleMojo(); mojo2.setGoal( "war:war" ); phase.setMojos( Arrays.asList( mojo1, mojo2 ) ); assertEquals( "jar:jar,war:war", phase.toString() ); } @Test public void testSet() { LifecyclePhase phase = new LifecyclePhase(); assertNull( phase.getMojos() ); phase.set( "" ); assertNotNull( phase.getMojos() ); assertEquals( 0, phase.getMojos().size() ); phase.set( "jar:jar, war:war" ); List mojos = phase.getMojos(); assertNotNull( mojos ); assertEquals( 2, mojos.size() ); LifecycleMojo mojo1 = mojos.get(0); assertNotNull( mojo1 ); assertEquals( "jar:jar", mojo1.getGoal() ); LifecycleMojo mojo2 = mojos.get(1); assertNotNull( mojo2 ); assertEquals( "war:war", mojo2.getGoal() ); } } maven-maven-3.5.2/maven-core/src/test/java/org/apache/maven/plugin/000077500000000000000000000000001317160430700250745ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/java/org/apache/maven/plugin/PluginManagerTest.java000066400000000000000000000353401317160430700313350ustar00rootroot00000000000000package org.apache.maven.plugin; /* * 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.util.List; import org.apache.maven.AbstractCoreMavenComponentTestCase; import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.repository.DefaultRepositoryRequest; import org.apache.maven.artifact.repository.RepositoryRequest; import org.apache.maven.execution.MavenSession; import org.apache.maven.model.Plugin; import org.apache.maven.plugin.descriptor.MojoDescriptor; import org.apache.maven.plugin.descriptor.PluginDescriptor; import org.apache.maven.project.MavenProject; import org.codehaus.plexus.classworlds.realm.ClassRealm; import org.codehaus.plexus.component.annotations.Requirement; import org.codehaus.plexus.component.repository.ComponentDescriptor; public class PluginManagerTest extends AbstractCoreMavenComponentTestCase { @Requirement private DefaultBuildPluginManager pluginManager; protected void setUp() throws Exception { super.setUp(); pluginManager = (DefaultBuildPluginManager) lookup( BuildPluginManager.class ); } @Override protected void tearDown() throws Exception { pluginManager = null; super.tearDown(); } protected String getProjectsDirectory() { return "src/test/projects/plugin-manager"; } public void testPluginLoading() throws Exception { MavenSession session = createMavenSession( null ); Plugin plugin = new Plugin(); plugin.setGroupId( "org.apache.maven.its.plugins" ); plugin.setArtifactId( "maven-it-plugin" ); plugin.setVersion( "0.1" ); PluginDescriptor pluginDescriptor = pluginManager.loadPlugin( plugin, session.getCurrentProject().getRemotePluginRepositories(), session.getRepositorySession() ); assertNotNull( pluginDescriptor ); } public void testMojoDescriptorRetrieval() throws Exception { MavenSession session = createMavenSession( null ); String goal = "it"; Plugin plugin = new Plugin(); plugin.setGroupId( "org.apache.maven.its.plugins" ); plugin.setArtifactId( "maven-it-plugin" ); plugin.setVersion( "0.1" ); MojoDescriptor mojoDescriptor = pluginManager.getMojoDescriptor( plugin, goal, session.getCurrentProject().getRemotePluginRepositories(), session.getRepositorySession() ); assertNotNull( mojoDescriptor ); assertEquals( goal, mojoDescriptor.getGoal() ); // igorf: plugin realm comes later // assertNotNull( mojoDescriptor.getRealm() ); PluginDescriptor pluginDescriptor = mojoDescriptor.getPluginDescriptor(); assertNotNull( pluginDescriptor ); assertEquals( "org.apache.maven.its.plugins", pluginDescriptor.getGroupId() ); assertEquals( "maven-it-plugin", pluginDescriptor.getArtifactId() ); assertEquals( "0.1", pluginDescriptor.getVersion() ); } // ----------------------------------------------------------------------------------------------- // Tests which exercise the lifecycle executor when it is dealing with individual goals. // ----------------------------------------------------------------------------------------------- //TODO These two tests display a lack of symmetry with respect to the input which is a free form string and the // mojo descriptor which comes back. All the free form parsing needs to be done somewhere else, this is // really the function of the CLI, and then the pre-processing of that output still needs to be fed into // a hinting process which helps flesh out the full specification of the plugin. The plugin manager should // only deal in concrete terms -- all version finding mumbo jumbo is a customization to base functionality // the plugin manager provides. public void testRemoteResourcesPlugin() throws Exception { //TODO turn an equivalent back on when the RR plugin is released. /* This will not work until the RR plugin is released to get rid of the binding to the reporting exception which is a mistake. This happens after removing the reporting API from the core: java.lang.NoClassDefFoundError: org/apache/maven/reporting/MavenReportException MavenSession session = createMavenSession( getProject( "project-with-inheritance" ) ); String goal = "process"; Plugin plugin = new Plugin(); plugin.setGroupId( "org.apache.maven.plugins" ); plugin.setArtifactId( "maven-remote-resources-plugin" ); plugin.setVersion( "1.0-beta-2" ); MojoDescriptor mojoDescriptor = pluginManager.getMojoDescriptor( plugin, goal, session.getCurrentProject(), session.getLocalRepository() ); assertPluginDescriptor( mojoDescriptor, "org.apache.maven.plugins", "maven-remote-resources-plugin", "1.0-beta-2" ); MojoExecution mojoExecution = new MojoExecution( mojoDescriptor ); pluginManager.executeMojo( session, mojoExecution ); */ } //TODO this will be the basis of the customizable lifecycle execution so need to figure this out quickly. public void testSurefirePlugin() throws Exception { /* MavenSession session = createMavenSession( getProject( "project-with-inheritance" ) ); String goal = "test"; Plugin plugin = new Plugin(); plugin.setGroupId( "org.apache.maven.plugins" ); plugin.setArtifactId( "maven-surefire-plugin" ); plugin.setVersion( "2.4.2" ); // The project has already been fully interpolated so getting the raw mojoDescriptor is not going to have the processes configuration. MojoDescriptor mojoDescriptor = pluginManager.getMojoDescriptor( plugin, goal, session.getLocalRepository(), session.getCurrentProject().getPluginArtifactRepositories() ); assertPluginDescriptor( mojoDescriptor, "org.apache.maven.plugins", "maven-surefire-plugin", "2.4.2" ); System.out.println( session.getCurrentProject().getBuild().getPluginsAsMap() ); Xpp3Dom configuration = (Xpp3Dom) session.getCurrentProject().getBuild().getPluginsAsMap().get( plugin.getKey() ).getExecutions().get( 0 ).getConfiguration(); MojoExecution mojoExecution = new MojoExecution( mojoDescriptor, configuration ); pluginManager.executeMojo( session, mojoExecution ); */ } public void testMojoConfigurationIsMergedCorrectly() throws Exception { } /** * The case where the user wants to specify an alternate version of the underlying tool. Common case * is in the Antlr plugin which comes bundled with a version of Antlr but the user often times needs * to use a specific version. We need to make sure the version that they specify takes precedence. */ public void testMojoWhereInternallyStatedDependencyIsOverriddenByProject() throws Exception { } /** * The case where you have a plugin in the current build that you want to be used on projects in * the current build. */ public void testMojoThatIsPresentInTheCurrentBuild() throws Exception { } /** * This is the case where the Mojo wants to execute on every project and then do something at the end * with the results of each project. */ public void testAggregatorMojo() throws Exception { } /** * This is the case where a Mojo needs the lifecycle run to a certain phase before it can do * anything useful. */ public void testMojoThatRequiresExecutionToAGivenPhaseBeforeExecutingItself() throws Exception { } // test that mojo which does not require dependency resolution trigger no downloading of dependencies // test interpolation of basedir values in mojo configuration // test a build where projects use different versions of the same plugin public void testThatPluginDependencyThatHasSystemScopeIsResolved() throws Exception { /* File systemPath = new File( getBasedir(), "pom.xml" ); Plugin plugin = new PluginBuilder( "org.apache.maven", "project-test", "1.0" ) .addDependency( "org.apache.maven", "system-dependency", "1.0", Artifact.SCOPE_SYSTEM, systemPath.getAbsolutePath() ) .get(); MavenProject pluginProject = new ProjectBuilder( "org.apache.maven", "project-test", "1.0" ) .addPlugin( plugin ) .addDependency( "junit", "junit", "3.8.1", Artifact.SCOPE_COMPILE ) .get(); // i'm making this artifact which is assumed to come from a pom in the metadata processor, then it tries to create a POM artifact // and parse it for the dependencies and it blows up. // // we need to pass this through as is so it doesn't get parsed again. Artifact pluginArtifact = new ProjectArtifact( pluginProject ); Set artifacts = pluginManager.getPluginArtifacts( pluginArtifact, plugin, getLocalRepository(), getPluginArtifactRepositories() ); System.out.println( artifacts ); */ MavenSession session = createMavenSession( getProject( "project-contributing-system-scope-plugin-dep" ) ); MavenProject project = session.getCurrentProject(); Plugin plugin = project.getPlugin( "org.apache.maven.its.plugins:maven-it-plugin" ); RepositoryRequest repositoryRequest = new DefaultRepositoryRequest(); repositoryRequest.setLocalRepository( getLocalRepository() ); repositoryRequest.setRemoteRepositories( getPluginArtifactRepositories() ); PluginDescriptor pluginDescriptor = pluginManager.loadPlugin( plugin, session.getCurrentProject().getRemotePluginRepositories(), session.getRepositorySession() ); pluginManager.getPluginRealm( session, pluginDescriptor ); List artifacts = pluginDescriptor.getArtifacts(); for ( Artifact a : artifacts ) { if ( a.getGroupId().equals( "org.apache.maven.its.mng3586" ) && a.getArtifactId().equals( "tools" ) ) { // The system scoped dependencies will be present in the classloader for the plugin return; } } fail( "Can't find the system scoped dependency in the plugin artifacts." ); } // ----------------------------------------------------------------------------------------------- // Testing help // ----------------------------------------------------------------------------------------------- protected void assertPluginDescriptor( MojoDescriptor mojoDescriptor, String groupId, String artifactId, String version ) { assertNotNull( mojoDescriptor ); PluginDescriptor pd = mojoDescriptor.getPluginDescriptor(); assertNotNull( pd ); assertEquals( groupId, pd.getGroupId() ); assertEquals( artifactId, pd.getArtifactId() ); assertEquals( version, pd.getVersion() ); } public void testPluginRealmCache() throws Exception { RepositoryRequest repositoryRequest = new DefaultRepositoryRequest(); repositoryRequest.setLocalRepository( getLocalRepository() ); repositoryRequest.setRemoteRepositories( getPluginArtifactRepositories() ); // prime realm cache MavenSession session = createMavenSession( getProject( "project-contributing-system-scope-plugin-dep" ) ); MavenProject project = session.getCurrentProject(); Plugin plugin = project.getPlugin( "org.apache.maven.its.plugins:maven-it-plugin" ); PluginDescriptor pluginDescriptor = pluginManager.loadPlugin( plugin, session.getCurrentProject().getRemotePluginRepositories(), session.getRepositorySession() ); pluginManager.getPluginRealm( session, pluginDescriptor ); assertEquals( 1, pluginDescriptor.getDependencies().size() ); for ( ComponentDescriptor descriptor : pluginDescriptor.getComponents() ) { assertNotNull( descriptor.getRealm() ); assertNotNull( descriptor.getImplementationClass() ); } // reload plugin realm from cache session = createMavenSession( getProject( "project-contributing-system-scope-plugin-dep" ) ); project = session.getCurrentProject(); plugin = project.getPlugin( "org.apache.maven.its.plugins:maven-it-plugin" ); pluginDescriptor = pluginManager.loadPlugin( plugin, session.getCurrentProject().getRemotePluginRepositories(), session.getRepositorySession() ); pluginManager.getPluginRealm( session, pluginDescriptor ); assertEquals( 1, pluginDescriptor.getDependencies().size() ); for ( ComponentDescriptor descriptor : pluginDescriptor.getComponents() ) { assertNotNull( descriptor.getRealm() ); assertNotNull( descriptor.getImplementationClass() ); } } public void testBuildExtensionsPluginLoading() throws Exception { RepositoryRequest repositoryRequest = new DefaultRepositoryRequest(); repositoryRequest.setLocalRepository( getLocalRepository() ); repositoryRequest.setRemoteRepositories( getPluginArtifactRepositories() ); // prime realm cache MavenSession session = createMavenSession( getProject( "project-with-build-extensions-plugin" ) ); MavenProject project = session.getCurrentProject(); Plugin plugin = project.getPlugin( "org.apache.maven.its.plugins:maven-it-plugin" ); PluginDescriptor pluginDescriptor = pluginManager.loadPlugin( plugin, session.getCurrentProject().getRemotePluginRepositories(), session.getRepositorySession() ); ClassRealm pluginRealm = pluginManager.getPluginRealm( session, pluginDescriptor ); assertEquals(pluginRealm, pluginDescriptor.getComponents().get(0).getRealm()); } } maven-maven-3.5.2/maven-core/src/test/java/org/apache/maven/plugin/PluginParameterExceptionTest.java000066400000000000000000000142671317160430700335670ustar00rootroot00000000000000package org.apache.maven.plugin; /* * 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.util.Collections; import org.apache.maven.plugin.descriptor.MojoDescriptor; import org.apache.maven.plugin.descriptor.Parameter; import org.apache.maven.plugin.descriptor.PluginDescriptor; import junit.framework.TestCase; /** * MNG-3131 * * @author Robert Scholte * */ public class PluginParameterExceptionTest extends TestCase { public void testMissingRequiredStringArrayTypeParameter() { MojoDescriptor mojoDescriptor = new MojoDescriptor(); mojoDescriptor.setGoal( "goal" ); PluginDescriptor pluginDescriptor = new PluginDescriptor(); pluginDescriptor.setGoalPrefix( "goalPrefix" ); pluginDescriptor.setArtifactId( "artifactId" ); mojoDescriptor.setPluginDescriptor( pluginDescriptor ); Parameter parameter = new Parameter(); parameter.setType( "java.lang.String[]" ); parameter.setName( "toAddresses" ); parameter.setRequired( true ); PluginParameterException exception = new PluginParameterException( mojoDescriptor, Collections.singletonList( parameter ) ); assertEquals( "One or more required plugin parameters are invalid/missing for 'goalPrefix:goal'\n" + "\n" + "[0] Inside the definition for plugin 'artifactId', specify the following:\n" + "\n" + "\n" + " ...\n" + " \n" + " VALUE\n" + " \n" + ".\n", exception.buildDiagnosticMessage() ); } public void testMissingRequiredCollectionTypeParameter() { MojoDescriptor mojoDescriptor = new MojoDescriptor(); mojoDescriptor.setGoal( "goal" ); PluginDescriptor pluginDescriptor = new PluginDescriptor(); pluginDescriptor.setGoalPrefix( "goalPrefix" ); pluginDescriptor.setArtifactId( "artifactId" ); mojoDescriptor.setPluginDescriptor( pluginDescriptor ); Parameter parameter = new Parameter(); parameter.setType( "java.util.List" ); parameter.setName( "toAddresses" ); parameter.setRequired( true ); PluginParameterException exception = new PluginParameterException( mojoDescriptor, Collections.singletonList( parameter ) ); assertEquals( "One or more required plugin parameters are invalid/missing for 'goalPrefix:goal'\n" + "\n" + "[0] Inside the definition for plugin 'artifactId', specify the following:\n" + "\n" + "\n" + " ...\n" + " \n" + " VALUE\n" + " \n" + ".\n", exception.buildDiagnosticMessage() ); } public void testMissingRequiredMapTypeParameter() { MojoDescriptor mojoDescriptor = new MojoDescriptor(); mojoDescriptor.setGoal( "goal" ); PluginDescriptor pluginDescriptor = new PluginDescriptor(); pluginDescriptor.setGoalPrefix( "goalPrefix" ); pluginDescriptor.setArtifactId( "artifactId" ); mojoDescriptor.setPluginDescriptor( pluginDescriptor ); Parameter parameter = new Parameter(); parameter.setType( "java.util.Map" ); parameter.setName( "toAddresses" ); parameter.setRequired( true ); PluginParameterException exception = new PluginParameterException( mojoDescriptor, Collections.singletonList( parameter ) ); assertEquals( "One or more required plugin parameters are invalid/missing for 'goalPrefix:goal'\n" + "\n" + "[0] Inside the definition for plugin 'artifactId', specify the following:\n" + "\n" + "\n" + " ...\n" + " \n" + " VALUE\n" + " \n" + ".\n", exception.buildDiagnosticMessage() ); } public void testMissingRequiredPropertiesTypeParameter() { MojoDescriptor mojoDescriptor = new MojoDescriptor(); mojoDescriptor.setGoal( "goal" ); PluginDescriptor pluginDescriptor = new PluginDescriptor(); pluginDescriptor.setGoalPrefix( "goalPrefix" ); pluginDescriptor.setArtifactId( "artifactId" ); mojoDescriptor.setPluginDescriptor( pluginDescriptor ); Parameter parameter = new Parameter(); parameter.setType( "java.util.Properties" ); parameter.setName( "toAddresses" ); parameter.setRequired( true ); PluginParameterException exception = new PluginParameterException( mojoDescriptor, Collections.singletonList( parameter ) ); assertEquals( "One or more required plugin parameters are invalid/missing for 'goalPrefix:goal'\n" + "\n" + "[0] Inside the definition for plugin 'artifactId', specify the following:\n" + "\n" + "\n" + " ...\n" + " \n" + " \n" + " KEY\n" + " VALUE\n" + " \n" + " \n" + ".\n", exception.buildDiagnosticMessage() ); } } PluginParameterExpressionEvaluatorTest.java000066400000000000000000000346751317160430700356010ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/java/org/apache/maven/pluginpackage org.apache.maven.plugin; /* * 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.File; import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.Map; import java.util.Properties; import org.apache.maven.AbstractCoreMavenComponentTestCase; import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.ArtifactUtils; import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.execution.DefaultMavenExecutionRequest; import org.apache.maven.execution.DefaultMavenExecutionResult; import org.apache.maven.execution.MavenExecutionRequest; import org.apache.maven.execution.MavenSession; import org.apache.maven.model.Build; import org.apache.maven.model.Dependency; import org.apache.maven.model.Model; import org.apache.maven.plugin.descriptor.MojoDescriptor; import org.apache.maven.plugin.descriptor.PluginDescriptor; import org.apache.maven.project.DuplicateProjectException; import org.apache.maven.project.MavenProject; import org.apache.maven.repository.RepositorySystem; import org.codehaus.plexus.MutablePlexusContainer; import org.codehaus.plexus.PlexusContainer; import org.codehaus.plexus.component.configurator.expression.ExpressionEvaluator; import org.codehaus.plexus.util.dag.CycleDetectedException; /** * @author Jason van Zyl */ public class PluginParameterExpressionEvaluatorTest extends AbstractCoreMavenComponentTestCase { private static final String FS = System.getProperty( "file.separator" ); private RepositorySystem factory; public void setUp() throws Exception { super.setUp(); factory = lookup( RepositorySystem.class ); } @Override protected void tearDown() throws Exception { factory = null; super.tearDown(); } public void testPluginDescriptorExpressionReference() throws Exception { MojoExecution exec = newMojoExecution(); MavenSession session = newMavenSession(); Object result = new PluginParameterExpressionEvaluator( session, exec ).evaluate( "${plugin}" ); System.out.println( "Result: " + result ); assertSame( "${plugin} expression does not return plugin descriptor.", exec.getMojoDescriptor().getPluginDescriptor(), result ); } public void testPluginArtifactsExpressionReference() throws Exception { MojoExecution exec = newMojoExecution(); Artifact depArtifact = createArtifact( "group", "artifact", "1" ); List deps = new ArrayList<>(); deps.add( depArtifact ); exec.getMojoDescriptor().getPluginDescriptor().setArtifacts( deps ); MavenSession session = newMavenSession(); @SuppressWarnings( "unchecked" ) List depResults = (List) new PluginParameterExpressionEvaluator( session, exec ).evaluate( "${plugin.artifacts}" ); System.out.println( "Result: " + depResults ); assertNotNull( depResults ); assertEquals( 1, depResults.size() ); assertSame( "dependency artifact is wrong.", depArtifact, depResults.get( 0 ) ); } public void testPluginArtifactMapExpressionReference() throws Exception { MojoExecution exec = newMojoExecution(); Artifact depArtifact = createArtifact( "group", "artifact", "1" ); List deps = new ArrayList<>(); deps.add( depArtifact ); exec.getMojoDescriptor().getPluginDescriptor().setArtifacts( deps ); MavenSession session = newMavenSession(); @SuppressWarnings( "unchecked" ) Map depResults = (Map) new PluginParameterExpressionEvaluator( session, exec ).evaluate( "${plugin.artifactMap}" ); System.out.println( "Result: " + depResults ); assertNotNull( depResults ); assertEquals( 1, depResults.size() ); assertSame( "dependency artifact is wrong.", depArtifact, depResults.get( ArtifactUtils.versionlessKey( depArtifact ) ) ); } public void testPluginArtifactIdExpressionReference() throws Exception { MojoExecution exec = newMojoExecution(); MavenSession session = newMavenSession(); Object result = new PluginParameterExpressionEvaluator( session, exec ).evaluate( "${plugin.artifactId}" ); System.out.println( "Result: " + result ); assertSame( "${plugin.artifactId} expression does not return plugin descriptor's artifactId.", exec.getMojoDescriptor().getPluginDescriptor().getArtifactId(), result ); } public void testValueExtractionWithAPomValueContainingAPath() throws Exception { String expected = getTestFile( "target/test-classes/target/classes" ).getCanonicalPath(); Build build = new Build(); build.setDirectory( expected.substring( 0, expected.length() - "/classes".length() ) ); Model model = new Model(); model.setBuild( build ); MavenProject project = new MavenProject( model ); project.setFile( new File( "pom.xml" ).getCanonicalFile() ); ExpressionEvaluator expressionEvaluator = createExpressionEvaluator( project, null, new Properties() ); Object value = expressionEvaluator.evaluate( "${project.build.directory}/classes" ); String actual = new File( value.toString() ).getCanonicalPath(); assertEquals( expected, actual ); } public void testEscapedVariablePassthrough() throws Exception { String var = "${var}"; Model model = new Model(); model.setVersion( "1" ); MavenProject project = new MavenProject( model ); ExpressionEvaluator ee = createExpressionEvaluator( project, null, new Properties() ); Object value = ee.evaluate( "$" + var ); assertEquals( var, value ); } public void testEscapedVariablePassthroughInLargerExpression() throws Exception { String var = "${var}"; String key = var + " with version: ${project.version}"; Model model = new Model(); model.setVersion( "1" ); MavenProject project = new MavenProject( model ); ExpressionEvaluator ee = createExpressionEvaluator( project, null, new Properties() ); Object value = ee.evaluate( "$" + key ); assertEquals( "${var} with version: 1", value ); } public void testMultipleSubExpressionsInLargerExpression() throws Exception { String key = "${project.artifactId} with version: ${project.version}"; Model model = new Model(); model.setArtifactId( "test" ); model.setVersion( "1" ); MavenProject project = new MavenProject( model ); ExpressionEvaluator ee = createExpressionEvaluator( project, null, new Properties() ); Object value = ee.evaluate( key ); assertEquals( "test with version: 1", value ); } public void testMissingPOMPropertyRefInLargerExpression() throws Exception { String expr = "/path/to/someproject-${baseVersion}"; MavenProject project = new MavenProject( new Model() ); ExpressionEvaluator ee = createExpressionEvaluator( project, null, new Properties() ); Object value = ee.evaluate( expr ); assertEquals( expr, value ); } public void testPOMPropertyExtractionWithMissingProject_WithDotNotation() throws Exception { String key = "m2.name"; String checkValue = "value"; Properties properties = new Properties(); properties.setProperty( key, checkValue ); Model model = new Model(); model.setProperties( properties ); MavenProject project = new MavenProject( model ); ExpressionEvaluator ee = createExpressionEvaluator( project, null, new Properties() ); Object value = ee.evaluate( "${" + key + "}" ); assertEquals( checkValue, value ); } public void testBasedirExtractionWithMissingProject() throws Exception { ExpressionEvaluator ee = createExpressionEvaluator( null, null, new Properties() ); Object value = ee.evaluate( "${basedir}" ); assertEquals( System.getProperty( "user.dir" ), value ); } public void testValueExtractionFromSystemPropertiesWithMissingProject() throws Exception { String sysprop = "PPEET_sysprop1"; Properties executionProperties = new Properties(); if ( executionProperties.getProperty( sysprop ) == null ) { executionProperties.setProperty( sysprop, "value" ); } ExpressionEvaluator ee = createExpressionEvaluator( null, null, executionProperties ); Object value = ee.evaluate( "${" + sysprop + "}" ); assertEquals( "value", value ); } public void testValueExtractionFromSystemPropertiesWithMissingProject_WithDotNotation() throws Exception { String sysprop = "PPEET.sysprop2"; Properties executionProperties = new Properties(); if ( executionProperties.getProperty( sysprop ) == null ) { executionProperties.setProperty( sysprop, "value" ); } ExpressionEvaluator ee = createExpressionEvaluator( null, null, executionProperties ); Object value = ee.evaluate( "${" + sysprop + "}" ); assertEquals( "value", value ); } @SuppressWarnings( "deprecation" ) private static MavenSession createSession( PlexusContainer container, ArtifactRepository repo, Properties properties ) throws CycleDetectedException, DuplicateProjectException { MavenExecutionRequest request = new DefaultMavenExecutionRequest() .setSystemProperties( properties ) .setGoals( Collections.emptyList() ) .setBaseDirectory( new File( "" ) ) .setLocalRepository( repo ); return new MavenSession( container, request, new DefaultMavenExecutionResult(), Collections.emptyList() ); } public void testLocalRepositoryExtraction() throws Exception { ExpressionEvaluator expressionEvaluator = createExpressionEvaluator( createDefaultProject(), null, new Properties() ); Object value = expressionEvaluator.evaluate( "${localRepository}" ); assertEquals( "local", ( (ArtifactRepository) value ).getId() ); } public void testTwoExpressions() throws Exception { Build build = new Build(); build.setDirectory( "expected-directory" ); build.setFinalName( "expected-finalName" ); Model model = new Model(); model.setBuild( build ); ExpressionEvaluator expressionEvaluator = createExpressionEvaluator( new MavenProject( model ), null, new Properties() ); Object value = expressionEvaluator.evaluate( "${project.build.directory}" + FS + "${project.build.finalName}" ); assertEquals( "expected-directory" + File.separatorChar + "expected-finalName", value ); } public void testShouldExtractPluginArtifacts() throws Exception { PluginDescriptor pd = new PluginDescriptor(); Artifact artifact = createArtifact( "testGroup", "testArtifact", "1.0" ); pd.setArtifacts( Collections.singletonList( artifact ) ); ExpressionEvaluator ee = createExpressionEvaluator( createDefaultProject(), pd, new Properties() ); Object value = ee.evaluate( "${plugin.artifacts}" ); assertTrue( value instanceof List ); @SuppressWarnings( "unchecked" ) List artifacts = (List) value; assertEquals( 1, artifacts.size() ); Artifact result = artifacts.get( 0 ); assertEquals( "testGroup", result.getGroupId() ); } private MavenProject createDefaultProject() { return new MavenProject( new Model() ); } private ExpressionEvaluator createExpressionEvaluator( MavenProject project, PluginDescriptor pluginDescriptor, Properties executionProperties ) throws Exception { ArtifactRepository repo = factory.createDefaultLocalRepository(); MutablePlexusContainer container = (MutablePlexusContainer) getContainer(); MavenSession session = createSession( container, repo, executionProperties ); session.setCurrentProject( project ); MojoDescriptor mojo = new MojoDescriptor(); mojo.setPluginDescriptor( pluginDescriptor ); mojo.setGoal( "goal" ); MojoExecution mojoExecution = new MojoExecution( mojo ); return new PluginParameterExpressionEvaluator( session, mojoExecution ); } protected Artifact createArtifact( String groupId, String artifactId, String version ) throws Exception { Dependency dependency = new Dependency(); dependency.setGroupId( groupId ); dependency.setArtifactId( artifactId ); dependency.setVersion( version ); dependency.setType( "jar" ); dependency.setScope( "compile" ); return factory.createDependencyArtifact( dependency ); } private MojoExecution newMojoExecution() { PluginDescriptor pd = new PluginDescriptor(); pd.setArtifactId( "my-plugin" ); pd.setGroupId( "org.myco.plugins" ); pd.setVersion( "1" ); MojoDescriptor md = new MojoDescriptor(); md.setPluginDescriptor( pd ); pd.addComponentDescriptor( md ); return new MojoExecution( md ); } private MavenSession newMavenSession() throws Exception { return createMavenSession( null ); } @Override protected String getProjectsDirectory() { // TODO Auto-generated method stub return null; } } maven-maven-3.5.2/maven-core/src/test/java/org/apache/maven/plugin/internal/000077500000000000000000000000001317160430700267105ustar00rootroot00000000000000DefaultLegacySupportTest.java000066400000000000000000000046171317160430700344520ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/java/org/apache/maven/plugin/internalpackage org.apache.maven.plugin.internal; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import junit.framework.TestCase; import org.apache.maven.execution.DefaultMavenExecutionRequest; import org.apache.maven.execution.MavenExecutionRequest; import org.apache.maven.execution.MavenSession; import java.util.concurrent.CountDownLatch; /** * @author Kristian Rosenvold */ public class DefaultLegacySupportTest extends TestCase { final CountDownLatch latch = new CountDownLatch(1); final DefaultLegacySupport defaultLegacySupport = new DefaultLegacySupport(); public void testSetSession() throws Exception { MavenExecutionRequest mavenExecutionRequest = new DefaultMavenExecutionRequest(); MavenSession m1 = new MavenSession(null, null, mavenExecutionRequest, null); defaultLegacySupport.setSession(m1); MyRunnable myRunnable = new MyRunnable(); Thread thread = new Thread(myRunnable); thread.start(); MavenSession m2 = new MavenSession(null, null, mavenExecutionRequest, null); defaultLegacySupport.setSession(m2); latch.countDown(); thread.join(); assertNull( myRunnable.getSession()); } class MyRunnable implements Runnable { private volatile MavenSession session; public void run() { try { latch.await(); } catch (InterruptedException ignore) { // Test may fail if we get interrupted } session = defaultLegacySupport.getSession(); } public MavenSession getSession() { return session; } } } maven-maven-3.5.2/maven-core/src/test/java/org/apache/maven/project/000077500000000000000000000000001317160430700252445ustar00rootroot00000000000000AbstractMavenProjectTestCase.java000066400000000000000000000154571317160430700335610ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/java/org/apache/maven/projectpackage org.apache.maven.project; /* * 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.File; import java.io.FileNotFoundException; import java.net.URI; import java.net.URISyntaxException; import java.net.URL; import java.util.Arrays; import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout; import org.apache.maven.model.building.ModelBuildingException; import org.apache.maven.model.building.ModelProblem; import org.apache.maven.repository.RepositorySystem; import org.apache.maven.repository.internal.MavenRepositorySystemUtils; import org.codehaus.plexus.ContainerConfiguration; import org.codehaus.plexus.PlexusConstants; import org.codehaus.plexus.PlexusTestCase; import org.eclipse.aether.DefaultRepositorySystemSession; /** * @author Jason van Zyl */ public abstract class AbstractMavenProjectTestCase extends PlexusTestCase { protected ProjectBuilder projectBuilder; protected RepositorySystem repositorySystem; @Override protected void customizeContainerConfiguration( ContainerConfiguration containerConfiguration ) { super.customizeContainerConfiguration( containerConfiguration ); containerConfiguration.setAutoWiring( true ); containerConfiguration.setClassPathScanning( PlexusConstants.SCANNING_INDEX ); } protected void setUp() throws Exception { super.setUp(); if ( getContainer().hasComponent( ProjectBuilder.class, "test" ) ) { projectBuilder = lookup( ProjectBuilder.class, "test" ); } else { // default over to the main project builder... projectBuilder = lookup( ProjectBuilder.class ); } repositorySystem = lookup( RepositorySystem.class ); } @Override protected void tearDown() throws Exception { projectBuilder = null; super.tearDown(); } protected ProjectBuilder getProjectBuilder() { return projectBuilder; } @Override protected String getCustomConfigurationName() { String name = AbstractMavenProjectTestCase.class.getName().replace( '.', '/' ) + ".xml"; System.out.println( name ); return name; } // ---------------------------------------------------------------------- // Local repository // ---------------------------------------------------------------------- protected File getLocalRepositoryPath() throws FileNotFoundException, URISyntaxException { File markerFile = getFileForClasspathResource( "local-repo/marker.txt" ); return markerFile.getAbsoluteFile().getParentFile(); } protected static File getFileForClasspathResource( String resource ) throws FileNotFoundException { ClassLoader cloader = Thread.currentThread().getContextClassLoader(); URL resourceUrl = cloader.getResource( resource ); if ( resourceUrl == null ) { throw new FileNotFoundException( "Unable to find: " + resource ); } return new File( URI.create( resourceUrl.toString().replaceAll( " ", "%20" ) ) ); } protected ArtifactRepository getLocalRepository() throws Exception { ArtifactRepositoryLayout repoLayout = lookup( ArtifactRepositoryLayout.class, "legacy" ); ArtifactRepository r = repositorySystem.createArtifactRepository( "local", "file://" + getLocalRepositoryPath().getAbsolutePath(), repoLayout, null, null ); return r; } // ---------------------------------------------------------------------- // Project building // ---------------------------------------------------------------------- protected MavenProject getProjectWithDependencies( File pom ) throws Exception { ProjectBuildingRequest configuration = newBuildingRequest(); configuration.setRemoteRepositories( Arrays.asList( new ArtifactRepository[] {} ) ); configuration.setProcessPlugins( false ); configuration.setResolveDependencies( true ); try { return projectBuilder.build( pom, configuration ).getProject(); } catch ( Exception e ) { Throwable cause = e.getCause(); if ( cause instanceof ModelBuildingException ) { String message = "In: " + pom + "\n\n"; for ( ModelProblem problem : ( (ModelBuildingException) cause ).getProblems() ) { message += problem + "\n"; } System.out.println( message ); } throw e; } } protected MavenProject getProject( File pom ) throws Exception { ProjectBuildingRequest configuration = newBuildingRequest(); return projectBuilder.build( pom, configuration ).getProject(); } protected MavenProject getProjectFromRemoteRepository( final File pom ) throws Exception { final ProjectBuildingRequest configuration = new DefaultProjectBuildingRequest(); configuration.setLocalRepository( this.getLocalRepository() ); configuration.setRemoteRepositories( Arrays.asList( this.repositorySystem.createDefaultRemoteRepository() ) ); initRepoSession( configuration ); return projectBuilder.build( pom, configuration ).getProject(); } protected ProjectBuildingRequest newBuildingRequest() throws Exception { ProjectBuildingRequest configuration = new DefaultProjectBuildingRequest(); configuration.setLocalRepository( getLocalRepository() ); initRepoSession( configuration ); return configuration; } protected void initRepoSession( ProjectBuildingRequest request ) { File localRepo = new File( request.getLocalRepository().getBasedir() ); DefaultRepositorySystemSession repoSession = MavenRepositorySystemUtils.newSession(); repoSession.setLocalRepositoryManager( new LegacyLocalRepositoryManager( localRepo ) ); request.setRepositorySession( repoSession ); } } DefaultMavenProjectBuilderTest.java000066400000000000000000000257711317160430700341150ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/java/org/apache/maven/projectpackage org.apache.maven.project; /* * 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.File; import java.util.ArrayList; import java.util.List; import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout; import org.codehaus.plexus.util.FileUtils; public class DefaultMavenProjectBuilderTest extends AbstractMavenProjectTestCase { private List filesToDelete = new ArrayList<>(); private File localRepoDir; @Override public void setUp() throws Exception { super.setUp(); projectBuilder = lookup( ProjectBuilder.class ); localRepoDir = new File( System.getProperty( "java.io.tmpdir" ), "local-repo." + System.currentTimeMillis() ); localRepoDir.mkdirs(); filesToDelete.add( localRepoDir ); } @Override public void tearDown() throws Exception { super.tearDown(); if ( !filesToDelete.isEmpty() ) { for ( File file : filesToDelete ) { if ( file.exists() ) { if ( file.isDirectory() ) { FileUtils.deleteDirectory( file ); } else { file.delete(); } } } } } protected MavenProject getProject( Artifact pom, boolean allowStub ) throws Exception { ProjectBuildingRequest configuration = new DefaultProjectBuildingRequest(); configuration.setLocalRepository( getLocalRepository() ); initRepoSession( configuration ); return projectBuilder.build( pom, allowStub, configuration ).getProject(); } /** * Check that we can build ok from the middle pom of a (parent,child,grandchild) hierarchy * @throws Exception */ public void testBuildFromMiddlePom() throws Exception { File f1 = getTestFile( "src/test/resources/projects/grandchild-check/child/pom.xml"); File f2 = getTestFile( "src/test/resources/projects/grandchild-check/child/grandchild/pom.xml"); getProject( f1 ); // it's the building of the grandchild project, having already cached the child project // (but not the parent project), which causes the problem. getProject( f2 ); } public void testDuplicatePluginDefinitionsMerged() throws Exception { File f1 = getTestFile( "src/test/resources/projects/duplicate-plugins-merged-pom.xml" ); MavenProject project = getProject( f1 ); assertEquals( 2, project.getBuildPlugins().get( 0 ).getDependencies().size() ); assertEquals( 2, project.getBuildPlugins().get( 0 ).getExecutions().size() ); assertEquals( "first", project.getBuildPlugins().get( 0 ).getExecutions().get( 0 ).getId() ); } public void testBuildStubModelForMissingRemotePom() throws Exception { Artifact pom = repositorySystem.createProjectArtifact( "org.apache.maven.its", "missing", "0.1" ); MavenProject project = getProject( pom, true ); assertNotNull( project.getArtifactId() ); assertNotNull( project.getRemoteArtifactRepositories() ); assertFalse( project.getRemoteArtifactRepositories().isEmpty() ); assertNotNull( project.getPluginArtifactRepositories() ); assertFalse( project.getPluginArtifactRepositories().isEmpty() ); assertNull( project.getParent() ); assertNull( project.getParentArtifact() ); assertFalse( project.isExecutionRoot() ); } @Override protected ArtifactRepository getLocalRepository() throws Exception { ArtifactRepositoryLayout repoLayout = lookup( ArtifactRepositoryLayout.class, "default" ); ArtifactRepository r = repositorySystem.createArtifactRepository( "local", "file://" + localRepoDir.getAbsolutePath(), repoLayout, null, null ); return r; } public void xtestLoop() throws Exception { while ( true ) { File f1 = getTestFile( "src/test/resources/projects/duplicate-plugins-merged-pom.xml" ); getProject( f1 ); } } public void testPartialResultUponBadDependencyDeclaration() throws Exception { File pomFile = getTestFile( "src/test/resources/projects/bad-dependency.xml" ); try { ProjectBuildingRequest request = newBuildingRequest(); request.setProcessPlugins( false ); request.setResolveDependencies( true ); projectBuilder.build( pomFile, request ); fail( "Project building did not fail despite invalid POM" ); } catch ( ProjectBuildingException e ) { List results = e.getResults(); assertNotNull( results ); assertEquals( 1, results.size() ); ProjectBuildingResult result = results.get( 0 ); assertNotNull( result ); assertNotNull( result.getProject() ); assertEquals( 1, result.getProblems().size() ); assertEquals( 1, result.getProject().getArtifacts().size() ); assertNotNull( result.getDependencyResolutionResult() ); } } public void testImportScopePomResolvesFromPropertyBasedRepository() throws Exception { File pomFile = getTestFile( "src/test/resources/projects/import-scope-pom-resolves-from-property-based-repository.xml" ); ProjectBuildingRequest request = newBuildingRequest(); request.setProcessPlugins( false ); request.setResolveDependencies( true ); projectBuilder.build( pomFile, request ); } /** * Tests whether local version range parent references are build correctly. * * @throws Exception */ public void testBuildValidParentVersionRangeLocally() throws Exception { File f1 = getTestFile( "src/test/resources/projects/parent-version-range-local-valid/child/pom.xml" ); final MavenProject childProject = getProject( f1 ); assertNotNull( childProject.getParentArtifact() ); assertEquals( childProject.getParentArtifact().getVersion(), "1" ); assertNotNull( childProject.getParent() ); assertEquals( childProject.getParent().getVersion(), "1" ); assertNotNull( childProject.getModel().getParent() ); assertEquals( childProject.getModel().getParent().getVersion(), "[1,10]" ); } /** * Tests whether local version range parent references are build correctly. * * @throws Exception */ public void testBuildParentVersionRangeLocallyWithoutChildVersion() throws Exception { File f1 = getTestFile( "src/test/resources/projects/parent-version-range-local-child-without-version/child/pom.xml" ); try { getProject( f1 ); fail( "Expected 'ProjectBuildingException' not thrown." ); } catch ( final ProjectBuildingException e ) { assertNotNull( e.getMessage() ); assertTrue( e.getMessage().contains( "Version must be a constant" ) ); } } /** * Tests whether local version range parent references are build correctly. * * @throws Exception */ public void testBuildParentVersionRangeLocallyWithChildVersionExpression() throws Exception { File f1 = getTestFile( "src/test/resources/projects/parent-version-range-local-child-version-expression/child/pom.xml" ); try { getProject( f1 ); fail( "Expected 'ProjectBuildingException' not thrown." ); } catch ( final ProjectBuildingException e ) { assertNotNull( e.getMessage() ); assertTrue( e.getMessage().contains( "Version must be a constant" ) ); } } /** * Tests whether external version range parent references are build correctly. * * @throws Exception */ public void testBuildParentVersionRangeExternally() throws Exception { File f1 = getTestFile( "src/test/resources/projects/parent-version-range-external-valid/pom.xml" ); final MavenProject childProject = this.getProjectFromRemoteRepository( f1 ); assertNotNull( childProject.getParentArtifact() ); assertEquals( childProject.getParentArtifact().getVersion(), "1" ); assertNotNull( childProject.getParent() ); assertEquals( childProject.getParent().getVersion(), "1" ); assertNotNull( childProject.getModel().getParent() ); assertEquals( childProject.getModel().getParent().getVersion(), "[1,1]" ); } /** * Tests whether external version range parent references are build correctly. * * @throws Exception */ public void testBuildParentVersionRangeExternallyWithoutChildVersion() throws Exception { File f1 = getTestFile( "src/test/resources/projects/parent-version-range-external-child-without-version/pom.xml" ); try { this.getProjectFromRemoteRepository( f1 ); fail( "Expected 'ProjectBuildingException' not thrown." ); } catch ( final ProjectBuildingException e ) { assertNotNull( e.getMessage() ); assertTrue( e.getMessage().contains( "Version must be a constant" ) ); } } /** * Tests whether external version range parent references are build correctly. * * @throws Exception */ public void testBuildParentVersionRangeExternallyWithChildVersionExpression() throws Exception { File f1 = getTestFile( "src/test/resources/projects/parent-version-range-external-child-version-expression/pom.xml" ); try { this.getProjectFromRemoteRepository( f1 ); fail( "Expected 'ProjectBuildingException' not thrown." ); } catch ( final ProjectBuildingException e ) { assertNotNull( e.getMessage() ); assertTrue( e.getMessage().contains( "Version must be a constant" ) ); } } } maven-maven-3.5.2/maven-core/src/test/java/org/apache/maven/project/EmptyLifecycleExecutor.java000066400000000000000000000070611317160430700325500ustar00rootroot00000000000000package org.apache.maven.project; /* * 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.util.Collections; import java.util.LinkedHashSet; import java.util.List; import java.util.Set; import org.apache.maven.execution.MavenSession; import org.apache.maven.lifecycle.LifecycleExecutor; import org.apache.maven.lifecycle.MavenExecutionPlan; import org.apache.maven.model.Plugin; import org.apache.maven.model.PluginExecution; import org.apache.maven.plugin.MojoExecution; /** * A stub implementation that assumes an empty lifecycle to bypass interaction with the plugin manager and to avoid * plugin artifact resolution from repositories. * * @author Benjamin Bentmann */ public class EmptyLifecycleExecutor implements LifecycleExecutor { public MavenExecutionPlan calculateExecutionPlan( MavenSession session, String... tasks ) { return new MavenExecutionPlan( null, null ); } public MavenExecutionPlan calculateExecutionPlan( MavenSession session, boolean setup, String... tasks ) { return new MavenExecutionPlan( null, null ); } public void execute( MavenSession session ) { } public Set getPluginsBoundByDefaultToAllLifecycles( String packaging ) { Set plugins; // NOTE: The upper-case packaging name is intentional, that's a special hinting mode used for certain tests if ( "JAR".equals( packaging ) ) { plugins = new LinkedHashSet<>(); plugins.add( newPlugin( "maven-compiler-plugin", "compile", "testCompile" ) ); plugins.add( newPlugin( "maven-resources-plugin", "resources", "testResources" ) ); plugins.add( newPlugin( "maven-surefire-plugin", "test" ) ); plugins.add( newPlugin( "maven-jar-plugin", "jar" ) ); plugins.add( newPlugin( "maven-install-plugin", "install" ) ); plugins.add( newPlugin( "maven-deploy-plugin", "deploy" ) ); } else { plugins = Collections.emptySet(); } return plugins; } private Plugin newPlugin( String artifactId, String... goals ) { Plugin plugin = new Plugin(); plugin.setGroupId( "org.apache.maven.plugins" ); plugin.setArtifactId( artifactId ); for ( String goal : goals ) { PluginExecution pluginExecution = new PluginExecution(); pluginExecution.setId( "default-" + goal ); pluginExecution.addGoal( goal ); plugin.addExecution( pluginExecution ); } return plugin; } public void calculateForkedExecutions( MojoExecution mojoExecution, MavenSession session ) { } public List executeForkedExecutions( MojoExecution mojoExecution, MavenSession session ) { return Collections.emptyList(); } } maven-maven-3.5.2/maven-core/src/test/java/org/apache/maven/project/EmptyProjectBuildingHelper.java000066400000000000000000000040261317160430700333540ustar00rootroot00000000000000package org.apache.maven.project; /* * 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.util.ArrayList; import java.util.List; import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.model.Model; import org.apache.maven.model.Repository; /** * A stub implementation to bypass artifact resolution from repositories. * * @author Benjamin Bentmann */ public class EmptyProjectBuildingHelper implements ProjectBuildingHelper { public List createArtifactRepositories( List pomRepositories, List externalRepositories, ProjectBuildingRequest request ) { if ( externalRepositories != null ) { return externalRepositories; } else { return new ArrayList<>(); } } public ProjectRealmCache.CacheRecord createProjectRealm( MavenProject project, Model model, ProjectBuildingRequest request ) { return new ProjectRealmCache.CacheRecord( null, null ); } public void selectProjectRealm( MavenProject project ) { } } ExtensionDescriptorBuilderTest.java000066400000000000000000000060271317160430700342170ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/java/org/apache/maven/projectpackage org.apache.maven.project; /* * 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.ByteArrayInputStream; import java.io.InputStream; import java.io.UnsupportedEncodingException; import java.util.Arrays; import junit.framework.TestCase; /** * Tests {@link ExtensionDescriptorBuilder}. * * @author Benjamin Bentmann */ public class ExtensionDescriptorBuilderTest extends TestCase { private ExtensionDescriptorBuilder builder; @Override protected void setUp() throws Exception { super.setUp(); builder = new ExtensionDescriptorBuilder(); } @Override protected void tearDown() throws Exception { builder = null; super.tearDown(); } private InputStream toStream( String xml ) { try { return new ByteArrayInputStream( xml.getBytes( "UTF-8" ) ); } catch ( UnsupportedEncodingException e ) { throw new IllegalStateException( e ); } } public void testEmptyDescriptor() throws Exception { String xml = ""; ExtensionDescriptor ed = builder.build( toStream( xml ) ); assertNotNull( ed ); assertNotNull( ed.getExportedPackages() ); assertTrue( ed.getExportedPackages().isEmpty() ); assertNotNull( ed.getExportedArtifacts() ); assertTrue( ed.getExportedArtifacts().isEmpty() ); } public void testCompleteDescriptor() throws Exception { String xml = "" + "" + "" + "a" + "b" + "c" + "" + "" + "x" + "y" + " z " + "" + ""; ExtensionDescriptor ed = builder.build( toStream( xml ) ); assertNotNull( ed ); assertEquals( Arrays.asList( "a", "b", "c" ), ed.getExportedPackages() ); assertEquals( Arrays.asList( "x", "y", "z" ), ed.getExportedArtifacts() ); } } LegacyLocalRepositoryManager.java000066400000000000000000000133471317160430700336120ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/java/org/apache/maven/projectpackage org.apache.maven.project; /* * 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.File; import org.eclipse.aether.RepositorySystemSession; import org.eclipse.aether.artifact.Artifact; import org.eclipse.aether.metadata.Metadata; import org.eclipse.aether.repository.LocalArtifactRegistration; import org.eclipse.aether.repository.LocalArtifactRequest; import org.eclipse.aether.repository.LocalArtifactResult; import org.eclipse.aether.repository.LocalMetadataRegistration; import org.eclipse.aether.repository.LocalMetadataRequest; import org.eclipse.aether.repository.LocalMetadataResult; import org.eclipse.aether.repository.LocalRepository; import org.eclipse.aether.repository.LocalRepositoryManager; import org.eclipse.aether.repository.RemoteRepository; /** * @author Benjamin Bentmann */ public class LegacyLocalRepositoryManager implements LocalRepositoryManager { private final LocalRepository repository; public LegacyLocalRepositoryManager( File basedir ) { this.repository = new LocalRepository( basedir.getAbsoluteFile(), "legacy" ); } public LocalRepository getRepository() { return repository; } public String getPathForLocalArtifact( Artifact artifact ) { StringBuilder path = new StringBuilder( 128 ); path.append( artifact.getGroupId() ).append( '/' ); path.append( artifact.getExtension() ).append( "s/" ); path.append( artifact.getArtifactId() ).append( '-' ).append( artifact.getVersion() ); if ( artifact.getClassifier().length() > 0 ) { path.append( '-' ).append( artifact.getClassifier() ); } path.append( '.' ).append( artifact.getExtension() ); return path.toString(); } public String getPathForRemoteArtifact( Artifact artifact, RemoteRepository repository, String context ) { return getPathForLocalArtifact( artifact ); } public String getPathForLocalMetadata( Metadata metadata ) { return getPath( metadata, "local" ); } public String getPathForRemoteMetadata( Metadata metadata, RemoteRepository repository, String context ) { return getPath( metadata, getRepositoryKey( repository, context ) ); } String getRepositoryKey( RemoteRepository repository, String context ) { return repository.getId(); } private String getPath( Metadata metadata, String repositoryKey ) { StringBuilder path = new StringBuilder( 128 ); if ( metadata.getGroupId().length() > 0 ) { path.append( metadata.getGroupId().replace( '.', '/' ) ).append( '/' ); if ( metadata.getArtifactId().length() > 0 ) { path.append( metadata.getArtifactId() ).append( '/' ); if ( metadata.getVersion().length() > 0 ) { path.append( metadata.getVersion() ).append( '/' ); } } } path.append( insertRepositoryKey( metadata.getType(), repositoryKey ) ); return path.toString(); } private String insertRepositoryKey( String filename, String repositoryKey ) { String result; int idx = filename.indexOf( '.' ); if ( idx < 0 ) { result = filename + '-' + repositoryKey; } else { result = filename.substring( 0, idx ) + '-' + repositoryKey + filename.substring( idx ); } return result; } public LocalArtifactResult find( RepositorySystemSession session, LocalArtifactRequest request ) { String path = getPathForLocalArtifact( request.getArtifact() ); File file = new File( getRepository().getBasedir(), path ); LocalArtifactResult result = new LocalArtifactResult( request ); if ( file.isFile() ) { result.setFile( file ); result.setAvailable( true ); } return result; } public void add( RepositorySystemSession session, LocalArtifactRegistration request ) { // noop } public LocalMetadataResult find( RepositorySystemSession session, LocalMetadataRequest request ) { LocalMetadataResult result = new LocalMetadataResult( request ); String path; Metadata metadata = request.getMetadata(); String context = request.getContext(); RemoteRepository remote = request.getRepository(); if ( remote != null ) { path = getPathForRemoteMetadata( metadata, remote, context ); } else { path = getPathForLocalMetadata( metadata ); } File file = new File( getRepository().getBasedir(), path ); if ( file.isFile() ) { result.setFile( file ); } return result; } public void add( RepositorySystemSession session, LocalMetadataRegistration request ) { // noop } public String toString() { return String.valueOf( getRepository() ); } } maven-maven-3.5.2/maven-core/src/test/java/org/apache/maven/project/MavenProjectTest.java000066400000000000000000000156001317160430700313460ustar00rootroot00000000000000package org.apache.maven.project; /* * 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.File; import java.io.IOException; import java.util.List; import java.util.Map; import org.apache.maven.model.DependencyManagement; import org.apache.maven.model.Model; import org.apache.maven.model.Parent; import org.apache.maven.model.Profile; public class MavenProjectTest extends AbstractMavenProjectTestCase { public void testShouldInterpretChildPathAdjustmentBasedOnModulePaths() throws IOException { Model parentModel = new Model(); parentModel.addModule( "../child" ); MavenProject parentProject = new MavenProject( parentModel ); Model childModel = new Model(); childModel.setArtifactId( "artifact" ); MavenProject childProject = new MavenProject( childModel ); File childFile = new File( System.getProperty( "java.io.tmpdir" ), "maven-project-tests" + System.currentTimeMillis() + "/child/pom.xml" ); childProject.setFile( childFile ); String adjustment = parentProject.getModulePathAdjustment( childProject ); assertNotNull( adjustment ); assertEquals( "..", adjustment ); } public void testIdentityProtoInheritance() { Parent parent = new Parent(); parent.setGroupId( "test-group" ); parent.setVersion( "1000" ); parent.setArtifactId( "test-artifact" ); Model model = new Model(); model.setParent( parent ); model.setArtifactId( "real-artifact" ); MavenProject project = new MavenProject( model ); assertEquals( "groupId proto-inheritance failed.", "test-group", project.getGroupId() ); assertEquals( "artifactId is masked.", "real-artifact", project.getArtifactId() ); assertEquals( "version proto-inheritance failed.", "1000", project.getVersion() ); // draw the NPE. project.getId(); } public void testEmptyConstructor() { MavenProject project = new MavenProject(); assertEquals( MavenProject.EMPTY_PROJECT_GROUP_ID + ":" + MavenProject.EMPTY_PROJECT_ARTIFACT_ID + ":jar:" + MavenProject.EMPTY_PROJECT_VERSION, project.getId() ); } public void testClone() throws Exception { File f = getFileForClasspathResource( "canonical-pom.xml" ); MavenProject projectToClone = getProject( f ); MavenProject clonedProject = projectToClone.clone(); assertEquals( "maven-core", clonedProject.getArtifactId() ); Map clonedMap = clonedProject.getManagedVersionMap(); assertNotNull( "ManagedVersionMap not copied", clonedMap ); assertTrue( "ManagedVersionMap is not empty", clonedMap.isEmpty() ); } public void testCloneWithDependencyManagement() throws Exception { File f = getFileForClasspathResource( "dependencyManagement-pom.xml" ); MavenProject projectToClone = getProjectWithDependencies( f ); DependencyManagement dep = projectToClone.getDependencyManagement(); assertNotNull( "No dependencyManagement", dep ); List list = dep.getDependencies(); assertNotNull( "No dependencies", list ); assertTrue( "Empty dependency list", !list.isEmpty() ); Map map = projectToClone.getManagedVersionMap(); assertNotNull( "No ManagedVersionMap", map ); assertTrue( "ManagedVersionMap is empty", !map.isEmpty() ); MavenProject clonedProject = projectToClone.clone(); assertEquals( "maven-core", clonedProject.getArtifactId() ); Map clonedMap = clonedProject.getManagedVersionMap(); assertNotNull( "ManagedVersionMap not copied", clonedMap ); assertTrue( "ManagedVersionMap is empty", !clonedMap.isEmpty() ); assertTrue( "ManagedVersionMap does not contain test key", clonedMap.containsKey( "maven-test:maven-test-b:jar" ) ); } public void testGetModulePathAdjustment() throws IOException { Model moduleModel = new Model(); MavenProject module = new MavenProject( moduleModel ); module.setFile( new File( "module-dir/pom.xml" ) ); Model parentModel = new Model(); parentModel.addModule( "../module-dir" ); MavenProject parent = new MavenProject( parentModel ); parent.setFile( new File( "parent-dir/pom.xml" ) ); String pathAdjustment = parent.getModulePathAdjustment( module ); assertEquals( "..", pathAdjustment ); } public void testCloneWithDistributionManagement() throws Exception { File f = getFileForClasspathResource( "distributionManagement-pom.xml" ); MavenProject projectToClone = getProject( f ); MavenProject clonedProject = projectToClone.clone(); assertNotNull( "clonedProject - distributionManagement", clonedProject.getDistributionManagementArtifactRepository() ); } public void testCloneWithActiveProfile() throws Exception { File f = getFileForClasspathResource( "withActiveByDefaultProfile-pom.xml" ); MavenProject projectToClone = getProject( f ); List activeProfilesOrig = projectToClone.getActiveProfiles(); assertEquals( "Expecting 1 active profile", 1, activeProfilesOrig.size() ); MavenProject clonedProject = projectToClone.clone(); List activeProfilesClone = clonedProject.getActiveProfiles(); assertEquals( "Expecting 1 active profile", 1, activeProfilesClone.size() ); assertNotSame( "The list of active profiles should have been cloned too but is same", activeProfilesOrig, activeProfilesClone ); } public void testUndefinedOutputDirectory() throws Exception { MavenProject p = new MavenProject(); assertNoNulls( p.getCompileClasspathElements() ); assertNoNulls( p.getSystemClasspathElements() ); assertNoNulls( p.getRuntimeClasspathElements() ); assertNoNulls( p.getTestClasspathElements() ); } private void assertNoNulls( List elements ) { assertFalse( elements.contains( null ) ); } } maven-maven-3.5.2/maven-core/src/test/java/org/apache/maven/project/PomConstructionTest.java000066400000000000000000002616141317160430700321270ustar00rootroot00000000000000package org.apache.maven.project; /* * 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.File; import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.Map; import java.util.Properties; import org.apache.maven.artifact.repository.layout.DefaultRepositoryLayout; import org.apache.maven.model.Plugin; import org.apache.maven.model.PluginExecution; import org.apache.maven.model.building.ModelBuildingRequest; import org.apache.maven.project.harness.PomTestWrapper; import org.apache.maven.repository.RepositorySystem; import org.apache.maven.repository.internal.MavenRepositorySystemUtils; import org.codehaus.plexus.ContainerConfiguration; import org.codehaus.plexus.PlexusConstants; import org.codehaus.plexus.PlexusTestCase; import org.eclipse.aether.DefaultRepositorySystemSession; import org.eclipse.aether.internal.impl.SimpleLocalRepositoryManagerFactory; import org.eclipse.aether.repository.LocalRepository; public class PomConstructionTest extends PlexusTestCase { private static String BASE_DIR = "src/test"; private static String BASE_POM_DIR = BASE_DIR + "/resources-project-builder"; private static String BASE_MIXIN_DIR = BASE_DIR + "/resources-mixins"; private DefaultProjectBuilder projectBuilder; private RepositorySystem repositorySystem; private File testDirectory; @Override protected void customizeContainerConfiguration( ContainerConfiguration containerConfiguration ) { super.customizeContainerConfiguration( containerConfiguration ); containerConfiguration.setAutoWiring( true ); containerConfiguration.setClassPathScanning( PlexusConstants.SCANNING_INDEX ); } protected void setUp() throws Exception { testDirectory = new File( getBasedir(), BASE_POM_DIR ); new File( getBasedir(), BASE_MIXIN_DIR ); projectBuilder = (DefaultProjectBuilder) lookup( ProjectBuilder.class ); repositorySystem = lookup( RepositorySystem.class ); } @Override protected void tearDown() throws Exception { projectBuilder = null; super.tearDown(); } /** * Will throw exception if url is empty. MNG-4050 * * @throws Exception */ public void testEmptyUrl() throws Exception { buildPom( "empty-distMng-repo-url" ); } /** * Tests that modules is not overridden by profile * * @throws Exception */ /* MNG-786*/ public void testProfileModules() throws Exception { PomTestWrapper pom = buildPom( "profile-module", "a" ); assertEquals( "test-prop", pom.getValue( "properties[1]/b" ) );// verifies profile applied assertEquals( 4, ( (List) pom.getValue( "modules" ) ).size() ); assertEquals( "module-2", pom.getValue( "modules[1]" ) ); assertEquals( "module-1", pom.getValue( "modules[2]" ) ); assertEquals( "module-3", pom.getValue( "modules[3]" ) ); assertEquals( "module-4", pom.getValue( "modules[4]" ) ); } /** * Will throw exception if doesn't find parent(s) in build * * @throws Exception */ public void testParentInheritance() throws Exception { buildPom( "parent-inheritance/sub" ); } /*MNG-3995*/ public void testExecutionConfigurationJoin() throws Exception { PomTestWrapper pom = buildPom( "execution-configuration-join" ); assertEquals( 2, ( (List) pom.getValue( "build/plugins[1]/executions[1]/configuration[1]/fileset[1]" ) ).size() ); } /*MNG-3803*/ public void testPluginConfigProperties() throws Exception { PomTestWrapper pom = buildPom( "plugin-config-properties" ); assertEquals( "my.property", pom.getValue( "build/plugins[1]/configuration[1]/systemProperties[1]/property[1]/name" ) ); } /*MNG-3900*/ public void testProfilePropertiesInterpolation() throws Exception { PomTestWrapper pom = buildPom( "profile-properties-interpolation", "interpolation-profile" ); assertEquals( "PASSED", pom.getValue( "properties[1]/test" ) ); assertEquals( "PASSED", pom.getValue( "properties[1]/property" ) ); } // Some better conventions for the test poms needs to be created and each of these tests // that represent a verification of a specification item needs to be a couple lines at most. // The expressions help a lot, but we need a clean to pick up a directory of POMs, automatically load // them into a resolver, create the expression to extract the data to validate the Model, and the URI // to validate the properties. We also need a way to navigate from the Tex specification documents to // the test in question and vice versa. A little Eclipse plugin would do the trick. public void testThatExecutionsWithoutIdsAreMergedAndTheChildWins() throws Exception { PomTestWrapper tester = buildPom( "micromailer" ); assertModelEquals( tester, "child-descriptor", "build/plugins[1]/executions[1]/goals[1]" ); } /*MNG- public void testDependencyScope() throws Exception { PomTestWrapper pom = buildPom( "dependency-scope/sub" ); } /*MNG- 4010*/ public void testDuplicateExclusionsDependency() throws Exception { PomTestWrapper pom = buildPom( "duplicate-exclusions-dependency/sub" ); assertEquals( 1, ( (List) pom.getValue( "dependencies[1]/exclusions" ) ).size() ); } /*MNG- 4008*/ public void testMultipleFilters() throws Exception { PomTestWrapper pom = buildPom( "multiple-filters" ); assertEquals( 4, ( (List) pom.getValue( "build/filters" ) ).size() ); } /** MNG-4005: postponed to 3.1 public void testValidationErrorUponNonUniqueDependencyKey() throws Exception { try { buildPom( "unique-dependency-key/deps" ); fail( "Non-unique dependency keys did not cause validation error" ); } catch ( ProjectBuildingException e ) { // expected } } public void testValidationErrorUponNonUniqueDependencyManagementKey() throws Exception { try { buildPom( "unique-dependency-key/dep-mgmt" ); fail( "Non-unique dependency keys did not cause validation error" ); } catch ( ProjectBuildingException e ) { // expected } } public void testValidationErrorUponNonUniqueDependencyKeyInProfile() throws Exception { try { buildPom( "unique-dependency-key/deps-in-profile" ); fail( "Non-unique dependency keys did not cause validation error" ); } catch ( ProjectBuildingException e ) { // expected } } public void testValidationErrorUponNonUniqueDependencyManagementKeyInProfile() throws Exception { try { buildPom( "unique-dependency-key/dep-mgmt-in-profile" ); fail( "Non-unique dependency keys did not cause validation error" ); } catch ( ProjectBuildingException e ) { // expected } } */ public void testDuplicateDependenciesCauseLastDeclarationToBePickedInLenientMode() throws Exception { PomTestWrapper pom = buildPom( "unique-dependency-key/deps", true, null ); assertEquals( 1, ( (List) pom.getValue( "dependencies" ) ).size() ); assertEquals( "0.2", pom.getValue( "dependencies[1]/version" ) ); } /* MNG-3567*/ public void testParentInterpolation() throws Exception { PomTestWrapper pom = buildPom( "parent-interpolation/sub" ); pom = new PomTestWrapper( pom.getMavenProject().getParent() ); assertEquals( "1.3.0-SNAPSHOT", pom.getValue( "build/plugins[1]/version" ) ); } /* public void testMaven() throws Exception { PomTestWrapper pom = buildPomFromMavenProject( "maven-build/sub/pom.xml", null ); for( String s: pom.getMavenProject().getTestClasspathElements() ) { System.out.println( s ); } } */ /* MNG-3567*/ public void testPluginManagementInherited() throws Exception { PomTestWrapper pom = buildPom( "pluginmanagement-inherited/sub" ); assertEquals( "1.0-alpha-21", pom.getValue( "build/plugins[1]/version" ) ); } /* MNG-2174*/ public void testPluginManagementDependencies() throws Exception { PomTestWrapper pom = buildPom( "plugin-management-dependencies/sub", "test" ); assertEquals( "1.0-alpha-21", pom.getValue( "build/plugins[1]/version" ) ); assertEquals( "1.0", pom.getValue( "build/plugins[1]/dependencies[1]/version" ) ); } /* MNG-3877*/ public void testReportingInterpolation() throws Exception { PomTestWrapper pom = buildPom( "reporting-interpolation" ); assertEquals( createPath( Arrays.asList( System.getProperty( "user.dir" ), "src", "test", "resources-project-builder", "reporting-interpolation", "target", "site" ) ), pom.getValue( "reporting/outputDirectory" ) ); } public void testPluginOrder() throws Exception { PomTestWrapper pom = buildPom( "plugin-order" ); assertEquals( "plexus-component-metadata", pom.getValue( "build/plugins[1]/artifactId" ) ); assertEquals( "maven-surefire-plugin", pom.getValue( "build/plugins[2]/artifactId" ) ); } public void testErroneousJoiningOfDifferentPluginsWithEqualDependencies() throws Exception { PomTestWrapper pom = buildPom( "equal-plugin-deps" ); assertEquals( "maven-it-plugin-a", pom.getValue( "build/plugins[1]/artifactId" ) ); assertEquals( 1, ( (List) pom.getValue( "build/plugins[1]/dependencies" ) ).size() ); assertEquals( "maven-it-plugin-b", pom.getValue( "build/plugins[2]/artifactId" ) ); assertEquals( 1, ( (List) pom.getValue( "build/plugins[1]/dependencies" ) ).size() ); } /** MNG-3821 */ public void testErroneousJoiningOfDifferentPluginsWithEqualExecutionIds() throws Exception { PomTestWrapper pom = buildPom( "equal-plugin-exec-ids" ); assertEquals( "maven-it-plugin-a", pom.getValue( "build/plugins[1]/artifactId" ) ); assertEquals( 1, ( (List) pom.getValue( "build/plugins[1]/executions" ) ).size() ); assertEquals( "maven-it-plugin-b", pom.getValue( "build/plugins[2]/artifactId" ) ); assertEquals( 1, ( (List) pom.getValue( "build/plugins[1]/executions" ) ).size() ); assertEquals( "maven-it-plugin-a", pom.getValue( "reporting/plugins[1]/artifactId" ) ); assertEquals( 1, ( (List) pom.getValue( "reporting/plugins[1]/reportSets" ) ).size() ); assertEquals( "maven-it-plugin-b", pom.getValue( "reporting/plugins[2]/artifactId" ) ); assertEquals( 1, ( (List) pom.getValue( "reporting/plugins[1]/reportSets" ) ).size() ); } /** MNG-3998 */ public void testExecutionConfiguration() throws Exception { PomTestWrapper pom = buildPom( "execution-configuration" ); assertEquals( 2, ( (List) pom.getValue( "build/plugins[1]/executions" ) ).size() ); assertEquals( "src/main/mdo/nexus.xml", ( pom.getValue( "build/plugins[1]/executions[1]/configuration[1]/model" ) ) ); assertEquals( "src/main/mdo/security.xml", ( pom.getValue( "build/plugins[1]/executions[2]/configuration[1]/model" ) ) ); } /* public void testPluginConfigDuplicate() throws Exception { PomTestWrapper pom = buildPom( "plugin-config-duplicate/dup" ); } */ public void testSingleConfigurationInheritance() throws Exception { PomTestWrapper pom = buildPom( "single-configuration-inheritance" ); assertEquals( 2, ( (List) pom.getValue( "build/plugins[1]/executions[1]/configuration[1]/rules" ) ).size() ); assertEquals( "2.0.6", pom.getValue( "build/plugins[1]/executions[1]/configuration[1]/rules[1]/requireMavenVersion[1]/version" ) ); assertEquals( "[1.4,)", pom.getValue( "build/plugins[1]/executions[1]/configuration[1]/rules[1]/requireJavaVersion[1]/version" ) ); } public void testConfigWithPluginManagement() throws Exception { PomTestWrapper pom = buildPom( "config-with-plugin-mng" ); assertEquals( 2, ( (List) pom.getValue( "build/plugins[1]/executions" ) ).size() ); assertEquals( "src/main/mdo/security.xml", pom.getValue( "build/plugins[1]/executions[2]/configuration[1]/model" ) ); assertEquals( "1.0.8", pom.getValue( "build/plugins[1]/executions[1]/configuration[1]/version" ) ); } /** MNG-3965 */ public void testExecutionConfigurationSubcollections() throws Exception { PomTestWrapper pom = buildPom( "execution-configuration-subcollections" ); assertEquals( 2, ( (List) pom.getValue( "build/plugins[1]/executions[1]/configuration[1]/rules[1]/bannedDependencies" ) ).size() ); } /** MNG-3985 */ public void testMultipleRepositories() throws Exception { PomTestWrapper pom = buildPom( "multiple-repos/sub" ); assertEquals( 3, ( (List) pom.getValue( "repositories" ) ).size() ); } /** MNG-3965 */ public void testMultipleExecutionIds() throws Exception { PomTestWrapper pom = buildPom( "dual-execution-ids/sub" ); assertEquals( 1, ( (List) pom.getValue( "build/plugins[1]/executions" ) ).size() ); } /** MNG-3997 */ public void testConsecutiveEmptyElements() throws Exception { buildPom( "consecutive_empty_elements" ); } public void testOrderOfGoalsFromPluginExecutionWithoutPluginManagement() throws Exception { PomTestWrapper pom = buildPom( "plugin-exec-goals-order/wo-plugin-mgmt" ); assertEquals( 5, ( (List) pom.getValue( "build/plugins[1]/executions[1]/goals" ) ).size() ); assertEquals( "b", pom.getValue( "build/plugins[1]/executions[1]/goals[1]" ) ); assertEquals( "a", pom.getValue( "build/plugins[1]/executions[1]/goals[2]" ) ); assertEquals( "d", pom.getValue( "build/plugins[1]/executions[1]/goals[3]" ) ); assertEquals( "c", pom.getValue( "build/plugins[1]/executions[1]/goals[4]" ) ); assertEquals( "e", pom.getValue( "build/plugins[1]/executions[1]/goals[5]" ) ); } /* MNG-3886*/ public void testOrderOfGoalsFromPluginExecutionWithPluginManagement() throws Exception { PomTestWrapper pom = buildPom( "plugin-exec-goals-order/w-plugin-mgmt" ); assertEquals( 5, ( (List) pom.getValue( "build/plugins[1]/executions[1]/goals" ) ).size() ); assertEquals( "b", pom.getValue( "build/plugins[1]/executions[1]/goals[1]" ) ); assertEquals( "a", pom.getValue( "build/plugins[1]/executions[1]/goals[2]" ) ); assertEquals( "d", pom.getValue( "build/plugins[1]/executions[1]/goals[3]" ) ); assertEquals( "c", pom.getValue( "build/plugins[1]/executions[1]/goals[4]" ) ); assertEquals( "e", pom.getValue( "build/plugins[1]/executions[1]/goals[5]" ) ); } public void testOrderOfPluginExecutionsWithoutPluginManagement() throws Exception { PomTestWrapper pom = buildPom( "plugin-exec-order/wo-plugin-mgmt" ); assertEquals( 5, ( (List) pom.getValue( "build/plugins[1]/executions" ) ).size() ); assertEquals( "b", pom.getValue( "build/plugins[1]/executions[1]/id" ) ); assertEquals( "a", pom.getValue( "build/plugins[1]/executions[2]/id" ) ); assertEquals( "d", pom.getValue( "build/plugins[1]/executions[3]/id" ) ); assertEquals( "c", pom.getValue( "build/plugins[1]/executions[4]/id" ) ); assertEquals( "e", pom.getValue( "build/plugins[1]/executions[5]/id" ) ); } /* MNG-3887 */ public void testOrderOfPluginExecutionsWithPluginManagement() throws Exception { PomTestWrapper pom = buildPom( "plugin-exec-order/w-plugin-mgmt" ); assertEquals( 5, ( (List) pom.getValue( "build/plugins[1]/executions" ) ).size() ); assertEquals( "b", pom.getValue( "build/plugins[1]/executions[1]/id" ) ); assertEquals( "a", pom.getValue( "build/plugins[1]/executions[2]/id" ) ); assertEquals( "d", pom.getValue( "build/plugins[1]/executions[3]/id" ) ); assertEquals( "c", pom.getValue( "build/plugins[1]/executions[4]/id" ) ); assertEquals( "e", pom.getValue( "build/plugins[1]/executions[5]/id" ) ); } public void testMergeOfPluginExecutionsWhenChildInheritsPluginVersion() throws Exception { PomTestWrapper pom = buildPom( "plugin-exec-merging-wo-version/sub" ); assertEquals( 4, ( (List) pom.getValue( "build/plugins[1]/executions" ) ).size() ); } /* MNG-3943*/ public void testMergeOfPluginExecutionsWhenChildAndParentUseDifferentPluginVersions() throws Exception { PomTestWrapper pom = buildPom( "plugin-exec-merging-version-insensitive/sub" ); assertEquals( 4, ( (List) pom.getValue( "build/plugins[1]/executions" ) ).size() ); } public void testInterpolationWithXmlMarkup() throws Exception { PomTestWrapper pom = buildPom( "xml-markup-interpolation" ); assertEquals( "Tom&Jerry", pom.getValue( "properties/xmlTest" ) ); } /* MNG-3925 */ public void testOrderOfMergedPluginExecutionsWithoutPluginManagement() throws Exception { PomTestWrapper pom = buildPom( "merged-plugin-exec-order/wo-plugin-mgmt/sub" ); assertEquals( 5, ( (List) pom.getValue( "build/plugins[1]/executions" ) ).size() ); assertEquals( "parent-1", pom.getValue( "build/plugins[1]/executions[1]/goals[1]" ) ); assertEquals( "parent-2", pom.getValue( "build/plugins[1]/executions[2]/goals[1]" ) ); assertEquals( "child-default", pom.getValue( "build/plugins[1]/executions[3]/goals[1]" ) ); assertEquals( "child-1", pom.getValue( "build/plugins[1]/executions[4]/goals[1]" ) ); assertEquals( "child-2", pom.getValue( "build/plugins[1]/executions[5]/goals[1]" ) ); } public void testOrderOfMergedPluginExecutionsWithPluginManagement() throws Exception { PomTestWrapper pom = buildPom( "merged-plugin-exec-order/w-plugin-mgmt/sub" ); assertEquals( 5, ( (List) pom.getValue( "build/plugins[1]/executions" ) ).size() ); assertEquals( "parent-1", pom.getValue( "build/plugins[1]/executions[1]/goals[1]" ) ); assertEquals( "parent-2", pom.getValue( "build/plugins[1]/executions[2]/goals[1]" ) ); assertEquals( "child-default", pom.getValue( "build/plugins[1]/executions[3]/goals[1]" ) ); assertEquals( "child-1", pom.getValue( "build/plugins[1]/executions[4]/goals[1]" ) ); assertEquals( "child-2", pom.getValue( "build/plugins[1]/executions[5]/goals[1]" ) ); } /* MNG-3984*/ public void testDifferentContainersWithSameId() throws Exception { PomTestWrapper pom = buildPom( "join-different-containers-same-id" ); assertEquals( 1, ( (List) pom.getValue( "build/plugins[1]/executions[1]/goals" ) ).size() ); assertEquals( 1, ( (List) pom.getValue( "build/pluginManagement/plugins[@artifactId='maven-it-plugin-b']/executions[1]/goals" ) ).size() ); } /* MNG-3937*/ public void testOrderOfMergedPluginExecutionGoalsWithoutPluginManagement() throws Exception { PomTestWrapper pom = buildPom( "merged-plugin-exec-goals-order/wo-plugin-mgmt/sub" ); assertEquals( 5, ( (List) pom.getValue( "build/plugins[1]/executions[1]/goals" ) ).size() ); assertEquals( "child-a", pom.getValue( "build/plugins[1]/executions[1]/goals[1]" ) ); assertEquals( "merged", pom.getValue( "build/plugins[1]/executions[1]/goals[2]" ) ); assertEquals( "child-b", pom.getValue( "build/plugins[1]/executions[1]/goals[3]" ) ); assertEquals( "parent-b", pom.getValue( "build/plugins[1]/executions[1]/goals[4]" ) ); assertEquals( "parent-a", pom.getValue( "build/plugins[1]/executions[1]/goals[5]" ) ); } public void testOrderOfMergedPluginExecutionGoalsWithPluginManagement() throws Exception { PomTestWrapper pom = buildPom( "merged-plugin-exec-goals-order/w-plugin-mgmt/sub" ); assertEquals( 5, ( (List) pom.getValue( "build/plugins[1]/executions[1]/goals" ) ).size() ); assertEquals( "child-a", pom.getValue( "build/plugins[1]/executions[1]/goals[1]" ) ); assertEquals( "merged", pom.getValue( "build/plugins[1]/executions[1]/goals[2]" ) ); assertEquals( "child-b", pom.getValue( "build/plugins[1]/executions[1]/goals[3]" ) ); assertEquals( "parent-b", pom.getValue( "build/plugins[1]/executions[1]/goals[4]" ) ); assertEquals( "parent-a", pom.getValue( "build/plugins[1]/executions[1]/goals[5]" ) ); } /*MNG-3938*/ public void testOverridingOfInheritedPluginExecutionsWithoutPluginManagement() throws Exception { PomTestWrapper pom = buildPom( "plugin-exec-merging/wo-plugin-mgmt/sub" ); assertEquals( 2, ( (List) pom.getValue( "build/plugins[1]/executions" ) ).size() ); assertEquals( "child-default", pom.getValue( "build/plugins[1]/executions[@id='default']/phase" ) ); assertEquals( "child-non-default", pom.getValue( "build/plugins[1]/executions[@id='non-default']/phase" ) ); } /* MNG-3938 */ public void testOverridingOfInheritedPluginExecutionsWithPluginManagement() throws Exception { PomTestWrapper pom = buildPom( "plugin-exec-merging/w-plugin-mgmt/sub" ); assertEquals( 2, ( (List) pom.getValue( "build/plugins[1]/executions" ) ).size() ); assertEquals( "child-default", pom.getValue( "build/plugins[1]/executions[@id='default']/phase" ) ); assertEquals( "child-non-default", pom.getValue( "build/plugins[1]/executions[@id='non-default']/phase" ) ); } /* MNG-3906*/ public void testOrderOfMergedPluginDependenciesWithoutPluginManagement() throws Exception { PomTestWrapper pom = buildPom( "merged-plugin-class-path-order/wo-plugin-mgmt/sub" ); assertEquals( 5, ( (List) pom.getValue( "build/plugins[1]/dependencies" ) ).size() ); assertNotNull( pom.getValue( "build/plugins[1]/dependencies[1]" ) ); assertEquals( "c", pom.getValue( "build/plugins[1]/dependencies[1]/artifactId" ) ); assertEquals( "1", pom.getValue( "build/plugins[1]/dependencies[1]/version" ) ); assertEquals( "a", pom.getValue( "build/plugins[1]/dependencies[2]/artifactId" ) ); assertEquals( "2", pom.getValue( "build/plugins[1]/dependencies[2]/version" ) ); assertEquals( "b", pom.getValue( "build/plugins[1]/dependencies[3]/artifactId" ) ); assertEquals( "1", pom.getValue( "build/plugins[1]/dependencies[3]/version" ) ); assertEquals( "e", pom.getValue( "build/plugins[1]/dependencies[4]/artifactId" ) ); assertEquals( "1", pom.getValue( "build/plugins[1]/dependencies[4]/version" ) ); assertEquals( "d", pom.getValue( "build/plugins[1]/dependencies[5]/artifactId" ) ); assertEquals( "1", pom.getValue( "build/plugins[1]/dependencies[5]/version" ) ); } public void testOrderOfMergedPluginDependenciesWithPluginManagement() throws Exception { PomTestWrapper pom = buildPom( "merged-plugin-class-path-order/w-plugin-mgmt/sub" ); assertEquals( 5, ( (List) pom.getValue( "build/plugins[1]/dependencies" ) ).size() ); assertEquals( "c", pom.getValue( "build/plugins[1]/dependencies[1]/artifactId" ) ); assertEquals( "1", pom.getValue( "build/plugins[1]/dependencies[1]/version" ) ); assertEquals( "a", pom.getValue( "build/plugins[1]/dependencies[2]/artifactId" ) ); assertEquals( "2", pom.getValue( "build/plugins[1]/dependencies[2]/version" ) ); assertEquals( "b", pom.getValue( "build/plugins[1]/dependencies[3]/artifactId" ) ); assertEquals( "1", pom.getValue( "build/plugins[1]/dependencies[3]/version" ) ); assertEquals( "e", pom.getValue( "build/plugins[1]/dependencies[4]/artifactId" ) ); assertEquals( "1", pom.getValue( "build/plugins[1]/dependencies[4]/version" ) ); assertEquals( "d", pom.getValue( "build/plugins[1]/dependencies[5]/artifactId" ) ); assertEquals( "1", pom.getValue( "build/plugins[1]/dependencies[5]/version" ) ); } public void testInterpolationOfNestedBuildDirectories() throws Exception { PomTestWrapper pom = buildPom( "nested-build-dir-interpolation" ); assertEquals( new File( pom.getBasedir(), "target/classes/dir0" ), new File( (String) pom.getValue( "properties/dir0" ) ) ); assertEquals( new File( pom.getBasedir(), "src/test/dir1" ), new File( (String) pom.getValue( "properties/dir1" ) ) ); assertEquals( new File( pom.getBasedir(), "target/site/dir2" ), new File( (String) pom.getValue( "properties/dir2" ) ) ); } public void testAppendArtifactIdOfChildToInheritedUrls() throws Exception { PomTestWrapper pom = buildPom( "url-inheritance/sub" ); assertEquals( "http://parent.url/child", pom.getValue( "url" ) ); assertEquals( "http://parent.url/org", pom.getValue( "organization/url" ) ); assertEquals( "http://parent.url/license.txt", pom.getValue( "licenses[1]/url" ) ); assertEquals( "http://parent.url/viewvc/child", pom.getValue( "scm/url" ) ); assertEquals( "http://parent.url/scm/child", pom.getValue( "scm/connection" ) ); assertEquals( "https://parent.url/scm/child", pom.getValue( "scm/developerConnection" ) ); assertEquals( "http://parent.url/issues", pom.getValue( "issueManagement/url" ) ); assertEquals( "http://parent.url/ci", pom.getValue( "ciManagement/url" ) ); assertEquals( "http://parent.url/dist", pom.getValue( "distributionManagement/repository/url" ) ); assertEquals( "http://parent.url/snaps", pom.getValue( "distributionManagement/snapshotRepository/url" ) ); assertEquals( "http://parent.url/site/child", pom.getValue( "distributionManagement/site/url" ) ); assertEquals( "http://parent.url/download", pom.getValue( "distributionManagement/downloadUrl" ) ); } /* MNG-3846*/ public void testAppendArtifactIdOfParentAndChildToInheritedUrls() throws Exception { PomTestWrapper pom = buildPom( "url-inheritance/another-parent/sub" ); assertEquals( "http://parent.url/ap/child", pom.getValue( "url" ) ); assertEquals( "http://parent.url/org", pom.getValue( "organization/url" ) ); assertEquals( "http://parent.url/license.txt", pom.getValue( "licenses[1]/url" ) ); assertEquals( "http://parent.url/viewvc/ap/child", pom.getValue( "scm/url" ) ); assertEquals( "http://parent.url/scm/ap/child", pom.getValue( "scm/connection" ) ); assertEquals( "https://parent.url/scm/ap/child", pom.getValue( "scm/developerConnection" ) ); assertEquals( "http://parent.url/issues", pom.getValue( "issueManagement/url" ) ); assertEquals( "http://parent.url/ci", pom.getValue( "ciManagement/url" ) ); assertEquals( "http://parent.url/dist", pom.getValue( "distributionManagement/repository/url" ) ); assertEquals( "http://parent.url/snaps", pom.getValue( "distributionManagement/snapshotRepository/url" ) ); assertEquals( "http://parent.url/site/ap/child", pom.getValue( "distributionManagement/site/url" ) ); assertEquals( "http://parent.url/download", pom.getValue( "distributionManagement/downloadUrl" ) ); } //*/ public void testNonInheritedElementsInSubtreesOverriddenByChild() throws Exception { PomTestWrapper pom = buildPom( "limited-inheritance/child" ); assertEquals( null, pom.getValue( "organization/url" ) ); assertEquals( null, pom.getValue( "issueManagement/system" ) ); assertEquals( 0, ( (List) pom.getValue( "ciManagement/notifiers" ) ).size() ); assertEquals( "child-distros", pom.getValue( "distributionManagement/repository/id" ) ); assertEquals( "ssh://child.url/distros", pom.getValue( "distributionManagement/repository/url" ) ); assertEquals( null, pom.getValue( "distributionManagement/repository/name" ) ); assertEquals( true, pom.getValue( "distributionManagement/repository/uniqueVersion" ) ); assertEquals( "default", pom.getValue( "distributionManagement/repository/layout" ) ); assertEquals( "child-snaps", pom.getValue( "distributionManagement/snapshotRepository/id" ) ); assertEquals( "ssh://child.url/snaps", pom.getValue( "distributionManagement/snapshotRepository/url" ) ); assertEquals( null, pom.getValue( "distributionManagement/snapshotRepository/name" ) ); assertEquals( true, pom.getValue( "distributionManagement/snapshotRepository/uniqueVersion" ) ); assertEquals( "default", pom.getValue( "distributionManagement/snapshotRepository/layout" ) ); assertEquals( "child-site", pom.getValue( "distributionManagement/site/id" ) ); assertEquals( "scp://child.url/site", pom.getValue( "distributionManagement/site/url" ) ); assertEquals( null, pom.getValue( "distributionManagement/site/name" ) ); } public void testXmlTextCoalescing() throws Exception { PomTestWrapper pom = buildPom( "xml-coalesce-text" ); assertEquals( "A Test Project Property", pom.getValue( "properties/prop0" ) ); assertEquals( "That's a test!", pom.getValue( "properties/prop1" ) ); assertEquals( 32 * 1024, pom.getValue( "properties/prop2" ).toString().trim().replaceAll( "[\n\r]", "" ).length() ); } public void testFullInterpolationOfNestedExpressions() throws Exception { PomTestWrapper pom = buildPom( "full-interpolation" ); for ( int i = 0; i < 24; i++ ) { String index = ( ( i < 10 ) ? "0" : "" ) + i; assertEquals( "PASSED", pom.getValue( "properties/property" + index ) ); } } public void testInterpolationOfLegacyExpressionsThatDontIncludeTheProjectPrefix() throws Exception { PomTestWrapper pom = buildPom( "unprefixed-expression-interpolation/child" ); assertEquals( pom.getBasedir(), new File( pom.getValue( "properties/projectDir" ).toString() ) ); assertEquals( "org.apache.maven.its.mng3831.child", pom.getValue( "properties/projectGroupId" ) ); assertEquals( "child", pom.getValue( "properties/projectArtifactId" ) ); assertEquals( "2.0-alpha-1", pom.getValue( "properties/projectVersion" ) ); assertEquals( "jar", pom.getValue( "properties/projectPackaging" ) ); assertEquals( "child-name", pom.getValue( "properties/projectName" ) ); assertEquals( "child-desc", pom.getValue( "properties/projectDesc" ) ); assertEquals( "http://child.org/", pom.getValue( "properties/projectUrl" ) ); assertEquals( "2008", pom.getValue( "properties/projectYear" ) ); assertEquals( "child-org-name", pom.getValue( "properties/projectOrgName" ) ); assertEquals( "2.0.0", pom.getValue( "properties/projectPrereqMvn" ) ); assertEquals( "http://scm.org/", pom.getValue( "properties/projectScmUrl" ) ); assertEquals( "http://issue.org/", pom.getValue( "properties/projectIssueUrl" ) ); assertEquals( "http://ci.org/", pom.getValue( "properties/projectCiUrl" ) ); assertEquals( "child-dist-repo", pom.getValue( "properties/projectDistRepoName" ) ); assertEquals( "http://dist.org/", pom.getValue( "properties/projectDistRepoUrl" ) ); assertEquals( "http://site.org/", pom.getValue( "properties/projectDistSiteUrl" ) ); assertEquals( "org.apache.maven.its.mng3831", pom.getValue( "properties/parentGroupId" ) ); assertEquals( "parent", pom.getValue( "properties/parentArtifactId" ) ); assertEquals( "1.0", pom.getValue( "properties/parentVersion" ) ); assertTrue( pom.getValue( "properties/projectBuildOut" ).toString().endsWith( "bin" ) ); assertTrue( pom.getValue( "properties/projectSiteOut" ).toString().endsWith( "doc" ) ); } public void testInterpolationWithBasedirAlignedDirectories() throws Exception { PomTestWrapper pom = buildPom( "basedir-aligned-interpolation" ); assertEquals( new File( pom.getBasedir(), "src/main/java" ), new File( pom.getValue( "properties/buildMainSrc" ).toString() ) ); assertEquals( new File( pom.getBasedir(), "src/test/java" ), new File( pom.getValue( "properties/buildTestSrc" ).toString() ) ); assertEquals( new File( pom.getBasedir(), "src/main/scripts" ), new File( pom.getValue( "properties/buildScriptSrc" ).toString() ) ); assertEquals( new File( pom.getBasedir(), "target" ), new File( pom.getValue( "properties/buildOut" ).toString() ) ); assertEquals( new File( pom.getBasedir(), "target/classes" ), new File( pom.getValue( "properties/buildMainOut" ).toString() ) ); assertEquals( new File( pom.getBasedir(), "target/test-classes" ), new File( pom.getValue( "properties/buildTestOut" ).toString() ) ); assertEquals( new File( pom.getBasedir(), "target/site" ), new File( pom.getValue( "properties/siteOut" ).toString() ) ); } /* MNG-3944*/ public void testInterpolationOfBasedirInPomWithUnusualName() throws Exception { PomTestWrapper pom = buildPom( "basedir-interpolation/pom-with-unusual-name.xml" ); assertEquals( pom.getBasedir(), new File( pom.getValue( "properties/prop0" ).toString() ) ); assertEquals( pom.getBasedir(), new File( pom.getValue( "properties/prop1" ).toString() ) ); } /* MNG-3979 */ public void testJoiningOfContainersWhenChildHasEmptyElements() throws Exception { PomTestWrapper pom = buildPom( "id-container-joining-with-empty-elements/sub" ); assertNotNull( pom ); } public void testOrderOfPluginConfigurationElementsWithoutPluginManagement() throws Exception { PomTestWrapper pom = buildPom( "plugin-config-order/wo-plugin-mgmt" ); assertEquals( "one", pom.getValue( "build/plugins[1]/configuration/stringParams/stringParam[1]" ) ); assertEquals( "two", pom.getValue( "build/plugins[1]/configuration/stringParams/stringParam[2]" ) ); assertEquals( "three", pom.getValue( "build/plugins[1]/configuration/stringParams/stringParam[3]" ) ); assertEquals( "four", pom.getValue( "build/plugins[1]/configuration/stringParams/stringParam[4]" ) ); } /* MNG-3827*/ public void testOrderOfPluginConfigurationElementsWithPluginManagement() throws Exception { PomTestWrapper pom = buildPom( "plugin-config-order/w-plugin-mgmt" ); assertEquals( "one", pom.getValue( "build/plugins[1]/configuration/stringParams/stringParam[1]" ) ); assertEquals( "two", pom.getValue( "build/plugins[1]/configuration/stringParams/stringParam[2]" ) ); assertEquals( "three", pom.getValue( "build/plugins[1]/configuration/stringParams/stringParam[3]" ) ); assertEquals( "four", pom.getValue( "build/plugins[1]/configuration/stringParams/stringParam[4]" ) ); } public void testOrderOfPluginExecutionConfigurationElementsWithoutPluginManagement() throws Exception { PomTestWrapper pom = buildPom( "plugin-exec-config-order/wo-plugin-mgmt" ); String prefix = "build/plugins[1]/executions[1]/configuration/"; assertEquals( "one", pom.getValue( prefix + "stringParams/stringParam[1]" ) ); assertEquals( "two", pom.getValue( prefix + "stringParams/stringParam[2]" ) ); assertEquals( "three", pom.getValue( prefix + "stringParams/stringParam[3]" ) ); assertEquals( "four", pom.getValue( prefix + "stringParams/stringParam[4]" ) ); assertEquals( "key1", pom.getValue( prefix + "propertiesParam/property[1]/name" ) ); assertEquals( "key2", pom.getValue( prefix + "propertiesParam/property[2]/name" ) ); } /* MNG-3864*/ public void testOrderOfPluginExecutionConfigurationElementsWithPluginManagement() throws Exception { PomTestWrapper pom = buildPom( "plugin-exec-config-order/w-plugin-mgmt" ); String prefix = "build/plugins[1]/executions[1]/configuration/"; assertEquals( "one", pom.getValue( prefix + "stringParams/stringParam[1]" ) ); assertEquals( "two", pom.getValue( prefix + "stringParams/stringParam[2]" ) ); assertEquals( "three", pom.getValue( prefix + "stringParams/stringParam[3]" ) ); assertEquals( "four", pom.getValue( prefix + "stringParams/stringParam[4]" ) ); assertEquals( "key1", pom.getValue( prefix + "propertiesParam/property[1]/name" ) ); assertEquals( "key2", pom.getValue( prefix + "propertiesParam/property[2]/name" ) ); } /* MNG-3836*/ public void testMergeOfInheritedPluginConfiguration() throws Exception { PomTestWrapper pom = buildPom( "plugin-config-merging/child" ); String prefix = "build/plugins[1]/configuration/"; assertEquals( "PASSED", pom.getValue( prefix + "propertiesFile" ) ); assertEquals( "PASSED", pom.getValue( prefix + "parent" ) ); assertEquals( "PASSED-1", pom.getValue( prefix + "stringParams/stringParam[1]" ) ); assertEquals( "PASSED-3", pom.getValue( prefix + "stringParams/stringParam[2]" ) ); assertEquals( "PASSED-2", pom.getValue( prefix + "stringParams/stringParam[3]" ) ); assertEquals( "PASSED-4", pom.getValue( prefix + "stringParams/stringParam[4]" ) ); assertEquals( "PASSED-1", pom.getValue( prefix + "listParam/listParam[1]" ) ); assertEquals( "PASSED-3", pom.getValue( prefix + "listParam/listParam[2]" ) ); assertEquals( "PASSED-2", pom.getValue( prefix + "listParam/listParam[3]" ) ); assertEquals( "PASSED-4", pom.getValue( prefix + "listParam/listParam[4]" ) ); } /* MNG-2591 */ public void testAppendOfInheritedPluginConfigurationWithNoProfile() throws Exception { testAppendOfInheritedPluginConfiguration( "no-profile" ); } /* MNG-2591*/ public void testAppendOfInheritedPluginConfigurationWithActiveProfile() throws Exception { testAppendOfInheritedPluginConfiguration( "with-profile" ); } private void testAppendOfInheritedPluginConfiguration( String test ) throws Exception { PomTestWrapper pom = buildPom( "plugin-config-append/" + test + "/subproject" ); String prefix = "build/plugins[1]/configuration/"; assertEquals( "PARENT-1", pom.getValue( prefix + "stringParams/stringParam[1]" ) ); assertEquals( "PARENT-3", pom.getValue( prefix + "stringParams/stringParam[2]" ) ); assertEquals( "PARENT-2", pom.getValue( prefix + "stringParams/stringParam[3]" ) ); assertEquals( "PARENT-4", pom.getValue( prefix + "stringParams/stringParam[4]" ) ); assertEquals( "CHILD-1", pom.getValue( prefix + "stringParams/stringParam[5]" ) ); assertEquals( "CHILD-3", pom.getValue( prefix + "stringParams/stringParam[6]" ) ); assertEquals( "CHILD-2", pom.getValue( prefix + "stringParams/stringParam[7]" ) ); assertEquals( "CHILD-4", pom.getValue( prefix + "stringParams/stringParam[8]" ) ); assertEquals( null, pom.getValue( prefix + "stringParams/stringParam[9]" ) ); assertEquals( "PARENT-1", pom.getValue( prefix + "listParam/listParam[1]" ) ); assertEquals( "PARENT-3", pom.getValue( prefix + "listParam/listParam[2]" ) ); assertEquals( "PARENT-2", pom.getValue( prefix + "listParam/listParam[3]" ) ); assertEquals( "PARENT-4", pom.getValue( prefix + "listParam/listParam[4]" ) ); assertEquals( "CHILD-1", pom.getValue( prefix + "listParam/listParam[5]" ) ); assertEquals( "CHILD-3", pom.getValue( prefix + "listParam/listParam[6]" ) ); assertEquals( "CHILD-2", pom.getValue( prefix + "listParam/listParam[7]" ) ); assertEquals( "CHILD-4", pom.getValue( prefix + "listParam/listParam[8]" ) ); assertEquals( null, pom.getValue( prefix + "listParam/listParam[9]" ) ); } /* MNG-4000 */ public void testMultiplePluginExecutionsWithAndWithoutIdsWithoutPluginManagement() throws Exception { PomTestWrapper pom = buildPom( "plugin-exec-w-and-wo-id/wo-plugin-mgmt" ); assertEquals( 2, ( (List) pom.getValue( "build/plugins[1]/executions" ) ).size() ); assertEquals( "log-string", pom.getValue( "build/plugins[1]/executions[1]/goals[1]" ) ); assertEquals( "log-string", pom.getValue( "build/plugins[1]/executions[2]/goals[1]" ) ); } public void testMultiplePluginExecutionsWithAndWithoutIdsWithPluginManagement() throws Exception { PomTestWrapper pom = buildPom( "plugin-exec-w-and-wo-id/w-plugin-mgmt" ); assertEquals( 2, ( (List) pom.getValue( "build/plugins[1]/executions" ) ).size() ); assertEquals( "log-string", pom.getValue( "build/plugins[1]/executions[1]/goals[1]" ) ); assertEquals( "log-string", pom.getValue( "build/plugins[1]/executions[2]/goals[1]" ) ); } public void testDependencyOrderWithoutPluginManagement() throws Exception { PomTestWrapper pom = buildPom( "dependency-order/wo-plugin-mgmt" ); assertEquals( 4, ( (List) pom.getValue( "dependencies" ) ).size() ); assertEquals( "a", pom.getValue( "dependencies[1]/artifactId" ) ); assertEquals( "c", pom.getValue( "dependencies[2]/artifactId" ) ); assertEquals( "b", pom.getValue( "dependencies[3]/artifactId" ) ); assertEquals( "d", pom.getValue( "dependencies[4]/artifactId" ) ); } public void testDependencyOrderWithPluginManagement() throws Exception { PomTestWrapper pom = buildPom( "dependency-order/w-plugin-mgmt" ); assertEquals( 4, ( (List) pom.getValue( "dependencies" ) ).size() ); assertEquals( "a", pom.getValue( "dependencies[1]/artifactId" ) ); assertEquals( "c", pom.getValue( "dependencies[2]/artifactId" ) ); assertEquals( "b", pom.getValue( "dependencies[3]/artifactId" ) ); assertEquals( "d", pom.getValue( "dependencies[4]/artifactId" ) ); } public void testBuildDirectoriesUsePlatformSpecificFileSeparator() throws Exception { PomTestWrapper pom = buildPom( "platform-file-separator" ); assertPathWithNormalizedFileSeparators( pom.getValue( "build/directory" ) ); assertPathWithNormalizedFileSeparators( pom.getValue( "build/outputDirectory" ) ); assertPathWithNormalizedFileSeparators( pom.getValue( "build/testOutputDirectory" ) ); assertPathWithNormalizedFileSeparators( pom.getValue( "build/sourceDirectory" ) ); assertPathWithNormalizedFileSeparators( pom.getValue( "build/testSourceDirectory" ) ); assertPathWithNormalizedFileSeparators( pom.getValue( "build/resources[1]/directory" ) ); assertPathWithNormalizedFileSeparators( pom.getValue( "build/testResources[1]/directory" ) ); assertPathWithNormalizedFileSeparators( pom.getValue( "build/filters[1]" ) ); assertPathWithNormalizedFileSeparators( pom.getValue( "reporting/outputDirectory" ) ); } /* MNG-4008 */ public void testMergedFilterOrder() throws Exception { PomTestWrapper pom = buildPom( "merged-filter-order/sub" ); assertEquals( 7, ( (List) pom.getValue( "build/filters" ) ).size() ); assertTrue( pom.getValue( "build/filters[1]" ).toString().endsWith( "child-a.properties" ) ); assertTrue( pom.getValue( "build/filters[2]" ).toString().endsWith( "child-c.properties" ) ); assertTrue( pom.getValue( "build/filters[3]" ).toString().endsWith( "child-b.properties" ) ); assertTrue( pom.getValue( "build/filters[4]" ).toString().endsWith( "child-d.properties" ) ); assertTrue( pom.getValue( "build/filters[5]" ).toString().endsWith( "parent-c.properties" ) ); assertTrue( pom.getValue( "build/filters[6]" ).toString().endsWith( "parent-b.properties" ) ); assertTrue( pom.getValue( "build/filters[7]" ).toString().endsWith( "parent-d.properties" ) ); } /** MNG-4027*/ public void testProfileInjectedDependencies() throws Exception { PomTestWrapper pom = buildPom( "profile-injected-dependencies" ); assertEquals( 4, ( (List) pom.getValue( "dependencies" ) ).size() ); assertEquals( "a", pom.getValue( "dependencies[1]/artifactId" ) ); assertEquals( "c", pom.getValue( "dependencies[2]/artifactId" ) ); assertEquals( "b", pom.getValue( "dependencies[3]/artifactId" ) ); assertEquals( "d", pom.getValue( "dependencies[4]/artifactId" ) ); } /** IT-0021*/ public void testProfileDependenciesMultipleProfiles() throws Exception { PomTestWrapper pom = buildPom( "profile-dependencies-multiple-profiles", "profile-1", "profile-2" ); assertEquals(2, ( (List) pom.getValue( "dependencies" ) ).size() ); } public void testDependencyInheritance() throws Exception { PomTestWrapper pom = buildPom( "dependency-inheritance/sub" ); assertEquals( 1, ( (List) pom.getValue( "dependencies" ) ).size() ); assertEquals( "4.4", pom.getValue( "dependencies[1]/version" ) ); } /** MNG-4034 */ public void testManagedProfileDependency() throws Exception { PomTestWrapper pom = this.buildPom( "managed-profile-dependency/sub", "maven-core-it" ); assertEquals( 1, ( (List) pom.getValue( "dependencies" ) ).size() ); assertEquals( "org.apache.maven.its", pom.getValue( "dependencies[1]/groupId" ) ); assertEquals( "maven-core-it-support", pom.getValue( "dependencies[1]/artifactId" ) ); assertEquals( "1.3", pom.getValue( "dependencies[1]/version" ) ); assertEquals( "runtime", pom.getValue( "dependencies[1]/scope" ) ); assertEquals( 1, ( (List) pom.getValue( "dependencies[1]/exclusions" ) ).size() ); assertEquals( "commons-lang", pom.getValue( "dependencies[1]/exclusions[1]/groupId" ) ); } /** MNG-4040 */ public void testProfileModuleInheritance() throws Exception { PomTestWrapper pom = this.buildPom( "profile-module-inheritance/sub", "dist" ); assertEquals( 0, ( (List) pom.getValue( "modules" ) ).size() ); } /** MNG-3621 */ public void testUncPath() throws Exception { PomTestWrapper pom = this.buildPom( "unc-path/sub" ); assertEquals( "file:////host/site/test-child", pom.getValue( "distributionManagement/site/url" ) ); } /** MNG-2006 */ public void testUrlAppendWithChildPathAdjustment() throws Exception { PomTestWrapper pom = this.buildPom( "url-append/child" ); assertEquals( "http://project.url/child", pom.getValue( "url" ) ); assertEquals( "http://viewvc.project.url/child", pom.getValue( "scm/url" ) ); assertEquals( "http://scm.project.url/child", pom.getValue( "scm/connection" ) ); assertEquals( "https://scm.project.url/child", pom.getValue( "scm/developerConnection" ) ); assertEquals( "http://site.project.url/child", pom.getValue( "distributionManagement/site/url" ) ); } /** MNG-0479 */ public void testRepoInheritance() throws Exception { PomTestWrapper pom = this.buildPom( "repo-inheritance" ); assertEquals( 1, ( (List) pom.getValue( "repositories" ) ).size() ); assertEquals( "it0043", pom.getValue( "repositories[1]/name" ) ); } public void testEmptyScm() throws Exception { PomTestWrapper pom = this.buildPom( "empty-scm" ); assertNull( pom.getValue( "scm" ) ); } public void testPluginConfigurationUsingAttributesWithoutPluginManagement() throws Exception { PomTestWrapper pom = buildPom( "plugin-config-attributes/wo-plugin-mgmt" ); assertEquals( "src", pom.getValue( "build/plugins[1]/configuration/domParam/copy/@todir" ) ); assertEquals( "true", pom.getValue( "build/plugins[1]/configuration/domParam/copy/@overwrite" ) ); assertEquals( "target", pom.getValue( "build/plugins[1]/configuration/domParam/copy/fileset/@dir" ) ); assertEquals( null, pom.getValue( "build/plugins[1]/configuration/domParam/copy/fileset/@todir" ) ); assertEquals( null, pom.getValue( "build/plugins[1]/configuration/domParam/copy/fileset/@overwrite" ) ); } /** MNG-4053*/ public void testPluginConfigurationUsingAttributesWithPluginManagement() throws Exception { PomTestWrapper pom = buildPom( "plugin-config-attributes/w-plugin-mgmt" ); assertEquals( "src", pom.getValue( "build/plugins[1]/configuration/domParam/copy/@todir" ) ); assertEquals( "true", pom.getValue( "build/plugins[1]/configuration/domParam/copy/@overwrite" ) ); assertEquals( "target", pom.getValue( "build/plugins[1]/configuration/domParam/copy/fileset/@dir" ) ); assertEquals( null, pom.getValue( "build/plugins[1]/configuration/domParam/copy/fileset/@todir" ) ); assertEquals( null, pom.getValue( "build/plugins[1]/configuration/domParam/copy/fileset/@overwrite" ) ); } public void testPluginConfigurationUsingAttributesWithPluginManagementAndProfile() throws Exception { PomTestWrapper pom = buildPom( "plugin-config-attributes/w-profile", "maven-core-it" ); assertEquals( "src", pom.getValue( "build/plugins[1]/configuration/domParam/copy/@todir" ) ); assertEquals( "true", pom.getValue( "build/plugins[1]/configuration/domParam/copy/@overwrite" ) ); assertEquals( "target", pom.getValue( "build/plugins[1]/configuration/domParam/copy/fileset/@dir" ) ); assertEquals( null, pom.getValue( "build/plugins[1]/configuration/domParam/copy/fileset/@todir" ) ); assertEquals( null, pom.getValue( "build/plugins[1]/configuration/domParam/copy/fileset/@overwrite" ) ); } public void testPomEncoding() throws Exception { PomTestWrapper pom = buildPom( "pom-encoding/utf-8" ); assertEquals( "TEST-CHARS: \u00DF\u0131\u03A3\u042F\u05D0\u20AC", pom.getValue( "description" ) ); pom = buildPom( "pom-encoding/latin-1" ); assertEquals( "TEST-CHARS: \u00C4\u00D6\u00DC\u00E4\u00F6\u00FC\u00DF", pom.getValue( "description" ) ); } /* MNG-4070 */ public void testXmlWhitespaceHandling() throws Exception { PomTestWrapper pom = buildPom( "xml-whitespace/sub" ); assertEquals( "org.apache.maven.its.mng4070", pom.getValue( "groupId" ) ); } /* MNG-3760*/ public void testInterpolationOfBaseUrl() throws Exception { PomTestWrapper pom = buildPom( "baseurl-interpolation/pom.xml" ); assertEquals( pom.getBasedir().toURI().toString(), pom.getValue( "properties/prop1" ).toString() ); } /* MNG-3811*/ public void testReportingPluginConfig() throws Exception { PomTestWrapper pom = buildPom( "reporting-plugin-config/sub" ); assertEquals( 3, ( (List) pom.getValue( "reporting/plugins[1]/configuration/stringParams" ) ).size() ); assertEquals( "parentParam", pom.getValue( "reporting/plugins[1]/configuration/stringParams[1]/stringParam[1]" ) ); assertEquals( "childParam", pom.getValue( "reporting/plugins[1]/configuration/stringParams[1]/stringParam[2]" ) ); assertEquals( " preserve space ", pom.getValue( "reporting/plugins[1]/configuration/stringParams[1]/stringParam[3]" ) ); assertEquals( "true", pom.getValue( "reporting/plugins[1]/configuration/booleanParam" ) ); } public void testPropertiesNoDuplication() throws Exception { PomTestWrapper pom = buildPom( "properties-no-duplication/sub" ); assertEquals( 1, ( (Properties) pom.getValue( "properties" ) ).size() ); assertEquals( "child", pom.getValue( "properties/pomProfile" ) ); } public void testPomInheritance() throws Exception { PomTestWrapper pom = buildPom( "pom-inheritance/sub" ); assertEquals( "parent-description", pom.getValue( "description" ) ); assertEquals( "jar", pom.getValue( "packaging" ) ); } public void testCompleteModelWithoutParent() throws Exception { PomTestWrapper pom = buildPom( "complete-model/wo-parent" ); testCompleteModel( pom ); } public void testCompleteModelWithParent() throws Exception { PomTestWrapper pom = buildPom( "complete-model/w-parent/sub" ); testCompleteModel( pom ); } private void testCompleteModel( PomTestWrapper pom ) throws Exception { assertEquals( "4.0.0", pom.getValue( "modelVersion" ) ); assertEquals( "org.apache.maven.its.mng", pom.getValue( "groupId" ) ); assertEquals( "test", pom.getValue( "artifactId" ) ); assertEquals( "0.2", pom.getValue( "version" ) ); assertEquals( "pom", pom.getValue( "packaging" ) ); assertEquals( "project-name", pom.getValue( "name" ) ); assertEquals( "project-description", pom.getValue( "description" ) ); assertEquals( "http://project.url/", pom.getValue( "url" ) ); assertEquals( "2009", pom.getValue( "inceptionYear" ) ); assertEquals( "project-org", pom.getValue( "organization/name" ) ); assertEquals( "http://project-org.url/", pom.getValue( "organization/url" ) ); assertEquals( 1, ( (List) pom.getValue( "licenses" ) ).size() ); assertEquals( "project-license", pom.getValue( "licenses[1]/name" ) ); assertEquals( "http://project.url/license", pom.getValue( "licenses[1]/url" ) ); assertEquals( "repo", pom.getValue( "licenses[1]/distribution" ) ); assertEquals( "free", pom.getValue( "licenses[1]/comments" ) ); assertEquals( 1, ( (List) pom.getValue( "developers" ) ).size() ); assertEquals( "dev", pom.getValue( "developers[1]/id" ) ); assertEquals( "project-developer", pom.getValue( "developers[1]/name" ) ); assertEquals( "developer@", pom.getValue( "developers[1]/email" ) ); assertEquals( "http://developer", pom.getValue( "developers[1]/url" ) ); assertEquals( "developer", pom.getValue( "developers[1]/organization" ) ); assertEquals( "http://devel.org", pom.getValue( "developers[1]/organizationUrl" ) ); assertEquals( "-1", pom.getValue( "developers[1]/timezone" ) ); assertEquals( "yes", pom.getValue( "developers[1]/properties/developer" ) ); assertEquals( 1, ( (List) pom.getValue( "developers[1]/roles" ) ).size() ); assertEquals( "devel", pom.getValue( "developers[1]/roles[1]" ) ); assertEquals( 1, ( (List) pom.getValue( "contributors" ) ).size() ); assertEquals( "project-contributor", pom.getValue( "contributors[1]/name" ) ); assertEquals( "contributor@", pom.getValue( "contributors[1]/email" ) ); assertEquals( "http://contributor", pom.getValue( "contributors[1]/url" ) ); assertEquals( "contributor", pom.getValue( "contributors[1]/organization" ) ); assertEquals( "http://contrib.org", pom.getValue( "contributors[1]/organizationUrl" ) ); assertEquals( "+1", pom.getValue( "contributors[1]/timezone" ) ); assertEquals( "yes", pom.getValue( "contributors[1]/properties/contributor" ) ); assertEquals( 1, ( (List) pom.getValue( "contributors[1]/roles" ) ).size() ); assertEquals( "contrib", pom.getValue( "contributors[1]/roles[1]" ) ); assertEquals( 1, ( (List) pom.getValue( "mailingLists" ) ).size() ); assertEquals( "project-mailing-list", pom.getValue( "mailingLists[1]/name" ) ); assertEquals( "subscribe@", pom.getValue( "mailingLists[1]/subscribe" ) ); assertEquals( "unsubscribe@", pom.getValue( "mailingLists[1]/unsubscribe" ) ); assertEquals( "post@", pom.getValue( "mailingLists[1]/post" ) ); assertEquals( "mail-archive", pom.getValue( "mailingLists[1]/archive" ) ); assertEquals( 1, ( (List) pom.getValue( "mailingLists[1]/otherArchives" ) ).size() ); assertEquals( "other-archive", pom.getValue( "mailingLists[1]/otherArchives[1]" ) ); assertEquals( "2.0.1", pom.getValue( "prerequisites/maven" ) ); assertEquals( "http://project.url/trunk", pom.getValue( "scm/url" ) ); assertEquals( "http://project.url/scm", pom.getValue( "scm/connection" ) ); assertEquals( "https://project.url/scm", pom.getValue( "scm/developerConnection" ) ); assertEquals( "TAG", pom.getValue( "scm/tag" ) ); assertEquals( "issues", pom.getValue( "issueManagement/system" ) ); assertEquals( "http://project.url/issues", pom.getValue( "issueManagement/url" ) ); assertEquals( "ci", pom.getValue( "ciManagement/system" ) ); assertEquals( "http://project.url/ci", pom.getValue( "ciManagement/url" ) ); assertEquals( 1, ( (List) pom.getValue( "ciManagement/notifiers" ) ).size() ); assertEquals( "irc", pom.getValue( "ciManagement/notifiers[1]/type" ) ); assertEquals( "ci@", pom.getValue( "ciManagement/notifiers[1]/address" ) ); assertEquals( Boolean.TRUE, pom.getValue( "ciManagement/notifiers[1]/sendOnError" ) ); assertEquals( Boolean.FALSE, pom.getValue( "ciManagement/notifiers[1]/sendOnFailure" ) ); assertEquals( Boolean.FALSE, pom.getValue( "ciManagement/notifiers[1]/sendOnWarning" ) ); assertEquals( Boolean.FALSE, pom.getValue( "ciManagement/notifiers[1]/sendOnSuccess" ) ); assertEquals( "ci", pom.getValue( "ciManagement/notifiers[1]/configuration/ciProp" ) ); assertEquals( "project.distros", pom.getValue( "distributionManagement/repository/id" ) ); assertEquals( "distros", pom.getValue( "distributionManagement/repository/name" ) ); assertEquals( "http://project.url/dist", pom.getValue( "distributionManagement/repository/url" ) ); assertEquals( Boolean.TRUE, pom.getValue( "distributionManagement/repository/uniqueVersion" ) ); assertEquals( "project.snaps", pom.getValue( "distributionManagement/snapshotRepository/id" ) ); assertEquals( "snaps", pom.getValue( "distributionManagement/snapshotRepository/name" ) ); assertEquals( "http://project.url/snaps", pom.getValue( "distributionManagement/snapshotRepository/url" ) ); assertEquals( Boolean.FALSE, pom.getValue( "distributionManagement/snapshotRepository/uniqueVersion" ) ); assertEquals( "project.site", pom.getValue( "distributionManagement/site/id" ) ); assertEquals( "docs", pom.getValue( "distributionManagement/site/name" ) ); assertEquals( "http://project.url/site", pom.getValue( "distributionManagement/site/url" ) ); assertEquals( "http://project.url/download", pom.getValue( "distributionManagement/downloadUrl" ) ); assertEquals( "reloc-gid", pom.getValue( "distributionManagement/relocation/groupId" ) ); assertEquals( "reloc-aid", pom.getValue( "distributionManagement/relocation/artifactId" ) ); assertEquals( "reloc-version", pom.getValue( "distributionManagement/relocation/version" ) ); assertEquals( "project-reloc-msg", pom.getValue( "distributionManagement/relocation/message" ) ); assertEquals( 1, ( (List) pom.getValue( "modules" ) ).size() ); assertEquals( "sub", pom.getValue( "modules[1]" ) ); assertEquals( 1, ( (Map) pom.getValue( "properties" ) ).size() ); assertEquals( "project-property", pom.getValue( "properties[1]/itProperty" ) ); assertEquals( 1, ( (List) pom.getValue( "dependencyManagement/dependencies" ) ).size() ); assertEquals( "org.apache.maven.its", pom.getValue( "dependencyManagement/dependencies[1]/groupId" ) ); assertEquals( "managed-dep", pom.getValue( "dependencyManagement/dependencies[1]/artifactId" ) ); assertEquals( "0.1", pom.getValue( "dependencyManagement/dependencies[1]/version" ) ); assertEquals( "war", pom.getValue( "dependencyManagement/dependencies[1]/type" ) ); assertEquals( "runtime", pom.getValue( "dependencyManagement/dependencies[1]/scope" ) ); assertEquals( Boolean.FALSE, pom.getValue( "dependencyManagement/dependencies[1]/optional" ) ); assertEquals( 1, ( (List) pom.getValue( "dependencyManagement/dependencies[1]/exclusions" ) ).size() ); assertEquals( "org.apache.maven.its", pom.getValue( "dependencyManagement/dependencies[1]/exclusions[1]/groupId" ) ); assertEquals( "excluded-managed-dep", pom.getValue( "dependencyManagement/dependencies[1]/exclusions[1]/artifactId" ) ); assertEquals( 1, ( (List) pom.getValue( "dependencies" ) ).size() ); assertEquals( "org.apache.maven.its", pom.getValue( "dependencies[1]/groupId" ) ); assertEquals( "dep", pom.getValue( "dependencies[1]/artifactId" ) ); assertEquals( "0.2", pom.getValue( "dependencies[1]/version" ) ); assertEquals( "ejb", pom.getValue( "dependencies[1]/type" ) ); assertEquals( "test", pom.getValue( "dependencies[1]/scope" ) ); assertEquals( Boolean.TRUE, pom.getValue( "dependencies[1]/optional" ) ); assertEquals( 1, ( (List) pom.getValue( "dependencies[1]/exclusions" ) ).size() ); assertEquals( "org.apache.maven.its", pom.getValue( "dependencies[1]/exclusions[1]/groupId" ) ); assertEquals( "excluded-dep", pom.getValue( "dependencies[1]/exclusions[1]/artifactId" ) ); assertEquals( 2, ( (List) pom.getValue( "repositories" ) ).size() ); assertEquals( "project-remote-repo", pom.getValue( "repositories[1]/id" ) ); assertEquals( "http://project.url/remote", pom.getValue( "repositories[1]/url" ) ); assertEquals( "repo", pom.getValue( "repositories[1]/name" ) ); assertEquals( RepositorySystem.DEFAULT_REMOTE_REPO_ID, pom.getValue( "repositories[2]/id" ) ); assertEquals( RepositorySystem.DEFAULT_REMOTE_REPO_URL, pom.getValue( "repositories[2]/url" ) ); assertEquals( "test", pom.getValue( "build/defaultGoal" ) ); assertEquals( "coreit", pom.getValue( "build/finalName" ) ); assertPathSuffixEquals( "build", pom.getValue( "build/directory" ) ); assertPathSuffixEquals( "build/main", pom.getValue( "build/outputDirectory" ) ); assertPathSuffixEquals( "build/test", pom.getValue( "build/testOutputDirectory" ) ); assertPathSuffixEquals( "sources/main", pom.getValue( "build/sourceDirectory" ) ); assertPathSuffixEquals( "sources/test", pom.getValue( "build/testSourceDirectory" ) ); assertPathSuffixEquals( "sources/scripts", pom.getValue( "build/scriptSourceDirectory" ) ); assertEquals( 1, ( (List) pom.getValue( "build/filters" ) ).size() ); assertPathSuffixEquals( "src/main/filter/it.properties", pom.getValue( "build/filters[1]" ) ); assertEquals( 1, ( (List) pom.getValue( "build/resources" ) ).size() ); assertPathSuffixEquals( "res/main", pom.getValue( "build/resources[1]/directory" ) ); assertPathSuffixEquals( "main", pom.getValue( "build/resources[1]/targetPath" ) ); assertEquals( Boolean.TRUE, pom.getValue( "build/resources[1]/filtering" ) ); assertEquals( 1, ( (List) pom.getValue( "build/resources[1]/includes" ) ).size() ); assertPathSuffixEquals( "main.included", pom.getValue( "build/resources[1]/includes[1]" ) ); assertEquals( 1, ( (List) pom.getValue( "build/resources[1]/excludes" ) ).size() ); assertPathSuffixEquals( "main.excluded", pom.getValue( "build/resources[1]/excludes[1]" ) ); assertEquals( 1, ( (List) pom.getValue( "build/testResources" ) ).size() ); assertPathSuffixEquals( "res/test", pom.getValue( "build/testResources[1]/directory" ) ); assertPathSuffixEquals( "test", pom.getValue( "build/testResources[1]/targetPath" ) ); assertEquals( Boolean.TRUE, pom.getValue( "build/testResources[1]/filtering" ) ); assertEquals( 1, ( (List) pom.getValue( "build/testResources[1]/includes" ) ).size() ); assertPathSuffixEquals( "test.included", pom.getValue( "build/testResources[1]/includes[1]" ) ); assertEquals( 1, ( (List) pom.getValue( "build/testResources[1]/excludes" ) ).size() ); assertPathSuffixEquals( "test.excluded", pom.getValue( "build/testResources[1]/excludes[1]" ) ); assertEquals( 1, ( (List) pom.getValue( "build/extensions" ) ).size() ); assertEquals( "org.apache.maven.its.ext", pom.getValue( "build/extensions[1]/groupId" ) ); assertEquals( "ext", pom.getValue( "build/extensions[1]/artifactId" ) ); assertEquals( "3.0", pom.getValue( "build/extensions[1]/version" ) ); assertEquals( 1, ( (List) pom.getValue( "build/plugins" ) ).size() ); assertEquals( "org.apache.maven.its.plugins", pom.getValue( "build/plugins[1]/groupId" ) ); assertEquals( "maven-it-plugin-build", pom.getValue( "build/plugins[1]/artifactId" ) ); assertEquals( "2.1-SNAPSHOT", pom.getValue( "build/plugins[1]/version" ) ); assertEquals( "test.properties", pom.getValue( "build/plugins[1]/configuration/outputFile" ) ); assertEquals( 1, ( (List) pom.getValue( "build/plugins[1]/executions" ) ).size() ); assertEquals( "test", pom.getValue( "build/plugins[1]/executions[1]/id" ) ); assertEquals( "validate", pom.getValue( "build/plugins[1]/executions[1]/phase" ) ); assertEquals( "pom.properties", pom.getValue( "build/plugins[1]/executions[1]/configuration/outputFile" ) ); assertEquals( 1, ( (List) pom.getValue( "build/plugins[1]/executions[1]/goals" ) ).size() ); assertEquals( "eval", pom.getValue( "build/plugins[1]/executions[1]/goals[1]" ) ); assertEquals( 1, ( (List) pom.getValue( "build/plugins[1]/dependencies" ) ).size() ); assertEquals( "org.apache.maven.its", pom.getValue( "build/plugins[1]/dependencies[1]/groupId" ) ); assertEquals( "build-plugin-dep", pom.getValue( "build/plugins[1]/dependencies[1]/artifactId" ) ); assertEquals( "0.3", pom.getValue( "build/plugins[1]/dependencies[1]/version" ) ); assertEquals( "zip", pom.getValue( "build/plugins[1]/dependencies[1]/type" ) ); assertEquals( 1, ( (List) pom.getValue( "build/plugins[1]/dependencies[1]/exclusions" ) ).size() ); assertEquals( "org.apache.maven.its", pom.getValue( "build/plugins[1]/dependencies[1]/exclusions[1]/groupId" ) ); assertEquals( "excluded-build-plugin-dep", pom.getValue( "build/plugins[1]/dependencies[1]/exclusions[1]/artifactId" ) ); assertEquals( Boolean.TRUE, pom.getValue( "reporting/excludeDefaults" ) ); assertPathSuffixEquals( "docs", pom.getValue( "reporting/outputDirectory" ) ); assertEquals( 1, ( (List) pom.getValue( "reporting/plugins" ) ).size() ); assertEquals( "org.apache.maven.its.plugins", pom.getValue( "reporting/plugins[1]/groupId" ) ); assertEquals( "maven-it-plugin-reporting", pom.getValue( "reporting/plugins[1]/artifactId" ) ); assertEquals( "2.0-SNAPSHOT", pom.getValue( "reporting/plugins[1]/version" ) ); assertEquals( "test.html", pom.getValue( "reporting/plugins[1]/configuration/outputFile" ) ); assertEquals( 1, ( (List) pom.getValue( "reporting/plugins[1]/reportSets" ) ).size() ); assertEquals( "it", pom.getValue( "reporting/plugins[1]/reportSets[1]/id" ) ); assertEquals( "index.html", pom.getValue( "reporting/plugins[1]/reportSets[1]/configuration/outputFile" ) ); assertEquals( 1, ( (List) pom.getValue( "reporting/plugins[1]/reportSets[1]/reports" ) ).size() ); assertEquals( "run", pom.getValue( "reporting/plugins[1]/reportSets[1]/reports[1]" ) ); } /* MNG-2309*/ public void testProfileInjectionOrder() throws Exception { PomTestWrapper pom = buildPom( "profile-injection-order", "pom-a", "pom-b", "pom-e", "pom-c", "pom-d" ); assertEquals( "e", pom.getValue( "properties[1]/pomProperty" ) ); } public void testPropertiesInheritance() throws Exception { PomTestWrapper pom = buildPom( "properties-inheritance/sub" ); assertEquals( "parent-property", pom.getValue( "properties/parentProperty" ) ); assertEquals( "child-property", pom.getValue( "properties/childProperty" ) ); assertEquals( "child-override", pom.getValue( "properties/overriddenProperty" ) ); } /* MNG-4102*/ public void testInheritedPropertiesInterpolatedWithValuesFromChildWithoutProfiles() throws Exception { PomTestWrapper pom = buildPom( "inherited-properties-interpolation/no-profile/sub" ); assertEquals( "CHILD", pom.getValue( "properties/overridden" ) ); assertEquals( "CHILD", pom.getValue( "properties/interpolated" ) ); } /* MNG-4102 */ public void testInheritedPropertiesInterpolatedWithValuesFromChildWithActiveProfiles() throws Exception { PomTestWrapper pom = buildPom( "inherited-properties-interpolation/active-profile/sub" ); assertEquals( 1, pom.getMavenProject().getModel().getProfiles().size() ); buildPom( "inherited-properties-interpolation/active-profile/sub", "it-parent", "it-child" ); assertEquals( "CHILD", pom.getValue( "properties/overridden" ) ); assertEquals( "CHILD", pom.getValue( "properties/interpolated" ) ); } /* MNG-3545 */ public void testProfileDefaultActivation() throws Exception { PomTestWrapper pom = buildPom( "profile-default-deactivation", "profile4" ); assertEquals( 1, pom.getMavenProject().getActiveProfiles().size() ); assertEquals( 1, ( (List) pom.getValue( "build/plugins" ) ).size() ); assertEquals( "2.1", pom.getValue( "build/plugins[1]/version" ) ); } /* MNG-1995 */ public void testBooleanInterpolation() throws Exception { PomTestWrapper pom = buildPom( "boolean-interpolation" ); assertTrue ((Boolean) pom.getValue( "repositories[1]/releases/enabled" ) ); assertTrue((Boolean) pom.getValue( "build/resources[1]/filtering" ) ); } /* MNG-3899 */ public void testBuildExtensionInheritance() throws Exception { PomTestWrapper pom = buildPom( "build-extension-inheritance/sub" ); assertEquals( 3, ( (List) pom.getValue( "build/extensions" ) ).size() ); assertEquals( "b", pom.getValue( "build/extensions[1]/artifactId" ) ); assertEquals( "a", pom.getValue( "build/extensions[2]/artifactId" ) ); assertEquals( "0.2", pom.getValue( "build/extensions[2]/version" ) ); assertEquals( "c", pom.getValue( "build/extensions[3]/artifactId" ) ); } /*MNG-1957*/ public void testJdkActivation() throws Exception { Properties props = new Properties(); props.put( "java.version", "1.5.0_15" ); PomTestWrapper pom = buildPom( "jdk-activation", props ); assertEquals( 3, pom.getMavenProject().getActiveProfiles().size() ); assertEquals( "PASSED", pom.getValue( "properties/jdkProperty3" ) ); assertEquals( "PASSED", pom.getValue( "properties/jdkProperty2" ) ); assertEquals( "PASSED", pom.getValue( "properties/jdkProperty1" ) ); } /* MNG-2174 */ public void testProfilePluginMngDependencies() throws Exception { PomTestWrapper pom = buildPom( "profile-plugin-mng-dependencies/sub", "maven-core-it" ); assertEquals( "a", pom.getValue( "build/plugins[1]/dependencies[1]/artifactId" ) ); } /** MNG-4116 */ public void testPercentEncodedUrlsMustNotBeDecoded() throws Exception { PomTestWrapper pom = this.buildPom( "url-no-decoding" ); assertEquals( "http://maven.apache.org/spacy%20path", pom.getValue( "url" ) ); assertEquals( "http://svn.apache.org/viewvc/spacy%20path", pom.getValue( "scm/url" ) ); assertEquals( "scm:svn:svn+ssh://svn.apache.org/spacy%20path", pom.getValue( "scm/connection" ) ); assertEquals( "scm:svn:svn+ssh://svn.apache.org/spacy%20path", pom.getValue( "scm/developerConnection" ) ); assertEquals( "http://issues.apache.org/spacy%20path", pom.getValue( "issueManagement/url" ) ); assertEquals( "http://ci.apache.org/spacy%20path", pom.getValue( "ciManagement/url" ) ); assertEquals( "scm:svn:svn+ssh://dist.apache.org/spacy%20path", pom.getValue( "distributionManagement/repository/url" ) ); assertEquals( "scm:svn:svn+ssh://snap.apache.org/spacy%20path", pom.getValue( "distributionManagement/snapshotRepository/url" ) ); assertEquals( "scm:svn:svn+ssh://site.apache.org/spacy%20path", pom.getValue( "distributionManagement/site/url" ) ); } public void testPluginManagementInheritance() throws Exception { PomTestWrapper pom = this.buildPom( "plugin-management-inheritance" ); assertEquals( "0.1-stub-SNAPSHOT", pom.getValue( "build/pluginManagement/plugins[@artifactId='maven-compiler-plugin']/version" ) ); } public void testProfilePlugins() throws Exception { PomTestWrapper pom = this.buildPom( "profile-plugins", "standard" ); assertEquals( 2, ( (List) pom.getValue( "build/plugins" ) ).size() ); assertEquals( "maven-assembly2-plugin", pom.getValue( "build/plugins[2]/artifactId" ) ); } public void testPluginInheritanceSimple() throws Exception { PomTestWrapper pom = this.buildPom( "plugin-inheritance-simple/sub" ); assertEquals( 2, ( (List) pom.getValue( "build/plugins" ) ).size() ); } public void testPluginManagementDuplicate() throws Exception { PomTestWrapper pom = this.buildPom( "plugin-management-duplicate/sub" ); assertEquals( 12, ( (List) pom.getValue( "build/pluginManagement/plugins" ) ).size() ); } public void testDistributionManagement() throws Exception { PomTestWrapper pom = this.buildPom( "distribution-management" ); assertEquals( "legacy", pom.getValue( "distributionManagement/repository/layout" ) ); } public void testDependencyScopeInheritance() throws Exception { PomTestWrapper pom = buildPom( "dependency-scope-inheritance/sub" ); String scope = (String) pom.getValue( "dependencies[1]/scope" ); assertEquals( "compile", scope ); } public void testDependencyScope() throws Exception { buildPom( "dependency-scope/sub" ); } //This will fail on a validation error if incorrect public void testDependencyManagementWithInterpolation() throws Exception { buildPom( "dependency-management-with-interpolation/sub" ); } public void testInterpolationWithSystemProperty() throws Exception { Properties sysProps = new Properties(); sysProps.setProperty( "system.property", "PASSED" ); PomTestWrapper pom = buildPom( "system-property-interpolation", sysProps ); assertEquals( "PASSED", pom.getValue( "name" ) ); } /* MNG-4129 */ public void testPluginExecutionInheritanceWhenChildDoesNotDeclarePlugin() throws Exception { PomTestWrapper pom = buildPom( "plugin-exec-inheritance/wo-merge" ); @SuppressWarnings( "unchecked" ) List executions = (List) pom.getValue( "build/pluginsAsMap[@name='org.apache.maven.its.plugins:maven-it-plugin-log-file']/executions" ); assertEquals( 1, executions.size() ); assertEquals( "inherited-execution", executions.get( 0 ).getId() ); } public void testPluginExecutionInheritanceWhenChildDoesDeclarePluginAsWell() throws Exception { PomTestWrapper pom = buildPom( "plugin-exec-inheritance/w-merge" ); @SuppressWarnings( "unchecked" ) List executions = (List) pom.getValue( "build/pluginsAsMap[@name='org.apache.maven.its.plugins:maven-it-plugin-log-file']/executions" ); assertEquals( 1, executions.size() ); assertEquals( "inherited-execution", executions.get( 0 ).getId() ); } /* MNG-4193 */ public void testValidationErrorUponNonUniqueArtifactRepositoryId() throws Exception { try { buildPom( "unique-repo-id/artifact-repo" ); fail( "Non-unique repository ids did not cause validation error" ); } catch ( ProjectBuildingException e ) { // expected } } /* MNG-4193 */ public void testValidationErrorUponNonUniquePluginRepositoryId() throws Exception { try { buildPom( "unique-repo-id/plugin-repo" ); fail( "Non-unique repository ids did not cause validation error" ); } catch ( ProjectBuildingException e ) { // expected } } /* MNG-4193 */ public void testValidationErrorUponNonUniqueArtifactRepositoryIdInProfile() throws Exception { try { buildPom( "unique-repo-id/artifact-repo-in-profile" ); fail( "Non-unique repository ids did not cause validation error" ); } catch ( ProjectBuildingException e ) { // expected } } /* MNG-4193 */ public void testValidationErrorUponNonUniquePluginRepositoryIdInProfile() throws Exception { try { buildPom( "unique-repo-id/plugin-repo-in-profile" ); fail( "Non-unique repository ids did not cause validation error" ); } catch ( ProjectBuildingException e ) { // expected } } /** MNG-3843 */ public void testPrerequisitesAreNotInherited() throws Exception { PomTestWrapper pom = buildPom( "prerequisites-inheritance/child" ); assertSame( null, pom.getValue( "prerequisites" ) ); } public void testLicensesAreInheritedButNotAggregated() throws Exception { PomTestWrapper pom = buildPom( "licenses-inheritance/child-2" ); assertEquals( 1, ( (List) pom.getValue( "licenses" ) ).size() ); assertEquals( "child-license", pom.getValue( "licenses[1]/name" ) ); assertEquals( "http://child.url/license", pom.getValue( "licenses[1]/url" ) ); } public void testDevelopersAreInheritedButNotAggregated() throws Exception { PomTestWrapper pom = buildPom( "developers-inheritance/child-2" ); assertEquals( 1, ( (List) pom.getValue( "developers" ) ).size() ); assertEquals( "child-developer", pom.getValue( "developers[1]/name" ) ); } public void testContributorsAreInheritedButNotAggregated() throws Exception { PomTestWrapper pom = buildPom( "contributors-inheritance/child-2" ); assertEquals( 1, ( (List) pom.getValue( "contributors" ) ).size() ); assertEquals( "child-contributor", pom.getValue( "contributors[1]/name" ) ); } public void testMailingListsAreInheritedButNotAggregated() throws Exception { PomTestWrapper pom = buildPom( "mailing-lists-inheritance/child-2" ); assertEquals( 1, ( (List) pom.getValue( "mailingLists" ) ).size() ); assertEquals( "child-mailing-list", pom.getValue( "mailingLists[1]/name" ) ); } public void testPluginInheritanceOrder() throws Exception { PomTestWrapper pom = buildPom( "plugin-inheritance-order/child" ); assertEquals( "maven-it-plugin-log-file", pom.getValue( "build/plugins[1]/artifactId" ) ); assertEquals( "maven-it-plugin-expression", pom.getValue( "build/plugins[2]/artifactId" ) ); assertEquals( "maven-it-plugin-configuration", pom.getValue( "build/plugins[3]/artifactId" ) ); assertEquals( "maven-it-plugin-log-file", pom.getValue( "reporting/plugins[1]/artifactId" ) ); assertEquals( "maven-it-plugin-expression", pom.getValue( "reporting/plugins[2]/artifactId" ) ); assertEquals( "maven-it-plugin-configuration", pom.getValue( "reporting/plugins[3]/artifactId" ) ); } public void testCliPropsDominateProjectPropsDuringInterpolation() throws Exception { Properties props = new Properties(); props.setProperty( "testProperty", "PASSED" ); PomTestWrapper pom = buildPom( "interpolation-cli-wins", props ); assertEquals( "PASSED", pom.getValue( "properties/interpolatedProperty" ) ); } public void testParentPomPackagingMustBePom() throws Exception { try { buildPom( "parent-pom-packaging/sub" ); fail( "Wrong packaging of parent POM was not rejected" ); } catch ( ProjectBuildingException e ) { // expected } } /** MNG-522, MNG-3018 */ public void testManagedPluginConfigurationAppliesToImplicitPluginsIntroducedByPackaging() throws Exception { PomTestWrapper pom = buildPom( "plugin-management-for-implicit-plugin/child" ); assertEquals( "passed.txt", pom.getValue( "build/plugins[@artifactId='maven-resources-plugin']/configuration/pathname" ) ); assertEquals( "passed.txt", pom.getValue( "build/plugins[@artifactId='maven-it-plugin-log-file']/configuration/logFile" ) ); } public void testDefaultPluginsExecutionContributedByPackagingExecuteBeforeUserDefinedExecutions() throws Exception { PomTestWrapper pom = buildPom( "plugin-exec-order-and-default-exec" ); @SuppressWarnings( "unchecked" ) List executions = (List) pom.getValue( "build/plugins[@artifactId='maven-resources-plugin']/executions" ); assertNotNull( executions ); assertEquals( 4, executions.size() ); assertEquals( "default-resources", executions.get( 0 ).getId() ); assertEquals( "default-testResources", executions.get( 1 ).getId() ); assertEquals( "test-1", executions.get( 2 ).getId() ); assertEquals( "test-2", executions.get( 3 ).getId() ); } public void testPluginDeclarationsRetainPomOrderAfterInjectionOfDefaultPlugins() throws Exception { PomTestWrapper pom = buildPom( "plugin-exec-order-with-lifecycle" ); @SuppressWarnings( "unchecked" ) List plugins = (List) pom.getValue( "build/plugins" ); int resourcesPlugin = -1; int customPlugin = -1; for ( int i = 0; i < plugins.size(); i++ ) { Plugin plugin = plugins.get( i ); if ( "maven-resources-plugin".equals( plugin.getArtifactId() ) ) { assertTrue( resourcesPlugin < 0 ); resourcesPlugin = i; } else if ( "maven-it-plugin-log-file".equals( plugin.getArtifactId() ) ) { assertTrue( customPlugin < 0 ); customPlugin = i; } } assertTrue( plugins.toString(), customPlugin == resourcesPlugin - 1 ); } /** MNG-4415 */ public void testPluginOrderAfterMergingWithInheritedPlugins() throws Exception { PomTestWrapper pom = buildPom( "plugin-inheritance-merge-order/sub" ); List expected = new ArrayList<>(); expected.add( "maven-it-plugin-error" ); expected.add( "maven-it-plugin-configuration" ); expected.add( "maven-it-plugin-dependency-resolution" ); expected.add( "maven-it-plugin-packaging" ); expected.add( "maven-it-plugin-log-file" ); expected.add( "maven-it-plugin-expression" ); expected.add( "maven-it-plugin-fork" ); expected.add( "maven-it-plugin-touch" ); List actual = new ArrayList<>(); @SuppressWarnings( "unchecked" ) List plugins = (List) pom.getValue( "build/plugins" ); for ( Plugin plugin : plugins ) { actual.add( plugin.getArtifactId() ); } actual.retainAll( expected ); assertEquals( actual, expected ); } /** MNG-4416 */ public void testPluginOrderAfterMergingWithInjectedPlugins() throws Exception { PomTestWrapper pom = buildPom( "plugin-injection-merge-order" ); List expected = new ArrayList<>(); expected.add( "maven-it-plugin-error" ); expected.add( "maven-it-plugin-configuration" ); expected.add( "maven-it-plugin-dependency-resolution" ); expected.add( "maven-it-plugin-packaging" ); expected.add( "maven-it-plugin-log-file" ); expected.add( "maven-it-plugin-expression" ); expected.add( "maven-it-plugin-fork" ); expected.add( "maven-it-plugin-touch" ); List actual = new ArrayList<>(); @SuppressWarnings( "unchecked" ) List plugins = (List) pom.getValue( "build/plugins" ); for ( Plugin plugin : plugins ) { actual.add( plugin.getArtifactId() ); } actual.retainAll( expected ); assertEquals( actual, expected ); } public void testProjectArtifactIdIsNotInheritedButMandatory() throws Exception { try { buildPom( "artifact-id-inheritance/child" ); fail( "Missing artifactId did not cause validation error" ); } catch ( ProjectBuildingException e ) { // expected } } private void assertPathSuffixEquals( String expected, Object actual ) { String a = actual.toString(); a = a.substring( a.length() - expected.length() ).replace( '\\', '/' ); assertEquals( expected, a ); } private void assertPathWithNormalizedFileSeparators( Object value ) { assertEquals( new File( value.toString() ).getPath(), value.toString() ); } private PomTestWrapper buildPom( String pomPath, String... profileIds ) throws Exception { return buildPom( pomPath, null, profileIds ); } private PomTestWrapper buildPom( String pomPath, Properties executionProperties, String... profileIds ) throws Exception { return buildPom( pomPath, false, executionProperties, profileIds ); } private PomTestWrapper buildPom( String pomPath, boolean lenientValidation, Properties executionProperties, String... profileIds ) throws Exception { File pomFile = new File( testDirectory, pomPath ); if ( pomFile.isDirectory() ) { pomFile = new File( pomFile, "pom.xml" ); } ProjectBuildingRequest config = new DefaultProjectBuildingRequest(); String localRepoUrl = System.getProperty( "maven.repo.local", System.getProperty( "user.home" ) + "/.m2/repository" ); localRepoUrl = "file://" + localRepoUrl; config.setLocalRepository( repositorySystem.createArtifactRepository( "local", localRepoUrl, new DefaultRepositoryLayout(), null, null ) ); config.setActiveProfileIds( Arrays.asList( profileIds ) ); config.setSystemProperties( executionProperties ); config.setUserProperties( executionProperties ); config.setValidationLevel( lenientValidation ? ModelBuildingRequest.VALIDATION_LEVEL_MAVEN_2_0 : ModelBuildingRequest.VALIDATION_LEVEL_STRICT ); DefaultRepositorySystemSession repoSession = MavenRepositorySystemUtils.newSession(); LocalRepository localRepo = new LocalRepository( config.getLocalRepository().getBasedir() ); repoSession.setLocalRepositoryManager( new SimpleLocalRepositoryManagerFactory().newInstance( repoSession, localRepo ) ); config.setRepositorySession( repoSession ); return new PomTestWrapper( pomFile, projectBuilder.build( pomFile, config ).getProject() ); } protected void assertModelEquals( PomTestWrapper pom, Object expected, String expression ) { assertEquals( expected, pom.getValue( expression ) ); } private static String createPath( List elements ) { StringBuilder buffer = new StringBuilder( 256 ); for ( String s : elements ) { buffer.append( s ).append( File.separator ); } return buffer.toString().substring( 0, buffer.toString().length() - 1 ); } } maven-maven-3.5.2/maven-core/src/test/java/org/apache/maven/project/ProjectBuilderTest.java000066400000000000000000000064231317160430700316710ustar00rootroot00000000000000package org.apache.maven.project; /* * 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.File; import java.util.Properties; import org.apache.maven.AbstractCoreMavenComponentTestCase; import org.apache.maven.execution.MavenSession; import org.apache.maven.model.building.FileModelSource; import org.apache.maven.model.building.ModelSource; public class ProjectBuilderTest extends AbstractCoreMavenComponentTestCase { protected String getProjectsDirectory() { return "src/test/projects/project-builder"; } public void testSystemScopeDependencyIsPresentInTheCompileClasspathElements() throws Exception { File pom = getProject( "it0063" ); Properties eps = new Properties(); eps.setProperty( "jre.home", new File( pom.getParentFile(), "jdk/jre" ).getPath() ); MavenSession session = createMavenSession( pom, eps ); MavenProject project = session.getCurrentProject(); // Here we will actually not have any artifacts because the ProjectDependenciesResolver is not involved here. So // right now it's not valid to ask for artifacts unless plugins require the artifacts. project.getCompileClasspathElements(); } public void testBuildFromModelSource() throws Exception { File pomFile = new File( "src/test/resources/projects/modelsource/module01/pom.xml" ); MavenSession mavenSession = createMavenSession( pomFile ); ProjectBuildingRequest configuration = new DefaultProjectBuildingRequest(); configuration.setRepositorySession( mavenSession.getRepositorySession() ); ModelSource modelSource = new FileModelSource( pomFile ); ProjectBuildingResult result = lookup( org.apache.maven.project.ProjectBuilder.class ).build( modelSource, configuration ); assertNotNull( result.getProject().getParentFile() ); } public void testVersionlessManagedDependency() throws Exception { File pomFile = new File( "src/test/resources/projects/versionless-managed-dependency.xml" ); MavenSession mavenSession = createMavenSession( null ); ProjectBuildingRequest configuration = new DefaultProjectBuildingRequest(); configuration.setRepositorySession( mavenSession.getRepositorySession() ); try { lookup( org.apache.maven.project.ProjectBuilder.class ).build( pomFile, configuration ); fail(); } catch ( ProjectBuildingException e ) { // this is expected } } } maven-maven-3.5.2/maven-core/src/test/java/org/apache/maven/project/ProjectModelResolverTest.java000066400000000000000000000217561317160430700330730ustar00rootroot00000000000000package org.apache.maven.project; /* * 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.File; import java.util.Collections; import java.util.List; import org.apache.maven.artifact.InvalidRepositoryException; import org.apache.maven.model.Dependency; import org.apache.maven.model.Parent; import org.apache.maven.model.resolution.ModelResolver; import org.apache.maven.model.resolution.UnresolvableModelException; import org.apache.maven.repository.internal.MavenRepositorySystemUtils; import org.eclipse.aether.DefaultRepositorySystemSession; import org.eclipse.aether.RepositorySystem; import org.eclipse.aether.impl.RemoteRepositoryManager; import org.eclipse.aether.repository.RemoteRepository; import static junit.framework.TestCase.assertEquals; import static junit.framework.TestCase.assertNotNull; import static junit.framework.TestCase.assertTrue; import static junit.framework.TestCase.fail; import static org.codehaus.plexus.PlexusTestCase.getBasedir; /** * Test cases for the project {@code ModelResolver} implementation. * * @author Christian Schulte * @since 3.5.0 */ public class ProjectModelResolverTest extends AbstractMavenProjectTestCase { /** * Creates a new {@code ProjectModelResolverTest} instance. */ public ProjectModelResolverTest() { super(); } public void testResolveParentThrowsUnresolvableModelExceptionWhenNotFound() throws Exception { final Parent parent = new Parent(); parent.setGroupId( "org.apache" ); parent.setArtifactId( "apache" ); parent.setVersion( "0" ); try { this.newModelResolver().resolveModel( parent ); fail( "Expected 'UnresolvableModelException' not thrown." ); } catch ( final UnresolvableModelException e ) { assertNotNull( e.getMessage() ); assertTrue( e.getMessage().startsWith( "Could not find artifact org.apache:apache:pom:0 in central" ) ); } } public void testResolveParentThrowsUnresolvableModelExceptionWhenNoMatchingVersionFound() throws Exception { final Parent parent = new Parent(); parent.setGroupId( "org.apache" ); parent.setArtifactId( "apache" ); parent.setVersion( "[2.0,2.1)" ); try { this.newModelResolver().resolveModel( parent ); fail( "Expected 'UnresolvableModelException' not thrown." ); } catch ( final UnresolvableModelException e ) { assertEquals( "No versions matched the requested parent version range '[2.0,2.1)'", e.getMessage() ); } } public void testResolveParentThrowsUnresolvableModelExceptionWhenUsingRangesWithoutUpperBound() throws Exception { final Parent parent = new Parent(); parent.setGroupId( "org.apache" ); parent.setArtifactId( "apache" ); parent.setVersion( "[1,)" ); try { this.newModelResolver().resolveModel( parent ); fail( "Expected 'UnresolvableModelException' not thrown." ); } catch ( final UnresolvableModelException e ) { assertEquals( "The requested parent version range '[1,)' does not specify an upper bound", e.getMessage() ); } } public void testResolveParentSuccessfullyResolvesExistingParentWithoutRange() throws Exception { final Parent parent = new Parent(); parent.setGroupId( "org.apache" ); parent.setArtifactId( "apache" ); parent.setVersion( "1" ); assertNotNull( this.newModelResolver().resolveModel( parent ) ); assertEquals( "1", parent.getVersion() ); } public void testResolveParentSuccessfullyResolvesExistingParentUsingHighestVersion() throws Exception { final Parent parent = new Parent(); parent.setGroupId( "org.apache" ); parent.setArtifactId( "apache" ); parent.setVersion( "(,2.0)" ); assertNotNull( this.newModelResolver().resolveModel( parent ) ); assertEquals( "1", parent.getVersion() ); } public void testResolveDependencyThrowsUnresolvableModelExceptionWhenNotFound() throws Exception { final Dependency dependency = new Dependency(); dependency.setGroupId( "org.apache" ); dependency.setArtifactId( "apache" ); dependency.setVersion( "0" ); try { this.newModelResolver().resolveModel( dependency ); fail( "Expected 'UnresolvableModelException' not thrown." ); } catch ( final UnresolvableModelException e ) { assertNotNull( e.getMessage() ); assertTrue( e.getMessage().startsWith( "Could not find artifact org.apache:apache:pom:0 in central" ) ); } } public void testResolveDependencyThrowsUnresolvableModelExceptionWhenNoMatchingVersionFound() throws Exception { final Dependency dependency = new Dependency(); dependency.setGroupId( "org.apache" ); dependency.setArtifactId( "apache" ); dependency.setVersion( "[2.0,2.1)" ); try { this.newModelResolver().resolveModel( dependency ); fail( "Expected 'UnresolvableModelException' not thrown." ); } catch ( final UnresolvableModelException e ) { assertEquals( "No versions matched the requested dependency version range '[2.0,2.1)'", e.getMessage() ); } } public void testResolveDependencyThrowsUnresolvableModelExceptionWhenUsingRangesWithoutUpperBound() throws Exception { final Dependency dependency = new Dependency(); dependency.setGroupId( "org.apache" ); dependency.setArtifactId( "apache" ); dependency.setVersion( "[1,)" ); try { this.newModelResolver().resolveModel( dependency ); fail( "Expected 'UnresolvableModelException' not thrown." ); } catch ( final UnresolvableModelException e ) { assertEquals( "The requested dependency version range '[1,)' does not specify an upper bound", e.getMessage() ); } } public void testResolveDependencySuccessfullyResolvesExistingDependencyWithoutRange() throws Exception { final Dependency dependency = new Dependency(); dependency.setGroupId( "org.apache" ); dependency.setArtifactId( "apache" ); dependency.setVersion( "1" ); assertNotNull( this.newModelResolver().resolveModel( dependency ) ); assertEquals( "1", dependency.getVersion() ); } public void testResolveDependencySuccessfullyResolvesExistingDependencyUsingHighestVersion() throws Exception { final Dependency dependency = new Dependency(); dependency.setGroupId( "org.apache" ); dependency.setArtifactId( "apache" ); dependency.setVersion( "(,2.0)" ); assertNotNull( this.newModelResolver().resolveModel( dependency ) ); assertEquals( "1", dependency.getVersion() ); } private ModelResolver newModelResolver() throws Exception { final File localRepo = new File( this.getLocalRepository().getBasedir() ); final DefaultRepositorySystemSession repoSession = MavenRepositorySystemUtils.newSession(); repoSession.setLocalRepositoryManager( new LegacyLocalRepositoryManager( localRepo ) ); return new ProjectModelResolver( repoSession, null, lookup( RepositorySystem.class ), lookup( RemoteRepositoryManager.class ), this.getRemoteRepositories(), ProjectBuildingRequest.RepositoryMerging.REQUEST_DOMINANT, null ); } private List getRemoteRepositories() throws InvalidRepositoryException { final File repoDir = new File( getBasedir(), "src/test/remote-repo" ).getAbsoluteFile(); final RemoteRepository remoteRepository = new RemoteRepository.Builder( org.apache.maven.repository.RepositorySystem.DEFAULT_REMOTE_REPO_ID, "default", repoDir.toURI().toASCIIString() ).build(); return Collections.singletonList( remoteRepository ); } } maven-maven-3.5.2/maven-core/src/test/java/org/apache/maven/project/ProjectSorterTest.java000066400000000000000000000321161317160430700315570ustar00rootroot00000000000000package org.apache.maven.project; /* * 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.util.ArrayList; import java.util.Collections; import java.util.List; import junit.framework.TestCase; import org.apache.maven.model.Build; import org.apache.maven.model.Dependency; import org.apache.maven.model.Extension; import org.apache.maven.model.Model; import org.apache.maven.model.Parent; import org.apache.maven.model.Plugin; import org.apache.maven.model.PluginManagement; import org.codehaus.plexus.util.dag.CycleDetectedException; /** * Test sorting projects by dependencies. * * @author Brett Porter */ public class ProjectSorterTest extends TestCase { private Parent createParent( MavenProject project ) { return createParent( project.getGroupId(), project.getArtifactId(), project.getVersion() ); } private Parent createParent( String groupId, String artifactId, String version ) { Parent plugin = new Parent(); plugin.setGroupId( groupId ); plugin.setArtifactId( artifactId ); plugin.setVersion( version ); return plugin; } private Dependency createDependency( MavenProject project ) { return createDependency( project.getGroupId(), project.getArtifactId(), project.getVersion() ); } private Dependency createDependency( String groupId, String artifactId, String version ) { Dependency dependency = new Dependency(); dependency.setGroupId( groupId ); dependency.setArtifactId( artifactId ); dependency.setVersion( version ); return dependency; } private Plugin createPlugin( MavenProject project ) { return createPlugin( project.getGroupId(), project.getArtifactId(), project.getVersion() ); } private Plugin createPlugin( String groupId, String artifactId, String version ) { Plugin plugin = new Plugin(); plugin.setGroupId( groupId ); plugin.setArtifactId( artifactId ); plugin.setVersion( version ); return plugin; } private Extension createExtension( String groupId, String artifactId, String version ) { Extension extension = new Extension(); extension.setGroupId( groupId ); extension.setArtifactId( artifactId ); extension.setVersion( version ); return extension; } private static MavenProject createProject( String groupId, String artifactId, String version ) { Model model = new Model(); model.setGroupId( groupId ); model.setArtifactId( artifactId ); model.setVersion( version ); model.setBuild( new Build() ); return new MavenProject( model ); } public void testShouldNotFailWhenPluginDepReferencesCurrentProject() throws CycleDetectedException, DuplicateProjectException { MavenProject project = createProject( "group", "artifact", "1.0" ); Build build = project.getModel().getBuild(); Plugin plugin = createPlugin( "other.group", "other-artifact", "1.0" ); Dependency dep = createDependency( "group", "artifact", "1.0" ); plugin.addDependency( dep ); build.addPlugin( plugin ); new ProjectSorter( Collections.singletonList( project ) ); } public void testShouldNotFailWhenManagedPluginDepReferencesCurrentProject() throws CycleDetectedException, DuplicateProjectException { MavenProject project = createProject( "group", "artifact", "1.0" ); Build build = project.getModel().getBuild(); PluginManagement pMgmt = new PluginManagement(); Plugin plugin = createPlugin( "other.group", "other-artifact", "1.0" ); Dependency dep = createDependency( "group", "artifact", "1.0" ); plugin.addDependency( dep ); pMgmt.addPlugin( plugin ); build.setPluginManagement( pMgmt ); new ProjectSorter( Collections.singletonList( project ) ); } public void testShouldNotFailWhenProjectReferencesNonExistentProject() throws CycleDetectedException, DuplicateProjectException { MavenProject project = createProject( "group", "artifact", "1.0" ); Build build = project.getModel().getBuild(); Extension extension = createExtension( "other.group", "other-artifact", "1.0" ); build.addExtension( extension ); new ProjectSorter( Collections.singletonList( project ) ); } public void testMatchingArtifactIdsDifferentGroupIds() throws CycleDetectedException, DuplicateProjectException { List projects = new ArrayList<>(); MavenProject project1 = createProject( "groupId1", "artifactId", "1.0" ); projects.add( project1 ); MavenProject project2 = createProject( "groupId2", "artifactId", "1.0" ); projects.add( project2 ); project1.getDependencies().add( createDependency( project2 ) ); projects = new ProjectSorter( projects ).getSortedProjects(); assertEquals( project2, projects.get( 0 ) ); assertEquals( project1, projects.get( 1 ) ); } public void testMatchingGroupIdsDifferentArtifactIds() throws CycleDetectedException, DuplicateProjectException { List projects = new ArrayList<>(); MavenProject project1 = createProject( "groupId", "artifactId1", "1.0" ); projects.add( project1 ); MavenProject project2 = createProject( "groupId", "artifactId2", "1.0" ); projects.add( project2 ); project1.getDependencies().add( createDependency( project2 ) ); projects = new ProjectSorter( projects ).getSortedProjects(); assertEquals( project2, projects.get( 0 ) ); assertEquals( project1, projects.get( 1 ) ); } public void testMatchingIdsAndVersions() throws CycleDetectedException { List projects = new ArrayList<>(); MavenProject project1 = createProject( "groupId", "artifactId", "1.0" ); projects.add( project1 ); MavenProject project2 = createProject( "groupId", "artifactId", "1.0" ); projects.add( project2 ); try { projects = new ProjectSorter( projects ).getSortedProjects(); fail( "Duplicate projects should fail" ); } catch ( DuplicateProjectException e ) { // expected assertTrue( true ); } } public void testMatchingIdsAndDifferentVersions() throws CycleDetectedException, DuplicateProjectException { List projects = new ArrayList<>(); MavenProject project1 = createProject( "groupId", "artifactId", "1.0" ); projects.add( project1 ); MavenProject project2 = createProject( "groupId", "artifactId", "2.0" ); projects.add( project2 ); projects = new ProjectSorter( projects ).getSortedProjects(); assertEquals( project1, projects.get( 0 ) ); assertEquals( project2, projects.get( 1 ) ); } public void testPluginDependenciesInfluenceSorting() throws Exception { List projects = new ArrayList<>(); MavenProject parentProject = createProject( "groupId", "parent", "1.0" ); projects.add( parentProject ); MavenProject declaringProject = createProject( "groupId", "declarer", "1.0" ); declaringProject.setParent( parentProject ); declaringProject.getModel().setParent( createParent( parentProject ) ); projects.add( declaringProject ); MavenProject pluginLevelDepProject = createProject( "groupId", "plugin-level-dep", "1.0" ); pluginLevelDepProject.setParent( parentProject ); pluginLevelDepProject.getModel().setParent( createParent( parentProject ) ); projects.add( pluginLevelDepProject ); MavenProject pluginProject = createProject( "groupId", "plugin", "1.0" ); pluginProject.setParent( parentProject ); pluginProject.getModel().setParent( createParent( parentProject ) ); projects.add( pluginProject ); Plugin plugin = createPlugin( pluginProject ); plugin.addDependency( createDependency( pluginLevelDepProject ) ); Build build = declaringProject.getModel().getBuild(); build.addPlugin( plugin ); projects = new ProjectSorter( projects ).getSortedProjects(); assertEquals( parentProject, projects.get( 0 ) ); // the order of these two is non-deterministic, based on when they're added to the reactor. assertTrue( projects.contains( pluginProject ) ); assertTrue( projects.contains( pluginLevelDepProject ) ); // the declaring project MUST be listed after the plugin and its plugin-level dep, though. assertEquals( declaringProject, projects.get( 3 ) ); } public void testPluginDependenciesInfluenceSorting_DeclarationInParent() throws Exception { List projects = new ArrayList<>(); MavenProject parentProject = createProject( "groupId", "parent-declarer", "1.0" ); projects.add( parentProject ); MavenProject pluginProject = createProject( "groupId", "plugin", "1.0" ); pluginProject.setParent( parentProject ); pluginProject.getModel().setParent( createParent( parentProject ) ); projects.add( pluginProject ); MavenProject pluginLevelDepProject = createProject( "groupId", "plugin-level-dep", "1.0" ); pluginLevelDepProject.setParent( parentProject ); pluginLevelDepProject.getModel().setParent( createParent( parentProject ) ); projects.add( pluginLevelDepProject ); Plugin plugin = createPlugin( pluginProject ); plugin.addDependency( createDependency( pluginLevelDepProject ) ); Build build = parentProject.getModel().getBuild(); build.addPlugin( plugin ); projects = new ProjectSorter( projects ).getSortedProjects(); System.out.println( projects ); assertEquals( parentProject, projects.get( 0 ) ); // the order of these two is non-deterministic, based on when they're added to the reactor. assertTrue( projects.contains( pluginProject ) ); assertTrue( projects.contains( pluginLevelDepProject ) ); } public void testPluginVersionsAreConsidered() throws Exception { List projects = new ArrayList<>(); MavenProject pluginProjectA = createProject( "group", "plugin-a", "2.0-SNAPSHOT" ); projects.add( pluginProjectA ); pluginProjectA.getModel().getBuild().addPlugin( createPlugin( "group", "plugin-b", "1.0" ) ); MavenProject pluginProjectB = createProject( "group", "plugin-b", "2.0-SNAPSHOT" ); projects.add( pluginProjectB ); pluginProjectB.getModel().getBuild().addPlugin( createPlugin( "group", "plugin-a", "1.0" ) ); projects = new ProjectSorter( projects ).getSortedProjects(); assertTrue( projects.contains( pluginProjectA ) ); assertTrue( projects.contains( pluginProjectB ) ); } public void testDependencyPrecedesProjectThatUsesSpecificDependencyVersion() throws Exception { List projects = new ArrayList<>(); MavenProject usingProject = createProject( "group", "project", "1.0" ); projects.add( usingProject ); usingProject.getModel().addDependency( createDependency( "group", "dependency", "1.0" ) ); MavenProject pluginProject = createProject( "group", "dependency", "1.0" ); projects.add( pluginProject ); projects = new ProjectSorter( projects ).getSortedProjects(); assertEquals( pluginProject, projects.get( 0 ) ); assertEquals( usingProject, projects.get( 1 ) ); } public void testDependencyPrecedesProjectThatUsesUnresolvedDependencyVersion() throws Exception { List projects = new ArrayList<>(); MavenProject usingProject = createProject( "group", "project", "1.0" ); projects.add( usingProject ); usingProject.getModel().addDependency( createDependency( "group", "dependency", "[1.0,)" ) ); MavenProject pluginProject = createProject( "group", "dependency", "1.0" ); projects.add( pluginProject ); projects = new ProjectSorter( projects ).getSortedProjects(); assertEquals( pluginProject, projects.get( 0 ) ); assertEquals( usingProject, projects.get( 1 ) ); } } maven-maven-3.5.2/maven-core/src/test/java/org/apache/maven/project/TestMetadataSource.java000066400000000000000000000036251317160430700316560ustar00rootroot00000000000000package org.apache.maven.project; /* * 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.util.List; import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException; import org.apache.maven.artifact.metadata.ArtifactMetadataSource; import org.apache.maven.artifact.metadata.ResolutionGroup; import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.project.artifact.MavenMetadataSource; import org.codehaus.plexus.component.annotations.Component; @SuppressWarnings( "deprecation" ) @Component( role = ArtifactMetadataSource.class, hint = "classpath" ) public class TestMetadataSource extends MavenMetadataSource { @Override public ResolutionGroup retrieve( Artifact artifact, ArtifactRepository localRepository, List remoteRepositories ) throws ArtifactMetadataRetrievalException { ResolutionGroup rg = super.retrieve( artifact, localRepository, remoteRepositories ); for ( Artifact a : rg.getArtifacts() ) { a.setResolved( true ); } return rg; } }maven-maven-3.5.2/maven-core/src/test/java/org/apache/maven/project/artifact/000077500000000000000000000000001317160430700270415ustar00rootroot00000000000000DefaultMavenMetadataCacheTest.java000066400000000000000000000060151317160430700354270ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/java/org/apache/maven/project/artifactpackage org.apache.maven.project.artifact; /* * 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.util.Arrays; import java.util.Collections; import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.resolver.filter.ExcludesArtifactFilter; import org.apache.maven.project.artifact.DefaultMavenMetadataCache.CacheKey; import org.apache.maven.repository.DelegatingLocalArtifactRepository; import org.apache.maven.repository.RepositorySystem; import org.codehaus.plexus.PlexusTestCase; /** * @author Igor Fedorenko */ public class DefaultMavenMetadataCacheTest extends PlexusTestCase { private RepositorySystem repositorySystem; protected void setUp() throws Exception { super.setUp(); repositorySystem = lookup( RepositorySystem.class ); } @Override protected void tearDown() throws Exception { repositorySystem = null; super.tearDown(); } public void testCacheKey() throws Exception { Artifact a1 = repositorySystem.createArtifact( "testGroup", "testArtifact", "1.2.3", "jar" ); @SuppressWarnings( "deprecation" ) ArtifactRepository lr1 = new DelegatingLocalArtifactRepository( repositorySystem.createDefaultLocalRepository() ); ArtifactRepository rr1 = repositorySystem.createDefaultRemoteRepository(); a1.setDependencyFilter( new ExcludesArtifactFilter( Arrays.asList( "foo" ) ) ); Artifact a2 = repositorySystem.createArtifact( "testGroup", "testArtifact", "1.2.3", "jar" ); @SuppressWarnings( "deprecation" ) ArtifactRepository lr2 = new DelegatingLocalArtifactRepository( repositorySystem.createDefaultLocalRepository() ); ArtifactRepository rr2 = repositorySystem.createDefaultRemoteRepository(); a2.setDependencyFilter( new ExcludesArtifactFilter( Arrays.asList( "foo" ) ) ); // sanity checks assertNotSame( a1, a2 ); assertNotSame( lr1, lr2 ); assertNotSame( rr1, rr2 ); CacheKey k1 = new CacheKey( a1, false, lr1, Collections.singletonList( rr1 ) ); CacheKey k2 = new CacheKey( a2, false, lr2, Collections.singletonList( rr2 ) ); assertEquals(k1.hashCode(), k2.hashCode()); } } MavenMetadataSourceTest.java000066400000000000000000000133361317160430700343630ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/java/org/apache/maven/project/artifactpackage org.apache.maven.project.artifact; /* * 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 org.apache.maven.repository.RepositorySystem; import org.codehaus.plexus.PlexusTestCase; public class MavenMetadataSourceTest extends PlexusTestCase { private RepositorySystem repositorySystem; protected void setUp() throws Exception { super.setUp(); repositorySystem = lookup( RepositorySystem.class ); } @Override protected void tearDown() throws Exception { repositorySystem = null; super.tearDown(); } public void testShouldNotCarryExclusionsOverFromDependencyToDependency() throws Exception { /* Dependency dep1 = new Dependency(); dep1.setGroupId( "test" ); dep1.setArtifactId( "test-artifact" ); dep1.setVersion( "1" ); dep1.setType( "jar" ); Exclusion exc = new Exclusion(); exc.setGroupId( "test" ); exc.setArtifactId( "test-artifact3" ); dep1.addExclusion( exc ); Dependency dep2 = new Dependency(); dep2.setGroupId( "test" ); dep2.setArtifactId( "test-artifact2" ); dep2.setVersion( "1" ); dep2.setType( "jar" ); List deps = new ArrayList(); deps.add( dep1 ); deps.add( dep2 ); ArtifactFactory factory = lookup( ArtifactFactory.class ); ArtifactFilter dependencyFilter = new ScopeArtifactFilter( Artifact.SCOPE_COMPILE ); MavenProject project = new MavenProject( new Model() ); Set result = project.createArtifacts( dependencyFilter ); for ( Iterator it = result.iterator(); it.hasNext(); ) { Artifact artifact = ( Artifact ) it.next(); if ( "test-artifact2".equals( artifact.getArtifactId() ) ) { ArtifactFilter filter = artifact.getDependencyFilter(); assertSame( dependencyFilter, filter ); } } */ } //TODO restore these if it makes sense /* public void testShouldUseCompileScopeIfDependencyScopeEmpty() throws Exception { String groupId = "org.apache.maven"; String artifactId = "maven-model"; Dependency dep = new Dependency(); dep.setGroupId( groupId ); dep.setArtifactId( artifactId ); dep.setVersion( "2.0-alpha-3" ); Model model = new Model(); model.addDependency( dep ); MavenProject project = new MavenProject( model, repositorySystem ); project.setArtifacts( project.createArtifacts( null ) ); String key = ArtifactUtils.versionlessKey( groupId, artifactId ); Map artifactMap = project.getArtifactMap(); assertNotNull( "artifact-map should not be null.", artifactMap ); assertEquals( "artifact-map should contain 1 element.", 1, artifactMap.size() ); Artifact artifact = (Artifact) artifactMap.get( key ); assertNotNull( "dependency artifact not found in map.", artifact ); assertEquals( "dependency artifact has wrong scope.", Artifact.SCOPE_COMPILE, artifact.getScope() ); //check for back-propagation of default scope. assertEquals( "default scope NOT back-propagated to dependency.", Artifact.SCOPE_COMPILE, dep.getScope() ); } public void testShouldUseInjectedTestScopeFromDependencyManagement() throws Exception { String groupId = "org.apache.maven"; String artifactId = "maven-model"; Dependency dep = new Dependency(); dep.setGroupId( groupId ); dep.setArtifactId( artifactId ); dep.setVersion( "2.0-alpha-3" ); Model model = new Model(); model.addDependency( dep ); Dependency mgd = new Dependency(); mgd.setGroupId( groupId ); mgd.setArtifactId( artifactId ); mgd.setScope( Artifact.SCOPE_TEST ); DependencyManagement depMgmt = new DependencyManagement(); depMgmt.addDependency( mgd ); model.setDependencyManagement( depMgmt ); MavenProject project = new MavenProject( model, repositorySystem ); TestModelDefaultsInjector injector = new TestModelDefaultsInjector(); injector.injectDefaults( model ); project.setArtifacts( project.createArtifacts( null ) ); String key = ArtifactUtils.versionlessKey( groupId, artifactId ); Map artifactMap = project.getArtifactMap(); assertNotNull( "artifact-map should not be null.", artifactMap ); assertEquals( "artifact-map should contain 1 element.", 1, artifactMap.size() ); Artifact artifact = (Artifact) artifactMap.get( key ); assertNotNull( "dependency artifact not found in map.", artifact ); assertEquals( "dependency artifact has wrong scope.", Artifact.SCOPE_TEST, artifact.getScope() ); //check for back-propagation of default scope. assertEquals( "default scope NOT back-propagated to dependency.", Artifact.SCOPE_TEST, dep.getScope() ); } */ } maven-maven-3.5.2/maven-core/src/test/java/org/apache/maven/project/canonical/000077500000000000000000000000001317160430700271735ustar00rootroot00000000000000CanonicalProjectBuilderTest.java000066400000000000000000000065211317160430700353500ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/java/org/apache/maven/project/canonicalpackage org.apache.maven.project.canonical; /* * 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.File; import java.util.List; import org.apache.maven.model.Plugin; import org.apache.maven.model.PluginExecution; import org.apache.maven.project.AbstractMavenProjectTestCase; import org.apache.maven.project.MavenProject; import org.codehaus.plexus.util.xml.Xpp3Dom; /** * @author Jason van Zyl */ public class CanonicalProjectBuilderTest extends AbstractMavenProjectTestCase { public void testProjectBuilder() throws Exception { File f = getFileForClasspathResource( "canonical-pom.xml" ); MavenProject project = getProject( f ); // ---------------------------------------------------------------------- // Top-level elements // ---------------------------------------------------------------------- assertEquals( "4.0.0", project.getModelVersion() ); // ---------------------------------------------------------------------- // Plugins // ---------------------------------------------------------------------- List plugins = project.getBuildPlugins(); // Plugin0 [plexus] String key = "org.apache.maven.plugins:maven-plexus-plugin"; Plugin plugin = null; for ( Plugin check : plugins ) { if ( key.equals( check.getKey() ) ) { plugin = check; break; } } assertNotNull( plugin ); assertEquals( "1.0", plugin.getVersion() ); Xpp3Dom configuration = (Xpp3Dom) plugin.getConfiguration(); assertEquals( "src/conf/plexus.conf", configuration.getChild( "plexusConfiguration" ).getValue() ); assertEquals( "src/conf/plexus.properties", configuration.getChild( "plexusConfigurationPropertiesFile" ).getValue() ); assertEquals( "Continuum", configuration.getChild( "plexusApplicationName" ).getValue() ); // ---------------------------------------------------------------------- // Goal specific configuration // ---------------------------------------------------------------------- List executions = plugin.getExecutions(); PluginExecution execution = executions.get( 0 ); String g0 = execution.getGoals().get( 0 ); assertEquals( "plexus:runtime", g0 ); configuration = (Xpp3Dom) execution.getConfiguration(); assertEquals( "ContinuumPro", configuration.getChild( "plexusApplicationName" ).getValue() ); // Plugin1 [antlr] } } maven-maven-3.5.2/maven-core/src/test/java/org/apache/maven/project/harness/000077500000000000000000000000001317160430700267075ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/java/org/apache/maven/project/harness/PomTestWrapper.java000066400000000000000000000063171317160430700325150ustar00rootroot00000000000000package org.apache.maven.project.harness; /* * 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.File; import java.util.Iterator; import org.apache.commons.jxpath.JXPathContext; import org.apache.commons.jxpath.JXPathNotFoundException; import org.apache.commons.jxpath.ri.JXPathContextReferenceImpl; import org.apache.commons.lang3.Validate; import org.apache.maven.project.MavenProject; public class PomTestWrapper { private File pomFile; private JXPathContext context; private MavenProject mavenProject; static { JXPathContextReferenceImpl.addNodePointerFactory( new Xpp3DomPointerFactory() ); } public PomTestWrapper( File pomFile, MavenProject mavenProject ) { this.mavenProject = Validate.notNull( mavenProject, "mavenProject cannot be null" ); this.pomFile = pomFile; context = JXPathContext.newContext( mavenProject.getModel() ); } public PomTestWrapper( MavenProject mavenProject ) { this.mavenProject = Validate.notNull( mavenProject, "mavenProject cannot be null" ); context = JXPathContext.newContext( mavenProject.getModel() ); } public MavenProject getMavenProject() { return mavenProject; } public File getBasedir() { return ( pomFile != null ) ? pomFile.getParentFile() : null; } public void setValueOnModel( String expression, Object value ) { context.setValue( expression, value ); } /* public int containerCountForUri( String uri ) throws IOException { Validate.notEmpty( uri, "uri can neither be null nor empty " ); ModelDataSource source = new DefaultModelDataSource(); source.init( domainModel.getModelProperties(), null ); return source.queryFor( uri ).size(); } */ public Iterator getIteratorForXPathExpression( String expression ) { return context.iterate( expression ); } public boolean containsXPathExpression( String expression ) { return context.getValue( expression ) != null; } public Object getValue( String expression ) { try { return context.getValue( expression ); } catch ( JXPathNotFoundException e ) { return null; } } public boolean xPathExpressionEqualsValue( String expression, String value ) { return context.getValue( expression ) != null && context.getValue( expression ).equals( value ); } } Xpp3DomAttributeIterator.java000066400000000000000000000051111317160430700343610ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/java/org/apache/maven/project/harnesspackage org.apache.maven.project.harness; /* * 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.util.ArrayList; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import org.apache.commons.jxpath.ri.QName; import org.apache.commons.jxpath.ri.model.NodeIterator; import org.apache.commons.jxpath.ri.model.NodePointer; import org.codehaus.plexus.util.xml.Xpp3Dom; /** * An attribute iterator for JXPath to support Xpp3Dom. * * @author Benjamin Bentmann */ class Xpp3DomAttributeIterator implements NodeIterator { private NodePointer parent; private Xpp3Dom node; private List> attributes; private Map.Entry attribute; private int position; public Xpp3DomAttributeIterator( NodePointer parent, QName qname ) { this.parent = parent; this.node = (Xpp3Dom) parent.getNode(); Map map = new LinkedHashMap<>(); for ( String name : this.node.getAttributeNames() ) { if ( name.equals( qname.getName() ) || "*".equals( qname.getName() ) ) { String value = this.node.getAttribute( name ); map.put( name, value ); } } this.attributes = new ArrayList<>( map.entrySet() ); } public NodePointer getNodePointer() { if ( position == 0 ) { setPosition( 1 ); } return ( attribute == null ) ? null : new Xpp3DomAttributePointer( parent, attribute ); } public int getPosition() { return position; } public boolean setPosition( int position ) { this.position = position; attribute = ( position > 0 && position <= attributes.size() ) ? attributes.get( position - 1 ) : null; return attribute != null; } } Xpp3DomAttributePointer.java000066400000000000000000000044411317160430700342150ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/java/org/apache/maven/project/harnesspackage org.apache.maven.project.harness; /* * 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.util.Map; import org.apache.commons.jxpath.ri.QName; import org.apache.commons.jxpath.ri.model.NodePointer; /** * An attribute pointer for JXPath to support Xpp3Dom. * * @author Benjamin Bentmann */ class Xpp3DomAttributePointer extends NodePointer { private Map.Entry attrib; public Xpp3DomAttributePointer( NodePointer parent, Map.Entry attrib ) { super( parent ); this.attrib = attrib; } @Override public int compareChildNodePointers( NodePointer pointer1, NodePointer pointer2 ) { // should never happen because attributes have no children return 0; } @Override public Object getValue() { return attrib.getValue(); } @Override public Object getBaseValue() { return attrib; } @Override public Object getImmediateNode() { return attrib; } @Override public int getLength() { return 1; } @Override public QName getName() { return new QName( null, attrib.getKey() ); } @Override public boolean isActual() { return true; } @Override public boolean isCollection() { return false; } @Override public boolean isLeaf() { return true; } @Override public void setValue( Object value ) { throw new UnsupportedOperationException(); } } maven-maven-3.5.2/maven-core/src/test/java/org/apache/maven/project/harness/Xpp3DomNodeIterator.java000066400000000000000000000113451317160430700333700ustar00rootroot00000000000000package org.apache.maven.project.harness; /* * 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.util.ArrayList; import java.util.List; import org.apache.commons.jxpath.ri.Compiler; import org.apache.commons.jxpath.ri.compiler.NodeNameTest; import org.apache.commons.jxpath.ri.compiler.NodeTest; import org.apache.commons.jxpath.ri.compiler.NodeTypeTest; import org.apache.commons.jxpath.ri.model.NodeIterator; import org.apache.commons.jxpath.ri.model.NodePointer; import org.codehaus.plexus.util.StringUtils; import org.codehaus.plexus.util.xml.Xpp3Dom; /** * A node iterator for JXPath to support Xpp3Dom. * * @author Benjamin Bentmann */ class Xpp3DomNodeIterator implements NodeIterator { private NodePointer parent; private NodeTest test; private Xpp3Dom node; private Xpp3Dom[] children; private List filteredChildren = new ArrayList<>(); private int filteredIndex; private Xpp3Dom child; private int position; public Xpp3DomNodeIterator( NodePointer parent, NodeTest test, boolean reverse, NodePointer startWith ) { this.parent = parent; this.node = (Xpp3Dom) parent.getNode(); this.children = this.node.getChildren(); if ( startWith != null ) { Xpp3Dom startWithNode = (Xpp3Dom) startWith.getNode(); for ( ; filteredIndex < children.length; filteredIndex++ ) { if ( startWithNode.equals( children[filteredIndex] ) ) { filteredIndex++; break; } } } this.test = test; if ( reverse ) { throw new UnsupportedOperationException(); } } public NodePointer getNodePointer() { if ( position == 0 ) { setPosition( 1 ); } return ( child == null ) ? null : new Xpp3DomNodePointer( parent, child ); } public int getPosition() { return position; } public boolean setPosition( int position ) { this.position = position; filterChildren( position ); child = ( position > 0 && position <= filteredChildren.size() ) ? filteredChildren.get( position - 1 ) : null; return child != null; } private void filterChildren( int position ) { for ( ; position > filteredChildren.size() && filteredIndex < children.length; filteredIndex++ ) { Xpp3Dom child = children[filteredIndex]; if ( testNode( child ) ) { filteredChildren.add( child ); } } } private boolean testNode( Xpp3Dom node ) { if ( test == null ) { return true; } if ( test instanceof NodeNameTest ) { String nodeName = node.getName(); if ( StringUtils.isEmpty( nodeName ) ) { return false; } NodeNameTest nodeNameTest = (NodeNameTest) test; String namespaceURI = nodeNameTest.getNamespaceURI(); boolean wildcard = nodeNameTest.isWildcard(); String testName = nodeNameTest.getNodeName().getName(); String testPrefix = nodeNameTest.getNodeName().getPrefix(); if ( wildcard && testPrefix == null ) { return true; } if ( wildcard || testName.equals( nodeName ) ) { return StringUtils.isEmpty( namespaceURI ) || StringUtils.isEmpty( testPrefix ); } return false; } if ( test instanceof NodeTypeTest ) { switch ( ( (NodeTypeTest) test ).getNodeType() ) { case Compiler.NODE_TYPE_NODE: return true; case Compiler.NODE_TYPE_TEXT: return node.getValue() != null; default: return false; } } return false; } } maven-maven-3.5.2/maven-core/src/test/java/org/apache/maven/project/harness/Xpp3DomNodePointer.java000066400000000000000000000071651317160430700332240ustar00rootroot00000000000000package org.apache.maven.project.harness; /* * 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.util.ArrayList; import java.util.List; import org.apache.commons.jxpath.ri.QName; import org.apache.commons.jxpath.ri.compiler.NodeTest; import org.apache.commons.jxpath.ri.model.NodeIterator; import org.apache.commons.jxpath.ri.model.NodePointer; import org.codehaus.plexus.util.xml.Xpp3Dom; /** * A node pointer for JXPath to support Xpp3Dom. * * @author Benjamin Bentmann */ class Xpp3DomNodePointer extends NodePointer { private Xpp3Dom node; public Xpp3DomNodePointer( Xpp3Dom node ) { super( null ); this.node = node; } public Xpp3DomNodePointer( NodePointer parent, Xpp3Dom node ) { super( parent ); this.node = node; } @Override public int compareChildNodePointers( NodePointer pointer1, NodePointer pointer2 ) { Xpp3Dom node1 = (Xpp3Dom) pointer1.getBaseValue(); Xpp3Dom node2 = (Xpp3Dom) pointer2.getBaseValue(); if ( node1 == node2 ) { return 0; } for ( int i = 0; i < node.getChildCount(); i++ ) { Xpp3Dom child = node.getChild( i ); if ( child == node1 ) { return -1; } if ( child == node2 ) { return 1; } } return 0; } @Override public Object getValue() { return getValue( node ); } private static Object getValue( Xpp3Dom node ) { if ( node.getValue() != null ) { return node.getValue(); } else { List children = new ArrayList<>(); for ( int i = 0; i < node.getChildCount(); i++ ) { children.add( getValue( node.getChild( i ) ) ); } return children; } } @Override public Object getBaseValue() { return node; } @Override public Object getImmediateNode() { return node; } @Override public int getLength() { return 1; } @Override public QName getName() { return new QName( null, node.getName() ); } @Override public boolean isCollection() { return false; } @Override public boolean isLeaf() { return node.getChildCount() <= 0; } @Override public void setValue( Object value ) { throw new UnsupportedOperationException(); } @Override public NodeIterator childIterator( NodeTest test, boolean reverse, NodePointer startWith ) { return new Xpp3DomNodeIterator( this, test, reverse, startWith ); } @Override public NodeIterator attributeIterator( QName qname ) { return new Xpp3DomAttributeIterator( this, qname ); } } Xpp3DomPointerFactory.java000066400000000000000000000034411317160430700336600ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/java/org/apache/maven/project/harnesspackage org.apache.maven.project.harness; /* * 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.util.Locale; import org.apache.commons.jxpath.ri.QName; import org.apache.commons.jxpath.ri.model.NodePointer; import org.apache.commons.jxpath.ri.model.NodePointerFactory; import org.codehaus.plexus.util.xml.Xpp3Dom; /** * A node pointer factory for JXPath to support Xpp3Dom. * * @author Benjamin Bentmann */ public class Xpp3DomPointerFactory implements NodePointerFactory { public int getOrder() { return 200; } public NodePointer createNodePointer( QName name, Object object, Locale locale ) { if ( object instanceof Xpp3Dom ) { return new Xpp3DomNodePointer( (Xpp3Dom) object ); } return null; } public NodePointer createNodePointer( NodePointer parent, QName name, Object object ) { if ( object instanceof Xpp3Dom ) { return new Xpp3DomNodePointer( parent, (Xpp3Dom) object ); } return null; } } maven-maven-3.5.2/maven-core/src/test/java/org/apache/maven/repository/000077500000000000000000000000001317160430700260155ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/java/org/apache/maven/repository/LegacyRepositoryLayout.java000066400000000000000000000060211317160430700333610ustar00rootroot00000000000000package org.apache.maven.repository; /* * 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 org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.handler.ArtifactHandler; import org.apache.maven.artifact.metadata.ArtifactMetadata; import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout; import org.codehaus.plexus.component.annotations.Component; /** * @author jdcasey */ @Component(role=ArtifactRepositoryLayout.class, hint="legacy") public class LegacyRepositoryLayout implements ArtifactRepositoryLayout { private static final String PATH_SEPARATOR = "/"; public String getId() { return "legacy"; } public String pathOf( Artifact artifact ) { ArtifactHandler artifactHandler = artifact.getArtifactHandler(); StringBuilder path = new StringBuilder( 128 ); path.append( artifact.getGroupId() ).append( '/' ); path.append( artifactHandler.getDirectory() ).append( '/' ); path.append( artifact.getArtifactId() ).append( '-' ).append( artifact.getVersion() ); if ( artifact.hasClassifier() ) { path.append( '-' ).append( artifact.getClassifier() ); } if ( artifactHandler.getExtension() != null && artifactHandler.getExtension().length() > 0 ) { path.append( '.' ).append( artifactHandler.getExtension() ); } return path.toString(); } public String pathOfLocalRepositoryMetadata( ArtifactMetadata metadata, ArtifactRepository repository ) { return pathOfRepositoryMetadata( metadata, metadata.getLocalFilename( repository ) ); } private String pathOfRepositoryMetadata( ArtifactMetadata metadata, String filename ) { StringBuilder path = new StringBuilder( 128 ); path.append( metadata.getGroupId() ).append( PATH_SEPARATOR ).append( "poms" ).append( PATH_SEPARATOR ); path.append( filename ); return path.toString(); } public String pathOfRemoteRepositoryMetadata( ArtifactMetadata metadata ) { return pathOfRepositoryMetadata( metadata, metadata.getRemoteFilename() ); } } maven-maven-3.5.2/maven-core/src/test/java/org/apache/maven/repository/TestArtifactHandler.java000066400000000000000000000034431317160430700325570ustar00rootroot00000000000000package org.apache.maven.repository; /* * 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 org.apache.maven.artifact.handler.ArtifactHandler; /** * Assists unit testing. * * @author Benjamin Bentmann */ class TestArtifactHandler implements ArtifactHandler { private String type; private String extension; public TestArtifactHandler( String type ) { this( type, type ); } public TestArtifactHandler( String type, String extension ) { this.type = type; this.extension = extension; } public String getClassifier() { return null; } public String getDirectory() { return getPackaging() + "s"; } public String getExtension() { return extension; } public String getLanguage() { return "java"; } public String getPackaging() { return type; } public boolean isAddedToClasspath() { return true; } public boolean isIncludesDependencies() { return false; } } maven-maven-3.5.2/maven-core/src/test/java/org/apache/maven/repository/TestRepositoryConnector.java000066400000000000000000000123361317160430700335570ustar00rootroot00000000000000package org.apache.maven.repository; /* * 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.File; import java.io.IOException; import java.net.MalformedURLException; import java.net.URL; import java.util.Collection; import org.codehaus.plexus.util.FileUtils; import org.eclipse.aether.artifact.Artifact; import org.eclipse.aether.metadata.Metadata; import org.eclipse.aether.repository.RemoteRepository; import org.eclipse.aether.spi.connector.ArtifactDownload; import org.eclipse.aether.spi.connector.ArtifactUpload; import org.eclipse.aether.spi.connector.MetadataDownload; import org.eclipse.aether.spi.connector.MetadataUpload; import org.eclipse.aether.spi.connector.RepositoryConnector; import org.eclipse.aether.transfer.ArtifactNotFoundException; import org.eclipse.aether.transfer.ArtifactTransferException; import org.eclipse.aether.transfer.MetadataNotFoundException; import org.eclipse.aether.transfer.MetadataTransferException; /** * @author Benjamin Bentmann */ public class TestRepositoryConnector implements RepositoryConnector { private RemoteRepository repository; private File basedir; public TestRepositoryConnector( RemoteRepository repository ) { this.repository = repository; try { basedir = FileUtils.toFile( new URL( repository.getUrl() ) ); } catch ( MalformedURLException e ) { throw new IllegalStateException( e ); } } public void close() { } public void get( Collection artifactDownloads, Collection metadataDownloads ) { if ( artifactDownloads != null ) { for ( ArtifactDownload download : artifactDownloads ) { File remoteFile = new File( basedir, path( download.getArtifact() ) ); try { FileUtils.copyFile( remoteFile, download.getFile() ); } catch ( IOException e ) { if ( !remoteFile.exists() ) { download.setException( new ArtifactNotFoundException( download.getArtifact(), repository ) ); } else { download.setException( new ArtifactTransferException( download.getArtifact(), repository, e ) ); } } } } if ( metadataDownloads != null ) { for ( final MetadataDownload download : metadataDownloads ) { File remoteFile = new File( basedir, path( download.getMetadata() ) ); try { FileUtils.copyFile( remoteFile, download.getFile() ); } catch ( IOException e ) { if ( !remoteFile.exists() ) { download.setException( new MetadataNotFoundException( download.getMetadata(), repository ) ); } else { download.setException( new MetadataTransferException( download.getMetadata(), repository, e ) ); } } } } } private String path( Artifact artifact ) { StringBuilder path = new StringBuilder( 128 ); path.append( artifact.getGroupId().replace( '.', '/' ) ).append( '/' ); path.append( artifact.getArtifactId() ).append( '/' ); path.append( artifact.getBaseVersion() ).append( '/' ); path.append( artifact.getArtifactId() ).append( '-' ).append( artifact.getVersion() ); if ( artifact.getClassifier().length() > 0 ) { path.append( '-' ).append( artifact.getClassifier() ); } path.append( '.' ).append( artifact.getExtension() ); return path.toString(); } private String path( Metadata metadata ) { StringBuilder path = new StringBuilder( 128 ); path.append( metadata.getGroupId().replace( '.', '/' ) ).append( '/' ); path.append( metadata.getArtifactId() ).append( '/' ); path.append( "maven-metadata.xml" ); return path.toString(); } public void put( Collection artifactUploads, Collection metadataUploads ) { // TODO Auto-generated method stub } } TestRepositoryConnectorFactory.java000066400000000000000000000032351317160430700350260ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/java/org/apache/maven/repositorypackage org.apache.maven.repository; /* * 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 org.codehaus.plexus.component.annotations.Component; import org.eclipse.aether.RepositorySystemSession; import org.eclipse.aether.repository.RemoteRepository; import org.eclipse.aether.spi.connector.RepositoryConnector; import org.eclipse.aether.spi.connector.RepositoryConnectorFactory; import org.eclipse.aether.transfer.NoRepositoryConnectorException; /** * @author Benjamin Bentmann */ @Component( role = RepositoryConnectorFactory.class, hint = "test" ) public class TestRepositoryConnectorFactory implements RepositoryConnectorFactory { public RepositoryConnector newInstance( RepositorySystemSession session, RemoteRepository repository ) throws NoRepositoryConnectorException { return new TestRepositoryConnector( repository ); } public float getPriority() { return 0; } } maven-maven-3.5.2/maven-core/src/test/java/org/apache/maven/repository/TestRepositorySystem.java000066400000000000000000000276661317160430700331250ustar00rootroot00000000000000package org.apache.maven.repository; /* * 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.File; import java.io.IOException; import java.util.ArrayList; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.DefaultArtifact; import org.apache.maven.artifact.InvalidRepositoryException; import org.apache.maven.artifact.factory.ArtifactFactory; import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.repository.ArtifactRepositoryPolicy; import org.apache.maven.artifact.repository.MavenArtifactRepository; import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout; import org.apache.maven.artifact.repository.layout.DefaultRepositoryLayout; import org.apache.maven.artifact.resolver.ArtifactResolutionRequest; import org.apache.maven.artifact.resolver.ArtifactResolutionResult; import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException; import org.apache.maven.artifact.versioning.VersionRange; import org.apache.maven.model.Dependency; import org.apache.maven.model.Model; import org.apache.maven.model.Plugin; import org.apache.maven.model.Repository; import org.apache.maven.model.io.ModelReader; import org.apache.maven.project.artifact.ArtifactWithDependencies; import org.apache.maven.settings.Mirror; import org.apache.maven.settings.Proxy; import org.apache.maven.settings.Server; import org.codehaus.plexus.component.annotations.Component; import org.codehaus.plexus.component.annotations.Requirement; import org.codehaus.plexus.util.FileUtils; import org.codehaus.plexus.util.StringUtils; import org.eclipse.aether.RepositorySystemSession; /** * @author Benjamin Bentmann */ @Component( role = RepositorySystem.class ) public class TestRepositorySystem implements RepositorySystem { @Requirement private ModelReader modelReader; @Requirement private ArtifactFactory artifactFactory; public ArtifactRepository buildArtifactRepository( Repository repository ) throws InvalidRepositoryException { return new MavenArtifactRepository( repository.getId(), repository.getUrl(), new DefaultRepositoryLayout(), new ArtifactRepositoryPolicy(), new ArtifactRepositoryPolicy() ); } public Artifact createArtifact( String groupId, String artifactId, String version, String packaging ) { return createArtifact( groupId, artifactId, version, null, packaging ); } public Artifact createArtifact( String groupId, String artifactId, String version, String scope, String type ) { return new DefaultArtifact( groupId, artifactId, version, scope, type, null, new TestArtifactHandler( type ) ); } public ArtifactRepository createArtifactRepository( String id, String url, ArtifactRepositoryLayout repositoryLayout, ArtifactRepositoryPolicy snapshots, ArtifactRepositoryPolicy releases ) { return new MavenArtifactRepository( id, url, repositoryLayout, snapshots, releases ); } public Artifact createArtifactWithClassifier( String groupId, String artifactId, String version, String type, String classifier ) { return new DefaultArtifact( groupId, artifactId, version, null, type, classifier, new TestArtifactHandler( type ) ); } public ArtifactRepository createDefaultLocalRepository() throws InvalidRepositoryException { return createLocalRepository( new File( System.getProperty( "basedir", "" ), "target/local-repo" ).getAbsoluteFile() ); } public ArtifactRepository createDefaultRemoteRepository() throws InvalidRepositoryException { return new MavenArtifactRepository( DEFAULT_REMOTE_REPO_ID, "file://" + new File( System.getProperty( "basedir", "" ), "src/test/remote-repo" ).toURI().getPath(), new DefaultRepositoryLayout(), new ArtifactRepositoryPolicy(), new ArtifactRepositoryPolicy() ); } public Artifact createDependencyArtifact( Dependency dependency ) { Artifact artifact = new DefaultArtifact( dependency.getGroupId(), dependency.getArtifactId(), dependency.getVersion(), dependency.getScope(), dependency.getType(), dependency.getClassifier(), new TestArtifactHandler( dependency.getType() ) ); if ( Artifact.SCOPE_SYSTEM.equals( dependency.getScope() ) ) { artifact.setFile( new File( dependency.getSystemPath() ) ); artifact.setResolved( true ); } return artifact; } public ArtifactRepository createLocalRepository( File localRepository ) throws InvalidRepositoryException { return new MavenArtifactRepository( DEFAULT_LOCAL_REPO_ID, "file://" + localRepository.toURI().getPath(), new DefaultRepositoryLayout(), new ArtifactRepositoryPolicy(), new ArtifactRepositoryPolicy() ); } public Artifact createPluginArtifact( Plugin plugin ) { VersionRange versionRange; try { String version = plugin.getVersion(); if ( StringUtils.isEmpty( version ) ) { version = "RELEASE"; } versionRange = VersionRange.createFromVersionSpec( version ); } catch ( InvalidVersionSpecificationException e ) { return null; } return artifactFactory.createPluginArtifact( plugin.getGroupId(), plugin.getArtifactId(), versionRange ); } public Artifact createProjectArtifact( String groupId, String artifactId, String version ) { return createArtifact( groupId, artifactId, version, "pom" ); } public List getEffectiveRepositories( List repositories ) { return repositories; } public Mirror getMirror( ArtifactRepository repository, List mirrors ) { return null; } public void injectAuthentication( List repositories, List servers ) { } public void injectMirror( List repositories, List mirrors ) { } public void injectProxy( List repositories, List proxies ) { } public void publish( ArtifactRepository repository, File source, String remotePath, ArtifactTransferListener transferListener ) throws ArtifactTransferFailedException { // TODO Auto-generated method stub } public ArtifactResolutionResult resolve( ArtifactResolutionRequest request ) { ArtifactResolutionResult result = new ArtifactResolutionResult(); if ( request.isResolveRoot() ) { try { resolve( request.getArtifact(), request ); result.addArtifact( request.getArtifact() ); } catch ( IOException e ) { result.addMissingArtifact( request.getArtifact() ); } } if ( request.isResolveTransitively() ) { Map artifacts = new LinkedHashMap<>(); if ( request.getArtifactDependencies() != null ) { for ( Artifact artifact : request.getArtifactDependencies() ) { artifacts.put( artifact.getDependencyConflictId(), artifact ); } } List dependencies = new ArrayList<>(); if ( request.getArtifact() instanceof ArtifactWithDependencies ) { dependencies = ( (ArtifactWithDependencies) request.getArtifact() ).getDependencies(); } else { Artifact pomArtifact = createProjectArtifact( request.getArtifact().getGroupId(), request.getArtifact().getArtifactId(), request.getArtifact().getVersion() ); File pomFile = new File( request.getLocalRepository().getBasedir(), request.getLocalRepository().pathOf( pomArtifact ) ); try { Model model = modelReader.read( pomFile, null ); dependencies = model.getDependencies(); } catch ( IOException e ) { e.printStackTrace(); } } for ( Dependency dependency : dependencies ) { Artifact artifact = createDependencyArtifact( dependency ); if ( !artifacts.containsKey( artifact.getDependencyConflictId() ) ) { artifacts.put( artifact.getDependencyConflictId(), artifact ); } } for ( Artifact artifact : artifacts.values() ) { try { resolve( artifact, request ); result.addArtifact( artifact ); } catch ( IOException e ) { result.addMissingArtifact( artifact ); } } } return result; } private void resolve( Artifact artifact, ArtifactResolutionRequest request ) throws IOException { if ( Artifact.SCOPE_SYSTEM.equals( artifact.getScope() ) ) { return; } ArtifactRepository localRepo = request.getLocalRepository(); File localFile = new File( localRepo.getBasedir(), localRepo.pathOf( artifact ) ); artifact.setFile( localFile ); if ( !localFile.exists() ) { if ( request.getRemoteRepositories().isEmpty() ) { throw new IOException( localFile + " does not exist and no remote repositories are configured" ); } ArtifactRepository remoteRepo = request.getRemoteRepositories().get( 0 ); File remoteFile = new File( remoteRepo.getBasedir(), remoteRepo.pathOf( artifact ) ); FileUtils.copyFile( remoteFile, localFile ); } artifact.setResolved( true ); } public void retrieve( ArtifactRepository repository, File destination, String remotePath, ArtifactTransferListener transferListener ) throws ArtifactTransferFailedException, ArtifactDoesNotExistException { // TODO Auto-generated method stub } public void injectMirror( RepositorySystemSession session, List repositories ) { } public void injectProxy( RepositorySystemSession session, List repositories ) { } public void injectAuthentication( RepositorySystemSession session, List repositories ) { } } maven-maven-3.5.2/maven-core/src/test/java/org/apache/maven/rtinfo/000077500000000000000000000000001317160430700250775ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/java/org/apache/maven/rtinfo/internal/000077500000000000000000000000001317160430700267135ustar00rootroot00000000000000DefaultRuntimeInformationTest.java000066400000000000000000000045261317160430700355040ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/java/org/apache/maven/rtinfo/internalpackage org.apache.maven.rtinfo.internal; /* * 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 org.apache.maven.rtinfo.RuntimeInformation; import org.codehaus.plexus.PlexusTestCase; public class DefaultRuntimeInformationTest extends PlexusTestCase { public void testGetMavenVersion() throws Exception { RuntimeInformation rtInfo = lookup( RuntimeInformation.class ); String mavenVersion = rtInfo.getMavenVersion(); assertNotNull( mavenVersion ); assertTrue( mavenVersion.length() > 0 ); } public void testIsMavenVersion() throws Exception { RuntimeInformation rtInfo = lookup( RuntimeInformation.class ); assertTrue( rtInfo.isMavenVersion( "2.0" ) ); assertFalse( rtInfo.isMavenVersion( "9.9" ) ); assertTrue( rtInfo.isMavenVersion( "[2.0.11,2.1.0),[3.0,)" ) ); assertFalse( rtInfo.isMavenVersion( "[9.0,)" ) ); try { rtInfo.isMavenVersion( "[3.0," ); fail( "Bad version range wasn't rejected" ); } catch ( IllegalArgumentException e ) { assertTrue( true ); } try { rtInfo.isMavenVersion( "" ); fail( "Bad version range wasn't rejected" ); } catch ( IllegalArgumentException e ) { assertTrue( true ); } try { rtInfo.isMavenVersion( null ); fail( "Bad version range wasn't rejected" ); } catch ( NullPointerException e ) { assertTrue( true ); } } } maven-maven-3.5.2/maven-core/src/test/java/org/apache/maven/settings/000077500000000000000000000000001317160430700254365ustar00rootroot00000000000000PomConstructionWithSettingsTest.java000066400000000000000000000136601317160430700346130ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/java/org/apache/maven/settingspackage org.apache.maven.settings; /* * 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 org.apache.maven.artifact.repository.layout.DefaultRepositoryLayout; import org.apache.maven.model.Profile; import org.apache.maven.project.DefaultProjectBuilder; import org.apache.maven.project.DefaultProjectBuildingRequest; import org.apache.maven.project.ProjectBuilder; import org.apache.maven.project.ProjectBuildingRequest; import org.apache.maven.project.harness.PomTestWrapper; import org.apache.maven.repository.RepositorySystem; import org.apache.maven.repository.internal.MavenRepositorySystemUtils; import org.apache.maven.settings.io.xpp3.SettingsXpp3Reader; import org.codehaus.plexus.ContainerConfiguration; import org.codehaus.plexus.PlexusConstants; import org.codehaus.plexus.PlexusTestCase; import org.codehaus.plexus.util.ReaderFactory; import org.codehaus.plexus.util.xml.pull.XmlPullParserException; import org.eclipse.aether.DefaultRepositorySystemSession; import org.eclipse.aether.internal.impl.SimpleLocalRepositoryManagerFactory; import org.eclipse.aether.repository.LocalRepository; import java.io.File; import java.io.IOException; import java.io.Reader; public class PomConstructionWithSettingsTest extends PlexusTestCase { private static final String BASE_DIR = "src/test"; private static final String BASE_POM_DIR = BASE_DIR + "/resources-settings"; private DefaultProjectBuilder projectBuilder; private RepositorySystem repositorySystem; private File testDirectory; @Override protected void customizeContainerConfiguration( ContainerConfiguration containerConfiguration ) { super.customizeContainerConfiguration( containerConfiguration ); containerConfiguration.setAutoWiring( true ); containerConfiguration.setClassPathScanning( PlexusConstants.SCANNING_INDEX ); } protected void setUp() throws Exception { testDirectory = new File( getBasedir(), BASE_POM_DIR ); projectBuilder = (DefaultProjectBuilder) lookup( ProjectBuilder.class ); repositorySystem = lookup( RepositorySystem.class ); } @Override protected void tearDown() throws Exception { projectBuilder = null; super.tearDown(); } public void testSettingsNoPom() throws Exception { PomTestWrapper pom = buildPom( "settings-no-pom" ); assertEquals( "local-profile-prop-value", pom.getValue( "properties/local-profile-prop" ) ); } /** * MNG-4107 */ public void testPomAndSettingsInterpolation() throws Exception { PomTestWrapper pom = buildPom( "test-pom-and-settings-interpolation" ); assertEquals( "applied", pom.getValue( "properties/settingsProfile" ) ); assertEquals( "applied", pom.getValue( "properties/pomProfile" ) ); assertEquals( "settings", pom.getValue( "properties/pomVsSettings" ) ); assertEquals( "settings", pom.getValue( "properties/pomVsSettingsInterpolated" ) ); } /** * MNG-4107 */ public void testRepositories() throws Exception { PomTestWrapper pom = buildPom( "repositories" ); assertEquals( "maven-core-it-0", pom.getValue( "repositories[1]/id" ) ); } private PomTestWrapper buildPom( String pomPath ) throws Exception { File pomFile = new File( testDirectory + File.separator + pomPath, "pom.xml" ); File settingsFile = new File( testDirectory + File.separator + pomPath, "settings.xml" ); Settings settings = readSettingsFile( settingsFile ); ProjectBuildingRequest config = new DefaultProjectBuildingRequest(); for ( org.apache.maven.settings.Profile rawProfile : settings.getProfiles() ) { Profile profile = SettingsUtils.convertFromSettingsProfile( rawProfile ); config.addProfile( profile ); } String localRepoUrl = System.getProperty( "maven.repo.local", System.getProperty( "user.home" ) + "/.m2/repository" ); localRepoUrl = "file://" + localRepoUrl; config.setLocalRepository( repositorySystem.createArtifactRepository( "local", localRepoUrl, new DefaultRepositoryLayout(), null, null ) ); config.setActiveProfileIds( settings.getActiveProfiles() ); DefaultRepositorySystemSession repoSession = MavenRepositorySystemUtils.newSession(); LocalRepository localRepo = new LocalRepository( config.getLocalRepository().getBasedir() ); repoSession.setLocalRepositoryManager( new SimpleLocalRepositoryManagerFactory().newInstance( repoSession, localRepo ) ); config.setRepositorySession( repoSession ); return new PomTestWrapper( pomFile, projectBuilder.build( pomFile, config ).getProject() ); } private static Settings readSettingsFile( File settingsFile ) throws IOException, XmlPullParserException { Settings settings = null; try ( Reader reader = ReaderFactory.newXmlReader( settingsFile ) ) { SettingsXpp3Reader modelReader = new SettingsXpp3Reader(); settings = modelReader.read( reader ); } return settings; } } maven-maven-3.5.2/maven-core/src/test/java/org/apache/maven/settings/SettingsUtilsTest.java000066400000000000000000000132111317160430700317600ustar00rootroot00000000000000package org.apache.maven.settings; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import junit.framework.TestCase; import java.util.ArrayList; import java.util.List; import java.util.Properties; import java.util.Random; public class SettingsUtilsTest extends TestCase { public void testShouldAppendRecessivePluginGroupIds() { Settings dominant = new Settings(); dominant.addPluginGroup( "org.apache.maven.plugins" ); dominant.addPluginGroup( "org.codehaus.modello" ); Settings recessive = new Settings(); recessive.addPluginGroup( "org.codehaus.plexus" ); SettingsUtils.merge( dominant, recessive, Settings.GLOBAL_LEVEL ); List pluginGroups = dominant.getPluginGroups(); assertNotNull( pluginGroups ); assertEquals( 3, pluginGroups.size() ); assertEquals( "org.apache.maven.plugins", pluginGroups.get( 0 ) ); assertEquals( "org.codehaus.modello", pluginGroups.get( 1 ) ); assertEquals( "org.codehaus.plexus", pluginGroups.get( 2 ) ); } public void testRoundTripProfiles() { Random entropy = new Random(); Profile p = new Profile(); p.setId( "id" + Long.toHexString( entropy.nextLong() ) ); Activation a = new Activation(); a.setActiveByDefault( entropy.nextBoolean() ); a.setJdk( "jdk" + Long.toHexString( entropy.nextLong() ) ); ActivationFile af = new ActivationFile(); af.setExists( "exists" + Long.toHexString( entropy.nextLong() ) ); af.setMissing( "missing" + Long.toHexString( entropy.nextLong() ) ); a.setFile( af ); ActivationProperty ap = new ActivationProperty(); ap.setName( "name" + Long.toHexString( entropy.nextLong() ) ); ap.setValue( "value" + Long.toHexString( entropy.nextLong() ) ); a.setProperty( ap ); ActivationOS ao = new ActivationOS(); ao.setArch( "arch" + Long.toHexString( entropy.nextLong() ) ); ao.setFamily( "family" + Long.toHexString( entropy.nextLong() ) ); ao.setName( "name" + Long.toHexString( entropy.nextLong() ) ); ao.setVersion( "version" + Long.toHexString( entropy.nextLong() ) ); a.setOs( ao ); p.setActivation( a ); Properties props = new Properties(); int count = entropy.nextInt( 10 ); for ( int i = 0; i < count; i++ ) { props.setProperty( "name" + Long.toHexString( entropy.nextLong() ), "value" + Long.toHexString( entropy.nextLong() ) ); } p.setProperties( props ); count = entropy.nextInt( 3 ); List repos = new ArrayList<>(); for ( int i = 0; i < count; i++ ) { Repository r = new Repository(); r.setId( "id" + Long.toHexString( entropy.nextLong() ) ); r.setName( "name" + Long.toHexString( entropy.nextLong() ) ); r.setUrl( "url" + Long.toHexString( entropy.nextLong() ) ); repos.add( r ); } p.setRepositories( repos ); count = entropy.nextInt( 3 ); repos = new ArrayList<>(); for ( int i = 0; i < count; i++ ) { Repository r = new Repository(); r.setId( "id" + Long.toHexString( entropy.nextLong() ) ); r.setName( "name" + Long.toHexString( entropy.nextLong() ) ); r.setUrl( "url" + Long.toHexString( entropy.nextLong() ) ); repos.add( r ); } p.setPluginRepositories( repos ); Profile clone = SettingsUtils.convertToSettingsProfile( SettingsUtils.convertFromSettingsProfile( p ) ); assertEquals( p.getId(), clone.getId() ); assertEquals( p.getActivation().getJdk(), clone.getActivation().getJdk() ); assertEquals( p.getActivation().getFile().getExists(), clone.getActivation().getFile().getExists() ); assertEquals( p.getActivation().getFile().getMissing(), clone.getActivation().getFile().getMissing() ); assertEquals( p.getActivation().getProperty().getName(), clone.getActivation().getProperty().getName() ); assertEquals( p.getActivation().getProperty().getValue(), clone.getActivation().getProperty().getValue() ); assertEquals( p.getActivation().getOs().getArch(), clone.getActivation().getOs().getArch() ); assertEquals( p.getActivation().getOs().getFamily(), clone.getActivation().getOs().getFamily() ); assertEquals( p.getActivation().getOs().getName(), clone.getActivation().getOs().getName() ); assertEquals( p.getActivation().getOs().getVersion(), clone.getActivation().getOs().getVersion() ); assertEquals( p.getProperties(), clone.getProperties() ); assertEquals( p.getRepositories().size(), clone.getRepositories().size() ); // TODO deep compare the lists assertEquals( p.getPluginRepositories().size(), clone.getPluginRepositories().size() ); // TODO deep compare the lists } } maven-maven-3.5.2/maven-core/src/test/java/org/apache/maven/toolchain/000077500000000000000000000000001317160430700255565ustar00rootroot00000000000000DefaultToolchainManagerPrivateTest.java000066400000000000000000000141031317160430700352540ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/java/org/apache/maven/toolchainpackage org.apache.maven.toolchain; /* * 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.Assert.assertEquals; import static org.junit.Assert.fail; import static org.mockito.Matchers.anyString; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.never; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import org.apache.maven.execution.DefaultMavenExecutionRequest; import org.apache.maven.execution.MavenExecutionRequest; import org.apache.maven.execution.MavenSession; import org.apache.maven.toolchain.model.ToolchainModel; import org.codehaus.plexus.logging.Logger; import org.junit.Before; import org.junit.Test; import org.mockito.InjectMocks; import org.mockito.Mock; import org.mockito.MockitoAnnotations; public class DefaultToolchainManagerPrivateTest { // Mocks to inject into toolchainManager @Mock private Logger logger; @InjectMocks private DefaultToolchainManagerPrivate toolchainManager; @Mock private ToolchainFactory toolchainFactory_basicType; @Mock private ToolchainFactory toolchainFactory_rareType; @Before public void setUp() { toolchainManager = new DefaultToolchainManagerPrivate(); MockitoAnnotations.initMocks( this ); toolchainManager.factories = new HashMap<>(); toolchainManager.factories.put( "basic", toolchainFactory_basicType ); toolchainManager.factories.put( "rare", toolchainFactory_rareType ); } @Test public void testToolchainsForAvailableType() throws Exception { // prepare MavenSession session = mock( MavenSession.class ); MavenExecutionRequest req = new DefaultMavenExecutionRequest(); when( session.getRequest() ).thenReturn( req ); ToolchainPrivate basicToolchain = mock( ToolchainPrivate.class ); when( toolchainFactory_basicType.createDefaultToolchain() ).thenReturn( basicToolchain ); ToolchainPrivate rareToolchain = mock( ToolchainPrivate.class ); when( toolchainFactory_rareType.createDefaultToolchain() ).thenReturn( rareToolchain ); // execute ToolchainPrivate[] toolchains = toolchainManager.getToolchainsForType( "basic", session ); // verify verify( logger, never() ).error( anyString() ); assertEquals( 1, toolchains.length ); } @Test public void testToolchainsForUnknownType() throws Exception { // prepare MavenSession session = mock( MavenSession.class ); MavenExecutionRequest req = new DefaultMavenExecutionRequest(); when( session.getRequest() ).thenReturn( req ); ToolchainPrivate basicToolchain = mock( ToolchainPrivate.class ); when( toolchainFactory_basicType.createDefaultToolchain() ).thenReturn( basicToolchain ); ToolchainPrivate rareToolchain = mock( ToolchainPrivate.class ); when( toolchainFactory_rareType.createDefaultToolchain() ).thenReturn( rareToolchain ); // execute ToolchainPrivate[] toolchains = toolchainManager.getToolchainsForType( "unknown", session ); // verify verify( logger ).error( "Missing toolchain factory for type: unknown. Possibly caused by misconfigured project." ); assertEquals( 0, toolchains.length ); } @Test public void testToolchainsForConfiguredType() throws Exception { // prepare MavenSession session = mock( MavenSession.class ); MavenExecutionRequest req = new DefaultMavenExecutionRequest(); when( session.getRequest() ).thenReturn( req ); Map> groupedToolchains = new HashMap<>(); req.setToolchains( groupedToolchains ); List basicToolchains = new ArrayList<>(); ToolchainModel basicToolchainModel = new ToolchainModel(); basicToolchainModel.setType( "basic" ); basicToolchains.add( basicToolchainModel ); basicToolchains.add( basicToolchainModel ); groupedToolchains.put( "basic", basicToolchains ); List rareToolchains = new ArrayList<>(); ToolchainModel rareToolchainModel = new ToolchainModel(); rareToolchainModel.setType( "rare" ); rareToolchains.add( rareToolchainModel ); groupedToolchains.put( "rare", rareToolchains ); // execute ToolchainPrivate[] toolchains = toolchainManager.getToolchainsForType( "basic", session ); // verify verify( logger, never() ).error( anyString() ); assertEquals( 2, toolchains.length ); } @SuppressWarnings( "unchecked" ) @Test( expected = MisconfiguredToolchainException.class ) public void testMisconfiguredToolchain() throws Exception { // prepare MavenSession session = mock( MavenSession.class ); MavenExecutionRequest req = new DefaultMavenExecutionRequest(); when( session.getRequest() ).thenReturn( req ); when(toolchainFactory_basicType.createDefaultToolchain()).thenThrow( MisconfiguredToolchainException.class ); // execute toolchainManager.getToolchainsForType( "basic", session ); // verify fail( "Should exit with a MisconfiguredToolchainException" ); } } DefaultToolchainManagerTest.java000066400000000000000000000137651317160430700337360ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/java/org/apache/maven/toolchainpackage org.apache.maven.toolchain; /* * 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.Assert.assertEquals; import static org.mockito.Matchers.anyMap; import static org.mockito.Matchers.isA; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; import java.util.Arrays; import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; import org.apache.maven.execution.DefaultMavenExecutionRequest; import org.apache.maven.execution.MavenExecutionRequest; import org.apache.maven.execution.MavenSession; import org.apache.maven.toolchain.model.ToolchainModel; import org.codehaus.plexus.logging.Logger; import org.junit.Before; import org.junit.Test; import org.mockito.InjectMocks; import org.mockito.Mock; import org.mockito.MockitoAnnotations; public class DefaultToolchainManagerTest { // Mocks to inject into toolchainManager @Mock private Logger logger; @InjectMocks private DefaultToolchainManager toolchainManager; @Mock private ToolchainFactory toolchainFactory_basicType; @Mock private ToolchainFactory toolchainFactory_rareType; @Before public void onSetup() throws Exception { toolchainManager = new DefaultToolchainManager(); MockitoAnnotations.initMocks( this ); toolchainManager.factories = new HashMap<>(); toolchainManager.factories.put( "basic", toolchainFactory_basicType ); toolchainManager.factories.put( "rare", toolchainFactory_rareType ); } @Test public void testNoModels() { MavenSession session = mock( MavenSession.class ); MavenExecutionRequest executionRequest = new DefaultMavenExecutionRequest(); when( session.getRequest() ).thenReturn( executionRequest ); List toolchains = toolchainManager.getToolchains( session, "unknown", null ); assertEquals( 0, toolchains.size() ); } @Test public void testModelNoFactory() { MavenSession session = mock( MavenSession.class ); MavenExecutionRequest executionRequest = new DefaultMavenExecutionRequest(); Map> toolchainModels = new HashMap<>(); toolchainModels.put( "unknown", Collections.singletonList( new ToolchainModel() ) ); executionRequest.setToolchains( toolchainModels ); when( session.getRequest() ).thenReturn( executionRequest ); List toolchains = toolchainManager.getToolchains( session, "unknown", null ); assertEquals( 0, toolchains.size() ); verify( logger ).error( "Missing toolchain factory for type: unknown. Possibly caused by misconfigured project." ); } @Test public void testModelAndFactory() { MavenSession session = mock( MavenSession.class ); MavenExecutionRequest executionRequest = new DefaultMavenExecutionRequest(); Map> toolchainModels = new HashMap<>(); toolchainModels.put( "basic", Arrays.asList( new ToolchainModel(), new ToolchainModel() ) ); toolchainModels.put( "rare", Collections.singletonList( new ToolchainModel() ) ); executionRequest.setToolchains( toolchainModels ); when( session.getRequest() ).thenReturn( executionRequest ); List toolchains = toolchainManager.getToolchains( session, "rare", null ); assertEquals( 1, toolchains.size() ); } @Test public void testModelsAndFactory() { MavenSession session = mock( MavenSession.class ); MavenExecutionRequest executionRequest = new DefaultMavenExecutionRequest(); Map> toolchainModels = new HashMap<>(); toolchainModels.put( "basic", Arrays.asList( new ToolchainModel(), new ToolchainModel() ) ); toolchainModels.put( "rare", Collections.singletonList( new ToolchainModel() ) ); executionRequest.setToolchains( toolchainModels ); when( session.getRequest() ).thenReturn( executionRequest ); List toolchains = toolchainManager.getToolchains( session, "basic", null ); assertEquals( 2, toolchains.size() ); } @Test public void testRequirements() throws Exception { MavenSession session = mock( MavenSession.class ); MavenExecutionRequest executionRequest = new DefaultMavenExecutionRequest(); Map> toolchainModels = new HashMap<>(); toolchainModels.put( "basic", Arrays.asList( new ToolchainModel(), new ToolchainModel() ) ); toolchainModels.put( "rare", Collections.singletonList( new ToolchainModel() ) ); executionRequest.setToolchains( toolchainModels ); when( session.getRequest() ).thenReturn( executionRequest ); ToolchainPrivate basicPrivate = mock( ToolchainPrivate.class ); when( basicPrivate.matchesRequirements( anyMap() ) ).thenReturn( false ).thenReturn( true ); when( toolchainFactory_basicType.createToolchain( isA( ToolchainModel.class ) ) ).thenReturn( basicPrivate ); List toolchains = toolchainManager.getToolchains( session, "basic", Collections.singletonMap( "key", "value" ) ); assertEquals( 1, toolchains.size() ); } } maven-maven-3.5.2/maven-core/src/test/java/org/apache/maven/toolchain/DefaultToolchainTest.java000066400000000000000000000116331317160430700325120ustar00rootroot00000000000000package org.apache.maven.toolchain; /* * 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 org.apache.maven.toolchain.java.DefaultJavaToolChain; import org.apache.maven.toolchain.model.PersistedToolchains; import org.apache.maven.toolchain.model.ToolchainModel; import org.apache.maven.toolchain.model.io.xpp3.MavenToolchainsXpp3Reader; import org.codehaus.plexus.logging.Logger; import org.junit.Before; import org.junit.Test; import org.mockito.Mock; import org.mockito.MockitoAnnotations; import java.io.InputStream; import java.util.Collections; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; import static org.mockito.Mockito.verify; public class DefaultToolchainTest { @Mock private Logger logger; private MavenToolchainsXpp3Reader reader = new MavenToolchainsXpp3Reader(); @Before public void setUp() throws Exception { MockitoAnnotations.initMocks( this ); } private DefaultToolchain newDefaultToolchain( ToolchainModel model ) { return new DefaultToolchain( model, logger ) { @Override public String findTool( String toolName ) { return null; } }; } private DefaultToolchain newDefaultToolchain( ToolchainModel model, String type ) { return new DefaultToolchain( model, type, logger ) { @Override public String findTool( String toolName ) { return null; } }; } @Test public void testGetModel() { ToolchainModel model = new ToolchainModel(); DefaultToolchain toolchain = newDefaultToolchain( model ); assertEquals( model, toolchain.getModel() ); } @Test public void testGetType() { ToolchainModel model = new ToolchainModel(); DefaultToolchain toolchain = newDefaultToolchain( model, "TYPE" ); assertEquals( "TYPE", toolchain.getType() ); model.setType( "MODEL_TYPE" ); toolchain = newDefaultToolchain( model ); assertEquals( "MODEL_TYPE", toolchain.getType() ); } @Test public void testGetLogger() { ToolchainModel model = new ToolchainModel(); DefaultToolchain toolchain = newDefaultToolchain( model ); assertEquals( logger, toolchain.getLog() ); } @Test public void testMissingRequirementProperty() { ToolchainModel model = new ToolchainModel(); model.setType( "TYPE" ); DefaultToolchain toolchain = newDefaultToolchain( model ); assertFalse( toolchain.matchesRequirements( Collections.singletonMap( "name", "John Doe" ) ) ); verify( logger ).debug( "Toolchain type:TYPE{} is missing required property: name" ); } @Test public void testNonMatchingRequirementProperty() { ToolchainModel model = new ToolchainModel(); model.setType( "TYPE" ); DefaultToolchain toolchain = newDefaultToolchain( model ); toolchain.addProvideToken( "name", RequirementMatcherFactory.createExactMatcher( "Jane Doe" ) ); assertFalse( toolchain.matchesRequirements( Collections.singletonMap( "name", "John Doe" ) ) ); verify( logger ).debug( "Toolchain type:TYPE{name = Jane Doe} doesn't match required property: name" ); } @Test public void testEquals() throws Exception { try ( InputStream jdksIS = ToolchainModel.class.getResourceAsStream( "toolchains-jdks.xml" ); InputStream jdksExtraIS = ToolchainModel.class.getResourceAsStream( "toolchains-jdks-extra.xml" ) ) { PersistedToolchains jdks = reader.read( jdksIS ); PersistedToolchains jdksExtra = reader.read( jdksExtraIS ); DefaultToolchain tc1 = new DefaultJavaToolChain( jdks.getToolchains().get( 0 ), null ); DefaultToolchain tc2 = new DefaultJavaToolChain( jdksExtra.getToolchains().get( 0 ), null ); assertTrue( tc1.equals( tc1 ) ); assertFalse( tc1.equals( tc2 ) ); assertFalse( tc2.equals( tc1 ) ); assertTrue( tc2.equals( tc2 ) ); } } } RequirementMatcherFactoryTest.java000066400000000000000000000045401317160430700343410ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/java/org/apache/maven/toolchain/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package org.apache.maven.toolchain; import junit.framework.TestCase; /** * * @author mkleint */ public class RequirementMatcherFactoryTest extends TestCase { public RequirementMatcherFactoryTest( String testName ) { super( testName ); } /** * Test of createExactMatcher method, of class RequirementMatcherFactory. */ public void testCreateExactMatcher() { RequirementMatcher matcher; matcher = RequirementMatcherFactory.createExactMatcher( "foo" ); assertFalse( matcher.matches( "bar" ) ); assertFalse( matcher.matches( "foobar" ) ); assertFalse( matcher.matches( "foob" ) ); assertTrue( matcher.matches( "foo" ) ); } /** * Test of createVersionMatcher method, of class RequirementMatcherFactory. */ public void testCreateVersionMatcher() { RequirementMatcher matcher; matcher = RequirementMatcherFactory.createVersionMatcher( "1.5.2" ); assertFalse( matcher.matches( "1.5" ) ); assertTrue( matcher.matches( "1.5.2" ) ); assertFalse( matcher.matches( "[1.4,1.5)" ) ); assertFalse( matcher.matches( "[1.5,1.5.2)" ) ); assertFalse( matcher.matches( "(1.5.2,1.6)" ) ); assertTrue( matcher.matches( "(1.4,1.5.2]" ) ); assertTrue( matcher.matches( "(1.5,)" ) ); assertEquals( "1.5.2", matcher.toString() ); // Ensure it is not printed as 1.5.0 matcher = RequirementMatcherFactory.createVersionMatcher( "1.5" ); assertEquals( "1.5", matcher.toString() ); } } maven-maven-3.5.2/maven-core/src/test/java/org/apache/maven/toolchain/building/000077500000000000000000000000001317160430700273535ustar00rootroot00000000000000DefaultToolchainsBuilderTest.java000066400000000000000000000176251317160430700357310ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/java/org/apache/maven/toolchain/buildingpackage org.apache.maven.toolchain.building; /* * 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.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.mockito.Matchers.any; import static org.mockito.Matchers.anyMap; import static org.mockito.Mockito.when; import java.io.IOException; import java.io.InputStream; import org.apache.maven.building.StringSource; import org.apache.maven.toolchain.io.ToolchainsParseException; import org.apache.maven.toolchain.io.ToolchainsReader; import org.apache.maven.toolchain.model.PersistedToolchains; import org.apache.maven.toolchain.model.ToolchainModel; import org.junit.Before; import org.junit.Test; import org.mockito.InjectMocks; import org.mockito.Mock; import org.mockito.MockitoAnnotations; public class DefaultToolchainsBuilderTest { private static final String LS = System.getProperty( "line.separator" ); @Mock private ToolchainsReader toolchainsReader; @InjectMocks private DefaultToolchainsBuilder toolchainBuilder = new DefaultToolchainsBuilder(); @Before public void onSetup() { MockitoAnnotations.initMocks( this ); } @Test public void testBuildEmptyRequest() throws Exception { ToolchainsBuildingRequest request = new DefaultToolchainsBuildingRequest(); ToolchainsBuildingResult result = toolchainBuilder.build( request ); assertNotNull( result.getEffectiveToolchains() ); assertNotNull( result.getProblems() ); assertEquals( 0, result.getProblems().size() ); } @Test public void testBuildRequestWithUserToolchains() throws Exception { ToolchainsBuildingRequest request = new DefaultToolchainsBuildingRequest(); request.setUserToolchainsSource( new StringSource( "" ) ); PersistedToolchains userResult = new PersistedToolchains(); ToolchainModel toolchain = new ToolchainModel(); toolchain.setType( "TYPE" ); toolchain.addProvide( "key", "user_value" ); userResult.addToolchain( toolchain ); when( toolchainsReader.read( any( InputStream.class ), anyMap() ) ).thenReturn( userResult ); ToolchainsBuildingResult result = toolchainBuilder.build( request ); assertNotNull( result.getEffectiveToolchains() ); assertEquals( 1, result.getEffectiveToolchains().getToolchains().size() ); assertEquals( "TYPE", result.getEffectiveToolchains().getToolchains().get(0).getType() ); assertEquals( "user_value", result.getEffectiveToolchains().getToolchains().get(0).getProvides().getProperty( "key" ) ); assertNotNull( result.getProblems() ); assertEquals( 0, result.getProblems().size() ); } @Test public void testBuildRequestWithGlobalToolchains() throws Exception { ToolchainsBuildingRequest request = new DefaultToolchainsBuildingRequest(); request.setGlobalToolchainsSource( new StringSource( "" ) ); PersistedToolchains globalResult = new PersistedToolchains(); ToolchainModel toolchain = new ToolchainModel(); toolchain.setType( "TYPE" ); toolchain.addProvide( "key", "global_value" ); globalResult.addToolchain( toolchain ); when( toolchainsReader.read( any( InputStream.class ), anyMap() ) ).thenReturn( globalResult ); ToolchainsBuildingResult result = toolchainBuilder.build( request ); assertNotNull( result.getEffectiveToolchains() ); assertEquals( 1, result.getEffectiveToolchains().getToolchains().size() ); assertEquals( "TYPE", result.getEffectiveToolchains().getToolchains().get(0).getType() ); assertEquals( "global_value", result.getEffectiveToolchains().getToolchains().get(0).getProvides().getProperty( "key" ) ); assertNotNull( result.getProblems() ); assertEquals( 0, result.getProblems().size() ); } @Test public void testBuildRequestWithBothToolchains() throws Exception { ToolchainsBuildingRequest request = new DefaultToolchainsBuildingRequest(); request.setGlobalToolchainsSource( new StringSource( "" ) ); request.setUserToolchainsSource( new StringSource( "" ) ); PersistedToolchains userResult = new PersistedToolchains(); ToolchainModel userToolchain = new ToolchainModel(); userToolchain.setType( "TYPE" ); userToolchain.addProvide( "key", "user_value" ); userResult.addToolchain( userToolchain ); PersistedToolchains globalResult = new PersistedToolchains(); ToolchainModel globalToolchain = new ToolchainModel(); globalToolchain.setType( "TYPE" ); globalToolchain.addProvide( "key", "global_value" ); globalResult.addToolchain( globalToolchain ); when( toolchainsReader.read( any( InputStream.class ), anyMap() ) ).thenReturn( globalResult ).thenReturn( userResult ); ToolchainsBuildingResult result = toolchainBuilder.build( request ); assertNotNull( result.getEffectiveToolchains() ); assertEquals( 2, result.getEffectiveToolchains().getToolchains().size() ); assertEquals( "TYPE", result.getEffectiveToolchains().getToolchains().get(0).getType() ); assertEquals( "user_value", result.getEffectiveToolchains().getToolchains().get(0).getProvides().getProperty( "key" ) ); assertEquals( "TYPE", result.getEffectiveToolchains().getToolchains().get(1).getType() ); assertEquals( "global_value", result.getEffectiveToolchains().getToolchains().get(1).getProvides().getProperty( "key" ) ); assertNotNull( result.getProblems() ); assertEquals( 0, result.getProblems().size() ); } @Test public void testStrictToolchainsParseException() throws Exception { ToolchainsBuildingRequest request = new DefaultToolchainsBuildingRequest(); request.setGlobalToolchainsSource( new StringSource( "" ) ); ToolchainsParseException parseException = new ToolchainsParseException( "MESSAGE", 4, 2 ); when( toolchainsReader.read( any( InputStream.class ), anyMap() ) ).thenThrow( parseException ); try { toolchainBuilder.build( request ); } catch ( ToolchainsBuildingException e ) { assertEquals( "1 problem was encountered while building the effective toolchains" + LS + "[FATAL] Non-parseable toolchains (memory): MESSAGE @ line 4, column 2" + LS, e.getMessage() ); } } @Test public void testIOException() throws Exception { ToolchainsBuildingRequest request = new DefaultToolchainsBuildingRequest(); request.setGlobalToolchainsSource( new StringSource( "", "LOCATION" ) ); IOException ioException = new IOException( "MESSAGE" ); when( toolchainsReader.read( any( InputStream.class ), anyMap() ) ).thenThrow( ioException ); try { toolchainBuilder.build( request ); } catch ( ToolchainsBuildingException e ) { assertEquals( "1 problem was encountered while building the effective toolchains" + LS + "[FATAL] Non-readable toolchains LOCATION: MESSAGE" + LS, e.getMessage() ); } } } ToolchainsBuildingExceptionTest.java000066400000000000000000000060621317160430700364430ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/java/org/apache/maven/toolchain/buildingpackage org.apache.maven.toolchain.building; /* * 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.Assert.assertEquals; import java.util.Collections; import org.apache.maven.building.Problem; import org.apache.maven.building.ProblemCollector; import org.apache.maven.building.ProblemCollectorFactory; import org.junit.Test; public class ToolchainsBuildingExceptionTest { private static final String LS = System.getProperty( "line.separator" ); @Test public void testNoProblems() { ToolchainsBuildingException e = new ToolchainsBuildingException( Collections.emptyList() ); assertEquals( "0 problems were encountered while building the effective toolchains" + LS, e.getMessage() ); } @Test public void testOneProblem() { ProblemCollector problemCollector = ProblemCollectorFactory.newInstance( null ); problemCollector.add( Problem.Severity.ERROR, "MESSAGE", 3, 5, new Exception() ); ToolchainsBuildingException e = new ToolchainsBuildingException( problemCollector.getProblems() ); assertEquals( "1 problem was encountered while building the effective toolchains" + LS + "[ERROR] MESSAGE @ line 3, column 5" + LS, e.getMessage() ); } @Test public void testUnknownPositionAndSource() { ProblemCollector problemCollector = ProblemCollectorFactory.newInstance( null ); problemCollector.add( Problem.Severity.ERROR, "MESSAGE", -1, -1, new Exception() ); ToolchainsBuildingException e = new ToolchainsBuildingException( problemCollector.getProblems() ); assertEquals( "1 problem was encountered while building the effective toolchains" + LS + "[ERROR] MESSAGE" + LS, e.getMessage() ); } @Test public void testUnknownPosition() { ProblemCollector problemCollector = ProblemCollectorFactory.newInstance( null ); problemCollector.setSource( "SOURCE" ); problemCollector.add( Problem.Severity.ERROR, "MESSAGE", -1, -1, new Exception() ); ToolchainsBuildingException e = new ToolchainsBuildingException( problemCollector.getProblems() ); assertEquals( "1 problem was encountered while building the effective toolchains" + LS + "[ERROR] MESSAGE @ SOURCE" + LS, e.getMessage() ); } } maven-maven-3.5.2/maven-core/src/test/java/org/apache/maven/toolchain/merge/000077500000000000000000000000001317160430700266555ustar00rootroot00000000000000MavenToolchainMergerTest.java000066400000000000000000000136631317160430700343630ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/java/org/apache/maven/toolchain/mergepackage org.apache.maven.toolchain.merge; /* * 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 org.apache.maven.toolchain.model.PersistedToolchains; import org.apache.maven.toolchain.model.ToolchainModel; import org.apache.maven.toolchain.model.TrackableBase; import org.apache.maven.toolchain.model.io.xpp3.MavenToolchainsXpp3Reader; import org.codehaus.plexus.util.xml.Xpp3Dom; import org.junit.Test; import java.io.InputStream; import static org.junit.Assert.assertEquals; public class MavenToolchainMergerTest { private MavenToolchainMerger merger = new MavenToolchainMerger(); private MavenToolchainsXpp3Reader reader = new MavenToolchainsXpp3Reader(); @Test public void testMergeNulls() { merger.merge( null, null, null ); PersistedToolchains pt = new PersistedToolchains(); merger.merge( pt, null, null ); merger.merge( null, pt, null ); } @Test public void testMergeJdk() throws Exception { try ( InputStream isDominant = ToolchainModel.class.getResourceAsStream( "toolchains-jdks.xml" ); InputStream isRecessive = ToolchainModel.class.getResourceAsStream( "toolchains-jdks.xml" ) ) { PersistedToolchains dominant = reader.read( isDominant ); PersistedToolchains recessive = reader.read( isRecessive ); assertEquals( 2, dominant.getToolchains().size() ); merger.merge( dominant, recessive, TrackableBase.USER_LEVEL ); assertEquals( 2, dominant.getToolchains().size() ); } } @Test public void testMergeJdkExtra() throws Exception { try ( InputStream jdksIS = ToolchainModel.class.getResourceAsStream( "toolchains-jdks.xml" ); InputStream jdksExtraIS = ToolchainModel.class.getResourceAsStream( "toolchains-jdks-extra.xml" ) ) { PersistedToolchains jdks = reader.read( jdksIS ); PersistedToolchains jdksExtra = reader.read( jdksExtraIS ); assertEquals( 2, jdks.getToolchains().size() ); merger.merge( jdks, jdksExtra, TrackableBase.USER_LEVEL ); assertEquals( 4, jdks.getToolchains().size() ); assertEquals( 2, jdksExtra.getToolchains().size() ); } try ( InputStream jdksIS = ToolchainModel.class.getResourceAsStream( "toolchains-jdks.xml" ); InputStream jdksExtraIS = ToolchainModel.class.getResourceAsStream( "toolchains-jdks-extra.xml" ) ) { PersistedToolchains jdks = reader.read( jdksIS ); PersistedToolchains jdksExtra = reader.read( jdksExtraIS ); assertEquals( 2, jdks.getToolchains().size() ); // switch dominant with recessive merger.merge( jdksExtra, jdks, TrackableBase.USER_LEVEL ); assertEquals( 4, jdksExtra.getToolchains().size() ); assertEquals( 2, jdks.getToolchains().size() ); } } @Test public void testMergeJdkExtend() throws Exception { try ( InputStream jdksIS = ToolchainModel.class.getResourceAsStream( "toolchains-jdks.xml" ); InputStream jdksExtendIS = ToolchainModel.class.getResourceAsStream( "toolchains-jdks-extend.xml" ) ) { PersistedToolchains jdks = reader.read( jdksIS ); PersistedToolchains jdksExtend = reader.read( jdksExtendIS ); assertEquals( 2, jdks.getToolchains().size() ); merger.merge( jdks, jdksExtend, TrackableBase.USER_LEVEL ); assertEquals( 2, jdks.getToolchains().size() ); Xpp3Dom config0 = (Xpp3Dom) jdks.getToolchains().get( 0 ).getConfiguration(); assertEquals( "lib/tools.jar", config0.getChild( "toolsJar" ).getValue() ); assertEquals( 2, config0.getChildCount() ); Xpp3Dom config1 = (Xpp3Dom) jdks.getToolchains().get( 1 ).getConfiguration(); assertEquals( 2, config1.getChildCount() ); assertEquals( "lib/classes.jar", config1.getChild( "toolsJar" ).getValue() ); assertEquals( 2, jdksExtend.getToolchains().size() ); } try ( InputStream jdksIS = ToolchainModel.class.getResourceAsStream( "toolchains-jdks.xml" ); InputStream jdksExtendIS = ToolchainModel.class.getResourceAsStream( "toolchains-jdks-extend.xml" ) ) { PersistedToolchains jdks = reader.read( jdksIS ); PersistedToolchains jdksExtend = reader.read( jdksExtendIS ); assertEquals( 2, jdks.getToolchains().size() ); // switch dominant with recessive merger.merge( jdksExtend, jdks, TrackableBase.USER_LEVEL ); assertEquals( 2, jdksExtend.getToolchains().size() ); Xpp3Dom config0 = (Xpp3Dom) jdksExtend.getToolchains().get( 0 ).getConfiguration(); assertEquals( "lib/tools.jar", config0.getChild( "toolsJar" ).getValue() ); assertEquals( 2, config0.getChildCount() ); Xpp3Dom config1 = (Xpp3Dom) jdksExtend.getToolchains().get( 1 ).getConfiguration(); assertEquals( 2, config1.getChildCount() ); assertEquals( "lib/classes.jar", config1.getChild( "toolsJar" ).getValue() ); assertEquals( 2, jdks.getToolchains().size() ); } } } maven-maven-3.5.2/maven-core/src/test/projects/000077500000000000000000000000001317160430700213705ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/projects/default-maven/000077500000000000000000000000001317160430700241205ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/projects/default-maven/cyclic-reference/000077500000000000000000000000001317160430700273225ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/projects/default-maven/cyclic-reference/module-a/000077500000000000000000000000001317160430700310255ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/projects/default-maven/cyclic-reference/module-a/pom.xml000066400000000000000000000011521317160430700323410ustar00rootroot00000000000000 4.0.0 cyclic-reference parent 1.0-SNAPSHOT module-a cyclic-reference module-b 1.0-SNAPSHOT maven-maven-3.5.2/maven-core/src/test/projects/default-maven/cyclic-reference/module-b/000077500000000000000000000000001317160430700310265ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/projects/default-maven/cyclic-reference/module-b/pom.xml000066400000000000000000000011521317160430700323420ustar00rootroot00000000000000 4.0.0 cyclic-reference parent 1.0-SNAPSHOT module-b cyclic-reference module-a 1.0-SNAPSHOT maven-maven-3.5.2/maven-core/src/test/projects/default-maven/cyclic-reference/pom.xml000066400000000000000000000007351317160430700306440ustar00rootroot00000000000000 4.0.0 cyclic-reference parent 1.0-SNAPSHOT pom module-a module-b maven-maven-3.5.2/maven-core/src/test/projects/lifecycle-executor/000077500000000000000000000000001317160430700251635ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/projects/lifecycle-executor/mojo-configuration/000077500000000000000000000000001317160430700307745ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/projects/lifecycle-executor/mojo-configuration/pom.xml000066400000000000000000000043121317160430700323110ustar00rootroot00000000000000 4.0.0 org.apache.maven.lifecycle.test mojo-configuration jar 1.0 project-with-additional-lifecycle-elements http://maven.apache.org org.apache.maven.plugins maven-clean-plugin 0.1 org.apache.maven.plugins maven-compiler-plugin 0.1 org.apache.maven.plugins maven-deploy-plugin 0.1 org.apache.maven.plugins maven-install-plugin 0.1 org.apache.maven.plugins maven-jar-plugin 0.1 org.apache.maven.plugins maven-plugin-plugin 0.1 org.apache.maven.plugins maven-surefire-plugin 0.1 org.apache.maven.its.plugins maven-it-plugin 0.1 xpp3-reader generate-sources maven-maven-3.5.2/maven-core/src/test/projects/lifecycle-executor/project-basic/000077500000000000000000000000001317160430700277105ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/projects/lifecycle-executor/project-basic/pom.xml000066400000000000000000000050511317160430700312260ustar00rootroot00000000000000 4.0.0 org.apache.maven.lifecycle.test project-basic 1.0 jar Test Project 2009 org.apache.maven.plugins maven-clean-plugin 0.1 org.apache.maven.plugins maven-compiler-plugin 0.1 org.apache.maven.plugins maven-deploy-plugin 0.1 org.apache.maven.plugins maven-install-plugin 0.1 org.apache.maven.plugins maven-jar-plugin 0.1 org.apache.maven.plugins maven-plugin-plugin 0.1 org.apache.maven.plugins maven-resources-plugin 0.1 org.apache.maven.plugins maven-surefire-plugin 0.1 project-with-additional-lifecycle-elements/000077500000000000000000000000001317160430700354005ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/projects/lifecycle-executorpom.xml000066400000000000000000000046301317160430700367200ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/projects/lifecycle-executor/project-with-additional-lifecycle-elements 4.0.0 org.apache.maven.lifecycle.test project-with-additional-lifecycle-elements jar 1.0 project-with-additional-lifecycle-elements http://maven.apache.org org.apache.maven.plugins maven-clean-plugin 0.1 org.apache.maven.plugins maven-compiler-plugin 0.1 org.apache.maven.plugins maven-deploy-plugin 0.1 org.apache.maven.plugins maven-install-plugin 0.1 org.apache.maven.plugins maven-jar-plugin 0.1 org.apache.maven.plugins maven-plugin-plugin 0.1 org.apache.maven.plugins maven-surefire-plugin 0.1 org.apache.maven.its.plugins maven-it-plugin 0.1 generate-metadata generate-test-metadata org.apache.maven.plugins maven-resources-plugin 0.1 src/000077500000000000000000000000001317160430700361675ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/projects/lifecycle-executor/project-with-additional-lifecycle-elementsmain/000077500000000000000000000000001317160430700371135ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/projects/lifecycle-executor/project-with-additional-lifecycle-elements/srcjava/000077500000000000000000000000001317160430700400345ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/projects/lifecycle-executor/project-with-additional-lifecycle-elements/src/mainorg/000077500000000000000000000000001317160430700406235ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/projects/lifecycle-executor/project-with-additional-lifecycle-elements/src/main/javaapache/000077500000000000000000000000001317160430700420445ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/projects/lifecycle-executor/project-with-additional-lifecycle-elements/src/main/java/orgmaven/000077500000000000000000000000001317160430700431525ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/projects/lifecycle-executor/project-with-additional-lifecycle-elements/src/main/java/org/apachelifecycle/000077500000000000000000000000001317160430700451115ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/projects/lifecycle-executor/project-with-additional-lifecycle-elements/src/main/java/org/apache/maventest/000077500000000000000000000000001317160430700460705ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/projects/lifecycle-executor/project-with-additional-lifecycle-elements/src/main/java/org/apache/maven/lifecycleApp.java000066400000000000000000000003011317160430700474450ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/projects/lifecycle-executor/project-with-additional-lifecycle-elements/src/main/java/org/apache/maven/lifecycle/testpackage org.apache.maven.lifecycle.test; /** * Hello world! * */ public class App { public static void main( String[] args ) { System.out.println( "Hello World!" ); } } test/000077500000000000000000000000001317160430700371465ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/projects/lifecycle-executor/project-with-additional-lifecycle-elements/srcjava/000077500000000000000000000000001317160430700400675ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/projects/lifecycle-executor/project-with-additional-lifecycle-elements/src/testorg/000077500000000000000000000000001317160430700406565ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/projects/lifecycle-executor/project-with-additional-lifecycle-elements/src/test/javaapache/000077500000000000000000000000001317160430700420775ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/projects/lifecycle-executor/project-with-additional-lifecycle-elements/src/test/java/orgmaven/000077500000000000000000000000001317160430700432055ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/projects/lifecycle-executor/project-with-additional-lifecycle-elements/src/test/java/org/apachelifecycle/000077500000000000000000000000001317160430700451445ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/projects/lifecycle-executor/project-with-additional-lifecycle-elements/src/test/java/org/apache/maventest/000077500000000000000000000000001317160430700461235ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/projects/lifecycle-executor/project-with-additional-lifecycle-elements/src/test/java/org/apache/maven/lifecycleAppTest.java000066400000000000000000000012211317160430700503420ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/projects/lifecycle-executor/project-with-additional-lifecycle-elements/src/test/java/org/apache/maven/lifecycle/testpackage org.apache.maven.lifecycle.test; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; /** * Unit test for simple App. */ public class AppTest extends TestCase { /** * Create the test case * * @param testName name of the test case */ public AppTest( String testName ) { super( testName ); } /** * @return the suite of tests being tested */ public static Test suite() { return new TestSuite( AppTest.class ); } /** * Rigorous Test :-) */ public void testApp() { assertTrue( true ); } } maven-maven-3.5.2/maven-core/src/test/projects/lifecycle-executor/project-with-inheritance/000077500000000000000000000000001317160430700320715ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/projects/lifecycle-executor/project-with-inheritance/pom.xml000066400000000000000000000546221317160430700334170ustar00rootroot00000000000000 4.0.0 org.apache.maven maven-parent 11 ../pom/maven/pom.xml org.apache.maven maven 3.0-SNAPSHOT pom Apache Maven Maven is a project development management and comprehension tool. Based on the concept of a project object model: builds, dependency management, documentation creation, site publication, and distribution publication are all controlled from the declarative file. Maven can be extended by plugins to utilise a number of other development tools for reporting or the build process. http://maven.apache.org/ 2001 1.3 1.0 1.0-alpha-9 1.2_Java1.3 3.8.1 1.0-beta-3.0.7 1.0-alpha-6 1.1 1.0-alpha-1 1.5.8 1.6 1.0 1.0-beta-4 1.7-SNAPSHOT 1.0-alpha-6-SNAPSHOT 1.0-alpha-1 1.2 3.2.6 1.0.1-SNAPSHOT 1.3 jira http://jira.codehaus.org/browse/MNG Maven Developer List dev-subscribe@maven.apache.org dev-unsubscribe@maven.apache.org dev@maven.apache.org http://mail-archives.apache.org/mod_mbox/maven-dev http://www.mail-archive.com/dev@maven.apache.org/ http://www.nabble.com/Maven-Developers-f179.html http://maven.dev.markmail.org/ Maven User List users-subscribe@maven.apache.org users-unsubscribe@maven.apache.org users@maven.apache.org http://mail-archives.apache.org/mod_mbox/maven-users http://www.mail-archive.com/users@maven.apache.org/ http://www.nabble.com/Maven---Users-f178.html http://maven.users.markmail.org/ Maven Issues List issues-subscribe@maven.apache.org issues-unsubscribe@maven.apache.org http://mail-archives.apache.org/mod_mbox/maven-issues/ http://www.mail-archive.com/issues@maven.apache.org http://www.nabble.com/Maven---Issues-f15573.html http://maven.issues.markmail.org/ Maven Commits List commits-subscribe@maven.apache.org commits-unsubscribe@maven.apache.org http://mail-archives.apache.org/mod_mbox/maven-commits http://www.mail-archive.com/commits@maven.apache.org http://www.nabble.com/Maven---Commits-f15575.html http://maven.commits.markmail.org/ Maven Announcements List announce@maven.apache.org announce-subscribe@maven.apache.org announce-unsubscribe@maven.apache.org http://mail-archives.apache.org/mod_mbox/maven-announce/ http://www.mail-archive.com/announce@maven.apache.org http://www.nabble.com/Maven-Announcements-f15617.html http://maven.announce.markmail.org/ Maven Notifications List notifications-subscribe@maven.apache.org notifications-unsubscribe@maven.apache.org http://mail-archives.apache.org/mod_mbox/maven-notifications/ http://www.mail-archive.com/notifications@maven.apache.org http://www.nabble.com/Maven---Notifications-f15574.html http://maven.notifications.markmail.org/ scm:svn:http://svn.apache.org/repos/asf/maven/components/trunk scm:svn:https://svn.apache.org/repos/asf/maven/components/trunk http://svn.apache.org/viewcvs.cgi/maven/components/trunk org.codehaus.plexus plexus-component-metadata ${plexusVersion} generate-metadata generate-test-metadata org.apache.maven.plugins maven-compiler-plugin 2.0.2 1.5 1.5 maven-release-plugin https://svn.apache.org/repos/asf/maven/components/tags org.codehaus.modello modello-maven-plugin ${modelloVersion} true site-docs pre-site xdoc xsd standard java xpp3-reader xpp3-writer org.apache.felix maven-bundle-plugin 1.0.0 org.apache.maven.plugins maven-surefire-plugin 2.4.2 org.apache.maven.plugins maven-assembly-plugin 2.2-beta-2 org.apache.maven.plugins maven-resources-plugin 2.4-SNAPSHOT maven-core apache-maven maven-model maven-plugin-api maven-project maven-reporting-api maven-project-builder maven-mercury maven-embedder maven-toolchain maven-compat maven-repository maven-repository-mercury junit junit ${junitVersion} test org.apache.maven maven-mercury ${project.version} org.apache.maven maven-lifecycle ${project.version} org.apache.maven maven-reporting-api ${project.version} org.apache.maven maven-profile ${project.version} org.apache.maven maven-model ${project.version} org.apache.maven maven-project ${project.version} org.apache.maven maven-plugin-api ${project.version} org.apache.maven maven-toolchain ${project.version} org.apache.maven maven-embedder ${project.version} org.apache.maven maven-core ${project.version} org.apache.maven maven-project-builder ${project.version} org.apache.maven maven-repository ${project.version} org.apache.maven maven-compat ${project.version} org.codehaus.plexus plexus-utils ${plexusUtilsVersion} org.codehaus.plexus plexus-container-default ${plexusVersion} org.codehaus.plexus plexus-component-annotations ${plexusVersion} org.codehaus.plexus plexus-classworlds ${classWorldsVersion} org.codehaus.plexus plexus-interpolation ${plexusInterpolationVersion} org.codehaus.plexus plexus-interactivity-api ${plexusInteractivityVersion} org.codehaus.plexus plexus-component-api org.sonatype.plexus plexus-jetty6 ${plexusJetty6Version} test org.sonatype.spice plexus-webdav ${plexusWebdavVersion} test org.apache.maven.wagon wagon-provider-api ${wagonVersion} org.apache.maven.wagon wagon-file ${wagonVersion} org.apache.maven.wagon wagon-http-lightweight ${wagonVersion} org.apache.maven.wagon wagon-ssh ${wagonVersion} org.apache.maven.wagon wagon-ssh-external ${wagonVersion} org.apache.maven.doxia doxia-sink-api ${doxiaVersion} org.sonatype.spice model-builder ${modelBuilderVersion} org.codehaus.woodstox wstx-asl ${woodstoxVersion} commons-cli commons-cli ${commonsCliVersion} commons-lang commons-lang commons-logging commons-logging commons-jxpath commons-jxpath ${jxpathVersion} org.apache.maven.mercury mercury-artifact ${mercuryVersion} org.apache.maven.mercury mercury-external ${mercuryVersion} org.apache.maven.mercury mercury-plexus ${mercuryVersion} org.apache.maven.mercury mercury-repo-virtual ${mercuryVersion} org.sonatype.mercury mercury-mp3-cli ${mercuryMp3Version} org.sonatype.plexus plexus-sec-dispatcher ${securityDispatcherVersion} org.apache.maven.mercury mercury-repo-local-m2 ${mercuryVersion} test org.apache.maven.mercury mercury-repo-remote-m2 ${mercuryVersion} test org.apache.maven.mercury mercury-md-sat ${mercuryVersion} test org.apache.maven.mercury mercury-util ${mercuryVersion} test org.apache.maven.mercury mercury-transport-http ${mercuryVersion} test org.apache.maven.mercury mercury-transport-http ${mercuryVersion} test-jar test org.sonatype.plexus plexus-plugin-manager ${plexusPluginManagerVersion} easymock easymock ${easyMockVersion} test apache.website scp://people.apache.org/www/maven.apache.org/ref/${project.version}/ osgi org.apache.felix maven-bundle-plugin manifest org.apache.maven.plugins maven-jar-plugin 2.1 ${project.build.outputDirectory}/META-INF/MANIFEST.MF release maven-assembly-plugin false src/main/assembly/src.xml gnu maven-${project.version}-src make-assembly package single strict org.apache.maven.plugins maven-enforcer-plugin 1.0-alpha-3 enforce-jdk-15 enforce 1.5 maven-maven-3.5.2/maven-core/src/test/projects/lifecycle-executor/project-with-multiple-executions/000077500000000000000000000000001317160430700336175ustar00rootroot00000000000000pom.xml000066400000000000000000000074471317160430700350710ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/projects/lifecycle-executor/project-with-multiple-executions 4.0.0 org.apache.maven.plugins project-with-multiple-executions 1.0.1 maven-plugin org.apache.maven.plugins maven-clean-plugin 0.1 org.apache.maven.plugins maven-compiler-plugin 0.1 org.apache.maven.plugins maven-deploy-plugin 0.1 org.apache.maven.plugins maven-install-plugin 0.1 org.apache.maven.plugins maven-jar-plugin 0.1 org.apache.maven.plugins maven-plugin-plugin 0.1 org.apache.maven.plugins maven-resources-plugin 0.1 org.apache.maven.plugins maven-surefire-plugin 0.1 org.apache.maven.its.plugins maven-it-plugin 0.1 remote-resources xpp3-writer java xpp3-reader 1.1.0 src/main/mdo/remote-resources.mdo supplemental-models xpp3-writer java xpp3-reader 1.0.0 src/main/mdo/supplemental-model.mdo src/000077500000000000000000000000001317160430700343275ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/projects/lifecycle-executor/project-with-multiple-executionsmain/000077500000000000000000000000001317160430700352535ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/projects/lifecycle-executor/project-with-multiple-executions/srcmdo/000077500000000000000000000000001317160430700360325ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/projects/lifecycle-executor/project-with-multiple-executions/src/mainremote-resources.mdo000066400000000000000000000040261317160430700420400ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/projects/lifecycle-executor/project-with-multiple-executions/src/main/mdo remoteResourcesBundle RemoteResourcesBundle package org.apache.maven.plugin.resources.remote RemoteResourcesBundle 1.1.0 Root element of the remote-resources.xml file. remoteResources 1.1.0 String * sourceEncoding 1.1.0 String supplemental-model.mdo000066400000000000000000000041241317160430700423430ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/projects/lifecycle-executor/project-with-multiple-executions/src/main/mdo supplementalModel SupplementalDataModel Provides access to supplemental POM data models. package org.apache.maven.plugin.resources.remote SupplementalDataModel 1.0.0 Root element of the supplemental-models.xml file. supplement 1.0.0 Snippets of POM xml files used to supplement the data model. Supplement * Supplement 1.0.0 A single supplement project 1.0.0 Snippets of POM xml files used to supplement the data model. DOM project-with-plugin-level-configuration-only/000077500000000000000000000000001317160430700357505ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/projects/lifecycle-executorpom.xml000066400000000000000000000025731317160430700372740ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/projects/lifecycle-executor/project-with-plugin-level-configuration-only 4.0.0 org.apache.maven.plugins project-plugin-level-configuration-only 1.0.1 org.codehaus.modello modello-maven-plugin 1.0.1 1.1.0 src/main/mdo/remote-resources.mdo maven-maven-3.5.2/maven-core/src/test/projects/lifecycle-listener/000077500000000000000000000000001317160430700251525ustar00rootroot00000000000000lifecycle-listener-dependency-injection/000077500000000000000000000000001317160430700347515ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/projects/lifecycle-listenerpom.xml000066400000000000000000000012461317160430700362710ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/projects/lifecycle-listener/lifecycle-listener-dependency-injection 4.0.0 org.apache.maven.lifecycle-listener.test simple 1.0 ${injected} org.apache.maven.its.plugins maven-it-plugin 0.1 test validate it lifecycle-participant-reactor-dependency-injection/000077500000000000000000000000001317160430700370775ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/projects/lifecycle-listenermodule-a/000077500000000000000000000000001317160430700406025ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/projects/lifecycle-listener/lifecycle-participant-reactor-dependency-injectionpom.xml000066400000000000000000000004011317160430700421120ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/projects/lifecycle-listener/lifecycle-participant-reactor-dependency-injection/module-a 4.0.0 lifecycle-participant-reactor-dependency-injection parent 1.0 module-a module-b/000077500000000000000000000000001317160430700406035ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/projects/lifecycle-listener/lifecycle-participant-reactor-dependency-injectionpom.xml000066400000000000000000000004011317160430700421130ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/projects/lifecycle-listener/lifecycle-participant-reactor-dependency-injection/module-b 4.0.0 lifecycle-participant-reactor-dependency-injection parent 1.0 module-b pom.xml000066400000000000000000000004611317160430700404150ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/projects/lifecycle-listener/lifecycle-participant-reactor-dependency-injection 4.0.0 lifecycle-participant-reactor-dependency-injection parent 1.0 pom module-a module-b maven-maven-3.5.2/maven-core/src/test/projects/plugin-manager/000077500000000000000000000000001317160430700242765ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/projects/plugin-manager/mng-5003-plugin-realm-cache/000077500000000000000000000000001317160430700310775ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/projects/plugin-manager/mng-5003-plugin-realm-cache/pom.xml000066400000000000000000000002761317160430700324210ustar00rootroot00000000000000 4.0.0 org.apache.maven.its.mng5003 mng-5003-plugin-realm-cache 1.0 project-contributing-system-scope-plugin-dep/000077500000000000000000000000001317160430700350655ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/projects/plugin-managerpom.xml000066400000000000000000000024501317160430700364030ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/projects/plugin-manager/project-contributing-system-scope-plugin-dep 4.0.0 org.apache.maven.its.mng3586 test2 1.0 Maven Integration Test :: MNG-3586 Test that plugin dependencies with scope system are part of the plugin class realm. org.apache.maven.its.plugins maven-it-plugin 0.1 org.apache.maven.its.mng3586 tools 1.5.0 system ${basedir}/tools.jar load validate maven-core-it.properties target/pcl.properties load maven-maven-3.5.2/maven-core/src/test/projects/plugin-manager/project-with-build-extensions-plugin/000077500000000000000000000000001317160430700335035ustar00rootroot00000000000000pom.xml000066400000000000000000000015641317160430700347470ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/projects/plugin-manager/project-with-build-extensions-plugin 4.0.0 org.apache.maven.test project-with-build-extensions-plugin 1.0 org.apache.maven.its.plugins maven-it-plugin 0.1 true load validate maven-core-it.properties target/pcl.properties load maven-maven-3.5.2/maven-core/src/test/projects/plugin-manager/project-with-inheritance/000077500000000000000000000000001317160430700312045ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/projects/plugin-manager/project-with-inheritance/pom.xml000066400000000000000000000546221317160430700325320ustar00rootroot00000000000000 4.0.0 org.apache.maven maven-parent 11 ../pom/maven/pom.xml org.apache.maven maven 3.0-SNAPSHOT pom Apache Maven Maven is a project development management and comprehension tool. Based on the concept of a project object model: builds, dependency management, documentation creation, site publication, and distribution publication are all controlled from the declarative file. Maven can be extended by plugins to utilise a number of other development tools for reporting or the build process. http://maven.apache.org/ 2001 1.3 1.0 1.0-alpha-9 1.2_Java1.3 3.8.1 1.0-beta-3.0.7 1.0-alpha-6 1.1 1.0-alpha-1 1.5.8 1.6 1.0 1.0-beta-4 1.7-SNAPSHOT 1.0-alpha-6-SNAPSHOT 1.0-alpha-1 1.2 3.2.6 1.0.1-SNAPSHOT 1.3 jira http://jira.codehaus.org/browse/MNG Maven Developer List dev-subscribe@maven.apache.org dev-unsubscribe@maven.apache.org dev@maven.apache.org http://mail-archives.apache.org/mod_mbox/maven-dev http://www.mail-archive.com/dev@maven.apache.org/ http://www.nabble.com/Maven-Developers-f179.html http://maven.dev.markmail.org/ Maven User List users-subscribe@maven.apache.org users-unsubscribe@maven.apache.org users@maven.apache.org http://mail-archives.apache.org/mod_mbox/maven-users http://www.mail-archive.com/users@maven.apache.org/ http://www.nabble.com/Maven---Users-f178.html http://maven.users.markmail.org/ Maven Issues List issues-subscribe@maven.apache.org issues-unsubscribe@maven.apache.org http://mail-archives.apache.org/mod_mbox/maven-issues/ http://www.mail-archive.com/issues@maven.apache.org http://www.nabble.com/Maven---Issues-f15573.html http://maven.issues.markmail.org/ Maven Commits List commits-subscribe@maven.apache.org commits-unsubscribe@maven.apache.org http://mail-archives.apache.org/mod_mbox/maven-commits http://www.mail-archive.com/commits@maven.apache.org http://www.nabble.com/Maven---Commits-f15575.html http://maven.commits.markmail.org/ Maven Announcements List announce@maven.apache.org announce-subscribe@maven.apache.org announce-unsubscribe@maven.apache.org http://mail-archives.apache.org/mod_mbox/maven-announce/ http://www.mail-archive.com/announce@maven.apache.org http://www.nabble.com/Maven-Announcements-f15617.html http://maven.announce.markmail.org/ Maven Notifications List notifications-subscribe@maven.apache.org notifications-unsubscribe@maven.apache.org http://mail-archives.apache.org/mod_mbox/maven-notifications/ http://www.mail-archive.com/notifications@maven.apache.org http://www.nabble.com/Maven---Notifications-f15574.html http://maven.notifications.markmail.org/ scm:svn:http://svn.apache.org/repos/asf/maven/components/trunk scm:svn:https://svn.apache.org/repos/asf/maven/components/trunk http://svn.apache.org/viewcvs.cgi/maven/components/trunk org.codehaus.plexus plexus-component-metadata ${plexusVersion} generate-metadata generate-test-metadata org.apache.maven.plugins maven-compiler-plugin 2.0.2 1.5 1.5 maven-release-plugin https://svn.apache.org/repos/asf/maven/components/tags org.codehaus.modello modello-maven-plugin ${modelloVersion} true site-docs pre-site xdoc xsd standard java xpp3-reader xpp3-writer org.apache.felix maven-bundle-plugin 1.0.0 org.apache.maven.plugins maven-surefire-plugin 2.4.2 org.apache.maven.plugins maven-assembly-plugin 2.2-beta-2 org.apache.maven.plugins maven-resources-plugin 2.4-SNAPSHOT maven-core apache-maven maven-model maven-plugin-api maven-project maven-reporting-api maven-project-builder maven-mercury maven-embedder maven-toolchain maven-compat maven-repository maven-repository-mercury junit junit ${junitVersion} test org.apache.maven maven-mercury ${project.version} org.apache.maven maven-lifecycle ${project.version} org.apache.maven maven-reporting-api ${project.version} org.apache.maven maven-profile ${project.version} org.apache.maven maven-model ${project.version} org.apache.maven maven-project ${project.version} org.apache.maven maven-plugin-api ${project.version} org.apache.maven maven-toolchain ${project.version} org.apache.maven maven-embedder ${project.version} org.apache.maven maven-core ${project.version} org.apache.maven maven-project-builder ${project.version} org.apache.maven maven-repository ${project.version} org.apache.maven maven-compat ${project.version} org.codehaus.plexus plexus-utils ${plexusUtilsVersion} org.codehaus.plexus plexus-container-default ${plexusVersion} org.codehaus.plexus plexus-component-annotations ${plexusVersion} org.codehaus.plexus plexus-classworlds ${classWorldsVersion} org.codehaus.plexus plexus-interpolation ${plexusInterpolationVersion} org.codehaus.plexus plexus-interactivity-api ${plexusInteractivityVersion} org.codehaus.plexus plexus-component-api org.sonatype.plexus plexus-jetty6 ${plexusJetty6Version} test org.sonatype.spice plexus-webdav ${plexusWebdavVersion} test org.apache.maven.wagon wagon-provider-api ${wagonVersion} org.apache.maven.wagon wagon-file ${wagonVersion} org.apache.maven.wagon wagon-http-lightweight ${wagonVersion} org.apache.maven.wagon wagon-ssh ${wagonVersion} org.apache.maven.wagon wagon-ssh-external ${wagonVersion} org.apache.maven.doxia doxia-sink-api ${doxiaVersion} org.sonatype.spice model-builder ${modelBuilderVersion} org.codehaus.woodstox wstx-asl ${woodstoxVersion} commons-cli commons-cli ${commonsCliVersion} commons-lang commons-lang commons-logging commons-logging commons-jxpath commons-jxpath ${jxpathVersion} org.apache.maven.mercury mercury-artifact ${mercuryVersion} org.apache.maven.mercury mercury-external ${mercuryVersion} org.apache.maven.mercury mercury-plexus ${mercuryVersion} org.apache.maven.mercury mercury-repo-virtual ${mercuryVersion} org.sonatype.mercury mercury-mp3-cli ${mercuryMp3Version} org.sonatype.plexus plexus-sec-dispatcher ${securityDispatcherVersion} org.apache.maven.mercury mercury-repo-local-m2 ${mercuryVersion} test org.apache.maven.mercury mercury-repo-remote-m2 ${mercuryVersion} test org.apache.maven.mercury mercury-md-sat ${mercuryVersion} test org.apache.maven.mercury mercury-util ${mercuryVersion} test org.apache.maven.mercury mercury-transport-http ${mercuryVersion} test org.apache.maven.mercury mercury-transport-http ${mercuryVersion} test-jar test org.sonatype.plexus plexus-plugin-manager ${plexusPluginManagerVersion} easymock easymock ${easyMockVersion} test apache.website scp://people.apache.org/www/maven.apache.org/ref/${project.version}/ osgi org.apache.felix maven-bundle-plugin manifest org.apache.maven.plugins maven-jar-plugin 2.1 ${project.build.outputDirectory}/META-INF/MANIFEST.MF release maven-assembly-plugin false src/main/assembly/src.xml gnu maven-${project.version}-src make-assembly package single strict org.apache.maven.plugins maven-enforcer-plugin 1.0-alpha-3 enforce-jdk-15 enforce 1.5 project-with-plugin-classpath-ordering/000077500000000000000000000000001317160430700337215ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/projects/plugin-managerpom.xml000066400000000000000000000040631317160430700352410ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/projects/plugin-manager/project-with-plugin-classpath-ordering 4.0.0 org.apache.maven.its.mng3906 parent 0.1 pom Maven Integration Test :: MNG-3906 Test that project-level plugin dependencies are properly merged during inheritance. org.apache.maven.its.plugins maven-it-plugin-class-loader 2.1-SNAPSHOT org.apache.maven.its.mng3906 e 0.1 org.apache.maven.its.mng3906 a 0.1 org.apache.maven.its.mng3906 d 0.1 sub/000077500000000000000000000000001317160430700345125ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/projects/plugin-manager/project-with-plugin-classpath-orderingpom.xml000066400000000000000000000046771317160430700360450ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/projects/plugin-manager/project-with-plugin-classpath-ordering/sub 4.0.0 org.apache.maven.its.mng3906 parent 0.1 child Maven Integration Test :: MNG-3906 Test that project-level plugin dependencies are properly merged during inheritance. org.apache.maven.its.plugins maven-it-plugin-class-loader 2.1-SNAPSHOT org.apache.maven.its.mng3906 c 0.1 org.apache.maven.its.mng3906 a 0.2 org.apache.maven.its.mng3906 b 0.1 load validate org/apache/maven/its/mng3906/SomeClass.class target/pcl.properties load repo/000077500000000000000000000000001317160430700354575ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/projects/plugin-manager/project-with-plugin-classpath-ordering/suborg/000077500000000000000000000000001317160430700362465ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/projects/plugin-manager/project-with-plugin-classpath-ordering/sub/repoapache/000077500000000000000000000000001317160430700374675ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/projects/plugin-manager/project-with-plugin-classpath-ordering/sub/repo/orgmaven/000077500000000000000000000000001317160430700405755ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/projects/plugin-manager/project-with-plugin-classpath-ordering/sub/repo/org/apacheits/000077500000000000000000000000001317160430700413745ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/projects/plugin-manager/project-with-plugin-classpath-ordering/sub/repo/org/apache/mavenmng3906/000077500000000000000000000000001317160430700424775ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/projects/plugin-manager/project-with-plugin-classpath-ordering/sub/repo/org/apache/maven/itsa/000077500000000000000000000000001317160430700427175ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/projects/plugin-manager/project-with-plugin-classpath-ordering/sub/repo/org/apache/maven/its/mng39060.1/000077500000000000000000000000001317160430700432155ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/projects/plugin-manager/project-with-plugin-classpath-ordering/sub/repo/org/apache/maven/its/mng3906/aa-0.1.pom000066400000000000000000000031021317160430700444420ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/projects/plugin-manager/project-with-plugin-classpath-ordering/sub/repo/org/apache/maven/its/mng3906/a/0.1 4.0.0 org.apache.maven.its.mng3906 a 0.1 jar maven-core-it file:///${basedir}/repo true true . pom.xml src/** src/main/resources 0.2/000077500000000000000000000000001317160430700432165ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/projects/plugin-manager/project-with-plugin-classpath-ordering/sub/repo/org/apache/maven/its/mng3906/aa-0.2.pom000066400000000000000000000031021317160430700444440ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/projects/plugin-manager/project-with-plugin-classpath-ordering/sub/repo/org/apache/maven/its/mng3906/a/0.2 4.0.0 org.apache.maven.its.mng3906 a 0.2 jar maven-core-it file:///${basedir}/repo true true . pom.xml src/** src/main/resources maven-metadata.xml000066400000000000000000000005451317160430700463310ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/projects/plugin-manager/project-with-plugin-classpath-ordering/sub/repo/org/apache/maven/its/mng3906/a org.apache.maven.its.mng3906 a 0.1 0.2 0.1 0.2 20081214111115 b/000077500000000000000000000000001317160430700427205ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/projects/plugin-manager/project-with-plugin-classpath-ordering/sub/repo/org/apache/maven/its/mng39060.1/000077500000000000000000000000001317160430700432165ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/projects/plugin-manager/project-with-plugin-classpath-ordering/sub/repo/org/apache/maven/its/mng3906/bb-0.1.pom000066400000000000000000000031021317160430700444440ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/projects/plugin-manager/project-with-plugin-classpath-ordering/sub/repo/org/apache/maven/its/mng3906/b/0.1 4.0.0 org.apache.maven.its.mng3906 b 0.1 jar maven-core-it file:///${basedir}/repo true true . pom.xml src/** src/main/resources maven-metadata.xml000066400000000000000000000005101317160430700463220ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/projects/plugin-manager/project-with-plugin-classpath-ordering/sub/repo/org/apache/maven/its/mng3906/b org.apache.maven.its.mng3906 b 0.1 0.1 0.1 20081214111129 c/000077500000000000000000000000001317160430700427215ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/projects/plugin-manager/project-with-plugin-classpath-ordering/sub/repo/org/apache/maven/its/mng39060.1/000077500000000000000000000000001317160430700432175ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/projects/plugin-manager/project-with-plugin-classpath-ordering/sub/repo/org/apache/maven/its/mng3906/cc-0.1.pom000066400000000000000000000031021317160430700444460ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/projects/plugin-manager/project-with-plugin-classpath-ordering/sub/repo/org/apache/maven/its/mng3906/c/0.1 4.0.0 org.apache.maven.its.mng3906 c 0.1 jar maven-core-it file:///${basedir}/repo true true . pom.xml src/** src/main/resources maven-metadata.xml000066400000000000000000000005101317160430700463230ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/projects/plugin-manager/project-with-plugin-classpath-ordering/sub/repo/org/apache/maven/its/mng3906/c org.apache.maven.its.mng3906 c 0.1 0.1 0.1 20081214111138 d/000077500000000000000000000000001317160430700427225ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/projects/plugin-manager/project-with-plugin-classpath-ordering/sub/repo/org/apache/maven/its/mng39060.1/000077500000000000000000000000001317160430700432205ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/projects/plugin-manager/project-with-plugin-classpath-ordering/sub/repo/org/apache/maven/its/mng3906/dd-0.1.pom000066400000000000000000000031021317160430700444500ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/projects/plugin-manager/project-with-plugin-classpath-ordering/sub/repo/org/apache/maven/its/mng3906/d/0.1 4.0.0 org.apache.maven.its.mng3906 d 0.1 jar maven-core-it file:///${basedir}/repo true true . pom.xml src/** src/main/resources maven-metadata.xml000066400000000000000000000005101317160430700463240ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/projects/plugin-manager/project-with-plugin-classpath-ordering/sub/repo/org/apache/maven/its/mng3906/d org.apache.maven.its.mng3906 d 0.1 0.1 0.1 20081214111146 e/000077500000000000000000000000001317160430700427235ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/projects/plugin-manager/project-with-plugin-classpath-ordering/sub/repo/org/apache/maven/its/mng39060.1/000077500000000000000000000000001317160430700432215ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/projects/plugin-manager/project-with-plugin-classpath-ordering/sub/repo/org/apache/maven/its/mng3906/ee-0.1.pom000066400000000000000000000031021317160430700444520ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/projects/plugin-manager/project-with-plugin-classpath-ordering/sub/repo/org/apache/maven/its/mng3906/e/0.1 4.0.0 org.apache.maven.its.mng3906 e 0.1 jar maven-core-it file:///${basedir}/repo true true . pom.xml src/** src/main/resources maven-metadata.xml000066400000000000000000000005101317160430700463250ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/projects/plugin-manager/project-with-plugin-classpath-ordering/sub/repo/org/apache/maven/its/mng3906/e org.apache.maven.its.mng3906 e 0.1 0.1 0.1 20081214111155 settings-template.xml000066400000000000000000000032431317160430700407070ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/projects/plugin-manager/project-with-plugin-classpath-ordering/sub maven-core-it-repo maven-core-it @baseurl@/repo ignore false maven-core-it @baseurl@/repo ignore false maven-core-it-repo maven-maven-3.5.2/maven-core/src/test/projects/project-builder/000077500000000000000000000000001317160430700244625ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/projects/project-builder/it0063/000077500000000000000000000000001317160430700254075ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/projects/project-builder/it0063/jdk/000077500000000000000000000000001317160430700261575ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/projects/project-builder/it0063/jdk/jre/000077500000000000000000000000001317160430700267375ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/projects/project-builder/it0063/jdk/jre/placeholder.txt000066400000000000000000000000611317160430700317570ustar00rootroot00000000000000need it so that empty folder does not get deletedmaven-maven-3.5.2/maven-core/src/test/projects/project-builder/it0063/jdk/lib/000077500000000000000000000000001317160430700267255ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/projects/project-builder/it0063/pom.xml000066400000000000000000000033621317160430700267300ustar00rootroot00000000000000 4.0.0 org.apache.maven.its.it0063 maven-it-it0063 1.0 jar Maven Integration Test :: it0063 Test the use of a system scoped dependency to a (fake) tools.jar. com.sun tools 1.4.2 system ${jre.home}/../lib/tools.jar org.apache.maven.its.plugins maven-it-plugin-dependency-resolution 2.1-SNAPSHOT target/compile.txt maven-maven-3.5.2/maven-core/src/test/projects/project-builder/mng-3023/000077500000000000000000000000001317160430700256305ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/projects/project-builder/mng-3023/consumer/000077500000000000000000000000001317160430700274635ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/projects/project-builder/mng-3023/consumer/pom.xml000066400000000000000000000040551317160430700310040ustar00rootroot00000000000000 4.0.0 org.apache.maven.its.mng3023 parent 1 consumer Maven Integration Test :: MNG-3023 :: Consumer Test that reactor projects are included in dependency resolution. org.apache.maven.its.mng3023 dependency 1 org.apache.maven.its.plugins maven-it-plugin-dependency-resolution 2.1-SNAPSHOT compile-classpath validate compile ${project.build.directory}/compile.classpath 1 maven-maven-3.5.2/maven-core/src/test/projects/project-builder/mng-3023/dependency/000077500000000000000000000000001317160430700277465ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/projects/project-builder/mng-3023/dependency/pom.xml000066400000000000000000000042331317160430700312650ustar00rootroot00000000000000 4.0.0 org.apache.maven.its.mng3023 parent 1 dependency Maven Integration Test :: MNG-3023 :: Dependency Test that reactor projects are included in dependency resolution. dependency-classes org.apache.maven.its.plugins maven-it-plugin-artifact 2.1-SNAPSHOT compile initialize set dependency-classes install generate-sources set attach-pom install dependency-1.jar maven-maven-3.5.2/maven-core/src/test/projects/project-builder/mng-3023/pom.xml000066400000000000000000000023221317160430700271440ustar00rootroot00000000000000 4.0.0 org.apache.maven.its.mng3023 parent 1 pom Maven Integration Test :: MNG-3023 Test that reactor projects are included in dependency resolution. dependency consumer maven-maven-3.5.2/maven-core/src/test/projects/project-dependencies-resolver/000077500000000000000000000000001317160430700273215ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/projects/project-dependencies-resolver/it0063/000077500000000000000000000000001317160430700302465ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/projects/project-dependencies-resolver/it0063/jdk/000077500000000000000000000000001317160430700310165ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/projects/project-dependencies-resolver/it0063/jdk/jre/000077500000000000000000000000001317160430700315765ustar00rootroot00000000000000placeholder.txt000066400000000000000000000000611317160430700345370ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/projects/project-dependencies-resolver/it0063/jdk/jreneed it so that empty folder does not get deletedmaven-maven-3.5.2/maven-core/src/test/projects/project-dependencies-resolver/it0063/jdk/lib/000077500000000000000000000000001317160430700315645ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/projects/project-dependencies-resolver/it0063/pom.xml000066400000000000000000000033621317160430700315670ustar00rootroot00000000000000 4.0.0 org.apache.maven.its.it0063 maven-it-it0063 1.0 jar Maven Integration Test :: it0063 Test the use of a system scoped dependency to a (fake) tools.jar. com.sun tools 1.4.2 system ${jre.home}/../lib/tools.jar org.apache.maven.its.plugins maven-it-plugin-dependency-resolution 2.1-SNAPSHOT target/compile.txt project-with-exclusions/000077500000000000000000000000001317160430700340535ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/projects/project-dependencies-resolverpom.xml000066400000000000000000000025421317160430700353730ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/projects/project-dependencies-resolver/project-with-exclusions 4.0.0 org.apache.maven.its.mng4034 parent 1.0-SNAPSHOT org.apache.maven.its maven-core-it-support 1.3 runtime commons-lang commons-lang maven-maven-3.5.2/maven-core/src/test/remote-repo/000077500000000000000000000000001317160430700217755ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/remote-repo/org/000077500000000000000000000000001317160430700225645ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/remote-repo/org/apache/000077500000000000000000000000001317160430700240055ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/remote-repo/org/apache/apache/000077500000000000000000000000001317160430700252265ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/remote-repo/org/apache/apache/1/000077500000000000000000000000001317160430700253665ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/remote-repo/org/apache/apache/1/apache-1.pom000066400000000000000000000064001317160430700274620ustar00rootroot00000000000000 4.0.0 org.apache apache 1 pom The Apache Software Foundation The Apache Software Foundation provides support for the Apache community of open-source software projects. The Apache projects are characterized by a collaborative, consensus based development process, an open and pragmatic software license, and a desire to create high quality software that leads the way in its field. We consider ourselves not simply a group of projects sharing a server, but rather a community of developers and users. The Apache Software License, Version 2.0 http://www.apache.org/licenses/LICENSE-2.0.txt repo Apache Software Foundation http://www.apache.org/ http://www.apache.org/ apache.snapshots Apache Snapshot Repository http://svn.apache.org/maven-snapshot-repository false apache.releases Apache Release Distribution Repository scp://minotaur.apache.org/www/www.apache.org/dist/maven-repository apache.snapshots Apache Development Snapshot Repository scp://minotaur.apache.org/www/cvs.apache.org/maven-snapshot-repository Apache Announce List announce-subscribe@apache.org announce-unsubscribe@apache.org announce@apache.org http://mail-archives.apache.org/mod_mbox/www-announce/ maven-maven-3.5.2/maven-core/src/test/remote-repo/org/apache/apache/maven-metadata.xml000066400000000000000000000004671317160430700306430ustar00rootroot00000000000000 org.apache apache 1 1 1 20150428055824 maven-maven-3.5.2/maven-core/src/test/remote-repo/org/apache/maven/000077500000000000000000000000001317160430700251135ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/remote-repo/org/apache/maven/its/000077500000000000000000000000001317160430700257125ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/remote-repo/org/apache/maven/its/a/000077500000000000000000000000001317160430700261325ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/remote-repo/org/apache/maven/its/a/0.1/000077500000000000000000000000001317160430700264305ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/remote-repo/org/apache/maven/its/a/0.1/a-0.1.pom000066400000000000000000000023351317160430700276640ustar00rootroot00000000000000 4.0.0 org.apache.maven.its a 0.1 jar Maven Integration Test :: Dummy Artifact maven-core-it file:///${basedir}/repo maven-maven-3.5.2/maven-core/src/test/remote-repo/org/apache/maven/its/a/maven-metadata.xml000066400000000000000000000004471317160430700315450ustar00rootroot00000000000000 org.apache.maven.its a 0.1 0.1 20091023222756 maven-maven-3.5.2/maven-core/src/test/remote-repo/org/apache/maven/its/b/000077500000000000000000000000001317160430700261335ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/remote-repo/org/apache/maven/its/b/0.1/000077500000000000000000000000001317160430700264315ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/remote-repo/org/apache/maven/its/b/0.1/b-0.1.pom000066400000000000000000000026201317160430700276630ustar00rootroot00000000000000 4.0.0 org.apache.maven.its b 0.1 jar Maven Integration Test :: Dummy Artifact maven-core-it file:///${basedir}/repo org.apache.maven.its a 0.1 maven-maven-3.5.2/maven-core/src/test/remote-repo/org/apache/maven/its/b/maven-metadata.xml000066400000000000000000000004471317160430700315460ustar00rootroot00000000000000 org.apache.maven.its b 0.1 0.1 20091023222817 maven-maven-3.5.2/maven-core/src/test/remote-repo/org/apache/maven/its/plugins/000077500000000000000000000000001317160430700273735ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/remote-repo/org/apache/maven/its/plugins/maven-it-plugin/000077500000000000000000000000001317160430700324075ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/remote-repo/org/apache/maven/its/plugins/maven-it-plugin/0.1/000077500000000000000000000000001317160430700327055ustar00rootroot00000000000000maven-it-plugin-0.1.pom000066400000000000000000000041771317160430700366640ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/remote-repo/org/apache/maven/its/plugins/maven-it-plugin/0.1 4.0.0 org.apache.maven.its.plugins maven-it-plugin 0.1 maven-plugin Maven Integration Test Plugin A test plugin to assist testing of Maven core. 2009 maven-core-it file:///${basedir}/repo true true org.apache.maven maven-plugin-api 2.0 . pom.xml src/** src/main/resources pom.xml000066400000000000000000000041771317160430700341540ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/remote-repo/org/apache/maven/its/plugins/maven-it-plugin/0.1 4.0.0 org.apache.maven.its.plugins maven-it-plugin 0.1 maven-plugin Maven Integration Test Plugin A test plugin to assist testing of Maven core. 2009 maven-core-it file:///${basedir}/repo true true org.apache.maven maven-plugin-api 2.0 . pom.xml src/** src/main/resources maven-metadata.xml000066400000000000000000000005611317160430700357400ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/remote-repo/org/apache/maven/its/plugins/maven-it-plugin org.apache.maven.its.plugins maven-it-plugin 0.1 0.1 0.1 0.1 20091023233513 maven-maven-3.5.2/maven-core/src/test/remote-repo/org/apache/maven/its/plugins/maven-metadata.xml000066400000000000000000000003541317160430700330030ustar00rootroot00000000000000 Maven Integration Test Plugin it maven-it-plugin maven-maven-3.5.2/maven-core/src/test/remote-repo/org/apache/maven/maven-plugin-api/000077500000000000000000000000001317160430700302645ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/remote-repo/org/apache/maven/maven-plugin-api/2.0/000077500000000000000000000000001317160430700305635ustar00rootroot00000000000000maven-plugin-api-2.0.pom000066400000000000000000000011311317160430700346630ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/remote-repo/org/apache/maven/maven-plugin-api/2.0 maven org.apache.maven 2.0 4.0.0 org.apache.maven maven-plugin-api Maven Plugin API 2.0 junit junit 3.8.1 test deployed maven-maven-3.5.2/maven-core/src/test/remote-repo/org/apache/maven/maven/000077500000000000000000000000001317160430700262215ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/remote-repo/org/apache/maven/maven/2.0/000077500000000000000000000000001317160430700265205ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/remote-repo/org/apache/maven/maven/2.0/maven-2.0.pom000066400000000000000000000211001317160430700306320ustar00rootroot00000000000000 4.0.0 org.apache.maven maven pom Maven 2.0 Maven is a project development management and comprehension tool. Based on the concept of a project object model: builds, dependency management, documentation creation, site publication, and distribution publication are all controlled from the declarative file. Maven can be extended by plugins to utilise a number of other development tools for reporting or the build process. http://maven.apache.org/maven2/ jira http://jira.codehaus.org/browse/MNG continuum
    commits@maven.apache.org
    Maven User List users-subscribe@maven.apache.org users-unsubscribe@maven.apache.org users@maven.apache.org http://mail-archives.apache.org/mod_mbox/maven-users Maven Developer List dev-subscribe@maven.apache.org dev-unsubscribe@maven.apache.org dev@maven.apache.org http://mail-archives.apache.org/mod_mbox/maven-dev Maven Commits List commits-subscribe@maven.apache.org commits-unsubscribe@maven.apache.org commits@maven.apache.org http://mail-archives.apache.org/mod_mbox/maven-dev Apache Announce List announce-subscribe@apache.org announce-unsubscribe@apache.org announce@apache.org http://mail-archives.apache.org/mod_mbox/www-announce/ jvanzyl Jason van Zyl jason@maven.org ASF PMC Chair -5 brett Brett Porter brett@apache.org ASF PMC Member +10 evenisse Emmanuel Venisse evenisse@apache.org ASF PMC Member +1 jdcasey John Casey jdcasey@apache.org ASF PMC Member -5 kenney Kenney Westerhof kenney@apache.org Neonics PMC Member +1 trygvis Trygve Laugstol trygvis@apache.org ASF PMC Member +1 vmassol Vincent Massol vmassol@apache.org ASF PMC Member +1 vsiveton Vincent Siveton vsiveton@apache.org ASF Committer -5 The Apache Software License, Version 2.0 http://www.apache.org/licenses/LICENSE-2.0.txt repo scm:svn:http://svn.apache.org/repos/asf/maven/components/tags/maven-2.0 scm:svn:https://svn.apache.org/repos/asf/maven/components/tags/maven-2.0 http://svn.apache.org/viewcvs.cgi/maven/components/tags/maven-2.0 Apache Software Foundation http://www.apache.org/ maven-release-plugin https://svn.apache.org/repos/asf/maven/components/tags maven-archiver maven-artifact maven-artifact-manager maven-artifact-ant maven-artifact-test maven-core maven-error-diagnostics maven-model maven-monitor maven-plugin-api maven-plugin-descriptor maven-plugin-parameter-documenter maven-plugin-registry maven-plugin-tools maven-profile maven-project maven-reporting maven-repository-metadata maven-script maven-settings false snapshots Maven Central Development Repository http://snapshots.maven.codehaus.org/maven2 false snapshots Maven Central Plugins Development Repository http://snapshots.maven.codehaus.org/maven2 junit junit 3.8.1 test org.codehaus.plexus plexus-container-default 1.0-alpha-8 org.codehaus.plexus plexus-utils 1.0.4 org.apache.maven.wagon wagon-provider-api 1.0-alpha-5 org.apache.maven.wagon wagon-ssh 1.0-alpha-5 org.apache.maven.wagon wagon-file 1.0-alpha-5 org.apache.maven.wagon wagon-http-lightweight 1.0-alpha-5 repo1 Maven Central Repository scp://repo1.maven.org/home/projects/maven/repository-staging/to-ibiblio/maven2 snapshots Maven Central Development Repository scp://repo1.maven.org/home/projects/maven/repository-staging/snapshots/maven2 website scp://minotaur.apache.org/www/maven.apache.org/maven2/
    maven-maven-3.5.2/maven-core/src/test/remote-repo/org/apache/maven/plugins/000077500000000000000000000000001317160430700265745ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/remote-repo/org/apache/maven/plugins/maven-clean-plugin/000077500000000000000000000000001317160430700322565ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/remote-repo/org/apache/maven/plugins/maven-clean-plugin/0.1/000077500000000000000000000000001317160430700325545ustar00rootroot00000000000000maven-clean-plugin-0.1.pom000066400000000000000000000041761317160430700372000ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/remote-repo/org/apache/maven/plugins/maven-clean-plugin/0.1 4.0.0 org.apache.maven.plugins maven-clean-plugin 0.1 maven-plugin Maven Integration Test Plugin A test plugin to assist testing of Maven core. 2009 maven-core-it file:///${basedir}/repo true true org.apache.maven maven-plugin-api 2.0 . pom.xml src/** src/main/resources maven-metadata.xml000066400000000000000000000005601317160430700356060ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/remote-repo/org/apache/maven/plugins/maven-clean-plugin org.apache.maven.plugins maven-clean-plugin 0.1 0.1 0.1 0.1 20091023224342 maven-maven-3.5.2/maven-core/src/test/remote-repo/org/apache/maven/plugins/maven-compiler-plugin/000077500000000000000000000000001317160430700330065ustar00rootroot000000000000000.1/000077500000000000000000000000001317160430700332255ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/remote-repo/org/apache/maven/plugins/maven-compiler-pluginmaven-compiler-plugin-0.1.pom000066400000000000000000000042011317160430700404450ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/remote-repo/org/apache/maven/plugins/maven-compiler-plugin/0.1 4.0.0 org.apache.maven.plugins maven-compiler-plugin 0.1 maven-plugin Maven Integration Test Plugin A test plugin to assist testing of Maven core. 2009 maven-core-it file:///${basedir}/repo true true org.apache.maven maven-plugin-api 2.0 . pom.xml src/** src/main/resources maven-metadata.xml000066400000000000000000000005631317160430700363410ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/remote-repo/org/apache/maven/plugins/maven-compiler-plugin org.apache.maven.plugins maven-compiler-plugin 0.1 0.1 0.1 0.1 20091023224813 maven-maven-3.5.2/maven-core/src/test/remote-repo/org/apache/maven/plugins/maven-deploy-plugin/000077500000000000000000000000001317160430700324705ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/remote-repo/org/apache/maven/plugins/maven-deploy-plugin/0.1/000077500000000000000000000000001317160430700327665ustar00rootroot00000000000000maven-deploy-plugin-0.1.pom000066400000000000000000000041771317160430700376250ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/remote-repo/org/apache/maven/plugins/maven-deploy-plugin/0.1 4.0.0 org.apache.maven.plugins maven-deploy-plugin 0.1 maven-plugin Maven Integration Test Plugin A test plugin to assist testing of Maven core. 2009 maven-core-it file:///${basedir}/repo true true org.apache.maven maven-plugin-api 2.0 . pom.xml src/** src/main/resources maven-metadata.xml000066400000000000000000000005611317160430700360210ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/remote-repo/org/apache/maven/plugins/maven-deploy-plugin org.apache.maven.plugins maven-deploy-plugin 0.1 0.1 0.1 0.1 20091023224421 maven-maven-3.5.2/maven-core/src/test/remote-repo/org/apache/maven/plugins/maven-install-plugin/000077500000000000000000000000001317160430700326425ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/remote-repo/org/apache/maven/plugins/maven-install-plugin/0.1/000077500000000000000000000000001317160430700331405ustar00rootroot00000000000000maven-install-plugin-0.1.pom000066400000000000000000000042001317160430700401340ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/remote-repo/org/apache/maven/plugins/maven-install-plugin/0.1 4.0.0 org.apache.maven.plugins maven-install-plugin 0.1 maven-plugin Maven Integration Test Plugin A test plugin to assist testing of Maven core. 2009 maven-core-it file:///${basedir}/repo true true org.apache.maven maven-plugin-api 2.0 . pom.xml src/** src/main/resources maven-metadata.xml000066400000000000000000000005621317160430700361740ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/remote-repo/org/apache/maven/plugins/maven-install-plugin org.apache.maven.plugins maven-install-plugin 0.1 0.1 0.1 0.1 20091023224444 maven-maven-3.5.2/maven-core/src/test/remote-repo/org/apache/maven/plugins/maven-jar-plugin/000077500000000000000000000000001317160430700317505ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/remote-repo/org/apache/maven/plugins/maven-jar-plugin/0.1/000077500000000000000000000000001317160430700322465ustar00rootroot00000000000000maven-jar-plugin-0.1.pom000066400000000000000000000041741317160430700363620ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/remote-repo/org/apache/maven/plugins/maven-jar-plugin/0.1 4.0.0 org.apache.maven.plugins maven-jar-plugin 0.1 maven-plugin Maven Integration Test Plugin A test plugin to assist testing of Maven core. 2009 maven-core-it file:///${basedir}/repo true true org.apache.maven maven-plugin-api 2.0 . pom.xml src/** src/main/resources maven-metadata.xml000066400000000000000000000005561317160430700353050ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/remote-repo/org/apache/maven/plugins/maven-jar-plugin org.apache.maven.plugins maven-jar-plugin 0.1 0.1 0.1 0.1 20091023232454 maven-maven-3.5.2/maven-core/src/test/remote-repo/org/apache/maven/plugins/maven-metadata.xml000066400000000000000000000025071317160430700322060ustar00rootroot00000000000000 Maven Integration Test Plugin clean maven-clean-plugin Maven Integration Test Plugin deploy maven-deploy-plugin Maven Integration Test Plugin install maven-install-plugin Maven Integration Test Plugin jar maven-jar-plugin Maven Integration Test Plugin surefire maven-surefire-plugin Maven Integration Test Plugin compiler maven-compiler-plugin Maven Integration Test Plugin resources maven-resources-plugin Maven Integration Test Plugin plugin maven-plugin-plugin maven-maven-3.5.2/maven-core/src/test/remote-repo/org/apache/maven/plugins/maven-plugin-plugin/000077500000000000000000000000001317160430700324725ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/remote-repo/org/apache/maven/plugins/maven-plugin-plugin/0.1/000077500000000000000000000000001317160430700327705ustar00rootroot00000000000000maven-plugin-plugin-0.1.pom000066400000000000000000000041771317160430700376310ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/remote-repo/org/apache/maven/plugins/maven-plugin-plugin/0.1 4.0.0 org.apache.maven.plugins maven-plugin-plugin 0.1 maven-plugin Maven Integration Test Plugin A test plugin to assist testing of Maven core. 2009 maven-core-it file:///${basedir}/repo true true org.apache.maven maven-plugin-api 2.0 . pom.xml src/** src/main/resources maven-metadata.xml000066400000000000000000000005611317160430700360230ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/remote-repo/org/apache/maven/plugins/maven-plugin-plugin org.apache.maven.plugins maven-plugin-plugin 0.1 0.1 0.1 0.1 20091023225046 maven-maven-3.5.2/maven-core/src/test/remote-repo/org/apache/maven/plugins/maven-resources-plugin/000077500000000000000000000000001317160430700332065ustar00rootroot000000000000000.1/000077500000000000000000000000001317160430700334255ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/remote-repo/org/apache/maven/plugins/maven-resources-pluginmaven-resources-plugin-0.1.pom000066400000000000000000000042021317160430700410460ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/remote-repo/org/apache/maven/plugins/maven-resources-plugin/0.1 4.0.0 org.apache.maven.plugins maven-resources-plugin 0.1 maven-plugin Maven Integration Test Plugin A test plugin to assist testing of Maven core. 2009 maven-core-it file:///${basedir}/repo true true org.apache.maven maven-plugin-api 2.0 . pom.xml src/** src/main/resources maven-metadata.xml000066400000000000000000000005641317160430700365420ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/remote-repo/org/apache/maven/plugins/maven-resources-plugin org.apache.maven.plugins maven-resources-plugin 0.1 0.1 0.1 0.1 20091023224958 maven-maven-3.5.2/maven-core/src/test/remote-repo/org/apache/maven/plugins/maven-surefire-plugin/000077500000000000000000000000001317160430700330205ustar00rootroot000000000000000.1/000077500000000000000000000000001317160430700332375ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/remote-repo/org/apache/maven/plugins/maven-surefire-pluginmaven-surefire-plugin-0.1.pom000066400000000000000000000042011317160430700404710ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/remote-repo/org/apache/maven/plugins/maven-surefire-plugin/0.1 4.0.0 org.apache.maven.plugins maven-surefire-plugin 0.1 maven-plugin Maven Integration Test Plugin A test plugin to assist testing of Maven core. 2009 maven-core-it file:///${basedir}/repo true true org.apache.maven maven-plugin-api 2.0 . pom.xml src/** src/main/resources maven-metadata.xml000066400000000000000000000005631317160430700363530ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/remote-repo/org/apache/maven/plugins/maven-surefire-plugin org.apache.maven.plugins maven-surefire-plugin 0.1 0.1 0.1 0.1 20091023225125 maven-maven-3.5.2/maven-core/src/test/remote-repo/org/codehaus/000077500000000000000000000000001317160430700243575ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/remote-repo/org/codehaus/plexus/000077500000000000000000000000001317160430700256775ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/remote-repo/org/codehaus/plexus/plexus-utils/000077500000000000000000000000001317160430700303555ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/remote-repo/org/codehaus/plexus/plexus-utils/1.1/000077500000000000000000000000001317160430700306545ustar00rootroot00000000000000plexus-utils-1.1.pom000066400000000000000000000013771317160430700342750ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/remote-repo/org/codehaus/plexus/plexus-utils/1.1 plexus org.codehaus.plexus 1.0.4 4.0.0 plexus-utils Plexus Common Utilities 1.1 maven-surefire-plugin org/codehaus/plexus/util/FileBasedTestCase.java **/Test*.java deployed maven-maven-3.5.2/maven-core/src/test/resources-project-builder/000077500000000000000000000000001317160430700246415ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources-project-builder/artifact-id-inheritance/000077500000000000000000000000001317160430700313175ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources-project-builder/artifact-id-inheritance/child/000077500000000000000000000000001317160430700324025ustar00rootroot00000000000000pom.xml000066400000000000000000000021031317160430700336340ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources-project-builder/artifact-id-inheritance/child 4.0.0 org.apache.maven.its.mng parent 0.1 maven-maven-3.5.2/maven-core/src/test/resources-project-builder/artifact-id-inheritance/pom.xml000066400000000000000000000023241317160430700326350ustar00rootroot00000000000000 4.0.0 org.apache.maven.its.mng parent 0.1 pom http://maven.apache.org/ maven-maven-3.5.2/maven-core/src/test/resources-project-builder/basedir-aligned-interpolation/000077500000000000000000000000001317160430700325405ustar00rootroot00000000000000pom.xml000066400000000000000000000043541317160430700340040ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources-project-builder/basedir-aligned-interpolation 4.0.0 org.apache.maven.its.mng3822 test1 1.0-SNAPSHOT Maven Integration Test :: MNG-3822 Verify that POM interpolation uses basedir-aligned build directories. ${project.build.sourceDirectory} ${project.build.testSourceDirectory} ${project.build.scriptSourceDirectory} ${project.build.directory} ${project.build.outputDirectory} ${project.build.testOutputDirectory} ${project.reporting.outputDirectory} src/main/java src/test/java src/main/scripts target target/classes target/test-classes target/site maven-maven-3.5.2/maven-core/src/test/resources-project-builder/basedir-interpolation/000077500000000000000000000000001317160430700311375ustar00rootroot00000000000000pom-with-unusual-name.xml000066400000000000000000000024661317160430700357660ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources-project-builder/basedir-interpolation 4.0.0 org.apache.maven.its.mng3944 test1 1.0-SNAPSHOT Maven Integration Test :: MNG-3944 Test that interpolation of ${basedir} works for a POM that is not named "pom.xml" ${basedir} ${project.basedir} maven-maven-3.5.2/maven-core/src/test/resources-project-builder/baseurl-interpolation/000077500000000000000000000000001317160430700311635ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources-project-builder/baseurl-interpolation/pom.xml000066400000000000000000000023571317160430700325070ustar00rootroot00000000000000 4.0.0 org.apache.maven.its.mng3760 test1 1.0-SNAPSHOT Maven Integration Test :: MNG-3760 Test interpolation of ${project.baseUri} ${project.baseUri} maven-maven-3.5.2/maven-core/src/test/resources-project-builder/boolean-interpolation/000077500000000000000000000000001317160430700311455ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources-project-builder/boolean-interpolation/pom.xml000066400000000000000000000050031317160430700324600ustar00rootroot00000000000000 4.0.0 org.apache.maven.its.mng1995 test1 1.0 Maven Integration Test :: MNG-1995 Verify that POM fields that are of type boolean can be interpolated with expressions. true true maven-core-it file:///${basedir}/repo ${releasesEnabled} src/main/resources ${filter.resources} org.apache.maven.its.plugins maven-it-plugin-expression 2.1-SNAPSHOT target/expression.properties project/build/resources/0/filtering project/repositories test validate eval maven-maven-3.5.2/maven-core/src/test/resources-project-builder/build-extension-inheritance/000077500000000000000000000000001317160430700322415ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources-project-builder/build-extension-inheritance/pom.xml000066400000000000000000000027741317160430700335700ustar00rootroot00000000000000 4.0.0 org.apache.maven.its.mng3899 parent 0.1 pom Maven Integration Test :: MNG-3899 Test that build extensions are properly merged during inheritance. org.apache.maven.its.mng3899 a 0.1 org.apache.maven.its.mng3899 c 0.1 maven-maven-3.5.2/maven-core/src/test/resources-project-builder/build-extension-inheritance/sub/000077500000000000000000000000001317160430700330325ustar00rootroot00000000000000pom.xml000066400000000000000000000045211317160430700342720ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources-project-builder/build-extension-inheritance/sub 4.0.0 org.apache.maven.its.mng3899 parent 0.1 child Maven Integration Test :: MNG-3899 Test that build extensions are properly merged during inheritance. org.apache.maven.its.mng3899 b 0.1 org.apache.maven.its.mng3899 a 0.2 org.apache.maven.its.plugins maven-it-plugin-expression 2.1-SNAPSHOT validate eval target/extension.properties project/build/extensions maven-maven-3.5.2/maven-core/src/test/resources-project-builder/complete-model/000077500000000000000000000000001317160430700275475ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources-project-builder/complete-model/w-parent/000077500000000000000000000000001317160430700313045ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources-project-builder/complete-model/w-parent/pom.xml000066400000000000000000000020541317160430700326220ustar00rootroot00000000000000 4.0.0 org.apache.maven.its.mng parent 0.1 pom maven-maven-3.5.2/maven-core/src/test/resources-project-builder/complete-model/w-parent/sub/000077500000000000000000000000001317160430700320755ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources-project-builder/complete-model/w-parent/sub/pom.xml000066400000000000000000000213731317160430700334200ustar00rootroot00000000000000 4.0.0 org.apache.maven.its.mng parent 0.1 org.apache.maven.its.mng test 0.2 pom project-name project-description http://project.url/ 2009 project-org http://project-org.url/ project-license http://project.url/license repo free dev project-developer developer@ http://developer developer http://devel.org devel -1 yes project-contributor contributor@ http://contributor contributor http://contrib.org contrib +1 yes project-mailing-list subscribe@ unsubscribe@ post@ mail-archive other-archive 2.0.1 http://project.url/trunk http://project.url/scm https://project.url/scm TAG issues http://project.url/issues ci http://project.url/ci irc
    ci@
    true false false false ci
    http://project.url/dist project.distros distros http://project.url/snaps project.snaps snaps false http://project.url/site project.site docs http://project.url/download reloc-gid reloc-aid reloc-version project-reloc-msg sub project-property org.apache.maven.its managed-dep 0.1 war runtime org.apache.maven.its excluded-managed-dep org.apache.maven.its dep 0.2 ejb test true org.apache.maven.its excluded-dep project-remote-repo http://project.url/remote repo org.apache.maven.its.ext ext 3.0 test build sources/main sources/scripts sources/test build/main build/test coreit res/main true main main.included main.excluded res/test true test test.included test.excluded src/main/filter/it.properties org.apache.maven.its.plugins maven-it-plugin-build 2.1-SNAPSHOT test.properties test validate eval pom.properties org.apache.maven.its build-plugin-dep 0.3 zip org.apache.maven.its excluded-build-plugin-dep true docs org.apache.maven.its.plugins maven-it-plugin-reporting 2.0-SNAPSHOT test.html it run index.html
    maven-maven-3.5.2/maven-core/src/test/resources-project-builder/complete-model/wo-parent/000077500000000000000000000000001317160430700314635ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources-project-builder/complete-model/wo-parent/pom.xml000066400000000000000000000211641317160430700330040ustar00rootroot00000000000000 4.0.0 org.apache.maven.its.mng test 0.2 pom project-name project-description http://project.url/ 2009 project-org http://project-org.url/ project-license http://project.url/license repo free dev project-developer developer@ http://developer developer http://devel.org devel -1 yes project-contributor contributor@ http://contributor contributor http://contrib.org contrib +1 yes project-mailing-list subscribe@ unsubscribe@ post@ mail-archive other-archive 2.0.1 http://project.url/trunk http://project.url/scm https://project.url/scm TAG issues http://project.url/issues ci http://project.url/ci irc
    ci@
    true false false false ci
    http://project.url/dist project.distros distros http://project.url/snaps project.snaps snaps false http://project.url/site project.site docs http://project.url/download reloc-gid reloc-aid reloc-version project-reloc-msg sub project-property org.apache.maven.its managed-dep 0.1 war runtime org.apache.maven.its excluded-managed-dep org.apache.maven.its dep 0.2 ejb test true org.apache.maven.its excluded-dep project-remote-repo http://project.url/remote repo org.apache.maven.its.ext ext 3.0 test build sources/main sources/scripts sources/test build/main build/test coreit res/main true main main.included main.excluded res/test true test test.included test.excluded src/main/filter/it.properties org.apache.maven.its.plugins maven-it-plugin-build 2.1-SNAPSHOT test.properties test validate eval pom.properties org.apache.maven.its build-plugin-dep 0.3 zip org.apache.maven.its excluded-build-plugin-dep true docs org.apache.maven.its.plugins maven-it-plugin-reporting 2.0-SNAPSHOT test.html it run index.html
    maven-maven-3.5.2/maven-core/src/test/resources-project-builder/config-with-plugin-mng/000077500000000000000000000000001317160430700311325ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources-project-builder/config-with-plugin-mng/pom.xml000066400000000000000000000016321317160430700324510ustar00rootroot00000000000000 4.0.0 org.sonatype.nexus nexus 1.3.0-SNAPSHOT org.codehaus.modello modello-maven-plugin nexus.xml 1.0.8 security.xml 1.0.0 src/main/mdo/security.xml org.codehaus.modello modello-maven-plugin 1.0-alpha-21 maven-maven-3.5.2/maven-core/src/test/resources-project-builder/consecutive_empty_elements/000077500000000000000000000000001317160430700323025ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources-project-builder/consecutive_empty_elements/pom.xml000066400000000000000000000004421317160430700336170ustar00rootroot00000000000000 4.0.0 test artifact 1.0 maven-maven-3.5.2/maven-core/src/test/resources-project-builder/contributors-inheritance/000077500000000000000000000000001317160430700316655ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources-project-builder/contributors-inheritance/child-2/000077500000000000000000000000001317160430700331075ustar00rootroot00000000000000pom.xml000066400000000000000000000025331317160430700343500ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources-project-builder/contributors-inheritance/child-2 4.0.0 org.apache.maven.its.mng3843 parent-1 0.1 org.apache.maven.its.mng3843.child child-2 0.2 jar child-contributor maven-maven-3.5.2/maven-core/src/test/resources-project-builder/contributors-inheritance/pom.xml000066400000000000000000000021331317160430700332010ustar00rootroot00000000000000 4.0.0 org.apache.maven.its.mng3843 parent-1 0.1 pom parent-contributor maven-maven-3.5.2/maven-core/src/test/resources-project-builder/dependency-inheritance/000077500000000000000000000000001317160430700312465ustar00rootroot00000000000000maven-parent.xml000066400000000000000000000023001317160430700343010ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources-project-builder/dependency-inheritance 4.0.0 org.apache.maven maven-parent 11 pom Apache Maven maven-maven-3.5.2/maven-core/src/test/resources-project-builder/dependency-inheritance/pom.xml000066400000000000000000000032171317160430700325660ustar00rootroot00000000000000 4.0.0 org.apache.maven maven-parent 11 maven-parent.xml org.apache.maven maven 3.0-SNAPSHOT pom 3.8.1 junit junit ${junitVersion} test maven-maven-3.5.2/maven-core/src/test/resources-project-builder/dependency-inheritance/sub/000077500000000000000000000000001317160430700320375ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources-project-builder/dependency-inheritance/sub/pom.xml000066400000000000000000000030411317160430700333520ustar00rootroot00000000000000 maven org.apache.maven 3.0-SNAPSHOT 4.0.0 org.apache.maven maven-project-builder 3.0-SNAPSHOT Maven Project Builder junit junit 4.4 test dependency-management-with-interpolation/000077500000000000000000000000001317160430700346505ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources-project-builderpom.xml000066400000000000000000000006711317160430700361710ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources-project-builder/dependency-management-with-interpolation 4.0.0 asm-parent asm 3.0 pom asm-util ${project.groupId} ${project.version} sub/000077500000000000000000000000001317160430700354415ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources-project-builder/dependency-management-with-interpolationpom.xml000066400000000000000000000006131317160430700367560ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources-project-builder/dependency-management-with-interpolation/sub asm-parent asm 3.0 4.0.0 asm-xml 3.0 asm asm-util maven-maven-3.5.2/maven-core/src/test/resources-project-builder/dependency-order/000077500000000000000000000000001317160430700300705ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources-project-builder/dependency-order/w-plugin-mgmt/000077500000000000000000000000001317160430700325745ustar00rootroot00000000000000pom.xml000066400000000000000000000043651317160430700340420ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources-project-builder/dependency-order/w-plugin-mgmt 4.0.0 org.apache.maven.its.mng4003 test 1.0-SNAPSHOT Maven Integration Test :: MNG-4003 Verify that dependencies survive the project construction in the POM order. org.apache.maven.its.mng4003 a 1 org.apache.maven.its.mng4003 c 1 org.apache.maven.its.mng4003 b 1 org.apache.maven.its.mng4003 d 1 maven-clean-plugin 2.3 maven-maven-3.5.2/maven-core/src/test/resources-project-builder/dependency-order/wo-plugin-mgmt/000077500000000000000000000000001317160430700327535ustar00rootroot00000000000000pom.xml000066400000000000000000000042571317160430700342210ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources-project-builder/dependency-order/wo-plugin-mgmt 4.0.0 org.apache.maven.its.mng4003 test 1.0-SNAPSHOT Maven Integration Test :: MNG-4003 Verify that dependencies survive the project construction in the POM order. org.apache.maven.its.mng4003 a 1 org.apache.maven.its.mng4003 c 1 org.apache.maven.its.mng4003 b 1 org.apache.maven.its.mng4003 d 1 maven-clean-plugin 2.3 maven-maven-3.5.2/maven-core/src/test/resources-project-builder/dependency-scope-inheritance/000077500000000000000000000000001317160430700323555ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources-project-builder/dependency-scope-inheritance/pom.xml000066400000000000000000000005241317160430700336730ustar00rootroot00000000000000 4.0.0 p0 maven 1.0 pom maven-test 1.0 a test maven-maven-3.5.2/maven-core/src/test/resources-project-builder/dependency-scope-inheritance/sub/000077500000000000000000000000001317160430700331465ustar00rootroot00000000000000pom.xml000066400000000000000000000006431317160430700344070ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources-project-builder/dependency-scope-inheritance/sub p0 maven 1.0 4.0.0 maven p1 1.0 maven-test 1.0 a maven-maven-3.5.2/maven-core/src/test/resources-project-builder/dependency-scope/000077500000000000000000000000001317160430700300665ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources-project-builder/dependency-scope/pom.xml000066400000000000000000000006541317160430700314100ustar00rootroot00000000000000 4.0.0 maven-t10 p0 pom p0 1.0 maven-test t10-a 2.0 maven-maven-3.5.2/maven-core/src/test/resources-project-builder/dependency-scope/sub/000077500000000000000000000000001317160430700306575ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources-project-builder/dependency-scope/sub/pom.xml000066400000000000000000000010061317160430700321710ustar00rootroot00000000000000 p0 maven-t10 1.0 4.0.0 maven-t10 p1 pom p1 1.0 scm-url maven-test t10-a 1.0 maven-maven-3.5.2/maven-core/src/test/resources-project-builder/developers-inheritance/000077500000000000000000000000001317160430700313005ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources-project-builder/developers-inheritance/child-2/000077500000000000000000000000001317160430700325225ustar00rootroot00000000000000pom.xml000066400000000000000000000025171317160430700337650ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources-project-builder/developers-inheritance/child-2 4.0.0 org.apache.maven.its.mng3843 parent-1 0.1 org.apache.maven.its.mng3843.child child-2 0.2 jar child-developer maven-maven-3.5.2/maven-core/src/test/resources-project-builder/developers-inheritance/pom.xml000066400000000000000000000021211317160430700326110ustar00rootroot00000000000000 4.0.0 org.apache.maven.its.mng3843 parent-1 0.1 pom parent-developer maven-maven-3.5.2/maven-core/src/test/resources-project-builder/distribution-management/000077500000000000000000000000001317160430700314725ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources-project-builder/distribution-management/pom.xml000066400000000000000000000023271317160430700330130ustar00rootroot00000000000000 4.0.0 org.apache.maven.its.it0061 maven-it-it0061 1.0 jar Maven Integration Test :: it0061 test file:target/test-repo legacy maven-maven-3.5.2/maven-core/src/test/resources-project-builder/dual-execution-ids/000077500000000000000000000000001317160430700303445ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources-project-builder/dual-execution-ids/pom.xml000066400000000000000000000017331317160430700316650ustar00rootroot00000000000000 4.0.0 org.apache.maven.mercury mercury-parent 1.0.0-alpha-3-SNAPSHOT pom org.apache.maven.plugins maven-remote-resources-plugin process org.apache:apache-jar-resource-bundle:1.5 maven-maven-3.5.2/maven-core/src/test/resources-project-builder/dual-execution-ids/sub/000077500000000000000000000000001317160430700311355ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources-project-builder/dual-execution-ids/sub/pom.xml000066400000000000000000000021331317160430700324510ustar00rootroot00000000000000 mercury-parent org.apache.maven.mercury 1.0.0-alpha-3-SNAPSHOT 4.0.0 org.apache.maven.mercury mercury-util Mercury Shared Utilities 1.0.0-alpha-3-SNAPSHOT maven-remote-resources-plugin 1.0 maven-remote-resources-plugin 1.0 default process org.apache:apache-jar-resource-bundle:1.4 maven-maven-3.5.2/maven-core/src/test/resources-project-builder/duplicate-exclusions-dependency/000077500000000000000000000000001317160430700331215ustar00rootroot00000000000000nexus-parent.xml000066400000000000000000000016751317160430700362260ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources-project-builder/duplicate-exclusions-dependency 4.0.0 org.sonatype.nexus nexus-parent 8-SNAPSHOT pom 1.0-beta-3.0.5-SNAPSHOT org.codehaus.plexus plexus-container-default ${plexus.version} commons-logging commons-logging-api pom.xml000066400000000000000000000020431317160430700343560ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources-project-builder/duplicate-exclusions-dependency 4.0.0 org.sonatype.nexus nexus-parent 8-SNAPSHOT nexus-parent.xml org.sonatype.nexus nexus pom Nexus Repository Manager 1.3.0-SNAPSHOT org.codehaus.plexus plexus-container-default provided ${plexus.version} commons-logging commons-logging-api maven-maven-3.5.2/maven-core/src/test/resources-project-builder/duplicate-exclusions-dependency/sub/000077500000000000000000000000001317160430700337125ustar00rootroot00000000000000pom.xml000066400000000000000000000011601317160430700351460ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources-project-builder/duplicate-exclusions-dependency/sub org.sonatype.nexus nexus 1.3.0-SNAPSHOT 4.0.0 nexus-proxy org.codehaus.plexus plexus-container-default maven-maven-3.5.2/maven-core/src/test/resources-project-builder/empty-distMng-repo-url/000077500000000000000000000000001317160430700311455ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources-project-builder/empty-distMng-repo-url/pom.xml000066400000000000000000000005651317160430700324700ustar00rootroot00000000000000 4.0.0 org.apache.commons commons-parent pom 11 dummy Dummy to avoid accidental deploys maven-maven-3.5.2/maven-core/src/test/resources-project-builder/empty-scm/000077500000000000000000000000001317160430700265575ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources-project-builder/empty-scm/pom.xml000066400000000000000000000033141317160430700300750ustar00rootroot00000000000000 4.0.0 org.apache.maven.its.mng3843 test-1 0.1 test org.apache.maven.its.plugins maven-it-plugin-expression 2.1-SNAPSHOT validate eval target/pom.properties project maven-maven-3.5.2/maven-core/src/test/resources-project-builder/equal-plugin-deps/000077500000000000000000000000001317160430700301755ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources-project-builder/equal-plugin-deps/pom.xml000066400000000000000000000045321317160430700315160ustar00rootroot00000000000000 4.0.0 org.apache.maven.its.mng3838 test 1.0-SNAPSHOT Maven Integration Test :: MNG-3838 Verify that using the same dependency for different plugins doesn't blow up the project builder. org.apache.maven.its.plugins maven-it-plugin-a 1.0-SNAPSHOT org.apache.maven.its.mng3838 dep 123 org.apache.maven.its.plugins maven-it-plugin-b 1.0-SNAPSHOT org.apache.maven.its.mng3838 dep 123 maven-maven-3.5.2/maven-core/src/test/resources-project-builder/equal-plugin-exec-ids/000077500000000000000000000000001317160430700307435ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources-project-builder/equal-plugin-exec-ids/pom.xml000066400000000000000000000047301317160430700322640ustar00rootroot00000000000000 4.0.0 org.apache.maven.its.mng3821 test 1.0-SNAPSHOT Maven Integration Test :: MNG-3821 Verify that using the same id for executions/reportsets of different plugins doesn't blow up the project builder. org.apache.maven.its.plugins maven-it-plugin-a 1.0-SNAPSHOT the-one-and-only-id org.apache.maven.its.plugins maven-it-plugin-b 1.0-SNAPSHOT the-one-and-only-id org.apache.maven.its.plugins maven-it-plugin-a 1.0-SNAPSHOT the-one-and-only-id org.apache.maven.its.plugins maven-it-plugin-b 1.0-SNAPSHOT the-one-and-only-id maven-maven-3.5.2/maven-core/src/test/resources-project-builder/execution-configuration-join/000077500000000000000000000000001317160430700324465ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources-project-builder/execution-configuration-join/pom.xml000066400000000000000000000022571317160430700337710ustar00rootroot00000000000000 4.0.0 org.sonatype.nexus nexus 1.3.0-SNAPSHOT org.codehaus.modello modello-maven-plugin 1.0-alpha-21 org.codehaus.modello modello-maven-plugin 1.0-alpha-21 execution-configuration-subcollections/000077500000000000000000000000001317160430700344605ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources-project-builderpom.xml000066400000000000000000000033061317160430700357770ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources-project-builder/execution-configuration-subcollections 4.0.0 test nexus pom Nexus Repository Manager 1.1-M1 maven-enforcer-plugin 1.0 enforce enforce commons-logging:* a *:plexus-component-api maven-maven-3.5.2/maven-core/src/test/resources-project-builder/execution-configuration/000077500000000000000000000000001317160430700315115ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources-project-builder/execution-configuration/pom.xml000066400000000000000000000042411317160430700330270ustar00rootroot00000000000000 4.0.0 org.sonatype.nexus nexus 1.3.0-SNAPSHOT org.codehaus.modello modello-maven-plugin 1.0-alpha-21 nexus.xml java xpp3-reader xpp3-writer 1.0.8 1.0.0 1.0.1 1.0.6 src/main/mdo/nexus.xml security.xml java1 xpp3-reader1 xpp3-writer1 1.0.0 src/main/mdo/security.xml org.codehaus.modello modello-maven-plugin 1.0-alpha-21 maven-maven-3.5.2/maven-core/src/test/resources-project-builder/foo/000077500000000000000000000000001317160430700254245ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources-project-builder/foo/sub/000077500000000000000000000000001317160430700262155ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources-project-builder/foo/sub/pom.xml000066400000000000000000000373351317160430700275450ustar00rootroot00000000000000 4.0.0 archetype-common Maven Archetype Common jar org.apache.maven maven-core net.sourceforge.jchardet jchardet dom4j dom4j org.apache.maven maven-model org.apache.maven maven-project org.codehaus.plexus plexus-container-default org.codehaus.plexus plexus-utils org.apache.maven.shared maven-plugin-testing-harness test commons-io commons-io org.codehaus.plexus plexus-velocity velocity velocity dom4j dom4j commons-collections commons-collections junit junit org.codehaus.cargo cargo-core-api-container 0.9 test org.codehaus.cargo cargo-core-api-util 0.9 test org.codehaus.cargo cargo-core-api-generic 0.9 test org.codehaus.cargo cargo-core-api-module 0.9 test org.codehaus.cargo cargo-core-container-jetty 0.9 test org.mortbay.jetty jetty 6.1.4 test org.apache.maven.wagon wagon-file org.apache.maven.wagon wagon-http 1.0-beta-2 test ${project.groupId} archetype-repository ${project.version} war test ${project.groupId} archetype-proxy ${project.version} war test src/test/resources true org.codehaus.modello modello-maven-plugin 1.0-alpha-14 archetype-common java xsd xpp3-reader xpp3-writer 1.0.0 src/main/mdo/archetype-common.mdo archetype-registry java xsd xpp3-reader xpp3-writer 1.0.0 src/main/mdo/archetype-registry.mdo archetype-descriptor java xsd xpp3-reader xpp3-writer 1.0.0 src/main/mdo/archetype-descriptor.mdo archetype-catalog java xsd xpp3-reader xpp3-writer 1.0.0 src/main/mdo/archetype-catalog.mdo archetype-old java xsd xpp3-reader xpp3-writer 1.0.0 src/main/mdo/archetype.mdo org.apache.maven.plugins maven-dependency-plugin copy process-test-resources copy-dependencies ${project.build.directory}/wars true true war true org.apache.maven.plugins maven-antrun-plugin ant ant-antlr 1.6.5 archetype-test process-test-resources run archetype-test-partial process-test-resources run archetype-test-site process-test-resources run archetype-test-old process-test-resources run archetype-test-fileset process-test-resources run repository-metadata process-test-resources run org.apache.maven.plugins maven-surefire-plugin **/ArchetyperRoundtripTest.java **/ArchetyperRoundtripWithProxyTest.java **/DefaultRepositoryCrawlerTest.java org.codehaus.mojo cobertura-maven-plugin 2.2 internal-catalog org.apache.maven.plugins maven-surefire-plugin **/*Verification.java maven-maven-3.5.2/maven-core/src/test/resources-project-builder/full-interpolation/000077500000000000000000000000001317160430700304705ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources-project-builder/full-interpolation/pom.xml000066400000000000000000000046531317160430700320150ustar00rootroot00000000000000 4.0.0 org.apache.maven.its.mng3833 coreit 0.1 jar Maven Integration Test :: MNG-3833 Test that POM interpolation fully interpolates all properties in data flow chain, i.e. where property A depends on property B, and property B depends on property C and so on. ${property22} ${property20} ${property18} ${property16} ${property14} ${property12} ${property10} ${property08} ${property06} ${property04} ${property02} ${property00} PASSED ${property01} ${property03} ${property05} ${property09} ${property11} ${property07} ${property13} ${property15} ${property17} ${property19} ${property21} id-container-joining-with-empty-elements/000077500000000000000000000000001317160430700345105ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources-project-builderpom.xml000066400000000000000000000054461317160430700360360ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources-project-builder/id-container-joining-with-empty-elements 4.0.0 org.apache.maven.its.mng3979 parent 0.1 pom Maven Integration Test :: MNG-3979 Test that during inheritance the merging/joining of sub trees with equal identifier doesn't crash if the parent POM has a non-empty element and the child POM has an empty element to join. test equal-repo-id http://maven.apache.org/null false ignore org.apache.maven.its.plugins maven-it-plugin-log-file 2.1-SNAPSHOT equal-build-exec-id initialize reset target/exec.log test org.apache.maven.its.plugins maven-it-plugin-log-file 2.1-SNAPSHOT equal-report-exec-id reset target/exec.log test sub/000077500000000000000000000000001317160430700353015ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources-project-builder/id-container-joining-with-empty-elementspom.xml000066400000000000000000000045261317160430700366250ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources-project-builder/id-container-joining-with-empty-elements/sub 4.0.0 org.apache.maven.its.mng3979 parent 0.1 child Maven Integration Test :: MNG-3979 Test that during inheritance the merging/joining of sub trees with equal identifier doesn't crash if the parent POM has a non-empty element and the child POM has an empty element to join. equal-repo-id file:///${basedir}/null org.apache.maven.its.plugins maven-it-plugin-log-file 2.1-SNAPSHOT equal-build-exec-id initialize org.apache.maven.its.plugins maven-it-plugin-log-file 2.1-SNAPSHOT equal-report-exec-id maven-maven-3.5.2/maven-core/src/test/resources-project-builder/inherited-properties-interpolation/000077500000000000000000000000001317160430700336735ustar00rootroot00000000000000active-profile/000077500000000000000000000000001317160430700365255ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources-project-builder/inherited-properties-interpolationpom.xml000066400000000000000000000032311317160430700400410ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources-project-builder/inherited-properties-interpolation/active-profile 4.0.0 org.apache.maven.its.mng4102 parent 0.1 pom Maven Integration Test :: MNG-4102 Verify that the effective value of an inherited property reflects the values of any nested property as defined by the child. This boils down to the order of inheritance and (parent) interpolation. PARENT ${overridden} it-parent true sub/000077500000000000000000000000001317160430700373165ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources-project-builder/inherited-properties-interpolation/active-profilepom.xml000066400000000000000000000032101317160430700406270ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources-project-builder/inherited-properties-interpolation/active-profile/sub 4.0.0 org.apache.maven.its.mng4102 parent 0.1 org.apache.maven.its.mng4102 test 0.1 jar Maven Integration Test :: MNG-4102 :: Child Verify that the effective value of an inherited property reflects the values of any nested property as defined by the child. This boils down to the order of inheritance and (parent) interpolation. CHILD it-child true no-profile/000077500000000000000000000000001317160430700356665ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources-project-builder/inherited-properties-interpolationpom.xml000066400000000000000000000027601317160430700372100ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources-project-builder/inherited-properties-interpolation/no-profile 4.0.0 org.apache.maven.its.mng4102 parent 0.1 pom Maven Integration Test :: MNG-4102 Verify that the effective value of an inherited property reflects the values of any nested property as defined by the child. This boils down to the order of inheritance and (parent) interpolation. PARENT ${overridden} sub/000077500000000000000000000000001317160430700364575ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources-project-builder/inherited-properties-interpolation/no-profilepom.xml000066400000000000000000000027401317160430700377770ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources-project-builder/inherited-properties-interpolation/no-profile/sub 4.0.0 org.apache.maven.its.mng4102 parent 0.1 org.apache.maven.its.mng4102 test 0.1 jar Maven Integration Test :: MNG-4102 :: Child Verify that the effective value of an inherited property reflects the values of any nested property as defined by the child. This boils down to the order of inheritance and (parent) interpolation. CHILD maven-maven-3.5.2/maven-core/src/test/resources-project-builder/interpolation-cli-wins/000077500000000000000000000000001317160430700312535ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources-project-builder/interpolation-cli-wins/pom.xml000066400000000000000000000024521317160430700325730ustar00rootroot00000000000000 4.0.0 org.apache.maven.its.mng4208 test 0.1 jar Maven Integration Test :: MNG-4208 Test that CLI properties specified by the user override project properties during interpolation. FAILED ${testProperty} maven-maven-3.5.2/maven-core/src/test/resources-project-builder/jdk-activation/000077500000000000000000000000001317160430700275505ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources-project-builder/jdk-activation/pom.xml000066400000000000000000000054041317160430700310700ustar00rootroot00000000000000 4.0.0 org.apache.maven.its.mng1957 test 1.0-SNAPSHOT Maven Integration Test :: MNG-1957 Test that JDK profile activation allows version ranges. org.apache.maven.its.plugins maven-it-plugin-expression 2.1-SNAPSHOT validate eval target/jdk.properties project/properties test-1 [1.4,) PASSED test-2 (,100) PASSED test-3 (1.3,100) PASSED test-4 (100,) FAILED test-5 (,1.4) FAILED maven-maven-3.5.2/maven-core/src/test/resources-project-builder/join-different-containers-same-id/000077500000000000000000000000001317160430700332245ustar00rootroot00000000000000pom.xml000066400000000000000000000036131317160430700344650ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources-project-builder/join-different-containers-same-id 4.0.0 mng3984 test 0.1 pom MNG-3984 org.apache.maven.its.plugins maven-it-plugin-b 1.0-SNAPSHOT foo a org.apache.maven.its.plugins maven-it-plugin-a 1.0-SNAPSHOT foo b maven-maven-3.5.2/maven-core/src/test/resources-project-builder/licenses-inheritance/000077500000000000000000000000001317160430700307355ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources-project-builder/licenses-inheritance/child-2/000077500000000000000000000000001317160430700321575ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources-project-builder/licenses-inheritance/child-2/pom.xml000066400000000000000000000026251317160430700335010ustar00rootroot00000000000000 4.0.0 org.apache.maven.its.mng3843 parent-1 0.1 org.apache.maven.its.mng3843.child child-2 0.2 jar child-license http://child.url/license repo maven-maven-3.5.2/maven-core/src/test/resources-project-builder/licenses-inheritance/pom.xml000066400000000000000000000022321317160430700322510ustar00rootroot00000000000000 4.0.0 org.apache.maven.its.mng3843 parent-1 0.1 pom parent-license http://parent.url/license repo maven-maven-3.5.2/maven-core/src/test/resources-project-builder/limited-inheritance/000077500000000000000000000000001317160430700305575ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources-project-builder/limited-inheritance/child/000077500000000000000000000000001317160430700316425ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources-project-builder/limited-inheritance/child/pom.xml000066400000000000000000000033021317160430700331550ustar00rootroot00000000000000 4.0.0 org.apache.maven.its.mng3845 parent 0.1 child child-org https://child.url/scm http://child.url/issues child-ci http://child.url/ci child-distros ssh://child.url/distros child-snaps ssh://child.url/snaps child-site scp://child.url/site maven-maven-3.5.2/maven-core/src/test/resources-project-builder/limited-inheritance/pom.xml000066400000000000000000000051531317160430700321000ustar00rootroot00000000000000 4.0.0 org.apache.maven.its.mng3845 parent 0.1 pom Maven Integration Test :: MNG-3845 Test that inheritance is all-or-nothing for certain sub-trees of the POM. parent-org http://parent.url/org http://parent.url/viewvc http://parent.url/scm https://parent.url/scm parent-tag parent-issues http://parent.url/issues parent-ci http://parent.url/ci irc true true false false
    irc://parent.url/#ci
    parent-distros parent-distros ssh://parent.url/distros false legacy parent-snaps parent-snaps ssh://parent.url/snaps false legacy parent-site parent-site scp://parent.url/site
    maven-maven-3.5.2/maven-core/src/test/resources-project-builder/mailing-lists-inheritance/000077500000000000000000000000001317160430700317045ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources-project-builder/mailing-lists-inheritance/child-2/000077500000000000000000000000001317160430700331265ustar00rootroot00000000000000pom.xml000066400000000000000000000025341317160430700343700ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources-project-builder/mailing-lists-inheritance/child-2 4.0.0 org.apache.maven.its.mng3843 parent-1 0.1 org.apache.maven.its.mng3843.child child-2 0.2 jar child-mailing-list maven-maven-3.5.2/maven-core/src/test/resources-project-builder/mailing-lists-inheritance/pom.xml000066400000000000000000000021341317160430700332210ustar00rootroot00000000000000 4.0.0 org.apache.maven.its.mng3843 parent-1 0.1 pom parent-mailing-list maven-maven-3.5.2/maven-core/src/test/resources-project-builder/managed-profile-dependency/000077500000000000000000000000001317160430700320075ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources-project-builder/managed-profile-dependency/pom.xml000066400000000000000000000033001317160430700333200ustar00rootroot00000000000000 4.0.0 org.apache.maven.its.mng4034 parent 1.0-SNAPSHOT pom Maven Integration Test :: MNG-4034 Verify that dependencies defined in profiles are subject to the dependency management of the parent. sub org.apache.maven.its maven-core-it-support 1.3 runtime commons-lang commons-lang maven-maven-3.5.2/maven-core/src/test/resources-project-builder/managed-profile-dependency/sub/000077500000000000000000000000001317160430700326005ustar00rootroot00000000000000pom.xml000066400000000000000000000033471317160430700340450ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources-project-builder/managed-profile-dependency/sub 4.0.0 org.apache.maven.its.mng4034 parent 1.0-SNAPSHOT org.apache.maven.its.mng4034 child 1.0-SNAPSHOT Maven Integration Test :: MNG-4034 Verify that dependencies defined in profiles are subject to the dependency management of the parent. maven-core-it true org.apache.maven.its maven-core-it-support maven-maven-3.5.2/maven-core/src/test/resources-project-builder/merged-filter-order/000077500000000000000000000000001317160430700305005ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources-project-builder/merged-filter-order/pom.xml000066400000000000000000000033131317160430700320150ustar00rootroot00000000000000 4.0.0 org.apache.maven.its.mng4008 parent 1.0 pom Maven Integration Test :: MNG-4008 Verify that filter definitions are properly merged. src/main/filters/child-a.properties src/main/filters/parent-c.properties src/main/filters/parent-b.properties src/main/filters/parent-d.properties maven-maven-3.5.2/maven-core/src/test/resources-project-builder/merged-filter-order/sub/000077500000000000000000000000001317160430700312715ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources-project-builder/merged-filter-order/sub/pom.xml000066400000000000000000000033401317160430700326060ustar00rootroot00000000000000 4.0.0 org.apache.maven.its.mng4008 parent 1.0 org.apache.maven.its.mng4008 test 1.0 jar Maven Integration Test :: MNG-4008 Verify that filter definitions are properly merged. src/main/filters/child-a.properties src/main/filters/child-c.properties src/main/filters/child-b.properties src/main/filters/child-d.properties maven-maven-3.5.2/maven-core/src/test/resources-project-builder/merged-plugin-class-path-order/000077500000000000000000000000001317160430700325465ustar00rootroot00000000000000w-plugin-mgmt/000077500000000000000000000000001317160430700351735ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources-project-builder/merged-plugin-class-path-orderpom.xml000066400000000000000000000041421317160430700365110ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources-project-builder/merged-plugin-class-path-order/w-plugin-mgmt 4.0.0 org.apache.maven.its.mng3906 parent 0.1 pom Maven Integration Test :: MNG-3906 Test that project-level plugin dependencies are properly merged during inheritance. org.apache.maven.its.plugins maven-it-plugin-class-loader 2.1-SNAPSHOT org.apache.maven.its.mng3906 e 1 org.apache.maven.its.mng3906 a 1 org.apache.maven.its.mng3906 d 1 sub/000077500000000000000000000000001317160430700357645ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources-project-builder/merged-plugin-class-path-order/w-plugin-mgmtpom.xml000066400000000000000000000037601317160430700373070ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources-project-builder/merged-plugin-class-path-order/w-plugin-mgmt/sub 4.0.0 org.apache.maven.its.mng3906 parent 0.1 child Maven Integration Test :: MNG-3906 Test that project-level plugin dependencies are properly merged during inheritance. org.apache.maven.its.plugins maven-it-plugin-class-loader 2.1-SNAPSHOT org.apache.maven.its.mng3906 c 1 org.apache.maven.its.mng3906 a 2 org.apache.maven.its.mng3906 b 1 wo-plugin-mgmt/000077500000000000000000000000001317160430700353525ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources-project-builder/merged-plugin-class-path-orderpom.xml000066400000000000000000000040141317160430700366660ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources-project-builder/merged-plugin-class-path-order/wo-plugin-mgmt 4.0.0 org.apache.maven.its.mng3906 parent 0.1 pom Maven Integration Test :: MNG-3906 Test that project-level plugin dependencies are properly merged during inheritance. org.apache.maven.its.plugins maven-it-plugin-class-loader 2.1-SNAPSHOT org.apache.maven.its.mng3906 e 1 org.apache.maven.its.mng3906 a 1 org.apache.maven.its.mng3906 d 1 sub/000077500000000000000000000000001317160430700361435ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources-project-builder/merged-plugin-class-path-order/wo-plugin-mgmtpom.xml000066400000000000000000000037601317160430700374660ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources-project-builder/merged-plugin-class-path-order/wo-plugin-mgmt/sub 4.0.0 org.apache.maven.its.mng3906 parent 0.1 child Maven Integration Test :: MNG-3906 Test that project-level plugin dependencies are properly merged during inheritance. org.apache.maven.its.plugins maven-it-plugin-class-loader 2.1-SNAPSHOT org.apache.maven.its.mng3906 c 1 org.apache.maven.its.mng3906 a 2 org.apache.maven.its.mng3906 b 1 maven-maven-3.5.2/maven-core/src/test/resources-project-builder/merged-plugin-exec-goals-order/000077500000000000000000000000001317160430700325365ustar00rootroot00000000000000w-plugin-mgmt/000077500000000000000000000000001317160430700351635ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources-project-builder/merged-plugin-exec-goals-orderpom.xml000066400000000000000000000035501317160430700365030ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources-project-builder/merged-plugin-exec-goals-order/w-plugin-mgmt 4.0.0 org.apache.maven.its.mng3937 parent-2 0.1 pom Maven Integration Test :: MNG-3937 Test that during inheritance/merging of a plugin execution the goals specified by child and parent are properly ordered. org.apache.maven.its.plugins maven-it-plugin-a 1.0-SNAPSHOT merge validate parent-b merged parent-a sub/000077500000000000000000000000001317160430700357545ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources-project-builder/merged-plugin-exec-goals-order/w-plugin-mgmtpom.xml000066400000000000000000000033621317160430700372750ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources-project-builder/merged-plugin-exec-goals-order/w-plugin-mgmt/sub 4.0.0 org.apache.maven.its.mng3937 parent-2 0.1 child-2 Maven Integration Test :: MNG-3937 Test that during inheritance/merging of a plugin execution the goals specified by child and parent are properly ordered. org.apache.maven.its.plugins maven-it-plugin-a 1.0-SNAPSHOT merge validate child-a merged child-b wo-plugin-mgmt/000077500000000000000000000000001317160430700353425ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources-project-builder/merged-plugin-exec-goals-orderpom.xml000066400000000000000000000034351317160430700366640ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources-project-builder/merged-plugin-exec-goals-order/wo-plugin-mgmt 4.0.0 org.apache.maven.its.mng3937 parent-1 0.1 pom Maven Integration Test :: MNG-3937 Test that during inheritance/merging of a plugin execution the goals specified by child and parent are properly ordered. org.apache.maven.its.plugins maven-it-plugin-a 1.0-SNAPSHOT merge validate parent-b merged parent-a sub/000077500000000000000000000000001317160430700361335ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources-project-builder/merged-plugin-exec-goals-order/wo-plugin-mgmtpom.xml000066400000000000000000000033621317160430700374540ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources-project-builder/merged-plugin-exec-goals-order/wo-plugin-mgmt/sub 4.0.0 org.apache.maven.its.mng3937 parent-1 0.1 child-1 Maven Integration Test :: MNG-3937 Test that during inheritance/merging of a plugin execution the goals specified by child and parent are properly ordered. org.apache.maven.its.plugins maven-it-plugin-a 1.0-SNAPSHOT merge validate child-a merged child-b maven-maven-3.5.2/maven-core/src/test/resources-project-builder/merged-plugin-exec-order/000077500000000000000000000000001317160430700314335ustar00rootroot00000000000000w-plugin-mgmt/000077500000000000000000000000001317160430700340605ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources-project-builder/merged-plugin-exec-orderpom.xml000066400000000000000000000043411317160430700353770ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources-project-builder/merged-plugin-exec-order/w-plugin-mgmt 4.0.0 org.apache.maven.its.mng3925 parent 0.1 pom Maven Integration Test :: MNG-3925 Test that plugin executions (in the same phase) are properly ordered after inheritance/merge with parent executions. org.apache.maven.its.plugins maven-it-plugin-a 1.0-SNAPSHOT parent-1 validate parent-1 parent-2 validate parent-2 validate parent-default sub/000077500000000000000000000000001317160430700346515ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources-project-builder/merged-plugin-exec-order/w-plugin-mgmtpom.xml000066400000000000000000000041161317160430700361700ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources-project-builder/merged-plugin-exec-order/w-plugin-mgmt/sub 4.0.0 org.apache.maven.its.mng3925 parent 0.1 child Maven Integration Test :: MNG-3925 Test that plugin executions (in the same phase) are properly ordered after inheritance/merge with parent executions. org.apache.maven.its.plugins maven-it-plugin-a 1.0-SNAPSHOT child-1 validate child-1 child-2 validate child-2 validate child-default wo-plugin-mgmt/000077500000000000000000000000001317160430700342375ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources-project-builder/merged-plugin-exec-orderpom.xml000066400000000000000000000041761317160430700355640ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources-project-builder/merged-plugin-exec-order/wo-plugin-mgmt 4.0.0 org.apache.maven.its.mng3925 parent 0.1 pom Maven Integration Test :: MNG-3925 Test that plugin executions (in the same phase) are properly ordered after inheritance/merge with parent executions. org.apache.maven.its.plugins maven-it-plugin-a 1.0-SNAPSHOT parent-1 validate parent-1 parent-2 validate parent-2 validate parent-default sub/000077500000000000000000000000001317160430700350305ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources-project-builder/merged-plugin-exec-order/wo-plugin-mgmtpom.xml000066400000000000000000000041161317160430700363470ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources-project-builder/merged-plugin-exec-order/wo-plugin-mgmt/sub 4.0.0 org.apache.maven.its.mng3925 parent 0.1 child Maven Integration Test :: MNG-3925 Test that plugin executions (in the same phase) are properly ordered after inheritance/merge with parent executions. org.apache.maven.its.plugins maven-it-plugin-a 1.0-SNAPSHOT child-1 validate child-1 child-2 validate child-2 validate child-default maven-maven-3.5.2/maven-core/src/test/resources-project-builder/micromailer/000077500000000000000000000000001317160430700271445ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources-project-builder/micromailer/pom.xml000066400000000000000000000064211317160430700304640ustar00rootroot00000000000000 4.0.0 org.sonatype.spice spice-parent 11 spice-parent-9.pom org.sonatype.micromailer micromailer 1.0.3 jar Micro Mailer scm:svn:http://svn.sonatype.org/spice/trunk/micromailer http://svn.sonatype.org/spice/trunk/micromailer scm:svn:https://svn.sonatype.org/spice/trunk/micromailer org.codehaus.plexus plexus-container-default 1.0-alpha-47 jar compile commons-logging commons-logging commons-logging commons-logging-api log4j log4j org.codehaus.plexus plexus-utils 1.5.5 jar compile org.codehaus.plexus plexus-velocity 1.1.7 jar compile org.codehaus.plexus plexus-component-api velocity velocity commons-collections commons-collections org.apache.velocity velocity 1.5 jar compile javax.mail mail 1.4 jar compile junit junit 3.8.2 jar test org.codehaus.plexus plexus-maven-plugin 1.3.8 child-descriptor maven-maven-3.5.2/maven-core/src/test/resources-project-builder/micromailer/spice-parent-9.pom000066400000000000000000000057441317160430700324330ustar00rootroot00000000000000 4.0.0 org.sonatype.spice spice-parent 11 pom Sonatype Spice Components scm:svn:http://svn.sonatype.org/spice/trunk/spice-parent http://svn.sonatype.org/spice/trunk/spice-parent scm:svn:https://svn.sonatype.org/spice/trunk/spice-parent 6.1.12 org.codehaus.plexus plexus-container-default 1.0-beta-1 commons-logging commons-logging commons-logging commons-logging-api log4j log4j org.codehaus.plexus plexus-component-annotations 1.0-beta-1 org.codehaus.plexus plexus-utils 1.5.5 org.mortbay.jetty jetty ${jetty.version} org.mortbay.jetty jetty-client ${jetty.version} junit junit 4.5 test org.codehaus.plexus plexus-component-metadata 1.0-beta-1 process-classes generate-metadata org.codehaus.plexus plexus-maven-plugin 1.3.8 descriptor maven-maven-3.5.2/maven-core/src/test/resources-project-builder/multiple-filters/000077500000000000000000000000001317160430700301425ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources-project-builder/multiple-filters/pom.xml000066400000000000000000000011631317160430700314600ustar00rootroot00000000000000 4.0.0 a b 1.0 src/main/filters/a.properties src/main/filters/c.properties src/main/filters/b.properties src/main/filters/d.properties maven-maven-3.5.2/maven-core/src/test/resources-project-builder/multiple-repos/000077500000000000000000000000001317160430700276225ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources-project-builder/multiple-repos/pom.xml000066400000000000000000000024571317160430700311470ustar00rootroot00000000000000 4.0.0 mng3984 test-1 0.1 pom MNG-3984 central-parent Maven Repository Switchboard default http://repo1.maven.org/maven2 false maven-maven-3.5.2/maven-core/src/test/resources-project-builder/multiple-repos/sub/000077500000000000000000000000001317160430700304135ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources-project-builder/multiple-repos/sub/pom.xml000066400000000000000000000025631317160430700317360ustar00rootroot00000000000000 4.0.0 mng3984 test-1 0.1 mng3984 test-2 0.1 MNG-3984 central-child Maven Repository Switchboard default http://repo1.maven.org/maven2 false maven-maven-3.5.2/maven-core/src/test/resources-project-builder/nested-build-dir-interpolation/000077500000000000000000000000001317160430700326615ustar00rootroot00000000000000pom.xml000066400000000000000000000037161317160430700341260ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources-project-builder/nested-build-dir-interpolation 4.0.0 org.apache.maven.its.mng3904 test 0.1 jar Maven Integration Test :: MNG-3904 Test that properties which refer to build directories which in turn refer to other build directories are properly interpolated. ${project.build.outputDirectory}/dir0 ${project.build.testSourceDirectory}/dir1 ${project.reporting.outputDirectory}/dir2 ${project.basedir}/target ${project.build.directory}/classes ${basedir}/src ${project.build.sourceDirectory}/test ${project.build.directory}/site maven-maven-3.5.2/maven-core/src/test/resources-project-builder/parent-inheritance/000077500000000000000000000000001317160430700304215ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources-project-builder/parent-inheritance/child3.xml000066400000000000000000000002651317160430700323140ustar00rootroot00000000000000 gid child-3 1.0 pom 4.0.0 maven-maven-3.5.2/maven-core/src/test/resources-project-builder/parent-inheritance/pom.xml000066400000000000000000000004271317160430700317410ustar00rootroot00000000000000 gid child-3 1.0 child3.xml 4.0.0 child-2 pom maven-maven-3.5.2/maven-core/src/test/resources-project-builder/parent-inheritance/sub/000077500000000000000000000000001317160430700312125ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources-project-builder/parent-inheritance/sub/pom.xml000066400000000000000000000003161317160430700325270ustar00rootroot00000000000000 gid child-2 1.0 4.0.0 child-1 maven-maven-3.5.2/maven-core/src/test/resources-project-builder/parent-interpolation/000077500000000000000000000000001317160430700310175ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources-project-builder/parent-interpolation/pom.xml000066400000000000000000000007231317160430700323360ustar00rootroot00000000000000 4.0.0 org.sonatype.nexus nexus 1.3.0-SNAPSHOT pom org.codehaus.modello modello-maven-plugin ${project.version} maven-maven-3.5.2/maven-core/src/test/resources-project-builder/parent-interpolation/sub/000077500000000000000000000000001317160430700316105ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources-project-builder/parent-interpolation/sub/pom.xml000066400000000000000000000003611317160430700331250ustar00rootroot00000000000000 org.sonatype.nexus nexus 1.3.0-SNAPSHOT 4.0.0 a maven-maven-3.5.2/maven-core/src/test/resources-project-builder/parent-pom-packaging/000077500000000000000000000000001317160430700306455ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources-project-builder/parent-pom-packaging/pom.xml000066400000000000000000000023411317160430700321620ustar00rootroot00000000000000 4.0.0 org.apache.maven.its.mng4283 parent 0.1 jar Maven Integration Test :: MNG-4283 Test that the model builder fails when a parent POM has not "pom" packaging. maven-maven-3.5.2/maven-core/src/test/resources-project-builder/parent-pom-packaging/sub/000077500000000000000000000000001317160430700314365ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources-project-builder/parent-pom-packaging/sub/pom.xml000066400000000000000000000024301317160430700327520ustar00rootroot00000000000000 4.0.0 org.apache.maven.its.mng4283 parent 0.1 org.apache.maven.its.mng4283 test 0.1 jar Maven Integration Test :: MNG-4283 Test that the model builder fails when a parent POM has not "pom" packaging. maven-maven-3.5.2/maven-core/src/test/resources-project-builder/platform-file-separator/000077500000000000000000000000001317160430700314005ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources-project-builder/platform-file-separator/pom.xml000066400000000000000000000026761317160430700327300ustar00rootroot00000000000000 4.0.0 org.apache.maven.its.mng3877 test 1.0 jar Maven Integration Test :: MNG-3877 Verify that paths to project directories use the platform-specific file separator. src/main/filters/it.properties maven-maven-3.5.2/maven-core/src/test/resources-project-builder/plugin-config-append/000077500000000000000000000000001317160430700306475ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources-project-builder/plugin-config-append/no-profile/000077500000000000000000000000001317160430700327215ustar00rootroot00000000000000pom.xml000066400000000000000000000052061317160430700341620ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources-project-builder/plugin-config-append/no-profile 4.0.0 org.apache.maven.its.mng2591 parent 1.0 pom Maven Integration Test :: MNG-2591 Test aggregation of list configuration items for build plugins when using 'combine.children=append' attribute. subproject org.apache.maven.its.plugins maven-it-plugin-configuration 2.1-SNAPSHOT true PARENT-1 PARENT-3 PARENT-2 PARENT-4 org.apache.maven.its.plugins maven-it-plugin-configuration 2.1-SNAPSHOT true PARENT-1 PARENT-3 PARENT-2 PARENT-4 subproject/000077500000000000000000000000001317160430700350225ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources-project-builder/plugin-config-append/no-profilepom.xml000066400000000000000000000044441317160430700363450ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources-project-builder/plugin-config-append/no-profile/subproject 4.0.0 org.apache.maven.its.mng2591 parent 1.0 subproject 1.0 jar org.apache.maven.its.plugins maven-it-plugin-configuration 2.1-SNAPSHOT target/config.properties CHILD-1 CHILD-3 CHILD-2 CHILD-4 CHILD-1 CHILD-3 CHILD-2 CHILD-4 test validate config maven-maven-3.5.2/maven-core/src/test/resources-project-builder/plugin-config-append/with-profile/000077500000000000000000000000001317160430700332605ustar00rootroot00000000000000pom.xml000066400000000000000000000056401317160430700345230ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources-project-builder/plugin-config-append/with-profile 4.0.0 org.apache.maven.its.mng2591 parent 1.0 pom Maven Integration Test :: MNG-2591 Test aggregation of list configuration items for build plugins when using 'combine.children=append' attribute. subproject org.apache.maven.its.plugins maven-it-plugin-configuration 2.1-SNAPSHOT true PARENT-1 PARENT-3 PARENT-2 PARENT-4 org.apache.maven.its.plugins maven-it-plugin-configuration 2.1-SNAPSHOT true PARENT-1 PARENT-3 PARENT-2 PARENT-4 parent true subproject/000077500000000000000000000000001317160430700353615ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources-project-builder/plugin-config-append/with-profilepom.xml000066400000000000000000000050751317160430700367050ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources-project-builder/plugin-config-append/with-profile/subproject 4.0.0 org.apache.maven.its.mng2591 parent 1.0 subproject 1.0 jar org.apache.maven.its.plugins maven-it-plugin-configuration 2.1-SNAPSHOT target/config.properties CHILD-1 CHILD-3 CHILD-2 CHILD-4 CHILD-1 CHILD-3 CHILD-2 CHILD-4 test validate config child true maven-maven-3.5.2/maven-core/src/test/resources-project-builder/plugin-config-attributes/000077500000000000000000000000001317160430700315665ustar00rootroot00000000000000w-plugin-mgmt/000077500000000000000000000000001317160430700342135ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources-project-builder/plugin-config-attributespom.xml000066400000000000000000000040231317160430700355270ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources-project-builder/plugin-config-attributes/w-plugin-mgmt 4.0.0 org.apache.maven.its.mng4053 test2 1.0-SNAPSHOT Maven Integration Test :: MNG-4053 Verify that attributes in plugin configuration elements are not erroneously duplicated to other elements when plugin management is used. org.apache.maven.its.plugins maven-it-plugin-configuration 2.1-SNAPSHOT org.apache.maven.its.plugins maven-it-plugin-configuration 2.1-SNAPSHOT target/config.properties maven-maven-3.5.2/maven-core/src/test/resources-project-builder/plugin-config-attributes/w-profile/000077500000000000000000000000001317160430700334725ustar00rootroot00000000000000pom.xml000066400000000000000000000045661317160430700347430ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources-project-builder/plugin-config-attributes/w-profile 4.0.0 org.apache.maven.its.mng4053 test3 1.0-SNAPSHOT Maven Integration Test :: MNG-4053 Verify that attributes in plugin configuration elements are not erroneously duplicated to other elements when plugin management and a profile are used. org.apache.maven.its.plugins maven-it-plugin-configuration 2.1-SNAPSHOT maven-core-it true org.apache.maven.its.plugins maven-it-plugin-configuration 2.1-SNAPSHOT target/config.properties wo-plugin-mgmt/000077500000000000000000000000001317160430700343725ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources-project-builder/plugin-config-attributespom.xml000066400000000000000000000034061317160430700357120ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources-project-builder/plugin-config-attributes/wo-plugin-mgmt 4.0.0 org.apache.maven.its.mng4053 test1 1.0-SNAPSHOT Maven Integration Test :: MNG-4053 Verify that attributes in plugin configuration elements are not erroneously duplicated to other elements when no plugin management is used. org.apache.maven.its.plugins maven-it-plugin-configuration 2.1-SNAPSHOT target/config.properties maven-maven-3.5.2/maven-core/src/test/resources-project-builder/plugin-config-merging/000077500000000000000000000000001317160430700310305ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources-project-builder/plugin-config-merging/child/000077500000000000000000000000001317160430700321135ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources-project-builder/plugin-config-merging/child/pom.xml000066400000000000000000000047021317160430700334330ustar00rootroot00000000000000 4.0.0 org.apache.maven.its.mng3836 parent 1.0-SNAPSHOT org.apache.maven.its.mng3836 child 1.0-SNAPSHOT Maven Integration Test :: MNG-3836 Verify that children can *override* inherited plugin configuration. org.apache.maven.its.plugins maven-it-plugin-configuration 2.1-SNAPSHOT PASSED PASSED-1 PASSED-3 PASSED-2 PASSED-4 PASSED-1 PASSED-3 PASSED-2 PASSED-4 validate config maven-maven-3.5.2/maven-core/src/test/resources-project-builder/plugin-config-merging/pom.xml000066400000000000000000000045421317160430700323520ustar00rootroot00000000000000 4.0.0 org.apache.maven.its.mng3836 parent 1.0-SNAPSHOT pom Maven Integration Test :: MNG-3836 Verify that children can *override* inherited plugin configuration. org.apache.maven.its.plugins maven-it-plugin-configuration 2.1-SNAPSHOT FAILED FAILED-1 FAILED-3 FAILED-2 FAILED-4 org.apache.maven.its.plugins maven-it-plugin-configuration 2.1-SNAPSHOT FAILED FAILED-1 FAILED-3 FAILED-2 FAILED-4 PASSED maven-maven-3.5.2/maven-core/src/test/resources-project-builder/plugin-config-order/000077500000000000000000000000001317160430700305135ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources-project-builder/plugin-config-order/w-plugin-mgmt/000077500000000000000000000000001317160430700332175ustar00rootroot00000000000000pom.xml000066400000000000000000000041451317160430700344610ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources-project-builder/plugin-config-order/w-plugin-mgmt 4.0.0 org.apache.maven.its.mng3827 test2 1.0-SNAPSHOT Maven Integration Test :: MNG-3827 Verify that plain plugin configuration works correctly. org.apache.maven.its.plugins maven-it-plugin-configuration 2.1-SNAPSHOT org.apache.maven.its.plugins maven-it-plugin-configuration one two three four validate config maven-maven-3.5.2/maven-core/src/test/resources-project-builder/plugin-config-order/wo-plugin-mgmt/000077500000000000000000000000001317160430700333765ustar00rootroot00000000000000pom.xml000066400000000000000000000035641317160430700346440ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources-project-builder/plugin-config-order/wo-plugin-mgmt 4.0.0 org.apache.maven.its.mng3827 test1 1.0-SNAPSHOT Maven Integration Test :: MNG-3827 Verify that plain plugin configuration works correctly. org.apache.maven.its.plugins maven-it-plugin-configuration 1.0 one two three four validate config maven-maven-3.5.2/maven-core/src/test/resources-project-builder/plugin-config-properties/000077500000000000000000000000001317160430700315745ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources-project-builder/plugin-config-properties/pom.xml000066400000000000000000000020601317160430700331070ustar00rootroot00000000000000 4.0.0 a b 1.0 maven-surefire-plugin maven-surefire-plugin 2.4 my.property my.value maven-maven-3.5.2/maven-core/src/test/resources-project-builder/plugin-exec-config-order/000077500000000000000000000000001317160430700314355ustar00rootroot00000000000000w-plugin-mgmt/000077500000000000000000000000001317160430700340625ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources-project-builder/plugin-exec-config-orderpom.xml000066400000000000000000000047321317160430700354050ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources-project-builder/plugin-exec-config-order/w-plugin-mgmt 4.0.0 org.apache.maven.its.mng3827 test2 1.0-SNAPSHOT Maven Integration Test :: MNG-3864 Verify that plain per-execution plugin configuration works correctly. org.apache.maven.its.plugins maven-it-plugin-configuration 2.1-SNAPSHOT org.apache.maven.its.plugins maven-it-plugin-configuration validate config one two three four key1 value1 key2 value2 wo-plugin-mgmt/000077500000000000000000000000001317160430700342415ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources-project-builder/plugin-exec-config-orderpom.xml000066400000000000000000000043511317160430700355610ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources-project-builder/plugin-exec-config-order/wo-plugin-mgmt 4.0.0 org.apache.maven.its.mng3827 test1 1.0-SNAPSHOT Maven Integration Test :: MNG-3864 Verify that plain per-execution plugin configuration works correctly. org.apache.maven.its.plugins maven-it-plugin-configuration 1.0 validate config one two three four key1 value1 key2 value2 maven-maven-3.5.2/maven-core/src/test/resources-project-builder/plugin-exec-goals-order/000077500000000000000000000000001317160430700312755ustar00rootroot00000000000000w-plugin-mgmt/000077500000000000000000000000001317160430700337225ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources-project-builder/plugin-exec-goals-orderpom.xml000066400000000000000000000040341317160430700352400ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources-project-builder/plugin-exec-goals-order/w-plugin-mgmt 4.0.0 org.apache.maven.its.mng3886 test 0.1 pom Maven Integration Test :: MNG-3886 Test that the goals from a plugin execution are executed in the order given by the POM, regardless whether plugin management is present or not. org.apache.maven.its.plugins maven-it-plugin-a 1.0-SNAPSHOT org.apache.maven.its.plugins maven-it-plugin-a 1.0-SNAPSHOT b a d c e wo-plugin-mgmt/000077500000000000000000000000001317160430700341015ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources-project-builder/plugin-exec-goals-orderpom.xml000066400000000000000000000034301317160430700354160ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources-project-builder/plugin-exec-goals-order/wo-plugin-mgmt 4.0.0 org.apache.maven.its.mng3886 test 0.1 pom Maven Integration Test :: MNG-3886 Test that the goals from a plugin execution are executed in the order given by the POM, regardless whether plugin management is present or not. org.apache.maven.its.plugins maven-it-plugin-a 1.0-SNAPSHOT b a d c e maven-maven-3.5.2/maven-core/src/test/resources-project-builder/plugin-exec-inheritance/000077500000000000000000000000001317160430700313505ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources-project-builder/plugin-exec-inheritance/pom.xml000066400000000000000000000045121317160430700326670ustar00rootroot00000000000000 4.0.0 org.apache.maven.its.mng4129 parent 0.1 pom Maven Integration Test :: MNG-4129 Verify that plugin executions defined in the parent with inherited=false are not executed in child modules. child-1 child-2 org.apache.maven.its.plugins maven-it-plugin-log-file 2.1-SNAPSHOT inherited-execution true validate log-string target/executions.txt inherited-execution non-inherited-execution false validate log-string target/executions.txt non-inherited-execution maven-maven-3.5.2/maven-core/src/test/resources-project-builder/plugin-exec-inheritance/w-merge/000077500000000000000000000000001317160430700327135ustar00rootroot00000000000000pom.xml000066400000000000000000000031061317160430700341510ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources-project-builder/plugin-exec-inheritance/w-merge 4.0.0 org.apache.maven.its.mng4129 parent 0.1 child-1 Maven Integration Test :: MNG-4129 :: Child-1 Verify that plugin executions defined in the parent with inherited=false are not executed in child modules. org.apache.maven.its.plugins maven-it-plugin-log-file 2.1-SNAPSHOT maven-maven-3.5.2/maven-core/src/test/resources-project-builder/plugin-exec-inheritance/wo-merge/000077500000000000000000000000001317160430700330725ustar00rootroot00000000000000pom.xml000066400000000000000000000026201317160430700343300ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources-project-builder/plugin-exec-inheritance/wo-merge 4.0.0 org.apache.maven.its.mng4129 parent 0.1 child-2 Maven Integration Test :: MNG-4129 :: Child-2 Verify that plugin executions defined in the parent with inherited=false are not executed in child modules. plugin-exec-merging-version-insensitive/000077500000000000000000000000001317160430700344515ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources-project-builderpom.xml000066400000000000000000000033521317160430700357710ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources-project-builder/plugin-exec-merging-version-insensitive 4.0.0 org.apache.maven.its.mng3916 parent 0.1 pom Maven Integration Test :: MNG-3943 Test that plugin executions are properly merged during inheritance, even if the child uses a different plugin version than the parent. org.apache.maven.its.plugins maven-it-plugin-a 1.0 parent-1 parent-1 parent-2 parent-2 sub/000077500000000000000000000000001317160430700352425ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources-project-builder/plugin-exec-merging-version-insensitivepom.xml000066400000000000000000000034111317160430700365560ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources-project-builder/plugin-exec-merging-version-insensitive/sub 4.0.0 org.apache.maven.its.mng3916 parent 0.1 child Maven Integration Test :: MNG-3943 Test that plugin executions are properly merged during inheritance, even if the child uses a different plugin version than the parent. org.apache.maven.its.plugins maven-it-plugin-a 2.0 child-1 child-1 child-2 child-2 maven-maven-3.5.2/maven-core/src/test/resources-project-builder/plugin-exec-merging-wo-version/000077500000000000000000000000001317160430700326155ustar00rootroot00000000000000pom.xml000066400000000000000000000032401317160430700340520ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources-project-builder/plugin-exec-merging-wo-version 4.0.0 org.apache.maven.its.mng3916 parent 0.1 pom Maven Integration Test :: MNG-3916 Test that plugin executions are properly merged during inheritance, even if the child plugin section has no version. org.apache.maven.its.plugins maven-it-plugin-a 1.0 parent-1 parent-1 parent-2 parent-2 maven-maven-3.5.2/maven-core/src/test/resources-project-builder/plugin-exec-merging-wo-version/sub/000077500000000000000000000000001317160430700334065ustar00rootroot00000000000000pom.xml000066400000000000000000000033421317160430700346460ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources-project-builder/plugin-exec-merging-wo-version/sub 4.0.0 org.apache.maven.its.mng3916 parent 0.1 child Maven Integration Test :: MNG-3916 Test that plugin executions are properly merged during inheritance, even if the child plugin section has no version. org.apache.maven.its.plugins maven-it-plugin-a child-1 child-1 child-2 child-2 maven-maven-3.5.2/maven-core/src/test/resources-project-builder/plugin-exec-merging/000077500000000000000000000000001317160430700305075ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources-project-builder/plugin-exec-merging/w-plugin-mgmt/000077500000000000000000000000001317160430700332135ustar00rootroot00000000000000pom.xml000066400000000000000000000037641317160430700344630ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources-project-builder/plugin-exec-merging/w-plugin-mgmt 4.0.0 org.apache.maven.its.mng3938 parent 0.1 pom Maven Integration Test :: MNG-3938 Test that plugin executions with the same id are merged during inheritance, especially executions using the default id, regardless whether the id is given explicitly by the user or implicitly assumed from defaults. org.apache.maven.its.plugins maven-it-plugin-a 2.1-SNAPSHOT parent-default non-default parent-non-default sub/000077500000000000000000000000001317160430700337255ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources-project-builder/plugin-exec-merging/w-plugin-mgmtpom.xml000066400000000000000000000035771317160430700352560ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources-project-builder/plugin-exec-merging/w-plugin-mgmt/sub 4.0.0 org.apache.maven.its.mng3938 parent 0.1 child Maven Integration Test :: MNG-3938 Test that plugin executions with the same id are merged during inheritance, especially executions using the default id, regardless whether the id is given explicitly by the user or implicitly assumed from defaults. org.apache.maven.its.plugins maven-it-plugin-a 2.1-SNAPSHOT default child-default non-default child-non-default maven-maven-3.5.2/maven-core/src/test/resources-project-builder/plugin-exec-merging/wo-plugin-mgmt/000077500000000000000000000000001317160430700333725ustar00rootroot00000000000000pom.xml000066400000000000000000000036531317160430700346370ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources-project-builder/plugin-exec-merging/wo-plugin-mgmt 4.0.0 org.apache.maven.its.mng3938 parent 0.1 pom Maven Integration Test :: MNG-3938 Test that plugin executions with the same id are merged during inheritance, especially executions using the default id, regardless whether the id is given explicitly by the user or implicitly assumed from defaults. org.apache.maven.its.plugins maven-it-plugin-a 2.1-SNAPSHOT parent-default non-default parent-non-default sub/000077500000000000000000000000001317160430700341045ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources-project-builder/plugin-exec-merging/wo-plugin-mgmtpom.xml000066400000000000000000000035771317160430700354350ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources-project-builder/plugin-exec-merging/wo-plugin-mgmt/sub 4.0.0 org.apache.maven.its.mng3938 parent 0.1 child Maven Integration Test :: MNG-3938 Test that plugin executions with the same id are merged during inheritance, especially executions using the default id, regardless whether the id is given explicitly by the user or implicitly assumed from defaults. org.apache.maven.its.plugins maven-it-plugin-a 2.1-SNAPSHOT default child-default non-default child-non-default maven-maven-3.5.2/maven-core/src/test/resources-project-builder/plugin-exec-order-and-default-exec/000077500000000000000000000000001317160430700332765ustar00rootroot00000000000000pom.xml000066400000000000000000000043101317160430700345320ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources-project-builder/plugin-exec-order-and-default-exec 4.0.0 org.apache.maven.its.mng4332 test 0.1 JAR Maven Integration Test :: MNG-4332 Verify that default plugin executions contributed by the packaging are executed before user-defined executions from the POM's build section, regardless whether the executions are defined in the regular plugins section or the plugin management section. maven-resources-plugin 2.2 test-1 resources maven-resources-plugin 2.2 test-2 resources maven-maven-3.5.2/maven-core/src/test/resources-project-builder/plugin-exec-order-with-lifecycle/000077500000000000000000000000001317160430700331005ustar00rootroot00000000000000pom.xml000066400000000000000000000035671317160430700343510ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources-project-builder/plugin-exec-order-with-lifecycle 4.0.0 org.apache.maven.its.mng4341 test 0.1 JAR Maven Integration Test :: MNG-4341 Test that plugins bound to the same phase get executed in POM order even if one of the plugins participates in the default lifecycle bindings for the project's packaging. org.apache.maven.its.plugins maven-it-plugin-log-file 2.1-SNAPSHOT org.apache.maven.plugins maven-resources-plugin 0.1-stub-SNAPSHOT maven-maven-3.5.2/maven-core/src/test/resources-project-builder/plugin-exec-order/000077500000000000000000000000001317160430700301725ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources-project-builder/plugin-exec-order/w-plugin-mgmt/000077500000000000000000000000001317160430700326765ustar00rootroot00000000000000pom.xml000066400000000000000000000044221317160430700341360ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources-project-builder/plugin-exec-order/w-plugin-mgmt 4.0.0 org.apache.maven.its.mng3887 test 0.1 pom Maven Integration Test :: MNG-3887 Test that multiple plugin executions bound to the same phase are executed in the order given by the POM. org.apache.maven.its.plugins maven-it-plugin-a 1.0-SNAPSHOT org.apache.maven.its.plugins maven-it-plugin-a 1.0-SNAPSHOT b validate a validate d validate c validate e validate maven-maven-3.5.2/maven-core/src/test/resources-project-builder/plugin-exec-order/wo-plugin-mgmt/000077500000000000000000000000001317160430700330555ustar00rootroot00000000000000pom.xml000066400000000000000000000040161317160430700343140ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources-project-builder/plugin-exec-order/wo-plugin-mgmt 4.0.0 org.apache.maven.its.mng3887 test 0.1 pom Maven Integration Test :: MNG-3887 Test that multiple plugin executions bound to the same phase are executed in the order given by the POM. org.apache.maven.its.plugins maven-it-plugin-a 1.0-SNAPSHOT b validate a validate d validate c validate e validate maven-maven-3.5.2/maven-core/src/test/resources-project-builder/plugin-exec-w-and-wo-id/000077500000000000000000000000001317160430700311025ustar00rootroot00000000000000w-plugin-mgmt/000077500000000000000000000000001317160430700335275ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources-project-builder/plugin-exec-w-and-wo-idpom.xml000066400000000000000000000043251317160430700350500ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources-project-builder/plugin-exec-w-and-wo-id/w-plugin-mgmt 4.0.0 org.apache.maven.its.mng4000 test2 0.1 Maven Integration Test :: MNG-4000 Test that plugin executions without id are not lost among other plugin executions. org.apache.maven.its.plugins maven-it-plugin-log-file 2.1-SNAPSHOT org.apache.maven.its.plugins maven-it-plugin-log-file target/exec.log exec exec-1 validate log-string validate log-string wo-plugin-mgmt/000077500000000000000000000000001317160430700337065ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources-project-builder/plugin-exec-w-and-wo-idpom.xml000066400000000000000000000037621317160430700352330ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources-project-builder/plugin-exec-w-and-wo-id/wo-plugin-mgmt 4.0.0 org.apache.maven.its.mng4000 test1 0.1 Maven Integration Test :: MNG-4000 Test that plugin executions without id are not lost among other plugin executions. org.apache.maven.its.plugins maven-it-plugin-log-file 2.1-SNAPSHOT target/exec.log exec exec-1 validate log-string validate log-string maven-maven-3.5.2/maven-core/src/test/resources-project-builder/plugin-inheritance-merge-order/000077500000000000000000000000001317160430700326345ustar00rootroot00000000000000pom.xml000066400000000000000000000044041317160430700340740ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources-project-builder/plugin-inheritance-merge-order 4.0.0 org.apache.maven.its.mng4415 parent 0.1 pom Maven Integration Test :: MNG-4415 Test that merging of plugins during inheritance follows these rules regarding ordering: parent: X -> A -> B -> D -> E child: Y -> A -> C -> D -> F result: X -> Y -> A -> B -> C -> D -> E -> F org.apache.maven.its.plugins maven-it-plugin-error 2.1-SNAPSHOT org.apache.maven.its.plugins maven-it-plugin-dependency-resolution 2.1-SNAPSHOT org.apache.maven.its.plugins maven-it-plugin-packaging 2.1-SNAPSHOT org.apache.maven.its.plugins maven-it-plugin-expression 2.1-SNAPSHOT org.apache.maven.its.plugins maven-it-plugin-fork 2.1-SNAPSHOT maven-maven-3.5.2/maven-core/src/test/resources-project-builder/plugin-inheritance-merge-order/sub/000077500000000000000000000000001317160430700334255ustar00rootroot00000000000000pom.xml000066400000000000000000000045701317160430700346710ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources-project-builder/plugin-inheritance-merge-order/sub 4.0.0 org.apache.maven.its.mng4415 parent 0.1 org.apache.maven.its.mng4415 test 0.1 Maven Integration Test :: MNG-4415 Test that merging of plugins during inheritance follows these rules regarding ordering: parent: X -> A -> B -> D -> E child: Y -> A -> C -> D -> F result: X -> Y -> A -> B -> C -> D -> E -> F org.apache.maven.its.plugins maven-it-plugin-configuration 2.1-SNAPSHOT org.apache.maven.its.plugins maven-it-plugin-dependency-resolution 2.1-SNAPSHOT org.apache.maven.its.plugins maven-it-plugin-log-file 2.1-SNAPSHOT org.apache.maven.its.plugins maven-it-plugin-expression 2.1-SNAPSHOT org.apache.maven.its.plugins maven-it-plugin-touch 2.1-SNAPSHOT maven-maven-3.5.2/maven-core/src/test/resources-project-builder/plugin-inheritance-order/000077500000000000000000000000001317160430700315375ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources-project-builder/plugin-inheritance-order/child/000077500000000000000000000000001317160430700326225ustar00rootroot00000000000000pom.xml000066400000000000000000000027631317160430700340700ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources-project-builder/plugin-inheritance-order/child 4.0.0 org.apache.maven.its.mng3808 test 0.1 child org.apache.maven.its.plugins maven-it-plugin-configuration 2.1-SNAPSHOT org.apache.maven.its.plugins maven-it-plugin-configuration 2.1-SNAPSHOT maven-maven-3.5.2/maven-core/src/test/resources-project-builder/plugin-inheritance-order/pom.xml000066400000000000000000000040101317160430700330470ustar00rootroot00000000000000 4.0.0 org.apache.maven.its.mng3808 test 0.1 pom Maven Integration Test :: MNG-3808 Test the reports are executed in the order given in the POM. org.apache.maven.its.plugins maven-it-plugin-log-file 2.1-SNAPSHOT org.apache.maven.its.plugins maven-it-plugin-expression 2.1-SNAPSHOT org.apache.maven.its.plugins maven-it-plugin-log-file 2.1-SNAPSHOT org.apache.maven.its.plugins maven-it-plugin-expression 2.1-SNAPSHOT child maven-maven-3.5.2/maven-core/src/test/resources-project-builder/plugin-inheritance-simple/000077500000000000000000000000001317160430700317155ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources-project-builder/plugin-inheritance-simple/pom.xml000066400000000000000000000005601317160430700332330ustar00rootroot00000000000000 4.0.0 gid aid 1.0 pom org.codehaus.modello modello-maven-plugin 1.0-alpha-21 maven-maven-3.5.2/maven-core/src/test/resources-project-builder/plugin-inheritance-simple/sub/000077500000000000000000000000001317160430700325065ustar00rootroot00000000000000pom.xml000066400000000000000000000007201317160430700337430ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources-project-builder/plugin-inheritance-simple/sub gid aid 1.0 4.0.0 org.sonatype.nexus nexus 1.3.0-SNAPSHOT org.codehaus.modello modello-maven-plugin2 1.0-alpha-21 maven-maven-3.5.2/maven-core/src/test/resources-project-builder/plugin-injection-merge-order/000077500000000000000000000000001317160430700323255ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources-project-builder/plugin-injection-merge-order/pom.xml000066400000000000000000000105501317160430700336430ustar00rootroot00000000000000 4.0.0 org.apache.maven.its.mng4416 test 0.1 Maven Integration Test :: MNG-4416 Test that merging of plugins during profile injection follows these rules regarding ordering: model: X -> A -> B -> D -> E profile: Y -> A -> C -> D -> F result: X -> Y -> A -> B -> C -> D -> E -> F org.apache.maven.its.plugins maven-it-plugin-error 2.1-SNAPSHOT org.apache.maven.its.plugins maven-it-plugin-dependency-resolution 2.1-SNAPSHOT org.apache.maven.its.plugins maven-it-plugin-packaging 2.1-SNAPSHOT org.apache.maven.its.plugins maven-it-plugin-expression 2.1-SNAPSHOT org.apache.maven.its.plugins maven-it-plugin-fork 2.1-SNAPSHOT test !skip-mng4416 org.apache.maven.its.plugins maven-it-plugin-configuration 2.1-SNAPSHOT org.apache.maven.its.plugins maven-it-plugin-dependency-resolution 2.1-SNAPSHOT org.apache.maven.its.plugins maven-it-plugin-log-file 2.1-SNAPSHOT target/it.properties first validate reset org.apache.maven.its.plugins maven-it-plugin-expression 2.1-SNAPSHOT target/it.properties project/build/plugins second validate eval org.apache.maven.its.plugins maven-it-plugin-touch 2.1-SNAPSHOT maven-maven-3.5.2/maven-core/src/test/resources-project-builder/plugin-management-dependencies/000077500000000000000000000000001317160430700326755ustar00rootroot00000000000000pom.xml000066400000000000000000000013161317160430700341340ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources-project-builder/plugin-management-dependencies 4.0.0 gid aid 1.0 pom org.codehaus.modello modello-maven-plugin 1.0-alpha-21 a b 1.0 maven-maven-3.5.2/maven-core/src/test/resources-project-builder/plugin-management-dependencies/sub/000077500000000000000000000000001317160430700334665ustar00rootroot00000000000000pom.xml000066400000000000000000000013411317160430700347230ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources-project-builder/plugin-management-dependencies/sub gid aid 1.0 4.0.0 org.sonatype.nexus nexus 1.3.0-SNAPSHOT test org.codehaus.modello modello-maven-plugin 1.0-alpha-21 maven-maven-3.5.2/maven-core/src/test/resources-project-builder/plugin-management-duplicate/000077500000000000000000000000001317160430700322215ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources-project-builder/plugin-management-duplicate/pom.xml000066400000000000000000000023611317160430700335400ustar00rootroot00000000000000 4.0.0 gid aid 1.0 pom org.apache.maven.its.plugins maven-it-plugin-configuration 2.1-SNAPSHOT maven-maven-3.5.2/maven-core/src/test/resources-project-builder/plugin-management-duplicate/sub/000077500000000000000000000000001317160430700330125ustar00rootroot00000000000000pom.xml000066400000000000000000000037341317160430700342570ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources-project-builder/plugin-management-duplicate/sub gid aid 1.0 4.0.0 org.apache.maven.its.mng4053 test2 1.0-SNAPSHOT maven-compiler-plugin 0.1-stub-SNAPSHOT maven-jar-plugin 0.1-stub-SNAPSHOT maven-javadoc-plugin 0.1-stub-SNAPSHOT maven-resources-plugin 0.1-stub-SNAPSHOT maven-source-plugin 0.1-stub-SNAPSHOT maven-surefire-plugin 0.1-stub-SNAPSHOT plugin-management-for-implicit-plugin/000077500000000000000000000000001317160430700340625ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources-project-builderchild/000077500000000000000000000000001317160430700351455ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources-project-builder/plugin-management-for-implicit-pluginpom.xml000066400000000000000000000031721317160430700364650ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources-project-builder/plugin-management-for-implicit-plugin/child 4.0.0 org.apache.maven.its.mng0522 parent 1.0-SNAPSHOT child-project 1.0-SNAPSHOT JAR org.apache.maven.its.plugins maven-it-plugin-log-file test initialize reset pom.xml000066400000000000000000000040351317160430700354010ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources-project-builder/plugin-management-for-implicit-plugin 4.0.0 org.apache.maven.its.mng0522 parent 1.0-SNAPSHOT pom Maven Integration Test :: MNG-522 Test for pluginManagement injection of plugin configuration. child org.apache.maven.plugins maven-resources-plugin 0.1-stub-SNAPSHOT passed.txt org.apache.maven.its.plugins maven-it-plugin-log-file 2.1-SNAPSHOT passed.txt maven-maven-3.5.2/maven-core/src/test/resources-project-builder/plugin-management-inheritance/000077500000000000000000000000001317160430700325405ustar00rootroot00000000000000pom.xml000066400000000000000000000042061317160430700340000ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources-project-builder/plugin-management-inheritance 4.0.0 org.apache.maven.its.it0052 maven-it-it0052 1.0 jar Maven Integration Test :: it0052 Test that source attachment doesn't take place when -DperformRelease=true is missing. maven-compiler-plugin 0.1-stub-SNAPSHOT maven-jar-plugin 0.1-stub-SNAPSHOT maven-javadoc-plugin 0.1-stub-SNAPSHOT maven-resources-plugin 0.1-stub-SNAPSHOT maven-source-plugin 0.1-stub-SNAPSHOT maven-surefire-plugin 0.1-stub-SNAPSHOT maven-maven-3.5.2/maven-core/src/test/resources-project-builder/plugin-merge-simple/000077500000000000000000000000001317160430700305235ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources-project-builder/plugin-merge-simple/pom.xml000066400000000000000000000006621317160430700320440ustar00rootroot00000000000000 4.0.0 org.sonatype.nexus nexus-indexer 1.1.3-SNAPSHOT org.apache.maven.its.plugins maven-it-plugin-configuration 2.1-SNAPSHOT maven-maven-3.5.2/maven-core/src/test/resources-project-builder/plugin-order/000077500000000000000000000000001317160430700272505ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources-project-builder/plugin-order/nexus-parent.xml000066400000000000000000000007421317160430700324260ustar00rootroot00000000000000 4.0.0 org.sonatype.nexus nexus-parent 8-SNAPSHOT pom org.codehaus.plexus plexus-component-metadata 1.4.0 maven-maven-3.5.2/maven-core/src/test/resources-project-builder/plugin-order/pom.xml000066400000000000000000000012441317160430700305660ustar00rootroot00000000000000 4.0.0 org.sonatype.nexus nexus-parent 8-SNAPSHOT nexus-parent.xml org.sonatype.nexus nexus-indexer 1.1.3-SNAPSHOT org.codehaus.plexus plexus-component-metadata maven-surefire-plugin 2.4.3 maven-maven-3.5.2/maven-core/src/test/resources-project-builder/pluginmanagement-inherited/000077500000000000000000000000001317160430700321455ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources-project-builder/pluginmanagement-inherited/pom.xml000066400000000000000000000006751317160430700334720ustar00rootroot00000000000000 4.0.0 org.sonatype.nexus nexus 1.3.0-SNAPSHOT pom org.codehaus.modello modello-maven-plugin 1.0-alpha-21 maven-maven-3.5.2/maven-core/src/test/resources-project-builder/pluginmanagement-inherited/sub/000077500000000000000000000000001317160430700327365ustar00rootroot00000000000000pom.xml000066400000000000000000000007201317160430700341730ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources-project-builder/pluginmanagement-inherited/sub org.sonatype.nexus nexus 1.3.0-SNAPSHOT 4.0.0 a org.codehaus.modello modello-maven-plugin maven-maven-3.5.2/maven-core/src/test/resources-project-builder/pom-encoding/000077500000000000000000000000001317160430700272205ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources-project-builder/pom-encoding/latin-1/000077500000000000000000000000001317160430700304655ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources-project-builder/pom-encoding/latin-1/pom.xml000066400000000000000000000022741317160430700320070ustar00rootroot00000000000000 4.0.0 org.apache.maven.its.mng2254 latin-1 0.1-SNAPSHOT pom Maven Integration Test :: MNG-2254 :: Latin-1 TEST-CHARS: maven-maven-3.5.2/maven-core/src/test/resources-project-builder/pom-encoding/utf-8/000077500000000000000000000000001317160430700301635ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources-project-builder/pom-encoding/utf-8/pom.xml000066400000000000000000000022761317160430700315070ustar00rootroot00000000000000 4.0.0 org.apache.maven.its.mng2254 utf-8 0.1-SNAPSHOT pom Maven Integration Test :: MNG-2254 :: UTF-8 TEST-CHARS: ßıΣЯא€ maven-maven-3.5.2/maven-core/src/test/resources-project-builder/pom-inheritance/000077500000000000000000000000001317160430700277235ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources-project-builder/pom-inheritance/pom.xml000066400000000000000000000117221317160430700312430ustar00rootroot00000000000000 4.0.0 org.apache.maven.its.mng3843 parent-1 0.1 pom parent-name parent-description http://parent.url/ 2008 parent-org http://parent-org.url/ parent-license http://parent.url/license repo parent-developer parent-contributor parent-mailing-list 2.0 child-1 child-2 http://parent.url/trunk http://parent.url/scm https://parent.url/scm http://parent.url/issues http://parent.url/ci http://parent.url/dist parent.distros http://parent.url/snaps parent.snaps http://parent.url/site parent.site http://parent.url/download parent-reloc-msg parent-property parent-property org.apache.maven.its.mng3843 parent-dep-a 1 test org.apache.maven.its.mng3843 parent-dep-b 1 test parent-remote-repo http://parent.url/remote initialize out src/main src/scripts src/test out/main out/test res/main res/test org.apache.maven.its.plugins maven-it-plugin-expression 2.1-SNAPSHOT validate eval target/pom.properties project true site parent-profile maven-maven-3.5.2/maven-core/src/test/resources-project-builder/pom-inheritance/sub/000077500000000000000000000000001317160430700305145ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources-project-builder/pom-inheritance/sub/pom.xml000066400000000000000000000021341317160430700320310ustar00rootroot00000000000000 4.0.0 org.apache.maven.its.mng3843 parent-1 0.1 child-1 maven-maven-3.5.2/maven-core/src/test/resources-project-builder/prerequisites-inheritance/000077500000000000000000000000001317160430700320345ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources-project-builder/prerequisites-inheritance/child/000077500000000000000000000000001317160430700331175ustar00rootroot00000000000000pom.xml000066400000000000000000000022111317160430700343510ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources-project-builder/prerequisites-inheritance/child 4.0.0 org.apache.maven.its.mng3843 parent-1 0.1 child-1 maven-maven-3.5.2/maven-core/src/test/resources-project-builder/prerequisites-inheritance/pom.xml000066400000000000000000000020511317160430700333470ustar00rootroot00000000000000 4.0.0 org.apache.maven.its.mng3843 parent-1 0.1 pom 2.0 maven-maven-3.5.2/maven-core/src/test/resources-project-builder/profile-default-deactivation/000077500000000000000000000000001317160430700323735ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources-project-builder/profile-default-deactivation/pom.xml000066400000000000000000000021311317160430700337050ustar00rootroot00000000000000 4.0.0 org.apache.maven.its.mng3545 test-artifact 1.0-SNAPSHOT profile1 true org.apache.maven.its.plugins maven-it-plugin-touch 2.2 profile4 org.apache.maven.its.plugins maven-it-plugin-touch 2.1 profile-dependencies-multiple-profiles/000077500000000000000000000000001317160430700343205ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources-project-builderpom.xml000066400000000000000000000044661317160430700356470ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources-project-builder/profile-dependencies-multiple-profiles 4.0.0 org.apache.maven.its.it0021 test 1.0-SNAPSHOT Maven Integration Test :: it0021 Test pom-level profile inclusion (this one is activated by system property). org.apache.maven.its.plugins maven-it-plugin-dependency-resolution 2.1-SNAPSHOT test validate compile profile-1 includeProfile org.apache.maven.its.it0021 a 0.1 profile-2 org.apache.maven.its.it0021 b 0.1 maven-maven-3.5.2/maven-core/src/test/resources-project-builder/profile-injected-dependencies/000077500000000000000000000000001317160430700325105ustar00rootroot00000000000000pom.xml000066400000000000000000000045321317160430700337520ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources-project-builder/profile-injected-dependencies 4.0.0 org.apache.maven.its.mng1412 test 0.1-SNAPSHOT Maven Integration Test :: MNG-1412 Check that dependencies are available in classpath in same order as declared in POM. org.apache.maven.its.mng1412 a 0.1 org.apache.maven.its.mng1412 c 0.1 org.apache.maven.its.mng1412 b 0.1 mng-1412 true org.apache.maven.its.mng1412 a 0.1 org.apache.maven.its.mng1412 d 0.1 maven-maven-3.5.2/maven-core/src/test/resources-project-builder/profile-injection-order/000077500000000000000000000000001317160430700313725ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources-project-builder/profile-injection-order/pom.xml000066400000000000000000000036351317160430700327160ustar00rootroot00000000000000 4.0.0 org.apache.maven.its.mng2309 test 1.0-SNAPSHOT jar Maven Integration Test :: MNG-2309 Test that profiles are injected in declaration order, with the last profile being the most dominant. pom-a a pom-b b pom-c c pom-d d pom-e e maven-maven-3.5.2/maven-core/src/test/resources-project-builder/profile-module-inheritance/000077500000000000000000000000001317160430700320535ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources-project-builder/profile-module-inheritance/pom.xml000066400000000000000000000006011317160430700333650ustar00rootroot00000000000000 4.0.0 org.ops4j.pax construct 1.0 pom dist maven-inherit-plugin maven-pax-plugin maven-maven-3.5.2/maven-core/src/test/resources-project-builder/profile-module-inheritance/sub/000077500000000000000000000000001317160430700326445ustar00rootroot00000000000000pom.xml000066400000000000000000000004431317160430700341030ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources-project-builder/profile-module-inheritance/sub org.ops4j.pax construct 1.0 4.0.0 org.ops4j maven-inherit-plugin 1.1 maven-maven-3.5.2/maven-core/src/test/resources-project-builder/profile-module/000077500000000000000000000000001317160430700275645ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources-project-builder/profile-module/pom.xml000066400000000000000000000010111317160430700310720ustar00rootroot00000000000000 4.0.0 gid aid 1.0 pom module-2 module-1 module-3 a test-prop module-1 module-4 maven-maven-3.5.2/maven-core/src/test/resources-project-builder/profile-plugin-mng-dependencies/000077500000000000000000000000001317160430700330005ustar00rootroot00000000000000pom.xml000066400000000000000000000044641317160430700342460ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources-project-builder/profile-plugin-mng-dependencies 4.0.0 org.apache.maven.its.mng2174 parent 1.0-SNAPSHOT pom Maven Integration Test :: MNG-2174 Verify that plugin dependencies defined by plugin management of a parent profile are not lost when the parent's main plugin management section is also present. sub org.apache.maven.its.plugins maven-it-plugin-class-loader 2.1-SNAPSHOT maven-core-it true org.apache.maven.its.plugins maven-it-plugin-class-loader org.apache.maven.its.mng2174 a 0.1 maven-maven-3.5.2/maven-core/src/test/resources-project-builder/profile-plugin-mng-dependencies/sub/000077500000000000000000000000001317160430700335715ustar00rootroot00000000000000pom.xml000066400000000000000000000037351317160430700350370ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources-project-builder/profile-plugin-mng-dependencies/sub 4.0.0 org.apache.maven.its.mng2174 parent 1.0-SNAPSHOT org.apache.maven.its.mng2174 child 1.0-SNAPSHOT Maven Integration Test :: MNG-2174 Verify that plugin dependencies defined by plugin management of a parent profile are not lost when the parent's main plugin management section is also present. org.apache.maven.its.plugins maven-it-plugin-class-loader test validate mng-2174.properties target/pcl.properties load maven-maven-3.5.2/maven-core/src/test/resources-project-builder/profile-plugins/000077500000000000000000000000001317160430700277605ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources-project-builder/profile-plugins/pom.xml000066400000000000000000000035051317160430700313000ustar00rootroot00000000000000 4.0.0 org.apache.maven maven 3.0-SNAPSHOT org.apache.maven.plugins maven-surefire-plugin 2.4.3 standard true org.apache.maven.plugins maven-assembly2-plugin 2.0 maven-maven-3.5.2/maven-core/src/test/resources-project-builder/profile-properties-interpolation/000077500000000000000000000000001317160430700333605ustar00rootroot00000000000000pom.xml000066400000000000000000000032021317160430700346130ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources-project-builder/profile-properties-interpolation 4.0.0 org.apache.maven.its.mng3900 test 0.1 jar Maven Integration Test :: MNG-3900 Test that build properties defined via active profiles are used for interpolation. http://maven.apache.org/${test} FAILED ${test} interpolation-profile PASSED PASSED maven-maven-3.5.2/maven-core/src/test/resources-project-builder/properties-inheritance/000077500000000000000000000000001317160430700313245ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources-project-builder/properties-inheritance/pom.xml000066400000000000000000000021761317160430700326470ustar00rootroot00000000000000 4.0.0 org.apache.maven.its.mng3843 parent-1 0.1 pom parent-property parent-property maven-maven-3.5.2/maven-core/src/test/resources-project-builder/properties-inheritance/sub/000077500000000000000000000000001317160430700321155ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources-project-builder/properties-inheritance/sub/pom.xml000066400000000000000000000024141317160430700334330ustar00rootroot00000000000000 4.0.0 org.apache.maven.its.mng3843 parent-1 0.1 org.apache.maven.its.mng3843.child child-2 0.2 jar child-property child-override maven-maven-3.5.2/maven-core/src/test/resources-project-builder/properties-no-duplication/000077500000000000000000000000001317160430700317605ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources-project-builder/properties-no-duplication/pom.xml000066400000000000000000000007731317160430700333040ustar00rootroot00000000000000 4.0.0 org.apache.maven.its test-parent 1.0-SNAPSHOT pom parent maven-maven-3.5.2/maven-core/src/test/resources-project-builder/properties-no-duplication/sub/000077500000000000000000000000001317160430700325515ustar00rootroot00000000000000pom.xml000066400000000000000000000011441317160430700340070ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources-project-builder/properties-no-duplication/sub 4.0.0 org.apache.maven.its test-parent 1.0-SNAPSHOT org.apache.maven.its test 1.0-SNAPSHOT child maven-maven-3.5.2/maven-core/src/test/resources-project-builder/repo-inheritance/000077500000000000000000000000001317160430700300755ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources-project-builder/repo-inheritance/pom.xml000066400000000000000000000040241317160430700314120ustar00rootroot00000000000000 4.0.0 org.apache.maven.its.it0043 maven-it-it0043 1.0-SNAPSHOT Maven Integration Test :: it0043 Test for repository inheritance - ensure using the same id overrides the defaults central it0043 file:///${basedir}/target/maven-core-it0043-repo central it0043 file:///${basedir}/target/maven-core-it0043-repo org.apache.maven.its.plugins maven-it-plugin-expression 2.1-SNAPSHOT target/expression.properties project/repositories project/pluginRepositories maven-maven-3.5.2/maven-core/src/test/resources-project-builder/reporting-interpolation/000077500000000000000000000000001317160430700315375ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources-project-builder/reporting-interpolation/pom.xml000066400000000000000000000002141317160430700330510ustar00rootroot00000000000000 4.0.0 gid aid 1.0 maven-maven-3.5.2/maven-core/src/test/resources-project-builder/reporting-plugin-config/000077500000000000000000000000001317160430700314115ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources-project-builder/reporting-plugin-config/pom.xml000066400000000000000000000035141317160430700327310ustar00rootroot00000000000000 4.0.0 org.apache.maven.its.mng3811 test-parent 1.0-SNAPSHOT pom MNG-3811 :: Parent Test inheritance of reporting plugin configuration child org.apache.maven.its.plugins maven-it-plugin-configuration 2.1-SNAPSHOT true parentParam maven-maven-3.5.2/maven-core/src/test/resources-project-builder/reporting-plugin-config/sub/000077500000000000000000000000001317160430700322025ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources-project-builder/reporting-plugin-config/sub/pom.xml000066400000000000000000000034441317160430700335240ustar00rootroot00000000000000 4.0.0 org.apache.maven.its.mng3811 test-parent 1.0-SNAPSHOT test-child MNG-3811 :: Child org.apache.maven.its.plugins maven-it-plugin-configuration 2.1-SNAPSHOT childParam preserve space maven-maven-3.5.2/maven-core/src/test/resources-project-builder/single-configuration-inheritance/000077500000000000000000000000001317160430700332565ustar00rootroot00000000000000jetty-parent.xml000066400000000000000000000022601317160430700363470ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources-project-builder/single-configuration-inheritance 4.0.0 org.mortbay.jetty jetty-parent pom Jetty :: Administrative Parent 7 org.apache.maven.plugins maven-enforcer-plugin 1.0-alpha-3 enforce-java enforce [2.0.6,) [1.5,) pom.xml000066400000000000000000000025251317160430700345200ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources-project-builder/single-configuration-inheritance 4.0.0 org.mortbay.jetty jetty-parent 7 jetty-parent.xml org.mortbay.jetty project pom Jetty Server Project 6.1.12 install org.apache.maven.plugins maven-enforcer-plugin enforce-java enforce 2.0.6 [1.4,) maven-maven-3.5.2/maven-core/src/test/resources-project-builder/system-property-interpolation/000077500000000000000000000000001317160430700327345ustar00rootroot00000000000000pom.xml000066400000000000000000000017241317160430700341760ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources-project-builder/system-property-interpolation 4.0.0 gid aid 1.0 ${system.property} maven-maven-3.5.2/maven-core/src/test/resources-project-builder/unc-path/000077500000000000000000000000001317160430700263605ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources-project-builder/unc-path/pom.xml000066400000000000000000000030011317160430700276670ustar00rootroot00000000000000 4.0.0 org.apache.maven.its.mng3621 test-parent 1.0-SNAPSHOT pom MNG-3621 :: Parent Test inheritance of UNC paths child site file:////host/site maven-maven-3.5.2/maven-core/src/test/resources-project-builder/unc-path/sub/000077500000000000000000000000001317160430700271515ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources-project-builder/unc-path/sub/pom.xml000066400000000000000000000037351317160430700304760ustar00rootroot00000000000000 4.0.0 org.apache.maven.its.mng3621 test-parent 1.0-SNAPSHOT test-child MNG-3621 :: Child org.apache.maven.its.plugins maven-it-plugin-expression 2.1-SNAPSHOT target/pom.properties project/distributionManagement/site/url test validate eval maven-maven-3.5.2/maven-core/src/test/resources-project-builder/unique-dependency-key/000077500000000000000000000000001317160430700310515ustar00rootroot00000000000000dep-mgmt-in-profile/000077500000000000000000000000001317160430700345465ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources-project-builder/unique-dependency-keypom.xml000066400000000000000000000030061317160430700360620ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources-project-builder/unique-dependency-key/dep-mgmt-in-profile 4.0.0 org.apache.maven.its.mng4005 b 0.1 jar test org.apache.maven.its.mng4005 a 0.1 org.apache.maven.its.mng4005 a 0.2 maven-maven-3.5.2/maven-core/src/test/resources-project-builder/unique-dependency-key/dep-mgmt/000077500000000000000000000000001317160430700325635ustar00rootroot00000000000000pom.xml000066400000000000000000000026021317160430700340210ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources-project-builder/unique-dependency-key/dep-mgmt 4.0.0 org.apache.maven.its.mng4005 b 0.1 jar org.apache.maven.its.mng4005 a 0.1 org.apache.maven.its.mng4005 a 0.2 deps-in-profile/000077500000000000000000000000001317160430700337675ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources-project-builder/unique-dependency-keypom.xml000066400000000000000000000026631317160430700353130ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources-project-builder/unique-dependency-key/deps-in-profile 4.0.0 org.apache.maven.its.mng4005 b 0.1 jar test org.apache.maven.its.mng4005 a 0.1 org.apache.maven.its.mng4005 a 0.2 maven-maven-3.5.2/maven-core/src/test/resources-project-builder/unique-dependency-key/deps/000077500000000000000000000000001317160430700320045ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources-project-builder/unique-dependency-key/deps/pom.xml000066400000000000000000000024671317160430700333320ustar00rootroot00000000000000 4.0.0 org.apache.maven.its.mng4005 b 0.1 jar org.apache.maven.its.mng4005 a 0.1 org.apache.maven.its.mng4005 a 0.2 maven-maven-3.5.2/maven-core/src/test/resources-project-builder/unique-repo-id/000077500000000000000000000000001317160430700275045ustar00rootroot00000000000000artifact-repo-in-profile/000077500000000000000000000000001317160430700342275ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources-project-builder/unique-repo-idpom.xml000066400000000000000000000031121317160430700355410ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources-project-builder/unique-repo-id/artifact-repo-in-profile 4.0.0 org.apache.maven.its.mng4193 test 0.1 jar Maven Integration Test :: MNG-4193 Test that multiple artifact repository declarations with the same id cause a validation error even if the repositories are defined within a (non-active) profile. test one http://repo1.maven.org/maven2 one http://repository.codehaus.org/ maven-maven-3.5.2/maven-core/src/test/resources-project-builder/unique-repo-id/artifact-repo/000077500000000000000000000000001317160430700322445ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources-project-builder/unique-repo-id/artifact-repo/pom.xml000066400000000000000000000026171317160430700335670ustar00rootroot00000000000000 4.0.0 org.apache.maven.its.mng4193 test 0.1 jar Maven Integration Test :: MNG-4193 Test that multiple artifact repository declarations with the same id cause a validation error. one http://repo1.maven.org/maven2 one http://repository.codehaus.org/ plugin-repo-in-profile/000077500000000000000000000000001317160430700337305ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources-project-builder/unique-repo-idpom.xml000066400000000000000000000031541317160430700352500ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources-project-builder/unique-repo-id/plugin-repo-in-profile 4.0.0 org.apache.maven.its.mng4193 test 0.1 jar Maven Integration Test :: MNG-4193 Test that multiple plugin repository declarations with the same id cause a validation error even if the repositories are defined within a (non-active) profile. test one http://repo1.maven.org/maven2 one http://repository.codehaus.org/ maven-maven-3.5.2/maven-core/src/test/resources-project-builder/unique-repo-id/plugin-repo/000077500000000000000000000000001317160430700317455ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources-project-builder/unique-repo-id/plugin-repo/pom.xml000066400000000000000000000026611317160430700332670ustar00rootroot00000000000000 4.0.0 org.apache.maven.its.mng4193 test 0.1 jar Maven Integration Test :: MNG-4193 Test that multiple plugin repository declarations with the same id cause a validation error. one http://repo1.maven.org/maven2 one http://repository.codehaus.org/ maven-maven-3.5.2/maven-core/src/test/resources-project-builder/unprefixed-expression-interpolation/000077500000000000000000000000001317160430700340745ustar00rootroot00000000000000child/000077500000000000000000000000001317160430700351005ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources-project-builder/unprefixed-expression-interpolationpom.xml000066400000000000000000000070531317160430700364220ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources-project-builder/unprefixed-expression-interpolation/child 4.0.0 org.apache.maven.its.mng3831 parent 1.0 org.apache.maven.its.mng3831.child child 2.0-alpha-1 jar child-name child-desc http://child.org/ 2008 child-org-name 2.0.0 http://scm.org/ http://issue.org/ http://ci.org/ maven-core-it child-dist-repo http://dist.org/ maven-core-it child-site http://site.org/ ${basedir} ${groupId} ${artifactId} ${version} ${packaging} ${name} ${description} ${url} ${inceptionYear} ${organization.name} ${prerequisites.maven} ${scm.url} ${issueManagement.url} ${ciManagement.url} ${distributionManagement.repository.name} ${distributionManagement.repository.url} ${distributionManagement.site.url} ${build.outputDirectory} ${reporting.outputDirectory} ${parent.groupId} ${parent.artifactId} ${parent.version} target/bin target/doc pom.xml000066400000000000000000000026021317160430700353320ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources-project-builder/unprefixed-expression-interpolation 4.0.0 org.apache.maven.its.mng3831 parent 1.0 pom Maven Integration Test :: MNG-3831 Test POM interpolation with expressions of the form $ { * } (ugly but real) parent/child maven-maven-3.5.2/maven-core/src/test/resources-project-builder/url-append/000077500000000000000000000000001317160430700267105ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources-project-builder/url-append/child/000077500000000000000000000000001317160430700277735ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources-project-builder/url-append/child/pom.xml000066400000000000000000000040641317160430700313140ustar00rootroot00000000000000 4.0.0 org.apache.maven.its.mng2006 parent 0.1 ../parent/pom.xml child Child Project Test that inheritance of those URLs which automatically append the child's artifact id take the child's relative location to the parent into account. org.apache.maven.its.plugins maven-it-plugin-expression 2.1-SNAPSHOT validate eval target/pom.properties project/url project/scm project/distributionManagement/site maven-maven-3.5.2/maven-core/src/test/resources-project-builder/url-append/parent/000077500000000000000000000000001317160430700302015ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources-project-builder/url-append/parent/pom.xml000066400000000000000000000032401317160430700315150ustar00rootroot00000000000000 4.0.0 org.apache.maven.its.mng2006 parent 0.1 pom Maven Integration Test :: MNG-2006 Test that inheritance of those URLs which automatically append the child's artifact id take the child's relative location to the parent into account. ../child http://project.url/parent http://viewvc.project.url/parent http://scm.project.url/parent https://scm.project.url/parent http://site.project.url/parent parent.site maven-maven-3.5.2/maven-core/src/test/resources-project-builder/url-inheritance/000077500000000000000000000000001317160430700277325ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources-project-builder/url-inheritance/another-parent/000077500000000000000000000000001317160430700326615ustar00rootroot00000000000000pom.xml000066400000000000000000000023161317160430700341210ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources-project-builder/url-inheritance/another-parent 4.0.0 org.apache.maven.its.mng3846 parent 0.1 ap pom Another Parent to test multi-level URL adjustment maven-maven-3.5.2/maven-core/src/test/resources-project-builder/url-inheritance/another-parent/sub/000077500000000000000000000000001317160430700334525ustar00rootroot00000000000000pom.xml000066400000000000000000000022141317160430700347070ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources-project-builder/url-inheritance/another-parent/sub 4.0.0 org.apache.maven.its.mng3846 ap 0.1 child Child Project maven-maven-3.5.2/maven-core/src/test/resources-project-builder/url-inheritance/pom.xml000066400000000000000000000043031317160430700312470ustar00rootroot00000000000000 4.0.0 org.apache.maven.its.mng3846 parent 0.1 pom Maven Integration Test :: MNG-3846 Test that inheritance of certain URLs automatically appends the child's artifact id. http://parent.url parent-org http://parent.url/org parent-license http://parent.url/license.txt repo http://parent.url/viewvc http://parent.url/scm https://parent.url/scm http://parent.url/issues http://parent.url/ci http://parent.url/dist parent.distros http://parent.url/snaps parent.snaps http://parent.url/site parent.site http://parent.url/download maven-maven-3.5.2/maven-core/src/test/resources-project-builder/url-inheritance/sub/000077500000000000000000000000001317160430700305235ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources-project-builder/url-inheritance/sub/pom.xml000066400000000000000000000022201317160430700320340ustar00rootroot00000000000000 4.0.0 org.apache.maven.its.mng3846 parent 0.1 child Child Project maven-maven-3.5.2/maven-core/src/test/resources-project-builder/url-no-decoding/000077500000000000000000000000001317160430700276275ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources-project-builder/url-no-decoding/pom.xml000066400000000000000000000042221317160430700311440ustar00rootroot00000000000000 4.0.0 org.apache.maven.its.mng4116 test 1.0-SNAPSHOT jar Maven Integration Test :: MNG-4116 Test that the project builder does not decode URLs (which must be done by the transport layer instead). http://maven.apache.org/spacy%20path scm:svn:svn+ssh://svn.apache.org/spacy%20path scm:svn:svn+ssh://svn.apache.org/spacy%20path http://svn.apache.org/viewvc/spacy%20path none http://issues.apache.org/spacy%20path none http://ci.apache.org/spacy%20path dist scm:svn:svn+ssh://dist.apache.org/spacy%20path snap scm:svn:svn+ssh://snap.apache.org/spacy%20path site scm:svn:svn+ssh://site.apache.org/spacy%20path maven-maven-3.5.2/maven-core/src/test/resources-project-builder/xml-coalesce-text/000077500000000000000000000000001317160430700301775ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources-project-builder/xml-coalesce-text/pom.xml000066400000000000000000001047411317160430700315230ustar00rootroot00000000000000 4.0.0 org.apache.maven.its.mng3839 coreit 0.1 jar Maven Integration Test :: MNG-3839 Test that POM parsing properly coalesces text data. A ProjectProperty That's a test! 00 KB 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 01 KB 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 02 KB 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 03 KB 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 04 KB 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 05 KB 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 06 KB 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 07 KB 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 08 KB 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 09 KB 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 10 KB 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 11 KB 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 12 KB 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 13 KB 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 14 KB 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 15 KB 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 16 KB 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 17 KB 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 18 KB 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 19 KB 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 20 KB 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 21 KB 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 22 KB 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 23 KB 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 24 KB 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 25 KB 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 26 KB 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 27 KB 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 28 KB 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 29 KB 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 30 KB 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 31 KB 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X 0 1 2 3 4 5 6 X maven-maven-3.5.2/maven-core/src/test/resources-project-builder/xml-markup-interpolation/000077500000000000000000000000001317160430700316235ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources-project-builder/xml-markup-interpolation/pom.xml000066400000000000000000000026751317160430700331520ustar00rootroot00000000000000 4.0.0 org.apache.maven.its.mng3924 test 0.1-SNAPSHOT jar Maven Integration Test :: MNG-3924 Test that interpolation of properties that resolve to XML markup doesn't crash the project builder. <?xml version='1.0'?>Tom&Jerry ${xmlMarkup} maven-maven-3.5.2/maven-core/src/test/resources-project-builder/xml-whitespace/000077500000000000000000000000001317160430700275735ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources-project-builder/xml-whitespace/pom.xml000066400000000000000000000023731317160430700311150ustar00rootroot00000000000000 4.0.0 org.apache.maven.its.mng4070 parent 1.0 pom Maven Integration Test :: MNG-4070 Test that whitespace around artifact coordinates does not change artifact identity. maven-maven-3.5.2/maven-core/src/test/resources-project-builder/xml-whitespace/sub/000077500000000000000000000000001317160430700303645ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources-project-builder/xml-whitespace/sub/pom.xml000066400000000000000000000031411317160430700317000ustar00rootroot00000000000000 4.0.0 org.apache.maven.its.mng4070 parent 1.0 subproject 1.0 jar Maven Integration Test :: MNG-4070 :: Child Test that whitespace around artifact coordinates does not change artifact identity. org.apache.maven.its.mng4070 a 0.1 maven-maven-3.5.2/maven-core/src/test/resources-settings/000077500000000000000000000000001317160430700234075ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources-settings/repositories/000077500000000000000000000000001317160430700261365ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources-settings/repositories/pom.xml000066400000000000000000000017611317160430700274600ustar00rootroot00000000000000 4.0.0 org.apache.maven.its.mng4107 test 1.0-SNAPSHOT jar maven-maven-3.5.2/maven-core/src/test/resources-settings/repositories/settings.xml000066400000000000000000000032721317160430700305240ustar00rootroot00000000000000 maven-core-it-repo maven-core-it-0 @baseurl@/repo-0 ignore false maven-core-it-1 @baseurl@/repo-1 ignore ignore maven-core-it-repo maven-maven-3.5.2/maven-core/src/test/resources-settings/settings-no-pom/000077500000000000000000000000001317160430700264525ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources-settings/settings-no-pom/pom.xml000066400000000000000000000011231317160430700277640ustar00rootroot00000000000000 4.0.0 org.apache.maven.its.mng3099 maven-mng3099-plugin 1 maven-plugin maven-mng3099-plugin Tests properties injected as a result of active profiles in the user settings file. maven-maven-3.5.2/maven-core/src/test/resources-settings/settings-no-pom/settings.xml000066400000000000000000000010361317160430700310340ustar00rootroot00000000000000 local-profile local-profile-prop-value local-profile maven-maven-3.5.2/maven-core/src/test/resources-settings/test-pom-and-settings-interpolation/000077500000000000000000000000001317160430700324425ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources-settings/test-pom-and-settings-interpolation/pom.xml000066400000000000000000000047221317160430700337640ustar00rootroot00000000000000 4.0.0 org.apache.maven.its.mng4107 test 1.0-SNAPSHOT jar Maven Integration Test :: MNG-4107 Test that POM interpolation uses the property values from the dominant profile source (POM vs. profiles.xml vs. settings.xml). This boils down to the proper order of profile injection and interpolation, i.e. interpolate after profiles from all sources are injected. ${pomVsSettings} pom true applied pom org.apache.maven.its.plugins maven-it-plugin-expression 2.1-SNAPSHOT validate eval target/pom.properties project/properties settings.xml000066400000000000000000000021551317160430700347500ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources-settings/test-pom-and-settings-interpolation settings true applied settings maven-maven-3.5.2/maven-core/src/test/resources/000077500000000000000000000000001317160430700215515ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources/META-INF/000077500000000000000000000000001317160430700227115ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources/META-INF/maven/000077500000000000000000000000001317160430700240175ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources/META-INF/maven/org.apache.maven/000077500000000000000000000000001317160430700271335ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources/META-INF/maven/org.apache.maven/maven-core/000077500000000000000000000000001317160430700311675ustar00rootroot00000000000000pom.properties000066400000000000000000000000241317160430700340150ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources/META-INF/maven/org.apache.maven/maven-coreversion=2.1-SNAPSHOTmaven-maven-3.5.2/maven-core/src/test/resources/META-INF/plexus/000077500000000000000000000000001317160430700242315ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources/META-INF/plexus/components.xml000066400000000000000000000105611317160430700271430ustar00rootroot00000000000000 org.apache.maven.lifecycle.binding.LegacyLifecycleParsingTestComponent default org.apache.maven.lifecycle.binding.LegacyLifecycleParsingTestComponent default validate initialize generate-sources process-sources generate-resources process-resources compile process-classes generate-test-sources process-test-sources generate-test-resources process-test-resources test-compile process-test-classes test prepare-package package pre-integration-test integration-test post-integration-test verify install deploy clean pre-clean clean post-clean org.apache.maven.plugins:maven-clean-plugin:clean site pre-site site post-site site-deploy org.apache.maven.plugins:maven-site-plugin:site org.apache.maven.plugins:maven-site-plugin:deploy org.apache.maven.lifecycle.mapping.LifecycleMapping test-mapping org.apache.maven.lifecycle.mapping.DefaultLifecycleMapping default org.apache.maven.plugins:maven-site-plugin:attach-descriptor org.apache.maven.plugins:maven-install-plugin:install org.apache.maven.plugins:maven-deploy-plugin:deploy org.apache.maven.plugins:maven-site-plugin:attach-descriptor org.apache.maven.lifecycle.mapping.LifecycleMapping test-mapping2 org.apache.maven.lifecycle.mapping.DefaultLifecycleMapping default org.apache.maven.plugins:maven-site-plugin:attach-descriptor, org.apache.maven.plugins:maven-clean-plugin:clean org.apache.maven.plugins:maven-install-plugin:install org.apache.maven.plugins:maven-deploy-plugin:deploy org.apache.maven.plugins:maven-site-plugin:attach-descriptor maven-maven-3.5.2/maven-core/src/test/resources/canonical-pom.xml000066400000000000000000000036431317160430700250210ustar00rootroot00000000000000 4.0.0 maven maven-core 2.0-SNAPSHOT Maven maven-plexus-plugin 1.0 src/conf/plexus.conf src/conf/plexus.properties Continuum plexus:runtime ContinuumPro maven-maven-3.5.2/maven-core/src/test/resources/dependencyManagement-pom.xml000066400000000000000000000042301317160430700271760ustar00rootroot00000000000000 4.0.0 maven maven-core 2.0-SNAPSHOT Maven maven-test maven-test-b 1.0 maven-plexus-plugin 1.0 src/conf/plexus.conf src/conf/plexus.properties Continuum plexus:runtime ContinuumPro maven-maven-3.5.2/maven-core/src/test/resources/distributionManagement-pom.xml000066400000000000000000000030311317160430700275750ustar00rootroot00000000000000 4.0.0 maven maven-core 2.0-SNAPSHOT Maven repo-id my snapshot repository file:///path/to/snapshot/repo repo-id2 my repository file:///path/to/repo maven-maven-3.5.2/maven-core/src/test/resources/imports-repo/000077500000000000000000000000001317160430700242115ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources/imports-repo/t01/000077500000000000000000000000001317160430700246155ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources/imports-repo/t01/maven-test/000077500000000000000000000000001317160430700267005ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources/imports-repo/t01/maven-test/jars/000077500000000000000000000000001317160430700276375ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources/imports-repo/t01/maven-test/poms/000077500000000000000000000000001317160430700276565ustar00rootroot00000000000000maven-test-a-1.0.pom000066400000000000000000000005431317160430700331130ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources/imports-repo/t01/maven-test/poms 4.0.0 maven-test maven-test-a jar 1.0 central Fake Maven Central Repository file://dummy maven-test-a-1.1.pom000066400000000000000000000005431317160430700331140ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources/imports-repo/t01/maven-test/poms 4.0.0 maven-test maven-test-a jar 1.1 central Fake Maven Central Repository file://dummy maven-test-b-1.0.pom000066400000000000000000000002671317160430700331170ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources/imports-repo/t01/maven-test/poms 4.0.0 maven-test maven-test-b jar 1.0 maven-test-b-1.1.pom000066400000000000000000000002671317160430700331200ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources/imports-repo/t01/maven-test/poms 4.0.0 maven-test maven-test-b jar 1.1 maven-test-c-1.0.pom000066400000000000000000000002671317160430700331200ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources/imports-repo/t01/maven-test/poms 4.0.0 maven-test maven-test-c jar 1.0 maven-test-c-1.1.pom000066400000000000000000000002671317160430700331210ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources/imports-repo/t01/maven-test/poms 4.0.0 maven-test maven-test-c jar 1.1 maven-test-d-1.0.pom000066400000000000000000000002671317160430700331210ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources/imports-repo/t01/maven-test/poms 4.0.0 maven-test maven-test-d jar 1.0 maven-test-d-1.1.pom000066400000000000000000000002671317160430700331220ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources/imports-repo/t01/maven-test/poms 4.0.0 maven-test maven-test-d jar 1.1 maven-test-d-1.2.pom000066400000000000000000000002671317160430700331230ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources/imports-repo/t01/maven-test/poms 4.0.0 maven-test maven-test-d jar 1.2 maven-maven-3.5.2/maven-core/src/test/resources/imports-repo/t01/p0/000077500000000000000000000000001317160430700251345ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources/imports-repo/t01/p0/p1/000077500000000000000000000000001317160430700254545ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources/imports-repo/t01/p0/p1/pom.xml000066400000000000000000000021051317160430700267670ustar00rootroot00000000000000 p0 maven 1.0 4.0.0 maven p1 pom p1 1.0 scm-url maven-test maven-test-b 1.0 maven-test maven-test-a maven-test maven-test-b maven-antrun-plugin ${project.parent.basedir} maven-maven-3.5.2/maven-core/src/test/resources/imports-repo/t01/p0/p2/000077500000000000000000000000001317160430700254555ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources/imports-repo/t01/p0/p2/pom.xml000066400000000000000000000025721317160430700270000ustar00rootroot00000000000000 p0 maven 1.0 4.0.0 maven p2 pom p2 1.0 scm-url maven p1 1.0 pom import maven-test maven-test-c 1.0 maven-test maven-test-a maven-test maven-test-b maven-test maven-test-c maven-antrun-plugin ${project.parent.basedir} maven-maven-3.5.2/maven-core/src/test/resources/imports-repo/t01/p0/p3/000077500000000000000000000000001317160430700254565ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources/imports-repo/t01/p0/p3/pom.xml000066400000000000000000000027541317160430700270030ustar00rootroot00000000000000 p0 maven 1.0 4.0.0 maven p3 pom p3 1.0 scm-url maven-test maven-test-a 1.1 maven-test maven-test-c 1.1 maven-test maven-test-d 1.0 maven-test maven-test-a maven-test maven-test-c maven-test maven-test-d maven-antrun-plugin ${project.parent.basedir} maven-maven-3.5.2/maven-core/src/test/resources/imports-repo/t01/p0/p4/000077500000000000000000000000001317160430700254575ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources/imports-repo/t01/p0/p4/pom.xml000066400000000000000000000032571317160430700270030ustar00rootroot00000000000000 p0 maven 1.0 4.0.0 maven p4 pom p4 1.0 scm-url maven p2 1.0 pom import maven p3 1.0 pom import maven-test maven-test-b 1.1 maven-test maven-test-a maven-test maven-test-b maven-test maven-test-c maven-test maven-test-d maven-antrun-plugin ${project.parent.basedir} maven-maven-3.5.2/maven-core/src/test/resources/imports-repo/t01/p0/pom.xml000066400000000000000000000011441317160430700264510ustar00rootroot00000000000000 4.0.0 maven p0 pom p0 1.0 Codehaus maven-test maven-test-a 1.0 p1 p2 p3 p4 maven-maven-3.5.2/maven-core/src/test/resources/local-repo/000077500000000000000000000000001317160430700236065ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources/local-repo/marker.txt000066400000000000000000000000331317160430700256240ustar00rootroot00000000000000this is just a marker file.maven-maven-3.5.2/maven-core/src/test/resources/local-repo/maven-test/000077500000000000000000000000001317160430700256715ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources/local-repo/maven-test/jars/000077500000000000000000000000001317160430700266305ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources/local-repo/maven-test/poms/000077500000000000000000000000001317160430700266475ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources/local-repo/maven-test/poms/maven-test-a-1.0.pom000066400000000000000000000011121317160430700321540ustar00rootroot00000000000000 4.0.0 maven-test maven-test-a jar 1.0 central Fake Maven Central Repository file://dummy maven-test maven-test-b 1.0 jar compile maven-maven-3.5.2/maven-core/src/test/resources/local-repo/maven-test/poms/maven-test-b-1.0.pom000066400000000000000000000011421317160430700321600ustar00rootroot00000000000000 4.0.0 maven-test maven-test-b jar 1.0 maven-test maven-test-c 1.0 jar compile maven-test maven-test-d 1.1 jar compile maven-maven-3.5.2/maven-core/src/test/resources/local-repo/maven-test/poms/maven-test-c-1.0.pom000066400000000000000000000006361317160430700321700ustar00rootroot00000000000000 4.0.0 maven-test maven-test-c jar 1.0 maven-test maven-test-d 1.2 jar compile maven-maven-3.5.2/maven-core/src/test/resources/local-repo/maven-test/poms/maven-test-d-1.1.pom000066400000000000000000000002671317160430700321720ustar00rootroot00000000000000 4.0.0 maven-test maven-test-d jar 1.1 maven-maven-3.5.2/maven-core/src/test/resources/local-repo/maven-test/poms/maven-test-d-1.2.pom000066400000000000000000000002671317160430700321730ustar00rootroot00000000000000 4.0.0 maven-test maven-test-d jar 1.1 maven-maven-3.5.2/maven-core/src/test/resources/local-repo/snapshot-test/000077500000000000000000000000001317160430700264225ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources/local-repo/snapshot-test/jars/000077500000000000000000000000001317160430700273615ustar00rootroot00000000000000maven-snapshot-a-1.0-SNAPSHOT.jar.snapshot-version000066400000000000000000000000171317160430700402310ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources/local-repo/snapshot-test/jars20040101.101010maven-snapshot-b-1.0-SNAPSHOT.jar.snapshot-version000066400000000000000000000000171317160430700402320ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources/local-repo/snapshot-test/jars20040101.101010maven-snapshot-e-1.0-SNAPSHOT.jar.snapshot-version000066400000000000000000000000171317160430700402350ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources/local-repo/snapshot-test/jars20040101.101010maven-maven-3.5.2/maven-core/src/test/resources/local-repo/snapshot-test/poms/000077500000000000000000000000001317160430700274005ustar00rootroot00000000000000maven-test-snapshot-resolving-1.0.pom000066400000000000000000000026001317160430700362560ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources/local-repo/snapshot-test/poms snapshot-test maven-test-snapshot-resolving jar central Fake Maven Central Repository file://dummy snapshot-test maven-snapshot-a 1.0-SNAPSHOT jar compile snapshot-test maven-snapshot-b 1.0-SNAPSHOT jar compile snapshot-test maven-snapshot-c 1.0-SNAPSHOT jar compile snapshot-test maven-snapshot-d 1.0-SNAPSHOT jar compile snapshot-test maven-snapshot-e 1.0-SNAPSHOT jar compile maven-maven-3.5.2/maven-core/src/test/resources/org/000077500000000000000000000000001317160430700223405ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources/org/apache/000077500000000000000000000000001317160430700235615ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources/org/apache/maven/000077500000000000000000000000001317160430700246675ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources/org/apache/maven/MavenLifecycleParticipantTest.xml000066400000000000000000000004271317160430700333410ustar00rootroot00000000000000 org.apache.maven.project.ProjectBuildingHelper org.apache.maven.project.EmptyProjectBuildingHelper maven-maven-3.5.2/maven-core/src/test/resources/org/apache/maven/execution/000077500000000000000000000000001317160430700266725ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources/org/apache/maven/extension/000077500000000000000000000000001317160430700267035ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources/org/apache/maven/extension/test-extension-repo/000077500000000000000000000000001317160430700326375ustar00rootroot00000000000000junit/000077500000000000000000000000001317160430700337115ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources/org/apache/maven/extension/test-extension-repojunit/000077500000000000000000000000001317160430700350425ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources/org/apache/maven/extension/test-extension-repo/junit3.8.1/000077500000000000000000000000001317160430700355115ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources/org/apache/maven/extension/test-extension-repo/junit/junitjunit-3.8.1.jar.md5000066400000000000000000000000401317160430700404630ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources/org/apache/maven/extension/test-extension-repo/junit/junit/3.8.11f40fb782a4f2cf78f161d32670f7a3ajunit-3.8.1.jar.sha1000066400000000000000000000000501317160430700406330ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources/org/apache/maven/extension/test-extension-repo/junit/junit/3.8.199129f16442844f6a4a11ae22fbbee40b14d774fjunit-3.8.1.pom000066400000000000000000000017461317160430700400340ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources/org/apache/maven/extension/test-extension-repo/junit/junit/3.8.1 4.0.0 junit junit 3.8.1 JUnit http://junit.org JUnit is a regression testing framework written by Erich Gamma and Kent Beck. It is used by the developer who implements unit tests in Java. JUnit http://www.junit.org Common Public License Version 1.0 http://www.opensource.org/licenses/cpl1.0.txt http://junit.cvs.sourceforge.net/junit/ junit-3.8.1.pom.md5000066400000000000000000000000401317160430700405020ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources/org/apache/maven/extension/test-extension-repo/junit/junit/3.8.150b40cb7342f52b702e6337d5debf1aejunit-3.8.1.pom.sha1000066400000000000000000000000501317160430700406520ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources/org/apache/maven/extension/test-extension-repo/junit/junit/3.8.116d74791c801c89b0071b1680ea0bc85c93417bbmaven-maven-3.5.2/maven-core/src/test/resources/org/apache/maven/extension/test-extension-repo/org/000077500000000000000000000000001317160430700334265ustar00rootroot00000000000000apache/000077500000000000000000000000001317160430700345705ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources/org/apache/maven/extension/test-extension-repo/orgapache/000077500000000000000000000000001317160430700360115ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources/org/apache/maven/extension/test-extension-repo/org/apache3/000077500000000000000000000000001317160430700361535ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources/org/apache/maven/extension/test-extension-repo/org/apache/apacheapache-3.pom000066400000000000000000000064241317160430700402570ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources/org/apache/maven/extension/test-extension-repo/org/apache/apache/3 4.0.0 org.apache apache 3 pom The Apache Software Foundation The Apache Software Foundation provides support for the Apache community of open-source software projects. The Apache projects are characterized by a collaborative, consensus based development process, an open and pragmatic software license, and a desire to create high quality software that leads the way in its field. We consider ourselves not simply a group of projects sharing a server, but rather a community of developers and users. The Apache Software License, Version 2.0 http://www.apache.org/licenses/LICENSE-2.0.txt repo Apache Software Foundation http://www.apache.org/ http://www.apache.org/ apache.snapshots Apache Snapshot Repository http://people.apache.org/repo/m2-snapshot-repository false apache.releases Apache Release Distribution Repository scp://people.apache.org/www/people.apache.org/repo/m2-ibiblio-rsync-repository apache.snapshots Apache Development Snapshot Repository scp://people.apache.org/www/people.apache.org/repo/m2-snapshot-repository Apache Announce List announce-subscribe@apache.org announce-unsubscribe@apache.org announce@apache.org http://mail-archives.apache.org/mod_mbox/www-announce/ apache-3.pom.md5000066400000000000000000000000401317160430700407270ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources/org/apache/maven/extension/test-extension-repo/org/apache/apache/3c857ebbb5f303f435495e40e6c9e45a2apache-3.pom.sha1000066400000000000000000000000501317160430700410770ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources/org/apache/maven/extension/test-extension-repo/org/apache/apache/31bc0010136a890e2fd38d901a0b7ecdf0e3f9871maven/000077500000000000000000000000001317160430700356765ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources/org/apache/maven/extension/test-extension-repo/org/apacheartifact/000077500000000000000000000000001317160430700374735ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources/org/apache/maven/extension/test-extension-repo/org/apache/mavenmaven-artifact/000077500000000000000000000000001317160430700423745ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources/org/apache/maven/extension/test-extension-repo/org/apache/maven/artifact3.0-SNAPSHOT/000077500000000000000000000000001317160430700441315ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources/org/apache/maven/extension/test-extension-repo/org/apache/maven/artifact/maven-artifactmaven-artifact-3.0-SNAPSHOT.jar.md5000066400000000000000000000000401317160430700517410ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources/org/apache/maven/extension/test-extension-repo/org/apache/maven/artifact/maven-artifact/3.0-SNAPSHOT430da483dcfb2964a9dcd619c29a6c78maven-artifact-3.0-SNAPSHOT.jar.sha1000066400000000000000000000000501317160430700521110ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources/org/apache/maven/extension/test-extension-repo/org/apache/maven/artifact/maven-artifact/3.0-SNAPSHOTea9e3f3fdc25f386d5f9ac861a55b6c3bb773d91maven-artifact-3.0-SNAPSHOT.pom000066400000000000000000000145461317160430700513140ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources/org/apache/maven/extension/test-extension-repo/org/apache/maven/artifact/maven-artifact/3.0-SNAPSHOT maven-parent org.apache.maven 5 4.0.0 org.apache.maven.artifact maven-artifact 3.0-SNAPSHOT Maven Artifact scm:svn:http://svn.apache.org/repos/asf/maven/artifact/trunk scm:svn:https://svn.apache.org/repos/asf/maven/artifact/trunk http://svn.apache.org/viewcvs.cgi/maven/artifact/trunk org.codehaus.plexus plexus-utils 1.4.5 org.codehaus.plexus plexus-container-default 1.0-alpha-32 org.codehaus.plexus plexus-active-collections 1.0-beta-1 org.apache.maven.wagon wagon-provider-api 1.0-beta-2 org.apache.maven.wagon wagon-file 1.0-beta-2 test easymock easymock 1.2_Java1.3 test org.codehaus.modello modello-maven-plugin 1.0-alpha-17 1.0.0 src/main/mdo/metadata.mdo site-docs pre-site xdoc xsd standard java xpp3-reader xpp3-writer maven-surefire-plugin **/testutils/** maven-artifact-3.0-SNAPSHOT.pom.md5000066400000000000000000000000401317160430700517600ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources/org/apache/maven/extension/test-extension-repo/org/apache/maven/artifact/maven-artifact/3.0-SNAPSHOT794377b5385c68c660ee9ca26e6b5cf1maven-artifact-3.0-SNAPSHOT.pom.sha1000066400000000000000000000000501317160430700521300ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources/org/apache/maven/extension/test-extension-repo/org/apache/maven/artifact/maven-artifact/3.0-SNAPSHOT358254e73f075bcfb9d587d0da553083abd0cc45core/000077500000000000000000000000001317160430700366265ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources/org/apache/maven/extension/test-extension-repo/org/apache/maventest/000077500000000000000000000000001317160430700376055ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources/org/apache/maven/extension/test-extension-repo/org/apache/maven/coretest-extension/000077500000000000000000000000001317160430700425765ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources/org/apache/maven/extension/test-extension-repo/org/apache/maven/core/test1/000077500000000000000000000000001317160430700427365ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources/org/apache/maven/extension/test-extension-repo/org/apache/maven/core/test/test-extensiontest-extension-1.pom000066400000000000000000000044311317160430700466040ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources/org/apache/maven/extension/test-extension-repo/org/apache/maven/core/test/test-extension/1 4.0.0 org.apache.maven.core.test test-extension jar 1 test-extension org.apache.maven.artifact maven-artifact 3.0-SNAPSHOT org.codehaus.plexus plexus-utils 1.1 org.codehaus.plexus plexus 1.0.11 pom org.codehaus.plexus plexus-component-api 1.0-alpha-16 org.codehaus.plexus plexus-container-default 1.0-alpha-16 maven-assembly-plugin 2.2-beta-2-SNAPSHOT repo-assembly package single repo.xml test-extension true ${pom.basedir}/../../resources/org/apache/maven/extension true dummy file:///tmp/dummy-repo test-extension-1.pom.md5000066400000000000000000000000401317160430700472600ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources/org/apache/maven/extension/test-extension-repo/org/apache/maven/core/test/test-extension/1e8f6e0f4ef9c2ed3fb185ef44165fb40test-extension-1.pom.sha1000066400000000000000000000000501317160430700474300ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources/org/apache/maven/extension/test-extension-repo/org/apache/maven/core/test/test-extension/188ace5d78ee32fa0ce59714a4a42a73af3b52bd3test-lifecycle-and-artifactHandler/000077500000000000000000000000001317160430700463525ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources/org/apache/maven/extension/test-extension-repo/org/apache/maven/core/testtest-lifecycle-and-artifactHandler/1/000077500000000000000000000000001317160430700465125ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources/org/apache/maven/extension/test-extension-repo/org/apache/maven/core/testtest-lifecycle-and-artifactHandler/1/test-lifecycle-and-artifactHandler-1.pom000066400000000000000000000027231317160430700561360ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources/org/apache/maven/extension/test-extension-repo/org/apache/maven/core/test 4.0.0 org.apache.maven.core.test test-lifecycle-and-artifactHandler jar 1 test-lifecycle-and-artifactHandler maven-assembly-plugin 2.2-beta-2-SNAPSHOT repo-assembly package single repo.xml test-extension true ${pom.basedir}/../../resources/org/apache/maven/extension true dummy file:///tmp/dummy-repo test-lifecycle-and-artifactHandler/1/test-lifecycle-and-artifactHandler-1.pom.md5000066400000000000000000000000401317160430700566100ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources/org/apache/maven/extension/test-extension-repo/org/apache/maven/core/test7f10427af029d20cbea57c21d1aec65etest-lifecycle-and-artifactHandler/1/test-lifecycle-and-artifactHandler-1.pom.sha1000066400000000000000000000000501317160430700567600ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources/org/apache/maven/extension/test-extension-repo/org/apache/maven/core/tested98c808239aefb0ec51a8b9e96f191da7fd92e6maven-parent/000077500000000000000000000000001317160430700402735ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources/org/apache/maven/extension/test-extension-repo/org/apache/maven4/000077500000000000000000000000001317160430700404365ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources/org/apache/maven/extension/test-extension-repo/org/apache/maven/maven-parentmaven-parent-4.pom000066400000000000000000000234141317160430700437150ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources/org/apache/maven/extension/test-extension-repo/org/apache/maven/maven-parent/4 4.0.0 org.apache apache 3 ../asf/pom.xml org.apache.maven maven-parent 4 pom Apache Maven Maven is a software project management and comprehension tool. Based on the concept of a project object model (POM), Maven can manage a project's build, reporting and documentation from a central piece of information. http://maven.apache.org/ jira http://jira.codehaus.org/browse/MPA continuum http://maven.zones.apache.org:8080/continuum mail
    notifications@maven.apache.org
    2002 Maven Announcements List announce@maven.apache.org announce-subscribe@maven.apache.org announce-unsubscribe@maven.apache.org http://mail-archives.apache.org/mod_mbox/maven-announce/ Maven Issues List issues@maven.apache.org issues-subscribe@maven.apache.org issues-unsubscribe@maven.apache.org http://mail-archives.apache.org/mod_mbox/maven-issues/ Maven Notifications List notifications@maven.apache.org notifications-subscribe@maven.apache.org notifications-unsubscribe@maven.apache.org http://mail-archives.apache.org/mod_mbox/maven-notifications/ jvanzyl Jason van Zyl jason@maven.org ASF PMC Chair -5 brett Brett Porter brett@apache.org ASF PMC Member +10 evenisse Emmanuel Venisse evenisse@apache.org ASF PMC Member +1 kenney Kenney Westerhof kenney@apache.org Neonics PMC Member snicoll Stephane Nicoll snicoll@apache.org ASF PMC Member +1 vmassol Vincent Massol vmassol@apache.org ASF PMC Member +1 fgiust Fabrizio Giustina fgiust@apache.org openmind PMC Member +1 epunzalan Edwin Punzalan epunzalan@mergere.com Mergere Committer +8 mperham Mike Perham mperham@gmail.com IBM PMC Member -6 jdcasey John Casey jdcasey@apache.org ASF PMC Member -5 trygvis Trygve Laugstol trygvis@apache.org ASF PMC Member +1 vsiveton Vincent Siveton vsiveton@apache.org ASF PMC Member -5 carlos Carlos Sanchez carlos@apache.org ASF PMC Member +1 dennisl Dennis Lundberg dennisl@apache.org ASF PMC Member +1 apache.website scp://people.apache.org/www/maven.apache.org org.apache.maven.plugins maven-surefire-report-plugin org.apache.maven.plugins maven-checkstyle-plugin http://svn.apache.org/repos/asf/maven/plugins/trunk/maven-checkstyle-plugin/src/main/resources/config/maven_checks.xml http://svn.apache.org/repos/asf/maven/plugins/trunk/maven-checkstyle-plugin/src/main/resources/config/maven-header.txt org.apache.maven.plugins maven-pmd-plugin org.codehaus.mojo cobertura-maven-plugin org.codehaus.mojo taglist-maven-plugin org.apache.maven.plugins maven-jxr-plugin org.apache.maven.plugins maven-javadoc-plugin http://java.sun.com/j2ee/1.4/docs/api http://java.sun.com/j2se/1.5.0/docs/api http://jakarta.apache.org/commons/collections/apidocs-COLLECTIONS_3_0/ http://jakarta.apache.org/commons/dbcp/apidocs/ http://jakarta.apache.org/commons/fileupload/apidocs/ http://jakarta.apache.org/commons/httpclient/apidocs/ http://jakarta.apache.org/commons/logging/apidocs/ http://jakarta.apache.org/commons/pool/apidocs/ http://www.junit.org/junit/javadoc/ http://logging.apache.org/log4j/docs/api/ http://jakarta.apache.org/regexp/apidocs/ http://jakarta.apache.org/velocity/api/ scm:svn:http://svn.apache.org/repos/asf/maven/pom/maven/tags/maven-parent-4 scm:svn:https://svn.apache.org/repos/asf/maven/pom/maven/tags/maven-parent-4 http://svn.apache.org/viewvc/maven/pom/maven/tags/maven-parent-4
    maven-parent-4.pom.md5000066400000000000000000000000401317160430700443670ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources/org/apache/maven/extension/test-extension-repo/org/apache/maven/maven-parent/42a4e926f3a76c6e74b0b126f513ad4e7maven-parent-4.pom.sha1000066400000000000000000000000501317160430700445370ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources/org/apache/maven/extension/test-extension-repo/org/apache/maven/maven-parent/40fc039b0bd4d17d7c147a30e1d83994629c5297c5/000077500000000000000000000000001317160430700404375ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources/org/apache/maven/extension/test-extension-repo/org/apache/maven/maven-parentmaven-parent-5.pom000066400000000000000000000356061317160430700437250ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources/org/apache/maven/extension/test-extension-repo/org/apache/maven/maven-parent/5 4.0.0 org.apache apache 3 ../asf/pom.xml org.apache.maven maven-parent 5 pom Apache Maven Maven is a software project management and comprehension tool. Based on the concept of a project object model (POM), Maven can manage a project's build, reporting and documentation from a central piece of information. http://maven.apache.org/ jira http://jira.codehaus.org/browse/MPA continuum http://maven.zones.apache.org/continuum mail
    notifications@maven.apache.org
    2002 Maven Announcements List announce@maven.apache.org announce-subscribe@maven.apache.org announce-unsubscribe@maven.apache.org http://mail-archives.apache.org/mod_mbox/maven-announce/ Maven Issues List issues@maven.apache.org issues-subscribe@maven.apache.org issues-unsubscribe@maven.apache.org http://mail-archives.apache.org/mod_mbox/maven-issues/ Maven Notifications List notifications@maven.apache.org notifications-subscribe@maven.apache.org notifications-unsubscribe@maven.apache.org http://mail-archives.apache.org/mod_mbox/maven-notifications/ jvanzyl Jason van Zyl jason@maven.org ASF PMC Chair -5 brett Brett Porter brett@apache.org ASF PMC Member +10 evenisse Emmanuel Venisse evenisse@apache.org ASF PMC Member +1 kenney Kenney Westerhof kenney@apache.org Neonics PMC Member +1 snicoll Stephane Nicoll snicoll@apache.org ASF PMC Member +1 vmassol Vincent Massol vmassol@apache.org ASF PMC Member +1 fgiust Fabrizio Giustina fgiust@apache.org openmind PMC Member +1 epunzalan Edwin Punzalan epunzalan@mergere.com Mergere Committer +8 mperham Mike Perham mperham@gmail.com IBM PMC Member -6 jdcasey John Casey jdcasey@apache.org ASF PMC Member -5 trygvis Trygve Laugstol trygvis@apache.org ASF PMC Member +1 vsiveton Vincent Siveton vsiveton@apache.org ASF PMC Member -5 carlos Carlos Sanchez carlos@apache.org ASF PMC Member +1 dennisl Dennis Lundberg dennisl@apache.org ASF PMC Member +1 aheritier Arnaud Heritier aheritier@apache.org ASF PMC Member +1 handyande Andrew Williams handyande@apache.org Committer 0 jtolentino Ernesto Tolentino Jr. jtolentino@apache.org ASF PMC Member +8 joakime Joakim Erdfelt joakime@apache.org ASF PMC Member -5 jmcconnell Jesse McConnell jmcconnell@apache.org ASF PMC Member -6 wsmoak Wendy Smoak wsmoak@apache.org Committer -7 apache.website scp://people.apache.org/www/maven.apache.org org.apache.maven.plugins maven-release-plugin 2.0-beta-4 https://svn.apache.org/repos/asf/maven/pom/tags false deploy -Prelease ci org.apache.maven.plugins maven-pmd-plugin cpd-check reporting org.apache.maven.plugins maven-surefire-report-plugin org.apache.maven.plugins maven-checkstyle-plugin http://svn.apache.org/repos/asf/maven/plugins/trunk/maven-checkstyle-plugin/src/main/resources/config/maven_checks.xml http://svn.apache.org/repos/asf/maven/plugins/trunk/maven-checkstyle-plugin/src/main/resources/config/maven-header.txt org.apache.maven.plugins maven-pmd-plugin org.codehaus.mojo cobertura-maven-plugin org.codehaus.mojo taglist-maven-plugin org.apache.maven.plugins maven-jxr-plugin org.apache.maven.plugins maven-javadoc-plugin http://java.sun.com/j2ee/1.4/docs/api http://java.sun.com/j2se/1.5.0/docs/api http://jakarta.apache.org/commons/collections/apidocs-COLLECTIONS_3_0/ http://jakarta.apache.org/commons/dbcp/apidocs/ http://jakarta.apache.org/commons/fileupload/apidocs/ http://jakarta.apache.org/commons/httpclient/apidocs/ http://jakarta.apache.org/commons/logging/apidocs/ http://jakarta.apache.org/commons/pool/apidocs/ http://www.junit.org/junit/javadoc/ http://logging.apache.org/log4j/docs/api/ http://jakarta.apache.org/regexp/apidocs/ http://jakarta.apache.org/velocity/api/ release maven-gpg-plugin 1.0-alpha-1 ${gpg.passphrase} sign true maven-deploy-plugin 2.3 ${deploy.altRepository} true maven-remote-resources-plugin 1.0-alpha-1 process org.apache:apache-jar-resource-bundle:1.0 org.apache.maven.plugins maven-source-plugin 2.0.2 attach-sources jar org.apache.maven.plugins maven-javadoc-plugin 2.2 attach-javadocs jar scm:svn:https://svn.apache.org/repos/asf/maven/pom/tags/maven-parent-5 scm:svn:https://svn.apache.org/repos/asf/maven/pom/tags/maven-parent-5 https://svn.apache.org/repos/asf/maven/pom/tags/maven-parent-5
    maven-parent-5.pom.md5000066400000000000000000000000401317160430700443710ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources/org/apache/maven/extension/test-extension-repo/org/apache/maven/maven-parent/54da85635ce64dbec5b00232d5bb26453maven-parent-5.pom.sha1000066400000000000000000000000501317160430700445410ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources/org/apache/maven/extension/test-extension-repo/org/apache/maven/maven-parent/55c1ab38decaca1ccd08294aeab135047ebbae00dwagon/000077500000000000000000000000001317160430700370115ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources/org/apache/maven/extension/test-extension-repo/org/apache/mavenwagon-provider-api/000077500000000000000000000000001317160430700425235ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources/org/apache/maven/extension/test-extension-repo/org/apache/maven/wagon1.0-beta-2/000077500000000000000000000000001317160430700440715ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources/org/apache/maven/extension/test-extension-repo/org/apache/maven/wagon/wagon-provider-apiwagon-provider-api-1.0-beta-2.jar.md5000066400000000000000000000000401317160430700523230ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources/org/apache/maven/extension/test-extension-repo/org/apache/maven/wagon/wagon-provider-api/1.0-beta-2f41eb4e07a725eea3332743a29057855wagon-provider-api-1.0-beta-2.jar.sha1000066400000000000000000000000501317160430700524730ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources/org/apache/maven/extension/test-extension-repo/org/apache/maven/wagon/wagon-provider-api/1.0-beta-2abd1c9ace6e87c94a4b91f5176aeb09d954b23a3wagon-provider-api-1.0-beta-2.pom000066400000000000000000000012501317160430700516620ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources/org/apache/maven/extension/test-extension-repo/org/apache/maven/wagon/wagon-provider-api/1.0-beta-2 wagon org.apache.maven.wagon 1.0-beta-2 4.0.0 wagon-provider-api Maven Wagon API 1.0-beta-2 Maven Wagon API that defines the contract between different Wagon implementations org.codehaus.plexus plexus-utils deployed wagon-provider-api-1.0-beta-2.pom.md5000066400000000000000000000000401317160430700523420ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources/org/apache/maven/extension/test-extension-repo/org/apache/maven/wagon/wagon-provider-api/1.0-beta-297f0a0bd0b81520ccccf8736b1fe380cwagon-provider-api-1.0-beta-2.pom.sha1000066400000000000000000000000501317160430700525120ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources/org/apache/maven/extension/test-extension-repo/org/apache/maven/wagon/wagon-provider-api/1.0-beta-28b3013d0754edbeb694831ddf1c5d1a0019ee042wagon/000077500000000000000000000000001317160430700401245ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources/org/apache/maven/extension/test-extension-repo/org/apache/maven/wagon1.0-beta-2/000077500000000000000000000000001317160430700414725ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources/org/apache/maven/extension/test-extension-repo/org/apache/maven/wagon/wagonwagon-1.0-beta-2.pom000066400000000000000000000133721317160430700446740ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources/org/apache/maven/extension/test-extension-repo/org/apache/maven/wagon/wagon/1.0-beta-2 4.0.0 maven-parent org.apache.maven 4 ../pom/maven/pom.xml org.apache.maven.wagon wagon pom Maven Wagon 1.0-beta-2 Tools to manage artifacts and deployment http://maven.apache.org/wagon jira http://jira.codehaus.org/browse/WAGON 2003 Maven Wagon User List wagon-users-subscribe@maven.apache.org wagon-users-unsubscribe@maven.apache.org http://mail-archives.apache.org/mod_mbox/maven-wagon-users/ Maven Wagon Developer List wagon-dev-subscribe@maven.apache.org wagon-dev-unsubscribe@maven.apache.org http://mail-archives.apache.org/mod_mbox/maven-wagon-dev/ Maven Commits List wagon-commits-subscribe@maven.apache.org wagon-commits-unsubscribe@maven.apache.org http://mail-archives.apache.org/mod_mbox/maven-wagon-commits/ michal Michal Maczka michal@codehaus.org Codehaus Developer scm:svn:https://svn.apache.org/repos/asf/maven/wagon/tags/wagon-1.0-beta-2 scm:svn:https://svn.apache.org/repos/asf/maven/wagon/tags/wagon-1.0-beta-2 https://svn.apache.org/repos/asf/maven/wagon/tags/wagon-1.0-beta-2 maven-release-plugin https://svn.apache.org/repos/asf/maven/wagon/tags wagon-provider-api wagon-provider-test wagon-providers junit junit test org.apache.maven.wagon wagon-provider-api 1.0-beta-2 org.apache.maven.wagon wagon-provider-test 1.0-beta-2 org.apache.maven.wagon wagon-ssh-common-test 1.0-beta-2 org.apache.maven.wagon wagon-ssh-common 1.0-beta-2 junit junit 3.8.1 org.codehaus.plexus plexus-interactivity-api 1.0-alpha-4 org.codehaus.plexus plexus-container-default 1.0-alpha-8 org.codehaus.plexus plexus-utils 1.0.4 sharedResources people.apache.org http://people.apache.org/repo/m2-snapshot-repository true org.apache.maven.plugins maven-remote-resources-plugin 1.0-alpha-1 process org.apache:apache-jar-resource-bundle:1.0 wagon-1.0-beta-2.pom.md5000066400000000000000000000000401317160430700453440ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources/org/apache/maven/extension/test-extension-repo/org/apache/maven/wagon/wagon/1.0-beta-2e739bffedc84a18c6e10a0958e2006adwagon-1.0-beta-2.pom.sha1000066400000000000000000000000501317160430700455140ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources/org/apache/maven/extension/test-extension-repo/org/apache/maven/wagon/wagon/1.0-beta-26cf8a47018be792d2b1774d2bacd7541c888ae50codehaus/000077500000000000000000000000001317160430700351425ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources/org/apache/maven/extension/test-extension-repo/orgplexus/000077500000000000000000000000001317160430700364625ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources/org/apache/maven/extension/test-extension-repo/org/codehausplexus-active-collections/000077500000000000000000000000001317160430700435675ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources/org/apache/maven/extension/test-extension-repo/org/codehaus/plexus1.0-beta-1/000077500000000000000000000000001317160430700451345ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources/org/apache/maven/extension/test-extension-repo/org/codehaus/plexus/plexus-active-collectionsplexus-active-collections-1.0-beta-1.jar.md5000066400000000000000000000000401317160430700547600ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources/org/apache/maven/extension/test-extension-repo/org/codehaus/plexus/plexus-active-collections/1.0-beta-11078ac2103fe666952a3cbcbff19ec71plexus-active-collections-1.0-beta-1.jar.sha1000066400000000000000000000000501317160430700551300ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources/org/apache/maven/extension/test-extension-repo/org/codehaus/plexus/plexus-active-collections/1.0-beta-1c76ce4f9f1a3d04ef849c1d067519b77f07e01f3plexus-active-collections-1.0-beta-1.pom000066400000000000000000000032641317160430700543260ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources/org/apache/maven/extension/test-extension-repo/org/codehaus/plexus/plexus-active-collections/1.0-beta-1 4.0.0 plexus-components org.codehaus.plexus 1.1.6 plexus-active-collections 1.0-beta-1 Plexus Container-Backed Active Collections org.codehaus.plexus plexus-component-api 1.0-alpha-16 org.codehaus.plexus plexus-container-default 1.0-alpha-16 junit junit 3.8.1 test maven-surefire-plugin **/TestComponent.java **/TestBadComponent.java **/*TCK.java scm:svn:https://svn.codehaus.org/plexus/tags/plexus-active-collections-1.0-beta-1 scm:svn:https://svn.codehaus.org/plexus/tags/plexus-active-collections-1.0-beta-1 plexus-active-collections-1.0-beta-1.pom.md5000066400000000000000000000000401317160430700547770ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources/org/apache/maven/extension/test-extension-repo/org/codehaus/plexus/plexus-active-collections/1.0-beta-1d844f3e1934a76cefc25342bf02f3bffplexus-active-collections-1.0-beta-1.pom.sha1000066400000000000000000000000501317160430700551470ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources/org/apache/maven/extension/test-extension-repo/org/codehaus/plexus/plexus-active-collections/1.0-beta-1cf6a9d40df4ca79c210b2b8a90ce28fffb202769plexus-classworlds/000077500000000000000000000000001317160430700423405ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources/org/apache/maven/extension/test-extension-repo/org/codehaus/plexus1.2-alpha-10/000077500000000000000000000000001317160430700441415ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources/org/apache/maven/extension/test-extension-repo/org/codehaus/plexus/plexus-classworldsplexus-classworlds-1.2-alpha-10.jar.md5000066400000000000000000000000401317160430700527720ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources/org/apache/maven/extension/test-extension-repo/org/codehaus/plexus/plexus-classworlds/1.2-alpha-10f55402879506f435a386f2c002ed5001plexus-classworlds-1.2-alpha-10.jar.sha1000066400000000000000000000000501317160430700531420ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources/org/apache/maven/extension/test-extension-repo/org/codehaus/plexus/plexus-classworlds/1.2-alpha-10fc41205635dab152bf794785be80a0a70fda686eplexus-classworlds-1.2-alpha-10.pom000066400000000000000000000062331317160430700523370ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources/org/apache/maven/extension/test-extension-repo/org/codehaus/plexus/plexus-classworlds/1.2-alpha-10 plexus org.codehaus.plexus 1.0.10 4.0.0 org.codehaus.plexus plexus-classworlds jar Plexus Classworlds 1.2-alpha-10 2002 junit junit 3.8.1 jar compile maven-surefire-plugin once maven-compiler-plugin org/codehaus/plexus/classworlds/event/* debug aspectj aspectjrt 1.5.0 org.codehaus.mojo aspectj-maven-plugin compile 1.4 scm:svn:http://svn.codehaus.org/plexus/plexus-classworlds/tags/plexus-classworlds-1.2-alpha-10 scm:svn:https://svn.codehaus.org/plexus/plexus-classworlds/tags/plexus-classworlds-1.2-alpha-10 http://fisheye.codehaus.org/browse/plexus/plexus-classworlds/tags/plexus-classworlds-1.2-alpha-10 plexus-classworlds-1.2-alpha-10.pom.md5000066400000000000000000000000401317160430700530110ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources/org/apache/maven/extension/test-extension-repo/org/codehaus/plexus/plexus-classworlds/1.2-alpha-101a7177f5992983aeb393089af67e51dcplexus-classworlds-1.2-alpha-10.pom.sha1000066400000000000000000000000501317160430700531610ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources/org/apache/maven/extension/test-extension-repo/org/codehaus/plexus/plexus-classworlds/1.2-alpha-1011215912b045533ec9aaba9f63ea27acf6da850e1.2-alpha-7/000077500000000000000000000000001317160430700440675ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources/org/apache/maven/extension/test-extension-repo/org/codehaus/plexus/plexus-classworldsplexus-classworlds-1.2-alpha-7.jar.md5000066400000000000000000000000401317160430700526460ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources/org/apache/maven/extension/test-extension-repo/org/codehaus/plexus/plexus-classworlds/1.2-alpha-7b00a4521e82cd7cdf502039dd59a1ffbplexus-classworlds-1.2-alpha-7.jar.sha1000066400000000000000000000000501317160430700530160ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources/org/apache/maven/extension/test-extension-repo/org/codehaus/plexus/plexus-classworlds/1.2-alpha-7ed03d1eeb9b2576747df0d2883d9006fa5e1febeplexus-classworlds-1.2-alpha-7.pom000066400000000000000000000045041317160430700522120ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources/org/apache/maven/extension/test-extension-repo/org/codehaus/plexus/plexus-classworlds/1.2-alpha-7 plexus org.codehaus.plexus 1.0.9 4.0.0 org.codehaus.plexus plexus-classworlds Plexus Classworlds 1.2-alpha-7 2002 scm:svn:http://svn.codehaus.org/plexus/plexus-classworlds/tags/plexus-classworlds-1.2-alpha-7 scm:svn:https://svn.codehaus.org/plexus/plexus-classworlds/tags/plexus-classworlds-1.2-alpha-7 http://fisheye.codehaus.org/browse/plexus/plexus-classworlds/tags/plexus-classworlds-1.2-alpha-7 maven-surefire-plugin once maven-compiler-plugin org/codehaus/plexus/classworlds/event/* debug org.codehaus.mojo aspectj-maven-plugin compile 1.4 aspectj aspectjrt 1.5.0 junit junit 3.8.1 compile deployed plexus-classworlds-1.2-alpha-7.pom.md5000066400000000000000000000000401317160430700526650ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources/org/apache/maven/extension/test-extension-repo/org/codehaus/plexus/plexus-classworlds/1.2-alpha-780962d09b250824806ca66b0bd0ad4c1plexus-classworlds-1.2-alpha-7.pom.sha1000066400000000000000000000000501317160430700530350ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources/org/apache/maven/extension/test-extension-repo/org/codehaus/plexus/plexus-classworlds/1.2-alpha-76944ec0d0cab19adf167332f7197e045d64a577cplexus-component-api/000077500000000000000000000000001317160430700425515ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources/org/apache/maven/extension/test-extension-repo/org/codehaus/plexus1.0-alpha-16/000077500000000000000000000000001317160430700443565ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources/org/apache/maven/extension/test-extension-repo/org/codehaus/plexus/plexus-component-apiplexus-component-api-1.0-alpha-16.jar.md5000066400000000000000000000000401317160430700534240ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources/org/apache/maven/extension/test-extension-repo/org/codehaus/plexus/plexus-component-api/1.0-alpha-164fe3c03b97ff12905d0fb10fc5b36766plexus-component-api-1.0-alpha-16.jar.sha1000066400000000000000000000000501317160430700535740ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources/org/apache/maven/extension/test-extension-repo/org/codehaus/plexus/plexus-component-api/1.0-alpha-165a2100a1c6a37804b1abfc70000b0ea33b83b7f9plexus-component-api-1.0-alpha-16.pom000066400000000000000000000042471317160430700527740ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources/org/apache/maven/extension/test-extension-repo/org/codehaus/plexus/plexus-component-api/1.0-alpha-16 plexus-containers org.codehaus.plexus 1.0-alpha-16 4.0.0 plexus-component-api Plexus Component API 1.0-alpha-16 maven-surefire-plugin 2.2 **/Test*.java **/Abstract*.java org.codehaus.plexus plexus-classworlds maven-surefire-report-plugin maven-pmd-plugin maven-javadoc-plugin http://java.sun.com/j2ee/1.4/docs/api http://java.sun.com/j2se/1.5.0/docs/api http://jakarta.apache.org/commons/collections/apidocs-COLLECTIONS_3_0/ http://jakarta.apache.org/commons/dbcp/apidocs/ http://jakarta.apache.org/commons/fileupload/apidocs/ http://jakarta.apache.org/commons/httpclient/apidocs/ http://jakarta.apache.org/commons/logging/apidocs/ http://jakarta.apache.org/commons/pool/apidocs/ http://www.junit.org/junit/javadoc/ http://logging.apache.org/log4j/docs/api/ http://jakarta.apache.org/regexp/apidocs/ http://jakarta.apache.org/velocity/api/ deployed plexus-component-api-1.0-alpha-16.pom.md5000066400000000000000000000000401317160430700534430ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources/org/apache/maven/extension/test-extension-repo/org/codehaus/plexus/plexus-component-api/1.0-alpha-16751ea77f1e617aea90f36d7156762bf5plexus-component-api-1.0-alpha-16.pom.sha1000066400000000000000000000000501317160430700536130ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources/org/apache/maven/extension/test-extension-repo/org/codehaus/plexus/plexus-component-api/1.0-alpha-1653ad54acd9589c497ba54740f0455fec55db64d71.0-alpha-32/000077500000000000000000000000001317160430700443545ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources/org/apache/maven/extension/test-extension-repo/org/codehaus/plexus/plexus-component-apiplexus-component-api-1.0-alpha-32.jar.md5000066400000000000000000000000401317160430700534200ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources/org/apache/maven/extension/test-extension-repo/org/codehaus/plexus/plexus-component-api/1.0-alpha-327146edcc3412c2b54df27edaf66b00a6plexus-component-api-1.0-alpha-32.jar.sha1000066400000000000000000000000501317160430700535700ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources/org/apache/maven/extension/test-extension-repo/org/codehaus/plexus/plexus-component-api/1.0-alpha-32b226de4eb8db939dff4e14eb5aa1be045c39f6f4plexus-component-api-1.0-alpha-32.pom000066400000000000000000000043771317160430700527740ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources/org/apache/maven/extension/test-extension-repo/org/codehaus/plexus/plexus-component-api/1.0-alpha-32 4.0.0 org.codehaus.plexus plexus-containers 1.0-alpha-32 plexus-component-api Plexus Component API 1.0-alpha-32 maven-surefire-plugin 2.2 **/Test*.java **/Abstract*.java org.codehaus.plexus plexus-classworlds maven-surefire-report-plugin maven-pmd-plugin maven-javadoc-plugin http://java.sun.com/j2ee/1.4/docs/api http://java.sun.com/j2se/1.5.0/docs/api http://jakarta.apache.org/commons/collections/apidocs-COLLECTIONS_3_0/ http://jakarta.apache.org/commons/dbcp/apidocs/ http://jakarta.apache.org/commons/fileupload/apidocs/ http://jakarta.apache.org/commons/httpclient/apidocs/ http://jakarta.apache.org/commons/logging/apidocs/ http://jakarta.apache.org/commons/pool/apidocs/ http://www.junit.org/junit/javadoc/ http://logging.apache.org/log4j/docs/api/ http://jakarta.apache.org/regexp/apidocs/ http://jakarta.apache.org/velocity/api/ plexus-component-api-1.0-alpha-32.pom.md5000066400000000000000000000000401317160430700534370ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources/org/apache/maven/extension/test-extension-repo/org/codehaus/plexus/plexus-component-api/1.0-alpha-32a181ee89516009cff7658eec175ccb23plexus-component-api-1.0-alpha-32.pom.sha1000066400000000000000000000000501317160430700536070ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources/org/apache/maven/extension/test-extension-repo/org/codehaus/plexus/plexus-component-api/1.0-alpha-32e214782e714b87b38d5605cb8da53b7d98efde06plexus-components/000077500000000000000000000000001317160430700421655ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources/org/apache/maven/extension/test-extension-repo/org/codehaus/plexus1.1.6/000077500000000000000000000000001317160430700426305ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources/org/apache/maven/extension/test-extension-repo/org/codehaus/plexus/plexus-componentsplexus-components-1.1.6.pom000066400000000000000000000035401317160430700475130ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources/org/apache/maven/extension/test-extension-repo/org/codehaus/plexus/plexus-components/1.1.6 4.0.0 plexus org.codehaus.plexus 1.0.8 org.codehaus.plexus plexus-components pom 1.1.6 Plexus Components Parent Project org.codehaus.plexus plexus-container-default 1.0-alpha-8 plexus-action plexus-archiver plexus-bayesian plexus-command plexus-compiler plexus-drools plexus-formica plexus-formica-web plexus-hibernate plexus-i18n plexus-interactivity plexus-ircbot plexus-jdo plexus-jetty-httpd plexus-jetty plexus-mimetyper plexus-notification plexus-resource plexus-security plexus-summit plexus-taskqueue plexus-velocity plexus-xmlrpc plexus-components-1.1.6.pom.md5000066400000000000000000000000401317160430700501670ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources/org/apache/maven/extension/test-extension-repo/org/codehaus/plexus/plexus-components/1.1.6b76cb94eb4ade475f4743d3656c40899plexus-components-1.1.6.pom.sha1000066400000000000000000000000501317160430700503370ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources/org/apache/maven/extension/test-extension-repo/org/codehaus/plexus/plexus-components/1.1.6682713aa402653d0ea5e224870dc899803734519plexus-container-default/000077500000000000000000000000001317160430700434045ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources/org/apache/maven/extension/test-extension-repo/org/codehaus/plexus1.0-alpha-16/000077500000000000000000000000001317160430700452115ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources/org/apache/maven/extension/test-extension-repo/org/codehaus/plexus/plexus-container-defaultplexus-container-default-1.0-alpha-16.jar.md5000066400000000000000000000000401317160430700551120ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources/org/apache/maven/extension/test-extension-repo/org/codehaus/plexus/plexus-container-default/1.0-alpha-1600b4ce443fa584a1998cd6f991ea6514plexus-container-default-1.0-alpha-16.jar.sha1000066400000000000000000000000501317160430700552620ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources/org/apache/maven/extension/test-extension-repo/org/codehaus/plexus/plexus-container-default/1.0-alpha-16dcad8d44306c5ecc109b9449f292fb28b75d37efplexus-container-default-1.0-alpha-16.pom000066400000000000000000000031401317160430700544510ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources/org/apache/maven/extension/test-extension-repo/org/codehaus/plexus/plexus-container-default/1.0-alpha-16 plexus-containers org.codehaus.plexus 1.0-alpha-16 4.0.0 plexus-container-default Default Plexus Container 1.0-alpha-16 maven-surefire-plugin once **/Test*.java **/Abstract*.java maven-assembly-plugin jar-with-dependencies org.codehaus.plexus plexus-component-api org.codehaus.plexus plexus-utils org.codehaus.plexus plexus-classworlds jmock jmock 1.0.1 test deployed plexus-container-default-1.0-alpha-16.pom.md5000066400000000000000000000000401317160430700551310ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources/org/apache/maven/extension/test-extension-repo/org/codehaus/plexus/plexus-container-default/1.0-alpha-16883b6e1e40cccb06c1d1ce93728b0a9dplexus-container-default-1.0-alpha-16.pom.sha1000066400000000000000000000000501317160430700553010ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources/org/apache/maven/extension/test-extension-repo/org/codehaus/plexus/plexus-container-default/1.0-alpha-16435f5d09ea241e93acaecd4b6680ddb13a36837d1.0-alpha-32/000077500000000000000000000000001317160430700452075ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources/org/apache/maven/extension/test-extension-repo/org/codehaus/plexus/plexus-container-defaultplexus-container-default-1.0-alpha-32.jar.md5000066400000000000000000000000401317160430700551060ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources/org/apache/maven/extension/test-extension-repo/org/codehaus/plexus/plexus-container-default/1.0-alpha-32556231599b5413a7c1f16a5fd15be574plexus-container-default-1.0-alpha-32.jar.sha1000066400000000000000000000000501317160430700552560ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources/org/apache/maven/extension/test-extension-repo/org/codehaus/plexus/plexus-container-default/1.0-alpha-3291410b971f9659f76b0ff26a97b9fbac5de2f69eplexus-container-default-1.0-alpha-32.pom000066400000000000000000000070321317160430700544510ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources/org/apache/maven/extension/test-extension-repo/org/codehaus/plexus/plexus-container-default/1.0-alpha-32 4.0.0 org.codehaus.plexus plexus-containers 1.0-alpha-32 plexus-container-default Default Plexus Container 1.0-alpha-32 maven-surefire-plugin once **/Test*.java **/Abstract*.java shade-maven-plugin org.codehaus.mojo 1.0-alpha-9 package shade classworlds:classworlds junit:junit jmock:jmock org.codehaus.plexus:plexus-classworlds org.codehaus.plexus:plexus-utils org.codehaus.plexus plexus-component-api org.codehaus.plexus plexus-utils org.codehaus.plexus plexus-classworlds jmock jmock 1.0.1 test maven-pmd-plugin maven-javadoc-plugin http://java.sun.com/j2ee/1.4/docs/api http://java.sun.com/j2se/1.5.0/docs/api http://jakarta.apache.org/commons/collections/apidocs-COLLECTIONS_3_0/ http://jakarta.apache.org/commons/dbcp/apidocs/ http://jakarta.apache.org/commons/fileupload/apidocs/ http://jakarta.apache.org/commons/httpclient/apidocs/ http://jakarta.apache.org/commons/logging/apidocs/ http://jakarta.apache.org/commons/pool/apidocs/ http://www.junit.org/junit/javadoc/ http://logging.apache.org/log4j/docs/api/ http://jakarta.apache.org/regexp/apidocs/ http://jakarta.apache.org/velocity/api/ plexus-container-default-1.0-alpha-32.pom.md5000066400000000000000000000000401317160430700551250ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources/org/apache/maven/extension/test-extension-repo/org/codehaus/plexus/plexus-container-default/1.0-alpha-32af4ca0022b674405556b3f397e375adcplexus-container-default-1.0-alpha-32.pom.sha1000066400000000000000000000000501317160430700552750ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources/org/apache/maven/extension/test-extension-repo/org/codehaus/plexus/plexus-container-default/1.0-alpha-328f4d09d36a2345a39301dbd77ef9906c795887f7plexus-containers/000077500000000000000000000000001317160430700421455ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources/org/apache/maven/extension/test-extension-repo/org/codehaus/plexus1.0-alpha-16/000077500000000000000000000000001317160430700437525ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources/org/apache/maven/extension/test-extension-repo/org/codehaus/plexus/plexus-containersplexus-containers-1.0-alpha-16.pom000066400000000000000000000035351317160430700517630ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources/org/apache/maven/extension/test-extension-repo/org/codehaus/plexus/plexus-containers/1.0-alpha-16 4.0.0 org.codehaus.plexus plexus 1.0.9 org.codehaus.plexus plexus-containers pom Parent Plexus Container POM 1.0-alpha-16 plexus-component-api plexus-container-default scm:svn:http://svn.codehaus.org/plexus/plexus-containers/tags/plexus-containers-1.0-alpha-16 scm:svn:https://svn.codehaus.org/plexus/plexus-containers/tags/plexus-containers-1.0-alpha-16 http://fisheye.codehaus.org/browse/plexus/plexus-containers/tags/plexus-containers-1.0-alpha-16 junit junit 3.8.1 compile org.codehaus.plexus plexus-classworlds 1.2-alpha-7 org.codehaus.plexus plexus-component-api 1.0-alpha-16 org.codehaus.plexus plexus-utils 1.3 plexus-containers-1.0-alpha-16.pom.md5000066400000000000000000000000401317160430700524330ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources/org/apache/maven/extension/test-extension-repo/org/codehaus/plexus/plexus-containers/1.0-alpha-163eee2016e3e307618048e30f088b546eplexus-containers-1.0-alpha-16.pom.sha1000066400000000000000000000000501317160430700526030ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources/org/apache/maven/extension/test-extension-repo/org/codehaus/plexus/plexus-containers/1.0-alpha-1646b79dd7d6a8130d2fa81c80b16b695d491548fe1.0-alpha-32/000077500000000000000000000000001317160430700437505ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources/org/apache/maven/extension/test-extension-repo/org/codehaus/plexus/plexus-containersplexus-containers-1.0-alpha-32.pom000066400000000000000000000035411317160430700517540ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources/org/apache/maven/extension/test-extension-repo/org/codehaus/plexus/plexus-containers/1.0-alpha-32 4.0.0 org.codehaus.plexus plexus 1.0.11 org.codehaus.plexus plexus-containers pom Parent Plexus Container POM 1.0-alpha-32 plexus-component-api plexus-container-default scm:svn:http://svn.codehaus.org/plexus/plexus-containers/tags/plexus-containers-1.0-alpha-32 scm:svn:https://svn.codehaus.org/plexus/plexus-containers/tags/plexus-containers-1.0-alpha-32 http://fisheye.codehaus.org/browse/plexus/plexus-containers/tags/plexus-containers-1.0-alpha-32 junit junit 3.8.1 compile org.codehaus.plexus plexus-classworlds 1.2-alpha-10 org.codehaus.plexus plexus-utils 1.4.5 org.codehaus.plexus plexus-component-api 1.0-alpha-32 plexus-containers-1.0-alpha-32.pom.md5000066400000000000000000000000401317160430700524270ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources/org/apache/maven/extension/test-extension-repo/org/codehaus/plexus/plexus-containers/1.0-alpha-328ac33e07134648d37e2b1253286889a7plexus-containers-1.0-alpha-32.pom.sha1000066400000000000000000000000501317160430700525770ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources/org/apache/maven/extension/test-extension-repo/org/codehaus/plexus/plexus-containers/1.0-alpha-328486ff9b37d1ade2a4524c6fee72d394f88fbe08plexus-utils/000077500000000000000000000000001317160430700411405ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources/org/apache/maven/extension/test-extension-repo/org/codehaus/plexus1.1/000077500000000000000000000000001317160430700414375ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources/org/apache/maven/extension/test-extension-repo/org/codehaus/plexus/plexus-utilsplexus-utils-1.1.jar.md5000066400000000000000000000000401317160430700455660ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources/org/apache/maven/extension/test-extension-repo/org/codehaus/plexus/plexus-utils/1.149e112a6c1ad24962643ef9494f9cbe1plexus-utils-1.1.jar.sha1000066400000000000000000000000501317160430700457360ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources/org/apache/maven/extension/test-extension-repo/org/codehaus/plexus/plexus-utils/1.1fa632b7f1cb7c50963d0fb7d818ca93c75c10127plexus-utils-1.1.pom000066400000000000000000000013771317160430700451370ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources/org/apache/maven/extension/test-extension-repo/org/codehaus/plexus/plexus-utils/1.1 plexus org.codehaus.plexus 1.0.4 4.0.0 plexus-utils Plexus Common Utilities 1.1 maven-surefire-plugin org/codehaus/plexus/util/FileBasedTestCase.java **/Test*.java deployed plexus-utils-1.1.pom.md5000066400000000000000000000000401317160430700456050ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources/org/apache/maven/extension/test-extension-repo/org/codehaus/plexus/plexus-utils/1.16e902bab552ae52fef5875d27c4cf0a0plexus-utils-1.1.pom.sha1000066400000000000000000000000501317160430700457550ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources/org/apache/maven/extension/test-extension-repo/org/codehaus/plexus/plexus-utils/1.115492ecd00920daca9ec15f6acd695b626621e5b1.4.5/000077500000000000000000000000001317160430700416055ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources/org/apache/maven/extension/test-extension-repo/org/codehaus/plexus/plexus-utilsplexus-utils-1.4.5.jar.md5000066400000000000000000000000401317160430700461020ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources/org/apache/maven/extension/test-extension-repo/org/codehaus/plexus/plexus-utils/1.4.5e158df8d1a539cc6482567f9689cc36fplexus-utils-1.4.5.jar.sha1000066400000000000000000000000501317160430700462520ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources/org/apache/maven/extension/test-extension-repo/org/codehaus/plexus/plexus-utils/1.4.556559396674aacd498c298964b691db0177027c0plexus-utils-1.4.5.pom000066400000000000000000000043311317160430700454440ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources/org/apache/maven/extension/test-extension-repo/org/codehaus/plexus/plexus-utils/1.4.5 plexus org.codehaus.plexus 1.0.11 ../pom/pom.xml 4.0.0 plexus-utils Plexus Common Utilities 1.4.5 http://plexus.codehaus.org/plexus-utils maven-compiler-plugin 1.3 1.3 maven-surefire-plugin true org/codehaus/plexus/util/FileBasedTestCase.java **/Test*.java JAVA_HOME ${JAVA_HOME} M2_HOME ${M2_HOME} scm:svn:http://svn.codehaus.org/plexus/plexus-utils/tags/plexus-utils-1.4.5 scm:svn:https://svn.codehaus.org/plexus/plexus-utils/tags/plexus-utils-1.4.5 http://fisheye.codehaus.org/browse/plexus/plexus-utils/tags/plexus-utils-1.4.5 maven-javadoc-plugin maven-jxr-plugin plexus-utils-1.4.5.pom.md5000066400000000000000000000000401317160430700461210ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources/org/apache/maven/extension/test-extension-repo/org/codehaus/plexus/plexus-utils/1.4.5fccab705018ed5559df9f8e815b79aaaplexus-utils-1.4.5.pom.sha1000066400000000000000000000000501317160430700462710ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources/org/apache/maven/extension/test-extension-repo/org/codehaus/plexus/plexus-utils/1.4.50bdc8a7fbce7d9007a93d289a029b43e1196d85cplexus/000077500000000000000000000000001317160430700400025ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources/org/apache/maven/extension/test-extension-repo/org/codehaus/plexus1.0.10/000077500000000000000000000000001317160430700405175ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources/org/apache/maven/extension/test-extension-repo/org/codehaus/plexus/plexusplexus-1.0.10.pom000066400000000000000000000174511317160430700432770ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources/org/apache/maven/extension/test-extension-repo/org/codehaus/plexus/plexus/1.0.10 4.0.0 org.codehaus.plexus plexus pom Plexus 1.0.10 mail
    dev@plexus.codehaus.org
    irc irc.codehaus.org 6667 #plexus
    2001 Plexus User List http://xircles.codehaus.org/manage_email/user%40plexus.codehaus.org http://xircles.codehaus.org/manage_email/user%40plexus.codehaus.org http://archive.plexus.codehaus.org/user Plexus Developer List http://xircles.codehaus.org/manage_email/dev%40plexus.codehaus.org http://xircles.codehaus.org/manage_email/dev%40plexus.codehaus.org http://archive.plexus.codehaus.org/dev Plexus Announce List http://xircles.codehaus.org/manage_email/announce%40plexus.codehaus.org http://xircles.codehaus.org/manage_email/announce%40plexus.codehaus.org http://archive.plexus.codehaus.org/announce Plexus Commit List http://xircles.codehaus.org/manage_email/scm%40plexus.codehaus.org http://xircles.codehaus.org/manage_email/scm%40plexus.codehaus.org http://archive.plexus.codehaus.org/scm JIRA http://jira.codehaus.org/browse/PLX codehaus.org Plexus Central Repository dav:https://dav.codehaus.org/repository/plexus codehaus.org Plexus Central Development Repository dav:https://dav.codehaus.org/snapshots.repository/plexus codehaus.org dav:https://dav.codehaus.org/plexus codehaus.snapshots Codehaus Snapshot Development Repository http://snapshots.repository.codehaus.org false jvanzyl Jason van Zyl jason@maven.org Developer Release Manager kaz Pete Kazmier Developer jtaylor James Taylor james@jamestaylor.org Developer dandiep Dan Diephouse dan@envoisolutions.com Envoi solutions Developer kasper Kasper Nielsen apache@kav.dk Developer bwalding Ben Walding bwalding@codehaus.org Walding Consulting Services Developer mhw Mark Wilkinson mhw@kremvax.net Developer michal Michal Maczka mmaczka@interia.pl Developer evenisse Emmanuel Venisse evenisse@codehaus.org Developer Trygve Laugstol trygvis trygvis@codehaus.org Developer Kenney Westerhof kenney kenney@codehaus.org Developer Carlos Sanchez carlos carlos@codehaus.org Developer Brett Porter brett brett@codehaus.org Developer John Casey jdcasey jdcasey@codehaus.org Developer Andrew Williams handyande andy@handyande.co.uk Developer Rahul Thakur rahul rahul.thakur.xdev@gmail.com Developer Joakim Erdfelt joakime joakim@erdfelt.com Developer Olivier Lamy olamy olamy@codehaus.org Developer junit junit 3.8.1 test scm:svn:http://svn.codehaus.org/plexus/pom/tags/plexus-1.0.10 scm:svn:https://svn.codehaus.org/plexus/pom/tags/plexus-1.0.10 http://fisheye.codehaus.org/browse/plexus/pom/tags/plexus-1.0.10 Codehaus http://www.codehaus.org/ org.apache.maven.plugins maven-compiler-plugin 1.4 1.4 org.apache.maven.wagon wagon-webdav 1.0-beta-2
    plexus-1.0.10.pom.md5000066400000000000000000000000401317160430700437450ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources/org/apache/maven/extension/test-extension-repo/org/codehaus/plexus/plexus/1.0.106ab958c91424c0d7c3a2cc861867905eplexus-1.0.10.pom.sha1000066400000000000000000000000501317160430700441150ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources/org/apache/maven/extension/test-extension-repo/org/codehaus/plexus/plexus/1.0.10039c3f6a3cbe1f9e7b4a3309d9d7062b6e390fa71.0.11/000077500000000000000000000000001317160430700405205ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources/org/apache/maven/extension/test-extension-repo/org/codehaus/plexus/plexusplexus-1.0.11.pom000066400000000000000000000214111317160430700432700ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources/org/apache/maven/extension/test-extension-repo/org/codehaus/plexus/plexus/1.0.11 4.0.0 org.codehaus.plexus plexus pom Plexus 1.0.11 mail
    dev@plexus.codehaus.org
    irc irc.codehaus.org 6667 #plexus
    2001 The Apache Software License, Version 2.0 http://www.apache.org/licenses/LICENSE-2.0.txt repo Plexus User List http://xircles.codehaus.org/manage_email/user%40plexus.codehaus.org http://xircles.codehaus.org/manage_email/user%40plexus.codehaus.org http://archive.plexus.codehaus.org/user Plexus Developer List http://xircles.codehaus.org/manage_email/dev%40plexus.codehaus.org http://xircles.codehaus.org/manage_email/dev%40plexus.codehaus.org http://archive.plexus.codehaus.org/dev Plexus Announce List http://xircles.codehaus.org/manage_email/announce%40plexus.codehaus.org http://xircles.codehaus.org/manage_email/announce%40plexus.codehaus.org http://archive.plexus.codehaus.org/announce Plexus Commit List http://xircles.codehaus.org/manage_email/scm%40plexus.codehaus.org http://xircles.codehaus.org/manage_email/scm%40plexus.codehaus.org http://archive.plexus.codehaus.org/scm JIRA http://jira.codehaus.org/browse/PLX codehaus.org Plexus Central Repository dav:https://dav.codehaus.org/repository/plexus codehaus.org Plexus Central Development Repository dav:https://dav.codehaus.org/snapshots.repository/plexus codehaus.org dav:https://dav.codehaus.org/plexus codehaus.snapshots Codehaus Snapshot Development Repository http://snapshots.repository.codehaus.org false jvanzyl Jason van Zyl jason@maven.org Developer Release Manager kaz Pete Kazmier Developer jtaylor James Taylor james@jamestaylor.org Developer dandiep Dan Diephouse dan@envoisolutions.com Envoi solutions Developer kasper Kasper Nielsen apache@kav.dk Developer bwalding Ben Walding bwalding@codehaus.org Walding Consulting Services Developer mhw Mark Wilkinson mhw@kremvax.net Developer michal Michal Maczka mmaczka@interia.pl Developer evenisse Emmanuel Venisse evenisse@codehaus.org Developer Trygve Laugstol trygvis trygvis@codehaus.org Developer Kenney Westerhof kenney kenney@codehaus.org Developer Carlos Sanchez carlos carlos@codehaus.org Developer Brett Porter brett brett@codehaus.org Developer John Casey jdcasey jdcasey@codehaus.org Developer Andrew Williams handyande andy@handyande.co.uk Developer Rahul Thakur rahul rahul.thakur.xdev@gmail.com Developer Joakim Erdfelt joakime joakim@erdfelt.com Developer Olivier Lamy olamy olamy@codehaus.org Developer junit junit 3.8.1 test scm:svn:http://svn.codehaus.org/plexus/pom/trunk/ scm:svn:https://svn.codehaus.org/plexus/pom/trunk/ http://fisheye.codehaus.org/browse/plexus/pom/trunk/ Codehaus http://www.codehaus.org/ org.apache.maven.plugins maven-compiler-plugin 1.4 1.4 org.apache.maven.wagon wagon-webdav 1.0-beta-2 maven-release-plugin deploy
    plexus-1.0.11.pom.md5000066400000000000000000000000401317160430700437470ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources/org/apache/maven/extension/test-extension-repo/org/codehaus/plexus/plexus/1.0.11bdf8dcfe0877af604f7e19e9ffdf260bplexus-1.0.11.pom.sha1000066400000000000000000000000501317160430700441170ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources/org/apache/maven/extension/test-extension-repo/org/codehaus/plexus/plexus/1.0.114693d4512d50c5159bef1c49def1d2690a327c301.0.4/000077500000000000000000000000001317160430700404425ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources/org/apache/maven/extension/test-extension-repo/org/codehaus/plexus/plexusplexus-1.0.4.pom000066400000000000000000000131511317160430700431360ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources/org/apache/maven/extension/test-extension-repo/org/codehaus/plexus/plexus/1.0.4 4.0.0 org.codehaus.plexus plexus pom Plexus 1.0.4 mail
    dev@plexus.codehaus.org
    irc irc.codehaus.org 6667 #plexus
    2001 Plexus Developer List http://lists.codehaus.org/mailman/listinfo/plexus-dev http://lists.codehaus.org/mailman/listinfo/plexus-dev http://lists.codehaus.org/pipermail/plexus-dev/ repo1 Maven Central Repository scp://repo1.maven.org/home/projects/maven/repository-staging/to-ibiblio/maven2 snapshots Maven Central Development Repository scp://repo1.maven.org/home/projects/maven/repository-staging/snapshots/maven2 snapshots Maven Snapshot Development Repository http://snapshots.maven.codehaus.org/maven2 false snapshots-plugins Maven Snapshot Plugins Development Repository http://snapshots.maven.codehaus.org/maven2 false jvanzyl Jason van Zyl jason@zenplex.com Zenplex Developer Release Manager kaz Pete Kazmier Developer jtaylor James Taylor james@jamestaylor.org Developer dandiep Dan Diephouse dan@envoisolutions.com Envoi solutions Developer kasper Kasper Nielsen apache@kav.dk Developer bwalding Ben Walding bwalding@codehaus.org Walding Consulting Services Developer mhw Mark Wilkinson mhw@kremvax.net Developer michal Michal Maczka mmaczka@interia.pl Developer evenisse Emmanuel Venisse evenisse@codehaus.org Developer Trygve Laugstøl trygvis trygvis@codehaus.org Developer Kenney Westerhof kenney kenney@codehaus.org Developer junit junit 3.8.1 test scm:svn:svn://svn.codehaus.org/plexus/scm/trunk/ scm:svn:https://svn.codehaus.org/plexus/trunk Codehaus http://www.codehaus.org/ plexus-appserver plexus-archetypes plexus-components plexus-component-factories plexus-containers plexus-logging plexus-maven-plugin plexus-services plexus-tools plexus-utils org.apache.maven.plugins maven-release-plugin https://svn.codehaus.org/plexus/tags
    plexus-1.0.4.pom.md5000066400000000000000000000000401317160430700436130ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources/org/apache/maven/extension/test-extension-repo/org/codehaus/plexus/plexus/1.0.42e97f3a7666e337ce5d2d98b9c384caeplexus-1.0.4.pom.sha1000066400000000000000000000000501317160430700437630ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources/org/apache/maven/extension/test-extension-repo/org/codehaus/plexus/plexus/1.0.406f66b2f7d2eef1d805c11bca91c89984cda41371.0.8/000077500000000000000000000000001317160430700404465ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources/org/apache/maven/extension/test-extension-repo/org/codehaus/plexus/plexusplexus-1.0.8.pom000066400000000000000000000160761317160430700431570ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources/org/apache/maven/extension/test-extension-repo/org/codehaus/plexus/plexus/1.0.8 4.0.0 org.codehaus.plexus plexus pom Plexus 1.0.8 mail
    dev@plexus.codehaus.org
    irc irc.codehaus.org 6667 #plexus
    2001 Plexus Developer List http://lists.codehaus.org/mailman/listinfo/plexus-dev http://lists.codehaus.org/mailman/listinfo/plexus-dev http://lists.codehaus.org/pipermail/plexus-dev/ JIRA http://jira.codehaus.org/browse/PLX codehaus.org Plexus Central Repository dav:https://dav.codehaus.org/repository/plexus codehaus.org Plexus Central Development Repository dav:https://dav.codehaus.org/snapshots.repository/plexus codehaus.org dav:https://dav.codehaus.org/plexus apache-snapshots Snapshot repository http://people.apache.org/maven-snapshot-repository false codehaus-snapshots Codehaus Snapshot Development Repository http://snapshots.repository.codehaus.org false codehaus-snapshots Codehaus Snapshot Development Repository http://snapshots.repository.codehaus.org false jvanzyl Jason van Zyl jason@maven.org Developer Release Manager kaz Pete Kazmier Developer jtaylor James Taylor james@jamestaylor.org Developer dandiep Dan Diephouse dan@envoisolutions.com Envoi solutions Developer kasper Kasper Nielsen apache@kav.dk Developer bwalding Ben Walding bwalding@codehaus.org Walding Consulting Services Developer mhw Mark Wilkinson mhw@kremvax.net Developer michal Michal Maczka mmaczka@interia.pl Developer evenisse Emmanuel Venisse evenisse@codehaus.org Developer Trygve Laugstol trygvis trygvis@codehaus.org Developer Kenney Westerhof kenney kenney@codehaus.org Developer Carlos Sanchez carlos carlos@codehaus.org Developer Brett Porter brett brett@codehaus.org Developer John Casey jdcasey jdcasey@codehaus.org Developer junit junit 3.8.1 test scm:svn:http://svn.codehaus.org/plexus/trunk/ scm:svn:https://svn.codehaus.org/plexus/trunk Codehaus http://www.codehaus.org/ plexus-archetypes plexus-examples plexus-components plexus-component-factories plexus-containers plexus-logging plexus-maven-plugin plexus-tools plexus-utils org.apache.maven.wagon wagon-webdav 1.0-beta-1 org.apache.maven.plugins maven-release-plugin https://svn.codehaus.org/plexus/tags
    plexus-1.0.8.pom.md5000066400000000000000000000000401317160430700436230ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources/org/apache/maven/extension/test-extension-repo/org/codehaus/plexus/plexus/1.0.82da4039a1c4c959c75d3e6126f2029cfplexus-1.0.8.pom.sha1000066400000000000000000000000501317160430700437730ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources/org/apache/maven/extension/test-extension-repo/org/codehaus/plexus/plexus/1.0.89e7c8432829962afe796b32587c1bfa841a317d51.0.9/000077500000000000000000000000001317160430700404475ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources/org/apache/maven/extension/test-extension-repo/org/codehaus/plexus/plexusplexus-1.0.9.pom000066400000000000000000000170001317160430700431450ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources/org/apache/maven/extension/test-extension-repo/org/codehaus/plexus/plexus/1.0.9 4.0.0 org.codehaus.plexus plexus pom Plexus 1.0.9 mail
    dev@plexus.codehaus.org
    irc irc.codehaus.org 6667 #plexus
    2001 Plexus User List http://xircles.codehaus.org/manage_email/user%40plexus.codehaus.org http://xircles.codehaus.org/manage_email/user%40plexus.codehaus.org http://archive.plexus.codehaus.org/user Plexus Developer List http://xircles.codehaus.org/manage_email/dev%40plexus.codehaus.org http://xircles.codehaus.org/manage_email/dev%40plexus.codehaus.org http://archive.plexus.codehaus.org/dev Plexus Announce List http://xircles.codehaus.org/manage_email/announce%40plexus.codehaus.org http://xircles.codehaus.org/manage_email/announce%40plexus.codehaus.org http://archive.plexus.codehaus.org/announce Plexus Commit List http://xircles.codehaus.org/manage_email/scm%40plexus.codehaus.org http://xircles.codehaus.org/manage_email/scm%40plexus.codehaus.org http://archive.plexus.codehaus.org/scm JIRA http://jira.codehaus.org/browse/PLX codehaus.org Plexus Central Repository dav:https://dav.codehaus.org/repository/plexus codehaus.org Plexus Central Development Repository dav:https://dav.codehaus.org/snapshots.repository/plexus codehaus.org dav:https://dav.codehaus.org/plexus apache-snapshots Snapshot repository http://people.apache.org/maven-snapshot-repository false codehaus-snapshots Codehaus Snapshot Development Repository http://snapshots.repository.codehaus.org false codehaus-snapshots Codehaus Snapshot Development Repository http://snapshots.repository.codehaus.org false jvanzyl Jason van Zyl jason@maven.org Developer Release Manager kaz Pete Kazmier Developer jtaylor James Taylor james@jamestaylor.org Developer dandiep Dan Diephouse dan@envoisolutions.com Envoi solutions Developer kasper Kasper Nielsen apache@kav.dk Developer bwalding Ben Walding bwalding@codehaus.org Walding Consulting Services Developer mhw Mark Wilkinson mhw@kremvax.net Developer michal Michal Maczka mmaczka@interia.pl Developer evenisse Emmanuel Venisse evenisse@codehaus.org Developer Trygve Laugstol trygvis trygvis@codehaus.org Developer Kenney Westerhof kenney kenney@codehaus.org Developer Carlos Sanchez carlos carlos@codehaus.org Developer Brett Porter brett brett@codehaus.org Developer John Casey jdcasey jdcasey@codehaus.org Developer Andrew Williams handyande andy@handyande.co.uk Developer junit junit 3.8.1 test scm:svn:http://svn.codehaus.org/plexus/pom/tags/plexus-1.0.9 scm:svn:https://svn.codehaus.org/plexus/pom/tags/plexus-1.0.9 http://fisheye.codehaus.org/browse/plexus/pom/tags/plexus-1.0.9 Codehaus http://www.codehaus.org/ org.apache.maven.wagon wagon-webdav 1.0-beta-1
    plexus-1.0.9.pom.md5000066400000000000000000000000401317160430700436250ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources/org/apache/maven/extension/test-extension-repo/org/codehaus/plexus/plexus/1.0.9acf338e422e5c0d9c6242e4f21e63dc9plexus-1.0.9.pom.sha1000066400000000000000000000000501317160430700437750ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources/org/apache/maven/extension/test-extension-repo/org/codehaus/plexus/plexus/1.0.989d241b1e5ee6a72d3dd95d9eb90f635deebcdb2repo-marker.txt000066400000000000000000000001131317160430700355400ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources/org/apache/maven/extension/test-extension-repoThis is a marker file to allow the repository to be found in the classpath.maven-maven-3.5.2/maven-core/src/test/resources/org/apache/maven/lifecycle/000077500000000000000000000000001317160430700266265ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources/org/apache/maven/lifecycle/LifecycleExecutorTest.xml000066400000000000000000000004271317160430700336310ustar00rootroot00000000000000 org.apache.maven.project.ProjectBuildingHelper org.apache.maven.project.EmptyProjectBuildingHelper maven-maven-3.5.2/maven-core/src/test/resources/org/apache/maven/lifecycle/pom.xml000066400000000000000000000546171317160430700301600ustar00rootroot00000000000000 4.0.0 org.apache.maven maven-parent 11 ../pom/maven/pom.xml org.apache.maven maven 3.0-SNAPSHOT pom Apache Maven Maven is a project development management and comprehension tool. Based on the concept of a project object model: builds, dependency management, documentation creation, site publication, and distribution publication are all controlled from the declarative file. Maven can be extended by plugins to utilise a number of other development tools for reporting or the build process. http://maven.apache.org/ 2001 1.3 1.0 1.0-alpha-9 1.2_Java1.3 3.8.1 1.0-beta-3.0.7-SNAPSHOT 1.0-alpha-6 1.1 1.0-alpha-1 1.5.8 1.6 1.0 1.0-beta-4 1.7-SNAPSHOT 1.0-alpha-6-SNAPSHOT 1.0-alpha-1 1.2 3.2.6 1.0.1-SNAPSHOT 1.3 jira http://jira.codehaus.org/browse/MNG Maven Developer List dev-subscribe@maven.apache.org dev-unsubscribe@maven.apache.org dev@maven.apache.org http://mail-archives.apache.org/mod_mbox/maven-dev http://www.mail-archive.com/dev@maven.apache.org/ http://www.nabble.com/Maven-Developers-f179.html http://maven.dev.markmail.org/ Maven User List users-subscribe@maven.apache.org users-unsubscribe@maven.apache.org users@maven.apache.org http://mail-archives.apache.org/mod_mbox/maven-users http://www.mail-archive.com/users@maven.apache.org/ http://www.nabble.com/Maven---Users-f178.html http://maven.users.markmail.org/ Maven Issues List issues-subscribe@maven.apache.org issues-unsubscribe@maven.apache.org http://mail-archives.apache.org/mod_mbox/maven-issues/ http://www.mail-archive.com/issues@maven.apache.org http://www.nabble.com/Maven---Issues-f15573.html http://maven.issues.markmail.org/ Maven Commits List commits-subscribe@maven.apache.org commits-unsubscribe@maven.apache.org http://mail-archives.apache.org/mod_mbox/maven-commits http://www.mail-archive.com/commits@maven.apache.org http://www.nabble.com/Maven---Commits-f15575.html http://maven.commits.markmail.org/ Maven Announcements List announce@maven.apache.org announce-subscribe@maven.apache.org announce-unsubscribe@maven.apache.org http://mail-archives.apache.org/mod_mbox/maven-announce/ http://www.mail-archive.com/announce@maven.apache.org http://www.nabble.com/Maven-Announcements-f15617.html http://maven.announce.markmail.org/ Maven Notifications List notifications-subscribe@maven.apache.org notifications-unsubscribe@maven.apache.org http://mail-archives.apache.org/mod_mbox/maven-notifications/ http://www.mail-archive.com/notifications@maven.apache.org http://www.nabble.com/Maven---Notifications-f15574.html http://maven.notifications.markmail.org/ scm:svn:http://svn.apache.org/repos/asf/maven/components/trunk scm:svn:https://svn.apache.org/repos/asf/maven/components/trunk http://svn.apache.org/viewcvs.cgi/maven/components/trunk org.codehaus.plexus plexus-component-metadata ${plexusVersion} generate-metadata generate-test-metadata org.apache.maven.plugins maven-compiler-plugin 2.0.2 1.5 1.5 maven-release-plugin https://svn.apache.org/repos/asf/maven/components/tags org.codehaus.modello modello-maven-plugin ${modelloVersion} true site-docs pre-site xdoc xsd standard java xpp3-reader xpp3-writer org.apache.felix maven-bundle-plugin 1.0.0 org.apache.maven.plugins maven-surefire-plugin 2.4.2 org.apache.maven.plugins maven-assembly-plugin 2.2-beta-2 org.apache.maven.plugins maven-resources-plugin 2.4-SNAPSHOT maven-core apache-maven maven-model maven-plugin-api maven-project maven-reporting-api maven-project-builder maven-mercury maven-embedder maven-toolchain maven-compat maven-repository maven-repository-mercury junit junit ${junitVersion} test org.apache.maven maven-mercury ${project.version} org.apache.maven maven-lifecycle ${project.version} org.apache.maven maven-reporting-api ${project.version} org.apache.maven maven-profile ${project.version} org.apache.maven maven-model ${project.version} org.apache.maven maven-project ${project.version} org.apache.maven maven-plugin-api ${project.version} org.apache.maven maven-toolchain ${project.version} org.apache.maven maven-embedder ${project.version} org.apache.maven maven-core ${project.version} org.apache.maven maven-project-builder ${project.version} org.apache.maven maven-repository ${project.version} org.apache.maven maven-compat ${project.version} org.codehaus.plexus plexus-utils ${plexusUtilsVersion} org.codehaus.plexus plexus-container-default ${plexusVersion} org.codehaus.plexus plexus-component-annotations ${plexusVersion} org.codehaus.plexus plexus-classworlds ${classWorldsVersion} org.codehaus.plexus plexus-interpolation ${plexusInterpolationVersion} org.codehaus.plexus plexus-interactivity-api ${plexusInteractivityVersion} org.codehaus.plexus plexus-component-api org.sonatype.plexus plexus-jetty6 ${plexusJetty6Version} test org.sonatype.spice plexus-webdav ${plexusWebdavVersion} test org.apache.maven.wagon wagon-provider-api ${wagonVersion} org.apache.maven.wagon wagon-file ${wagonVersion} org.apache.maven.wagon wagon-http ${wagonVersion} org.apache.maven.wagon wagon-ssh ${wagonVersion} org.apache.maven.wagon wagon-ssh-external ${wagonVersion} org.apache.maven.doxia doxia-sink-api ${doxiaVersion} org.sonatype.spice model-builder ${modelBuilderVersion} org.codehaus.woodstox wstx-asl ${woodstoxVersion} commons-cli commons-cli ${commonsCliVersion} commons-lang commons-lang commons-logging commons-logging commons-jxpath commons-jxpath ${jxpathVersion} org.apache.maven.mercury mercury-artifact ${mercuryVersion} org.apache.maven.mercury mercury-external ${mercuryVersion} org.apache.maven.mercury mercury-plexus ${mercuryVersion} org.apache.maven.mercury mercury-repo-virtual ${mercuryVersion} org.sonatype.mercury mercury-mp3-cli ${mercuryMp3Version} org.sonatype.plexus plexus-sec-dispatcher ${securityDispatcherVersion} org.apache.maven.mercury mercury-repo-local-m2 ${mercuryVersion} test org.apache.maven.mercury mercury-repo-remote-m2 ${mercuryVersion} test org.apache.maven.mercury mercury-md-sat ${mercuryVersion} test org.apache.maven.mercury mercury-util ${mercuryVersion} test org.apache.maven.mercury mercury-transport-http ${mercuryVersion} test org.apache.maven.mercury mercury-transport-http ${mercuryVersion} test-jar test org.sonatype.plexus plexus-plugin-manager ${plexusPluginManagerVersion} easymock easymock ${easyMockVersion} test apache.website scp://people.apache.org/www/maven.apache.org/ref/${project.version}/ osgi org.apache.felix maven-bundle-plugin manifest org.apache.maven.plugins maven-jar-plugin 2.1 ${project.build.outputDirectory}/META-INF/MANIFEST.MF release maven-assembly-plugin false src/main/assembly/src.xml gnu maven-${project.version}-src make-assembly package single strict org.apache.maven.plugins maven-enforcer-plugin 1.0-alpha-3 enforce-jdk-15 enforce 1.5 maven-maven-3.5.2/maven-core/src/test/resources/org/apache/maven/plugin/000077500000000000000000000000001317160430700261655ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources/org/apache/maven/plugin/PluginManagerTest.xml000066400000000000000000000004271317160430700323030ustar00rootroot00000000000000 org.apache.maven.project.ProjectBuildingHelper org.apache.maven.project.EmptyProjectBuildingHelper maven-maven-3.5.2/maven-core/src/test/resources/org/apache/maven/project/000077500000000000000000000000001317160430700263355ustar00rootroot00000000000000AbstractMavenProjectTestCase.xml000066400000000000000000000004371317160430700345210ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources/org/apache/maven/project org.apache.maven.lifecycle.LifeCyclePluginAnalyzer org.apache.maven.lifecycle.EmptyLifecyclePluginAnalyzer maven-maven-3.5.2/maven-core/src/test/resources/org/apache/maven/project/PomConstructionTest.xml000066400000000000000000000007351317160430700330720ustar00rootroot00000000000000 org.apache.maven.lifecycle.LifeCyclePluginAnalyzer org.apache.maven.lifecycle.EmptyLifecyclePluginAnalyzer org.apache.maven.project.ProjectBuildingHelper org.apache.maven.project.EmptyProjectBuildingHelper maven-maven-3.5.2/maven-core/src/test/resources/org/apache/maven/project/workspace/000077500000000000000000000000001317160430700303335ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources/org/apache/maven/project/workspace/buildFromFile/000077500000000000000000000000001317160430700330565ustar00rootroot00000000000000pom.xml000066400000000000000000000002511317160430700343120ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources/org/apache/maven/project/workspace/buildFromFile 4.0.0 org.apache.maven.tests build-from-file 1 maven-maven-3.5.2/maven-core/src/test/resources/org/apache/maven/project/workspace/buildFromRepo/000077500000000000000000000000001317160430700331045ustar00rootroot00000000000000tests/000077500000000000000000000000001317160430700341675ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources/org/apache/maven/project/workspace/buildFromRepoproject-caching/000077500000000000000000000000001317160430700372275ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources/org/apache/maven/project/workspace/buildFromRepo/tests1/000077500000000000000000000000001317160430700373675ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources/org/apache/maven/project/workspace/buildFromRepo/tests/project-cachingproject-caching-1.pom000066400000000000000000000002341317160430700433010ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources/org/apache/maven/project/workspace/buildFromRepo/tests/project-caching/1 4.0.0 tests project-caching 1 maven-metadata-local.xml000066400000000000000000000003451317160430700437270ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources/org/apache/maven/project/workspace/buildFromRepo/tests/project-caching tests project-caching 1 1 1 buildModelLineage/000077500000000000000000000000001317160430700336215ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources/org/apache/maven/project/workspacepom.xml000066400000000000000000000002331317160430700351340ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources/org/apache/maven/project/workspace/buildModelLineage 4.0.0 tests build-model-lineage 1 maven-maven-3.5.2/maven-core/src/test/resources/org/apache/maven/project/workspace/resolveParentPom/000077500000000000000000000000001317160430700336405ustar00rootroot00000000000000childAndParent/000077500000000000000000000000001317160430700364415ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources/org/apache/maven/project/workspace/resolveParentPomchild/000077500000000000000000000000001317160430700375245ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources/org/apache/maven/project/workspace/resolveParentPom/childAndParentpom.xml000066400000000000000000000003521317160430700410410ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources/org/apache/maven/project/workspace/resolveParentPom/childAndParent/child 4.0.0 tests childAndParent-parent 1 childAndParent-child pom.xml000066400000000000000000000002351317160430700377560ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources/org/apache/maven/project/workspace/resolveParentPom/childAndParent 4.0.0 tests childAndParent-parent 1 pom.xml000066400000000000000000000003541317160430700351000ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources/org/apache/maven/project/workspace/resolveParentPom 4.0.0 tests resolve-parent-pom-parent 1 resolve-parent-pom maven-maven-3.5.2/maven-core/src/test/resources/org/apache/maven/settings/000077500000000000000000000000001317160430700265275ustar00rootroot00000000000000PomConstructionWithSettingsTest.xml000066400000000000000000000004211317160430700355520ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources/org/apache/maven/settings org.apache.maven.lifecycle.LifecycleExecutor org.apache.maven.project.EmptyLifecycleExecutor maven-maven-3.5.2/maven-core/src/test/resources/org/apache/maven/toolchain/000077500000000000000000000000001317160430700266475ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources/org/apache/maven/toolchain/global.xml000066400000000000000000000020671317160430700306360ustar00rootroot00000000000000 basic true rare true maven-maven-3.5.2/maven-core/src/test/resources/org/apache/maven/toolchain/model/000077500000000000000000000000001317160430700277475ustar00rootroot00000000000000toolchains-jdks-extend.xml000066400000000000000000000025521317160430700347770ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources/org/apache/maven/toolchain/model jdk 1.5 sun ${env.JAVA_HOME} lib/tools.jar jdk 1.6 sun ${env.JAVA_HOME} lib/classes.jar toolchains-jdks-extra.xml000066400000000000000000000025371317160430700346360ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources/org/apache/maven/toolchain/model jdk 1.4 sun ${env.JAVA_HOME} jdk 1.7 ibm ibm_17 ${env.JAVA_HOME} maven-maven-3.5.2/maven-core/src/test/resources/org/apache/maven/toolchain/model/toolchains-jdks.xml000066400000000000000000000024201317160430700335630ustar00rootroot00000000000000 jdk 1.5 sun ${env.JAVA_HOME} jdk 1.6 sun ${env.JAVA_HOME} maven-maven-3.5.2/maven-core/src/test/resources/org/apache/maven/toolchain/user.xml000066400000000000000000000020571317160430700303530ustar00rootroot00000000000000 basic true rare true maven-maven-3.5.2/maven-core/src/test/resources/org/codehaus/000077500000000000000000000000001317160430700241335ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources/org/codehaus/plexus/000077500000000000000000000000001317160430700254535ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources/org/codehaus/plexus/plexus-utils/000077500000000000000000000000001317160430700301315ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources/org/codehaus/plexus/plexus-utils/1.1/000077500000000000000000000000001317160430700304305ustar00rootroot00000000000000plexus-utils-1.1.jar.sha1000066400000000000000000000000501317160430700346500ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources/org/codehaus/plexus/plexus-utils/1.1fa632b7f1cb7c50963d0fb7d818ca93c75c10127plexus-utils-1.1.pom000066400000000000000000000013771317160430700340510ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources/org/codehaus/plexus/plexus-utils/1.1 plexus org.codehaus.plexus 1.0.4 4.0.0 plexus-utils Plexus Common Utilities 1.1 maven-surefire-plugin org/codehaus/plexus/util/FileBasedTestCase.java **/Test*.java deployed plexus-utils-1.1.pom.sha1000066400000000000000000000000501317160430700346670ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources/org/codehaus/plexus/plexus-utils/1.115492ecd00920daca9ec15f6acd695b626621e5bmaven-maven-3.5.2/maven-core/src/test/resources/pom.xml000066400000000000000000000033151317160430700230700ustar00rootroot00000000000000 4.0.0 org.apache.maven maven-core 2.0-SNAPSHOT jar Maven 2001 org.apache.maven maven-model 2.0-SNAPSHOT jar compile org.apache.maven maven-plugin 2.0-SNAPSHOT jar compile scm-connection maven-maven-3.5.2/maven-core/src/test/resources/project-dynamism/000077500000000000000000000000001317160430700250365ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources/project-dynamism/plugin-level-dep.pom.xml000066400000000000000000000014031317160430700315210ustar00rootroot00000000000000 4.0.0 testing plugin-level-dep jar 3.8.1 maven-compiler-plugin 2.0.2 junit junit ${pom.version} maven-maven-3.5.2/maven-core/src/test/resources/project-dynamism/pom-interp.xml000066400000000000000000000016031317160430700276520ustar00rootroot00000000000000 4.0.0 org.test test-build-dynamism 1 /${project.groupId}/src/main/java /${pom.groupId}/src/test/java /${groupId}/src/main/scripts my-plugin ${project.groupId} ${pom.groupId} ${groupId} maven-maven-3.5.2/maven-core/src/test/resources/project-dynamism/pom-relative.xml000066400000000000000000000021021317160430700301570ustar00rootroot00000000000000 4.0.0 org.test test-build-dynamism 1 ${pom.build.directory} ${pom.build.directory}/generated-resources/plexus ${pom.build.directory}/generated-filters.properties target src/main/java src/test/java src/main/scripts ${pom.build.directory}/classes ${pom.build.directory}/test-classes maven-maven-3.5.2/maven-core/src/test/resources/project-dynamism/pom.xml000066400000000000000000000021571317160430700263600ustar00rootroot00000000000000 4.0.0 org.test test-build-dynamism 1 ${pom.build.directory} ${pom.build.directory}/generated-resources/plexus ${pom.build.directory}/generated-filters.properties target ${pom.basedir}/src/main/java ${pom.basedir}/src/test/java ${pom.basedir}/src/main/scripts ${pom.build.directory}/classes ${pom.build.directory}/test-classes maven-maven-3.5.2/maven-core/src/test/resources/projects/000077500000000000000000000000001317160430700234025ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources/projects/bad-dependency.xml000066400000000000000000000011451317160430700267670ustar00rootroot00000000000000 4.0.0 test invalid 0.0.1-SNAPSHOT central file:src/test/remote-repo b 0.1 org.apache.maven.its a 0.1 maven-maven-3.5.2/maven-core/src/test/resources/projects/bad-project.xml000066400000000000000000000014221317160430700263150ustar00rootroot00000000000000i want to be a POM!maven-maven-3.5.2/maven-core/src/test/resources/projects/base-directory-alignment/000077500000000000000000000000001317160430700302725ustar00rootroot00000000000000project-which-needs-directory-alignment-child.xml000066400000000000000000000021161317160430700416360ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources/projects/base-directory-alignment project-which-needs-directory-alignment.xml maven project-which-needs-directory-alignment.xml 1.0-beta-9 maven maven-foo 1.0 project-which-needs-directory-alignment.xml000066400000000000000000000071131317160430700405570ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources/projects/base-directory-alignment 4.0.0 maven project-which-needs-directory-alignment Maven 1.0-beta-9 2001 Description http://maven.apache.org/ Apache Software Foundation http://apache.org/ anon-connection developer-connection repository-url Maven User List subscribe unsubscribe archive Jason van Zyl jvanzyl jason@maven.org Zenplex Founder Release Manager Martin van dem Bemt mvdb@mvdb.com g1 d1 1.0 g2 d2 2.0 g3 d3 g3 d3 3.0 sourceDirectory unitTestSourceDirectory src/test **/*.xml src/conf *.xsd *.dtd *.mod log4j.properties driver.jelly driver.properties src/messages org/apache/maven/messages messages*.properties maven-maven-3.5.2/maven-core/src/test/resources/projects/base-directory-alignment/subproject/000077500000000000000000000000001317160430700324525ustar00rootroot00000000000000project-which-needs-directory-alignment-child.xml000066400000000000000000000017631317160430700440250ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources/projects/base-directory-alignment/subproject ../project-which-needs-directory-alignment.xml maven project-which-needs-directory-alignment 1.0-beta-9 maven-maven-3.5.2/maven-core/src/test/resources/projects/build-path-expression-pom.xml000066400000000000000000000005751317160430700311520ustar00rootroot00000000000000 4.0.0 org.apache.maven.project.tests build-path-expression 1 sources ${project.build.sourceDirectory} maven-maven-3.5.2/maven-core/src/test/resources/projects/build.properties000066400000000000000000000014371317160430700266240ustar00rootroot00000000000000# 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. name = sarel maven-maven-3.5.2/maven-core/src/test/resources/projects/child-which-inherits-from-super-model.xml000066400000000000000000000016721317160430700333330ustar00rootroot00000000000000 foo bar Babar 4.5 maven-maven-3.5.2/maven-core/src/test/resources/projects/child-with-bogus-parent.xml000066400000000000000000000016631317160430700305720ustar00rootroot00000000000000 ${basedir}/bogus.xml maven bogus 1.0-beta-9 maven-maven-3.5.2/maven-core/src/test/resources/projects/child.xml000066400000000000000000000020351317160430700252070ustar00rootroot00000000000000 project.xml maven maven-project-test 1.0-beta-9 child-artifact maven 1.0-beta-9 maven-maven-3.5.2/maven-core/src/test/resources/projects/duplicate-plugins-merged-pom.xml000066400000000000000000000024021317160430700316050ustar00rootroot00000000000000 4.0.0 tests.project duplicate-plugin-defs-merged 1 maven-compiler-plugin group first 1 first compile maven-compiler-plugin group second 1 second compile maven-maven-3.5.2/maven-core/src/test/resources/projects/fully-populated-child.xml000066400000000000000000000113741317160430700303410ustar00rootroot00000000000000 project.xml maven maven-project-test 1.0-beta-9 3 maven maven Maven 1.0-beta-9 2001 org.apache.maven Description shortDescription http://maven.apache.org/ issueTrackingUrl childDistributionRepositoryId childDistributionRepositoryName childDistributionRepository childSiteDistributionId childSiteDistributionName childSiteDistributionUrl Apache Software Foundation http://apache.org/ /images/jakarta-logo-blue.gif anon-connection developer-connection repository-url Maven User List subscribe unsubscribe archive Jason van Zyl jvanzyl jason@maven.org Zenplex Founder Release Manager Martin van dem Bemt mvdb@mvdb.com g1 d1 1.0 d1-url g2 d2 2.0 d2-url jason@maven.org /sourceDirectory /unitTestSourceDirectory **/*Test.java **/RepositoryTest.java **/JAXPTest.java ${basedir}/src/test **/*.xml /src/conf *.xsd *.dtd *.mod log4j.properties driver.jelly driver.properties /src/messages org/apache/maven/messages messages*.properties maven-jdepend-plugin maven-checkstyle-plugin maven-changelog-plugin maven-file-activity-plugin maven-developer-activity-plugin maven-javadoc-plugin maven-jxr-plugin maven-junit-report-plugin maven-tasklist-plugin maven-jellydoc-plugin maven-maven-3.5.2/maven-core/src/test/resources/projects/grandchild-check/000077500000000000000000000000001317160430700265545ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources/projects/grandchild-check/child/000077500000000000000000000000001317160430700276375ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources/projects/grandchild-check/child/grandchild/000077500000000000000000000000001317160430700317365ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources/projects/grandchild-check/child/grandchild/pom.xml000066400000000000000000000003151317160430700332520ustar00rootroot00000000000000 4.0.0 grandchildtest child 1 grandchild maven-maven-3.5.2/maven-core/src/test/resources/projects/grandchild-check/child/pom.xml000066400000000000000000000004371317160430700311600ustar00rootroot00000000000000 4.0.0 grandchildtest root-pom 1 child pom grandchild maven-maven-3.5.2/maven-core/src/test/resources/projects/grandchild-check/pom.xml000066400000000000000000000002611317160430700300700ustar00rootroot00000000000000 4.0.0 grandchildtest root-pom 1 pom import-scope-pom-resolves-from-property-based-repository.xml000066400000000000000000000013151317160430700372330ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources/projects 4.0.0 test imported-pom-found 0.0.1-SNAPSHOT file:src/test/remote-repo central ${repo.url} org.apache.maven.its a 0.1 pom import maven-maven-3.5.2/maven-core/src/test/resources/projects/modelsource/000077500000000000000000000000001317160430700257235ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources/projects/modelsource/module01/000077500000000000000000000000001317160430700273515ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources/projects/modelsource/module01/pom.xml000066400000000000000000000006451317160430700306730ustar00rootroot00000000000000 4.0.0 test.readparent local-parent 1.0 module01 maven-maven-3.5.2/maven-core/src/test/resources/projects/modelsource/pom.xml000066400000000000000000000006661317160430700272500ustar00rootroot00000000000000 4.0.0 test.readparent local-parent pom 1.0 module parent-version-range-external-child-version-expression/000077500000000000000000000000001317160430700361525ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources/projectspom.xml000066400000000000000000000005361317160430700374730ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources/projects/parent-version-range-external-child-version-expression 4.0.0 org.apache apache [1,1] child ${some.property} pom parent-version-range-external-child-without-version/000077500000000000000000000000001317160430700354565ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources/projectspom.xml000066400000000000000000000005131317160430700367720ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources/projects/parent-version-range-external-child-without-version 4.0.0 org.apache apache [1,1] child pom maven-maven-3.5.2/maven-core/src/test/resources/projects/parent-version-range-external-valid/000077500000000000000000000000001317160430700323655ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources/projects/parent-version-range-external-valid/pom.xml000066400000000000000000000004111317160430700336760ustar00rootroot00000000000000 4.0.0 org.apache apache [1,1] child 2 pom parent-version-range-local-child-version-expression/000077500000000000000000000000001317160430700354225ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources/projectschild/000077500000000000000000000000001317160430700365055ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources/projects/parent-version-range-local-child-version-expressionpom.xml000066400000000000000000000005571317160430700400310ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources/projects/parent-version-range-local-child-version-expression/child 4.0.0 parent-version-range-local parent [1,10] child ${some.property} pom pom.xml000066400000000000000000000002731317160430700367410ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources/projects/parent-version-range-local-child-version-expression 4.0.0 parent-version-range-local parent 1 pom parent-version-range-local-child-without-version/000077500000000000000000000000001317160430700347265ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources/projectschild/000077500000000000000000000000001317160430700360115ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources/projects/parent-version-range-local-child-without-versionpom.xml000066400000000000000000000005341317160430700373300ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources/projects/parent-version-range-local-child-without-version/child 4.0.0 parent-version-range-local parent [1,10] child pom pom.xml000066400000000000000000000002731317160430700362450ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources/projects/parent-version-range-local-child-without-version 4.0.0 parent-version-range-local parent 1 pom maven-maven-3.5.2/maven-core/src/test/resources/projects/parent-version-range-local-valid/000077500000000000000000000000001317160430700316355ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources/projects/parent-version-range-local-valid/child/000077500000000000000000000000001317160430700327205ustar00rootroot00000000000000pom.xml000066400000000000000000000004321317160430700341550ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources/projects/parent-version-range-local-valid/child 4.0.0 parent-version-range-local parent [1,10] child 1 pom maven-maven-3.5.2/maven-core/src/test/resources/projects/parent-version-range-local-valid/pom.xml000066400000000000000000000002731317160430700331540ustar00rootroot00000000000000 4.0.0 parent-version-range-local parent 1 pom maven-maven-3.5.2/maven-core/src/test/resources/projects/project.xml000066400000000000000000000111061317160430700255710ustar00rootroot00000000000000 3 maven maven-project-test Maven 1.0-beta-9 2001 org.apache.maven Description shortDescription http://maven.apache.org/ issueTrackingUrl distributionRepositoryId distributionRepositoryName distributionRepository siteDistributionId siteDistributionName siteDistributionUrl Apache Software Foundation http://apache.org/ /images/jakarta-logo-blue.gif anon-connection developer-connection repository-url Maven User List subscribe unsubscribe archive Jason van Zyl jvanzyl jason@maven.org Zenplex Founder Release Manager Martin van dem Bemt mvdb@mvdb.com g1 d1 1.0 d1-url g2 d2 2.0 d2-url jason@maven.org /sourceDirectory /unitTestSourceDirectory **/*Test.java **/RepositoryTest.java **/JAXPTest.java ${basedir}/src/test **/*.xml /src/conf *.xsd *.dtd *.mod log4j.properties driver.jelly driver.properties /src/messages org/apache/maven/messages messages*.properties maven-jdepend-plugin maven-checkstyle-plugin maven-changelog-plugin maven-file-activity-plugin maven-developer-activity-plugin maven-javadoc-plugin maven-jxr-plugin maven-junit-report-plugin maven-tasklist-plugin maven-jellydoc-plugin maven-maven-3.5.2/maven-core/src/test/resources/projects/versionless-managed-dependency.xml000066400000000000000000000010431317160430700322040ustar00rootroot00000000000000 4.0.0 test versionless-managed-dependency.xml 0.0.1-SNAPSHOT org.apache.maven.its a org.apache.maven.its a maven-maven-3.5.2/maven-core/src/test/resources/remote-repo-1/000077500000000000000000000000001317160430700241455ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources/remote-repo-1/maven-test/000077500000000000000000000000001317160430700262305ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources/remote-repo-1/maven-test/jars/000077500000000000000000000000001317160430700271675ustar00rootroot00000000000000maven-test-b-1.0.jar.md5000066400000000000000000000000411317160430700330630ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources/remote-repo-1/maven-test/jarsa5c3b5cd0605bb7331d1846cdc14b13b maven-maven-3.5.2/maven-core/src/test/resources/remote-repo-1/maven-test/poms/000077500000000000000000000000001317160430700272065ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources/remote-repo-1/maven-test/poms/maven-test-b-1.0.pom000066400000000000000000000010401317160430700325140ustar00rootroot00000000000000 maven-test maven-test-a jar maven-test maven-test-b 1.0 jar compile maven-test maven-test-z 1.0 jar compile maven-maven-3.5.2/maven-core/src/test/resources/remote-repo-1/snapshot-test/000077500000000000000000000000001317160430700267615ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources/remote-repo-1/snapshot-test/jars/000077500000000000000000000000001317160430700277205ustar00rootroot00000000000000maven-snapshot-a-1.0-SNAPSHOT.jar.snapshot-version000066400000000000000000000000171317160430700405700ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources/remote-repo-1/snapshot-test/jars20050101.101010maven-snapshot-b-1.0-SNAPSHOT.jar.snapshot-version000066400000000000000000000000171317160430700405710ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources/remote-repo-1/snapshot-test/jars20030101.101010maven-snapshot-c-1.0-SNAPSHOT.jar.snapshot-version000066400000000000000000000000201317160430700405640ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources/remote-repo-1/snapshot-test/jars20040101.101010 maven-maven-3.5.2/maven-core/src/test/resources/remote-repo-2/000077500000000000000000000000001317160430700241465ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources/remote-repo-2/maven-test/000077500000000000000000000000001317160430700262315ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources/remote-repo-2/maven-test/jars/000077500000000000000000000000001317160430700271705ustar00rootroot00000000000000maven-maven-3.5.2/maven-core/src/test/resources/withActiveByDefaultProfile-pom.xml000066400000000000000000000025411317160430700303160ustar00rootroot00000000000000 4.0.0 maven maven-core 2.0-SNAPSHOT Maven true test maven-maven-3.5.2/maven-embedder/000077500000000000000000000000001317160430700166105ustar00rootroot00000000000000maven-maven-3.5.2/maven-embedder/pom.xml000066400000000000000000000140041317160430700201240ustar00rootroot00000000000000 4.0.0 org.apache.maven maven 3.5.2 maven-embedder Maven Embedder Maven embeddable component, with CLI and logging support. org.apache.maven maven-settings org.apache.maven maven-settings-builder org.apache.maven maven-core org.apache.maven maven-plugin-api org.apache.maven maven-model org.apache.maven maven-model-builder org.apache.maven maven-builder-support org.apache.maven.resolver maven-resolver-api org.apache.maven.resolver maven-resolver-util org.apache.maven.shared maven-shared-utils com.google.inject guice no_aop com.google.guava guava javax.inject javax.inject javax.annotation jsr250-api org.codehaus.plexus plexus-utils org.codehaus.plexus plexus-classworlds org.eclipse.sisu org.eclipse.sisu.plexus org.codehaus.plexus plexus-component-annotations org.sonatype.plexus plexus-sec-dispatcher org.sonatype.plexus plexus-cipher org.slf4j slf4j-api org.slf4j slf4j-simple true ch.qos.logback logback-classic true commons-cli commons-cli org.apache.commons commons-lang3 org.fusesource.jansi jansi test src/main/resources true org.apache.rat apache-rat-plugin src/main/resources/META-INF/MANIFEST.MF src/test/*-projects/** src/test/*-project/** src/test/plugin-version-references/** org.eclipse.sisu sisu-maven-plugin org.codehaus.plexus plexus-component-metadata org.codehaus.modello modello-maven-plugin 1.0.0 src/main/mdo/core-extensions.mdo maven-maven-3.5.2/maven-embedder/src/000077500000000000000000000000001317160430700173775ustar00rootroot00000000000000maven-maven-3.5.2/maven-embedder/src/examples/000077500000000000000000000000001317160430700212155ustar00rootroot00000000000000maven-maven-3.5.2/maven-embedder/src/examples/simple-project/000077500000000000000000000000001317160430700241525ustar00rootroot00000000000000maven-maven-3.5.2/maven-embedder/src/examples/simple-project/pom.xml000066400000000000000000000027061317160430700254740ustar00rootroot00000000000000 4.0.0 org.apache.maven.embedder simple-project 1.0-SNAPSHOT simple-project http://maven.apache.org junit junit 3.8.1 test development maven-maven-3.5.2/maven-embedder/src/examples/simple-project/settings.xml000066400000000000000000000016611317160430700265400ustar00rootroot00000000000000 org.codehaus.tycho org.sonatype.pwt maven-maven-3.5.2/maven-embedder/src/examples/simple-project/src/000077500000000000000000000000001317160430700247415ustar00rootroot00000000000000maven-maven-3.5.2/maven-embedder/src/examples/simple-project/src/main/000077500000000000000000000000001317160430700256655ustar00rootroot00000000000000maven-maven-3.5.2/maven-embedder/src/examples/simple-project/src/main/java/000077500000000000000000000000001317160430700266065ustar00rootroot00000000000000maven-maven-3.5.2/maven-embedder/src/examples/simple-project/src/main/java/org/000077500000000000000000000000001317160430700273755ustar00rootroot00000000000000maven-maven-3.5.2/maven-embedder/src/examples/simple-project/src/main/java/org/apache/000077500000000000000000000000001317160430700306165ustar00rootroot00000000000000maven-maven-3.5.2/maven-embedder/src/examples/simple-project/src/main/java/org/apache/maven/000077500000000000000000000000001317160430700317245ustar00rootroot00000000000000embedder/000077500000000000000000000000001317160430700334145ustar00rootroot00000000000000maven-maven-3.5.2/maven-embedder/src/examples/simple-project/src/main/java/org/apache/mavenApp.java000066400000000000000000000017221317160430700350010ustar00rootroot00000000000000maven-maven-3.5.2/maven-embedder/src/examples/simple-project/src/main/java/org/apache/maven/embedderpackage org.apache.maven.embedder; /* * Licensed to the Apache Software Foundation (ASF) under one or more contributor license * agreements. See the NOTICE file distributed with this work for additional information regarding * copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance with the License. You may obtain a * copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express * or implied. See the License for the specific language governing permissions and limitations under * the License. */ /** * Hello world! * */ public class App { public static void main( String[] args ) { System.out.println( "Hello World!" ); } } maven-maven-3.5.2/maven-embedder/src/examples/simple-project/src/test/000077500000000000000000000000001317160430700257205ustar00rootroot00000000000000maven-maven-3.5.2/maven-embedder/src/examples/simple-project/src/test/java/000077500000000000000000000000001317160430700266415ustar00rootroot00000000000000maven-maven-3.5.2/maven-embedder/src/examples/simple-project/src/test/java/org/000077500000000000000000000000001317160430700274305ustar00rootroot00000000000000maven-maven-3.5.2/maven-embedder/src/examples/simple-project/src/test/java/org/apache/000077500000000000000000000000001317160430700306515ustar00rootroot00000000000000maven-maven-3.5.2/maven-embedder/src/examples/simple-project/src/test/java/org/apache/maven/000077500000000000000000000000001317160430700317575ustar00rootroot00000000000000embedder/000077500000000000000000000000001317160430700334475ustar00rootroot00000000000000maven-maven-3.5.2/maven-embedder/src/examples/simple-project/src/test/java/org/apache/mavenAppTest.java000066400000000000000000000026421317160430700356760ustar00rootroot00000000000000maven-maven-3.5.2/maven-embedder/src/examples/simple-project/src/test/java/org/apache/maven/embedderpackage org.apache.maven.embedder; /* * Licensed to the Apache Software Foundation (ASF) under one or more contributor license * agreements. See the NOTICE file distributed with this work for additional information regarding * copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance with the License. You may obtain a * copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express * or implied. See the License for the specific language governing permissions and limitations under * the License. */ import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; /** * Unit test for simple App. */ public class AppTest extends TestCase { /** * Create the test case * * @param testName name of the test case */ public AppTest( String testName ) { super( testName ); } /** * @return the suite of tests being tested */ public static Test suite() { return new TestSuite( AppTest.class ); } /** * Rigorous Test :-) */ public void testApp() { assertTrue( true ); } } maven-maven-3.5.2/maven-embedder/src/main/000077500000000000000000000000001317160430700203235ustar00rootroot00000000000000maven-maven-3.5.2/maven-embedder/src/main/java/000077500000000000000000000000001317160430700212445ustar00rootroot00000000000000maven-maven-3.5.2/maven-embedder/src/main/java/org/000077500000000000000000000000001317160430700220335ustar00rootroot00000000000000maven-maven-3.5.2/maven-embedder/src/main/java/org/apache/000077500000000000000000000000001317160430700232545ustar00rootroot00000000000000maven-maven-3.5.2/maven-embedder/src/main/java/org/apache/maven/000077500000000000000000000000001317160430700243625ustar00rootroot00000000000000maven-maven-3.5.2/maven-embedder/src/main/java/org/apache/maven/cli/000077500000000000000000000000001317160430700251315ustar00rootroot00000000000000maven-maven-3.5.2/maven-embedder/src/main/java/org/apache/maven/cli/CLIManager.java000066400000000000000000000244271317160430700277070ustar00rootroot00000000000000package org.apache.maven.cli; /* * 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.PrintStream; import java.io.PrintWriter; import org.apache.commons.cli.CommandLine; import org.apache.commons.cli.CommandLineParser; import org.apache.commons.cli.GnuParser; import org.apache.commons.cli.HelpFormatter; import org.apache.commons.cli.OptionBuilder; import org.apache.commons.cli.Options; import org.apache.commons.cli.ParseException; /** * @author Jason van Zyl */ public class CLIManager { public static final char ALTERNATE_POM_FILE = 'f'; public static final char BATCH_MODE = 'B'; public static final char SET_SYSTEM_PROPERTY = 'D'; public static final char OFFLINE = 'o'; public static final char QUIET = 'q'; public static final char DEBUG = 'X'; public static final char ERRORS = 'e'; public static final char HELP = 'h'; public static final char VERSION = 'v'; public static final char SHOW_VERSION = 'V'; public static final char NON_RECURSIVE = 'N'; public static final char UPDATE_SNAPSHOTS = 'U'; public static final char ACTIVATE_PROFILES = 'P'; public static final String SUPRESS_SNAPSHOT_UPDATES = "nsu"; public static final char CHECKSUM_FAILURE_POLICY = 'C'; public static final char CHECKSUM_WARNING_POLICY = 'c'; public static final char ALTERNATE_USER_SETTINGS = 's'; public static final String ALTERNATE_GLOBAL_SETTINGS = "gs"; public static final char ALTERNATE_USER_TOOLCHAINS = 't'; public static final String ALTERNATE_GLOBAL_TOOLCHAINS = "gt"; public static final String FAIL_FAST = "ff"; public static final String FAIL_AT_END = "fae"; public static final String FAIL_NEVER = "fn"; public static final String RESUME_FROM = "rf"; public static final String PROJECT_LIST = "pl"; public static final String ALSO_MAKE = "am"; public static final String ALSO_MAKE_DEPENDENTS = "amd"; public static final String LOG_FILE = "l"; public static final String ENCRYPT_MASTER_PASSWORD = "emp"; public static final String ENCRYPT_PASSWORD = "ep"; public static final String THREADS = "T"; public static final String LEGACY_LOCAL_REPOSITORY = "llr"; public static final String BUILDER = "b"; protected Options options; @SuppressWarnings( { "static-access", "checkstyle:linelength" } ) public CLIManager() { options = new Options(); options.addOption( OptionBuilder.withLongOpt( "help" ).withDescription( "Display help information" ).create( HELP ) ); options.addOption( OptionBuilder.withLongOpt( "file" ).hasArg().withDescription( "Force the use of an alternate POM file (or directory with pom.xml)" ).create( ALTERNATE_POM_FILE ) ); options.addOption( OptionBuilder.withLongOpt( "define" ).hasArg().withDescription( "Define a system property" ).create( SET_SYSTEM_PROPERTY ) ); options.addOption( OptionBuilder.withLongOpt( "offline" ).withDescription( "Work offline" ).create( OFFLINE ) ); options.addOption( OptionBuilder.withLongOpt( "version" ).withDescription( "Display version information" ).create( VERSION ) ); options.addOption( OptionBuilder.withLongOpt( "quiet" ).withDescription( "Quiet output - only show errors" ).create( QUIET ) ); options.addOption( OptionBuilder.withLongOpt( "debug" ).withDescription( "Produce execution debug output" ).create( DEBUG ) ); options.addOption( OptionBuilder.withLongOpt( "errors" ).withDescription( "Produce execution error messages" ).create( ERRORS ) ); options.addOption( OptionBuilder.withLongOpt( "non-recursive" ).withDescription( "Do not recurse into sub-projects" ).create( NON_RECURSIVE ) ); options.addOption( OptionBuilder.withLongOpt( "update-snapshots" ).withDescription( "Forces a check for missing releases and updated snapshots on remote repositories" ).create( UPDATE_SNAPSHOTS ) ); options.addOption( OptionBuilder.withLongOpt( "activate-profiles" ).withDescription( "Comma-delimited list of profiles to activate" ).hasArg().create( ACTIVATE_PROFILES ) ); options.addOption( OptionBuilder.withLongOpt( "batch-mode" ).withDescription( "Run in non-interactive (batch) mode (disables output color)" ).create( BATCH_MODE ) ); options.addOption( OptionBuilder.withLongOpt( "no-snapshot-updates" ).withDescription( "Suppress SNAPSHOT updates" ).create( SUPRESS_SNAPSHOT_UPDATES ) ); options.addOption( OptionBuilder.withLongOpt( "strict-checksums" ).withDescription( "Fail the build if checksums don't match" ).create( CHECKSUM_FAILURE_POLICY ) ); options.addOption( OptionBuilder.withLongOpt( "lax-checksums" ).withDescription( "Warn if checksums don't match" ).create( CHECKSUM_WARNING_POLICY ) ); options.addOption( OptionBuilder.withLongOpt( "settings" ).withDescription( "Alternate path for the user settings file" ).hasArg().create( ALTERNATE_USER_SETTINGS ) ); options.addOption( OptionBuilder.withLongOpt( "global-settings" ).withDescription( "Alternate path for the global settings file" ).hasArg().create( ALTERNATE_GLOBAL_SETTINGS ) ); options.addOption( OptionBuilder.withLongOpt( "toolchains" ).withDescription( "Alternate path for the user toolchains file" ).hasArg().create( ALTERNATE_USER_TOOLCHAINS ) ); options.addOption( OptionBuilder.withLongOpt( "global-toolchains" ).withDescription( "Alternate path for the global toolchains file" ).hasArg().create( ALTERNATE_GLOBAL_TOOLCHAINS ) ); options.addOption( OptionBuilder.withLongOpt( "fail-fast" ).withDescription( "Stop at first failure in reactorized builds" ).create( FAIL_FAST ) ); options.addOption( OptionBuilder.withLongOpt( "fail-at-end" ).withDescription( "Only fail the build afterwards; allow all non-impacted builds to continue" ).create( FAIL_AT_END ) ); options.addOption( OptionBuilder.withLongOpt( "fail-never" ).withDescription( "NEVER fail the build, regardless of project result" ).create( FAIL_NEVER ) ); options.addOption( OptionBuilder.withLongOpt( "resume-from" ).hasArg().withDescription( "Resume reactor from specified project" ).create( RESUME_FROM ) ); options.addOption( OptionBuilder.withLongOpt( "projects" ).withDescription( "Comma-delimited list of specified reactor projects to build instead of all projects. A project can be specified by [groupId]:artifactId or by its relative path" ).hasArg().create( PROJECT_LIST ) ); options.addOption( OptionBuilder.withLongOpt( "also-make" ).withDescription( "If project list is specified, also build projects required by the list" ).create( ALSO_MAKE ) ); options.addOption( OptionBuilder.withLongOpt( "also-make-dependents" ).withDescription( "If project list is specified, also build projects that depend on projects on the list" ).create( ALSO_MAKE_DEPENDENTS ) ); options.addOption( OptionBuilder.withLongOpt( "log-file" ).hasArg().withDescription( "Log file where all build output will go (disables output color)" ).create( LOG_FILE ) ); options.addOption( OptionBuilder.withLongOpt( "show-version" ).withDescription( "Display version information WITHOUT stopping build" ).create( SHOW_VERSION ) ); options.addOption( OptionBuilder.withLongOpt( "encrypt-master-password" ).hasOptionalArg().withDescription( "Encrypt master security password" ).create( ENCRYPT_MASTER_PASSWORD ) ); options.addOption( OptionBuilder.withLongOpt( "encrypt-password" ).hasOptionalArg().withDescription( "Encrypt server password" ).create( ENCRYPT_PASSWORD ) ); options.addOption( OptionBuilder.withLongOpt( "threads" ).hasArg().withDescription( "Thread count, for instance 2.0C where C is core multiplied" ).create( THREADS ) ); options.addOption( OptionBuilder.withLongOpt( "legacy-local-repository" ).withDescription( "Use Maven 2 Legacy Local Repository behaviour, ie no use of _remote.repositories. Can also be activated by using -Dmaven.legacyLocalRepo=true" ).create( LEGACY_LOCAL_REPOSITORY ) ); options.addOption( OptionBuilder.withLongOpt( "builder" ).hasArg().withDescription( "The id of the build strategy to use" ).create( BUILDER ) ); // Adding this back in for compatibility with the verifier that hard codes this option. options.addOption( OptionBuilder.withLongOpt( "no-plugin-registry" ).withDescription( "Ineffective, only kept for backward compatibility" ).create( "npr" ) ); options.addOption( OptionBuilder.withLongOpt( "check-plugin-updates" ).withDescription( "Ineffective, only kept for backward compatibility" ).create( "cpu" ) ); options.addOption( OptionBuilder.withLongOpt( "update-plugins" ).withDescription( "Ineffective, only kept for backward compatibility" ).create( "up" ) ); options.addOption( OptionBuilder.withLongOpt( "no-plugin-updates" ).withDescription( "Ineffective, only kept for backward compatibility" ).create( "npu" ) ); } public CommandLine parse( String[] args ) throws ParseException { // We need to eat any quotes surrounding arguments... String[] cleanArgs = CleanArgument.cleanArgs( args ); CommandLineParser parser = new GnuParser(); return parser.parse( options, cleanArgs ); } public void displayHelp( PrintStream stdout ) { stdout.println(); PrintWriter pw = new PrintWriter( stdout ); HelpFormatter formatter = new HelpFormatter(); formatter.printHelp( pw, HelpFormatter.DEFAULT_WIDTH, "mvn [options] [] []", "\nOptions:", options, HelpFormatter.DEFAULT_LEFT_PAD, HelpFormatter.DEFAULT_DESC_PAD, "\n", false ); pw.flush(); } } maven-maven-3.5.2/maven-embedder/src/main/java/org/apache/maven/cli/CLIReportingUtils.java000066400000000000000000000153631317160430700313260ustar00rootroot00000000000000package org.apache.maven.cli; /* * 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.shared.utils.logging.MessageUtils.buffer; import java.io.IOException; import java.io.InputStream; import java.text.SimpleDateFormat; import java.util.Date; import java.util.Locale; import java.util.Properties; import org.apache.commons.lang3.StringUtils; import org.codehaus.plexus.util.Os; import org.slf4j.Logger; /** * Utility class used to report errors, statistics, application version info, etc. * * @author jdcasey */ public final class CLIReportingUtils { // CHECKSTYLE_OFF: MagicNumber public static final long MB = 1024 * 1024; private static final long ONE_SECOND = 1000L; private static final long ONE_MINUTE = 60 * ONE_SECOND; private static final long ONE_HOUR = 60 * ONE_MINUTE; private static final long ONE_DAY = 24 * ONE_HOUR; // CHECKSTYLE_ON: MagicNumber public static final String BUILD_VERSION_PROPERTY = "version"; public static String showVersion() { final String ls = System.getProperty( "line.separator" ); Properties properties = getBuildProperties(); StringBuilder version = new StringBuilder( 256 ); version.append( buffer().strong( createMavenVersionString( properties ) ) ).append( ls ); version.append( reduce( properties.getProperty( "distributionShortName" ) + " home: " + System.getProperty( "maven.home", "" ) ) ) .append( ls ); version.append( "Java version: " ).append( System.getProperty( "java.version", "" ) ).append( ", vendor: " ).append( System.getProperty( "java.vendor", "" ) ).append( ls ); version.append( "Java home: " ).append( System.getProperty( "java.home", "" ) ).append( ls ); version.append( "Default locale: " ).append( Locale.getDefault() ).append( ", platform encoding: " ).append( System.getProperty( "file.encoding", "" ) ).append( ls ); version.append( "OS name: \"" ).append( Os.OS_NAME ).append( "\", version: \"" ).append( Os.OS_VERSION ).append( "\", arch: \"" ).append( Os.OS_ARCH ).append( "\", family: \"" ).append( Os.OS_FAMILY ).append( '\"' ); return version.toString(); } /** * Create a human readable string containing the Maven version, buildnumber, and time of build * * @param buildProperties The build properties * @return Readable build info */ static String createMavenVersionString( Properties buildProperties ) { String timestamp = reduce( buildProperties.getProperty( "timestamp" ) ); String version = reduce( buildProperties.getProperty( BUILD_VERSION_PROPERTY ) ); String rev = reduce( buildProperties.getProperty( "buildNumber" ) ); String distributionName = reduce( buildProperties.getProperty( "distributionName" ) ); String msg = distributionName + " "; msg += ( version != null ? version : "" ); if ( rev != null || timestamp != null ) { msg += " ("; msg += ( rev != null ? rev : "" ); if ( StringUtils.isNotBlank( timestamp ) ) { String ts = formatTimestamp( Long.valueOf( timestamp ) ); msg += ( rev != null ? "; " : "" ) + ts; } msg += ")"; } return msg; } private static String reduce( String s ) { return ( s != null ? ( s.startsWith( "${" ) && s.endsWith( "}" ) ? null : s ) : null ); } static Properties getBuildProperties() { Properties properties = new Properties(); try ( InputStream resourceAsStream = MavenCli.class.getResourceAsStream( "/org/apache/maven/messages/build.properties" ) ) { if ( resourceAsStream != null ) { properties.load( resourceAsStream ); } } catch ( IOException e ) { System.err.println( "Unable determine version from JAR file: " + e.getMessage() ); } return properties; } public static void showError( Logger logger, String message, Throwable e, boolean showStackTrace ) { if ( showStackTrace ) { logger.error( message, e ); } else { logger.error( message ); if ( e != null ) { logger.error( e.getMessage() ); for ( Throwable cause = e.getCause(); cause != null; cause = cause.getCause() ) { logger.error( "Caused by: " + cause.getMessage() ); } } } } public static String formatTimestamp( long timestamp ) { SimpleDateFormat sdf = new SimpleDateFormat( "yyyy-MM-dd'T'HH:mm:ssXXX" ); return sdf.format( new Date( timestamp ) ); } public static String formatDuration( long duration ) { // CHECKSTYLE_OFF: MagicNumber long ms = duration % 1000; long s = ( duration / ONE_SECOND ) % 60; long m = ( duration / ONE_MINUTE ) % 60; long h = ( duration / ONE_HOUR ) % 24; long d = duration / ONE_DAY; // CHECKSTYLE_ON: MagicNumber String format; if ( d > 0 ) { // Length 11+ chars format = "%d d %02d:%02d h"; } else if ( h > 0 ) { // Length 7 chars format = "%2$02d:%3$02d h"; } else if ( m > 0 ) { // Length 9 chars format = "%3$02d:%4$02d min"; } else { // Length 7-8 chars format = "%4$d.%5$03d s"; } return String.format( format, d, h, m, s, ms ); } } maven-maven-3.5.2/maven-embedder/src/main/java/org/apache/maven/cli/CleanArgument.java000066400000000000000000000076421317160430700305320ustar00rootroot00000000000000package org.apache.maven.cli; /* * 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.util.ArrayList; import java.util.List; public class CleanArgument { public static String[] cleanArgs( String[] args ) { List cleaned = new ArrayList<>(); StringBuilder currentArg = null; for ( String arg : args ) { boolean addedToBuffer = false; if ( arg.startsWith( "\"" ) ) { // if we're in the process of building up another arg, push it and start over. // this is for the case: "-Dfoo=bar "-Dfoo2=bar two" (note the first unterminated quote) if ( currentArg != null ) { cleaned.add( currentArg.toString() ); } // start building an argument here. currentArg = new StringBuilder( arg.substring( 1 ) ); addedToBuffer = true; } // this has to be a separate "if" statement, to capture the case of: "-Dfoo=bar" if ( addedToBuffer && arg.endsWith( "\"" ) ) { String cleanArgPart = arg.substring( 0, arg.length() - 1 ); // if we're building an argument, keep doing so. if ( currentArg != null ) { // if this is the case of "-Dfoo=bar", then we need to adjust the buffer. if ( addedToBuffer ) { currentArg.setLength( currentArg.length() - 1 ); } // otherwise, we trim the trailing " and append to the buffer. else { // TODO introducing a space here...not sure what else to do but collapse whitespace currentArg.append( ' ' ).append( cleanArgPart ); } cleaned.add( currentArg.toString() ); } else { cleaned.add( cleanArgPart ); } currentArg = null; addedToBuffer = false; continue; } // if we haven't added this arg to the buffer, and we ARE building an argument // buffer, then append it with a preceding space...again, not sure what else to // do other than collapse whitespace. // NOTE: The case of a trailing quote is handled by nullifying the arg buffer. if ( !addedToBuffer ) { if ( currentArg != null ) { currentArg.append( ' ' ).append( arg ); } else { cleaned.add( arg ); } } } if ( currentArg != null ) { cleaned.add( currentArg.toString() ); } int cleanedSz = cleaned.size(); String[] cleanArgs; if ( cleanedSz == 0 ) { cleanArgs = args; } else { cleanArgs = cleaned.toArray( new String[cleanedSz] ); } return cleanArgs; } } maven-maven-3.5.2/maven-embedder/src/main/java/org/apache/maven/cli/CliRequest.java000066400000000000000000000052001317160430700300510ustar00rootroot00000000000000package org.apache.maven.cli; /* * 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.File; import java.util.Properties; import org.apache.commons.cli.CommandLine; import org.apache.maven.execution.DefaultMavenExecutionRequest; import org.apache.maven.execution.MavenExecutionRequest; import org.codehaus.plexus.classworlds.ClassWorld; public class CliRequest { String[] args; CommandLine commandLine; ClassWorld classWorld; String workingDirectory; File multiModuleProjectDirectory; boolean debug; boolean quiet; boolean showErrors = true; Properties userProperties = new Properties(); Properties systemProperties = new Properties(); MavenExecutionRequest request; CliRequest( String[] args, ClassWorld classWorld ) { this.args = args; this.classWorld = classWorld; this.request = new DefaultMavenExecutionRequest(); } public String[] getArgs() { return args; } public CommandLine getCommandLine() { return commandLine; } public ClassWorld getClassWorld() { return classWorld; } public String getWorkingDirectory() { return workingDirectory; } public File getMultiModuleProjectDirectory() { return multiModuleProjectDirectory; } public boolean isDebug() { return debug; } public boolean isQuiet() { return quiet; } public boolean isShowErrors() { return showErrors; } public Properties getUserProperties() { return userProperties; } public Properties getSystemProperties() { return systemProperties; } public MavenExecutionRequest getRequest() { return request; } public void setUserProperties( Properties properties ) { this.userProperties.putAll( properties ); } }maven-maven-3.5.2/maven-embedder/src/main/java/org/apache/maven/cli/MavenCli.java000066400000000000000000001745011317160430700275020ustar00rootroot00000000000000package org.apache.maven.cli; /* * 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 com.google.common.base.Charsets; import com.google.common.io.Files; import com.google.inject.AbstractModule; import org.apache.commons.cli.CommandLine; import org.apache.commons.cli.Option; import org.apache.commons.cli.ParseException; import org.apache.commons.cli.UnrecognizedOptionException; import org.apache.maven.BuildAbort; import org.apache.maven.InternalErrorException; import org.apache.maven.Maven; import org.apache.maven.building.FileSource; import org.apache.maven.building.Problem; import org.apache.maven.building.Source; import org.apache.maven.cli.configuration.ConfigurationProcessor; import org.apache.maven.cli.configuration.SettingsXmlConfigurationProcessor; import org.apache.maven.cli.event.DefaultEventSpyContext; import org.apache.maven.cli.event.ExecutionEventLogger; import org.apache.maven.cli.internal.BootstrapCoreExtensionManager; import org.apache.maven.cli.internal.extension.model.CoreExtension; import org.apache.maven.cli.internal.extension.model.io.xpp3.CoreExtensionsXpp3Reader; import org.apache.maven.cli.logging.Slf4jConfiguration; import org.apache.maven.cli.logging.Slf4jConfigurationFactory; import org.apache.maven.cli.logging.Slf4jLoggerManager; import org.apache.maven.cli.logging.Slf4jStdoutLogger; import org.apache.maven.cli.transfer.ConsoleMavenTransferListener; import org.apache.maven.cli.transfer.QuietMavenTransferListener; import org.apache.maven.cli.transfer.Slf4jMavenTransferListener; import org.apache.maven.eventspy.internal.EventSpyDispatcher; import org.apache.maven.exception.DefaultExceptionHandler; import org.apache.maven.exception.ExceptionHandler; import org.apache.maven.exception.ExceptionSummary; import org.apache.maven.execution.DefaultMavenExecutionRequest; import org.apache.maven.execution.ExecutionListener; import org.apache.maven.execution.MavenExecutionRequest; import org.apache.maven.execution.MavenExecutionRequestPopulationException; import org.apache.maven.execution.MavenExecutionRequestPopulator; import org.apache.maven.execution.MavenExecutionResult; import org.apache.maven.execution.scope.internal.MojoExecutionScopeModule; import org.apache.maven.extension.internal.CoreExports; import org.apache.maven.extension.internal.CoreExtensionEntry; import org.apache.maven.lifecycle.LifecycleExecutionException; import org.apache.maven.model.building.ModelProcessor; import org.apache.maven.project.MavenProject; import org.apache.maven.properties.internal.EnvironmentUtils; import org.apache.maven.properties.internal.SystemProperties; import org.apache.maven.session.scope.internal.SessionScopeModule; import org.apache.maven.shared.utils.logging.MessageBuilder; import org.apache.maven.shared.utils.logging.MessageUtils; import org.apache.maven.toolchain.building.DefaultToolchainsBuildingRequest; import org.apache.maven.toolchain.building.ToolchainsBuilder; import org.apache.maven.toolchain.building.ToolchainsBuildingResult; import org.codehaus.plexus.ContainerConfiguration; import org.codehaus.plexus.DefaultContainerConfiguration; import org.codehaus.plexus.DefaultPlexusContainer; import org.codehaus.plexus.PlexusConstants; import org.codehaus.plexus.PlexusContainer; import org.codehaus.plexus.classworlds.ClassWorld; import org.codehaus.plexus.classworlds.realm.ClassRealm; import org.codehaus.plexus.classworlds.realm.NoSuchRealmException; import org.codehaus.plexus.component.repository.exception.ComponentLookupException; import org.codehaus.plexus.logging.LoggerManager; import org.codehaus.plexus.util.StringUtils; import org.codehaus.plexus.util.xml.pull.XmlPullParserException; import org.eclipse.aether.transfer.TransferListener; import org.slf4j.ILoggerFactory; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.sonatype.plexus.components.cipher.DefaultPlexusCipher; import org.sonatype.plexus.components.sec.dispatcher.DefaultSecDispatcher; import org.sonatype.plexus.components.sec.dispatcher.SecDispatcher; import org.sonatype.plexus.components.sec.dispatcher.SecUtil; import org.sonatype.plexus.components.sec.dispatcher.model.SettingsSecurity; import java.io.BufferedInputStream; import java.io.Console; import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintStream; import java.util.ArrayList; import java.util.Collections; import java.util.HashSet; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import java.util.Map.Entry; import java.util.Properties; import java.util.Set; import java.util.StringTokenizer; import java.util.regex.Matcher; import java.util.regex.Pattern; import static org.apache.maven.shared.utils.logging.MessageUtils.buffer; // TODO push all common bits back to plexus cli and prepare for transition to Guice. We don't need 50 ways to make CLIs /** * @author Jason van Zyl */ public class MavenCli { public static final String LOCAL_REPO_PROPERTY = "maven.repo.local"; public static final String THREADS_DEPRECATED = "maven.threads.experimental"; public static final String MULTIMODULE_PROJECT_DIRECTORY = "maven.multiModuleProjectDirectory"; public static final String USER_HOME = System.getProperty( "user.home" ); public static final File USER_MAVEN_CONFIGURATION_HOME = new File( USER_HOME, ".m2" ); public static final File DEFAULT_USER_TOOLCHAINS_FILE = new File( USER_MAVEN_CONFIGURATION_HOME, "toolchains.xml" ); public static final File DEFAULT_GLOBAL_TOOLCHAINS_FILE = new File( System.getProperty( "maven.conf" ), "toolchains.xml" ); private static final String EXT_CLASS_PATH = "maven.ext.class.path"; private static final String EXTENSIONS_FILENAME = ".mvn/extensions.xml"; private static final String MVN_MAVEN_CONFIG = ".mvn/maven.config"; public static final String STYLE_COLOR_PROPERTY = "style.color"; private ClassWorld classWorld; private LoggerManager plexusLoggerManager; private ILoggerFactory slf4jLoggerFactory; private Logger slf4jLogger; private EventSpyDispatcher eventSpyDispatcher; private ModelProcessor modelProcessor; private Maven maven; private MavenExecutionRequestPopulator executionRequestPopulator; private ToolchainsBuilder toolchainsBuilder; private DefaultSecDispatcher dispatcher; private Map configurationProcessors; public MavenCli() { this( null ); } // This supports painless invocation by the Verifier during embedded execution of the core ITs public MavenCli( ClassWorld classWorld ) { this.classWorld = classWorld; } public static void main( String[] args ) { int result = main( args, null ); System.exit( result ); } public static int main( String[] args, ClassWorld classWorld ) { MavenCli cli = new MavenCli(); MessageUtils.systemInstall(); int result = cli.doMain( new CliRequest( args, classWorld ) ); MessageUtils.systemUninstall(); return result; } // TODO need to externalize CliRequest public static int doMain( String[] args, ClassWorld classWorld ) { MavenCli cli = new MavenCli(); return cli.doMain( new CliRequest( args, classWorld ) ); } /** * This supports painless invocation by the Verifier during embedded execution of the core ITs. * See * Embedded3xLauncher in maven-verifier */ public int doMain( String[] args, String workingDirectory, PrintStream stdout, PrintStream stderr ) { PrintStream oldout = System.out; PrintStream olderr = System.err; final Set realms; if ( classWorld != null ) { realms = new HashSet<>(); for ( ClassRealm realm : classWorld.getRealms() ) { realms.add( realm.getId() ); } } else { realms = Collections.emptySet(); } try { if ( stdout != null ) { System.setOut( stdout ); } if ( stderr != null ) { System.setErr( stderr ); } CliRequest cliRequest = new CliRequest( args, classWorld ); cliRequest.workingDirectory = workingDirectory; return doMain( cliRequest ); } finally { if ( classWorld != null ) { for ( ClassRealm realm : new ArrayList<>( classWorld.getRealms() ) ) { String realmId = realm.getId(); if ( !realms.contains( realmId ) ) { try { classWorld.disposeRealm( realmId ); } catch ( NoSuchRealmException ignored ) { // can't happen } } } } System.setOut( oldout ); System.setErr( olderr ); } } // TODO need to externalize CliRequest public int doMain( CliRequest cliRequest ) { PlexusContainer localContainer = null; try { initialize( cliRequest ); cli( cliRequest ); logging( cliRequest ); version( cliRequest ); properties( cliRequest ); localContainer = container( cliRequest ); commands( cliRequest ); configure( cliRequest ); toolchains( cliRequest ); populateRequest( cliRequest ); encryption( cliRequest ); repository( cliRequest ); return execute( cliRequest ); } catch ( ExitException e ) { return e.exitCode; } catch ( UnrecognizedOptionException e ) { // pure user error, suppress stack trace return 1; } catch ( BuildAbort e ) { CLIReportingUtils.showError( slf4jLogger, "ABORTED", e, cliRequest.showErrors ); return 2; } catch ( Exception e ) { CLIReportingUtils.showError( slf4jLogger, "Error executing Maven.", e, cliRequest.showErrors ); return 1; } finally { if ( localContainer != null ) { localContainer.dispose(); } } } void initialize( CliRequest cliRequest ) throws ExitException { if ( cliRequest.workingDirectory == null ) { cliRequest.workingDirectory = System.getProperty( "user.dir" ); } if ( cliRequest.multiModuleProjectDirectory == null ) { String basedirProperty = System.getProperty( MULTIMODULE_PROJECT_DIRECTORY ); if ( basedirProperty == null ) { System.err.format( "-D%s system property is not set.", MULTIMODULE_PROJECT_DIRECTORY ); throw new ExitException( 1 ); } File basedir = basedirProperty != null ? new File( basedirProperty ) : new File( "" ); try { cliRequest.multiModuleProjectDirectory = basedir.getCanonicalFile(); } catch ( IOException e ) { cliRequest.multiModuleProjectDirectory = basedir.getAbsoluteFile(); } } // // Make sure the Maven home directory is an absolute path to save us from confusion with say drive-relative // Windows paths. // String mavenHome = System.getProperty( "maven.home" ); if ( mavenHome != null ) { System.setProperty( "maven.home", new File( mavenHome ).getAbsolutePath() ); } } void cli( CliRequest cliRequest ) throws Exception { // // Parsing errors can happen during the processing of the arguments and we prefer not having to check if // the logger is null and construct this so we can use an SLF4J logger everywhere. // slf4jLogger = new Slf4jStdoutLogger(); CLIManager cliManager = new CLIManager(); List args = new ArrayList<>(); CommandLine mavenConfig = null; try { File configFile = new File( cliRequest.multiModuleProjectDirectory, MVN_MAVEN_CONFIG ); if ( configFile.isFile() ) { for ( String arg : Files.toString( configFile, Charsets.UTF_8 ).split( "\\s+" ) ) { if ( !arg.isEmpty() ) { args.add( arg ); } } mavenConfig = cliManager.parse( args.toArray( new String[args.size()] ) ); List unrecongized = mavenConfig.getArgList(); if ( !unrecongized.isEmpty() ) { throw new ParseException( "Unrecognized maven.config entries: " + unrecongized ); } } } catch ( ParseException e ) { System.err.println( "Unable to parse maven.config: " + e.getMessage() ); cliManager.displayHelp( System.out ); throw e; } try { if ( mavenConfig == null ) { cliRequest.commandLine = cliManager.parse( cliRequest.args ); } else { cliRequest.commandLine = cliMerge( cliManager.parse( cliRequest.args ), mavenConfig ); } } catch ( ParseException e ) { System.err.println( "Unable to parse command line options: " + e.getMessage() ); cliManager.displayHelp( System.out ); throw e; } if ( cliRequest.commandLine.hasOption( CLIManager.HELP ) ) { cliManager.displayHelp( System.out ); throw new ExitException( 0 ); } if ( cliRequest.commandLine.hasOption( CLIManager.VERSION ) ) { System.out.println( CLIReportingUtils.showVersion() ); throw new ExitException( 0 ); } } private CommandLine cliMerge( CommandLine mavenArgs, CommandLine mavenConfig ) { CommandLine.Builder commandLineBuilder = new CommandLine.Builder(); // the args are easy, cli first then config file for ( String arg : mavenArgs.getArgs() ) { commandLineBuilder.addArg( arg ); } for ( String arg : mavenConfig.getArgs() ) { commandLineBuilder.addArg( arg ); } // now add all options, except for -D with cli first then config file List