diff --git a/apache-maven/pom.xml b/apache-maven/pom.xml index ec11cc2b6935..437fc43ccd54 100644 --- a/apache-maven/pom.xml +++ b/apache-maven/pom.xml @@ -92,8 +92,8 @@ under the License. aether-transport-wagon - com.planet57.gossip - gossip-slf4j + org.apache.maven + maven-slf4j-provider org.fusesource.jansi diff --git a/apache-maven/src/bin/m2.conf b/apache-maven/src/bin/m2.conf index 213dc55d1d69..2235f820f5f0 100644 --- a/apache-maven/src/bin/m2.conf +++ b/apache-maven/src/bin/m2.conf @@ -1,8 +1,8 @@ main is org.apache.maven.cli.MavenCli from plexus.core -set maven.home default ${user.home}/m2 +set maven.conf default ${maven.home}/conf [plexus.core] -load ${maven.home}/conf/logging +load ${maven.conf}/logging optionally ${maven.home}/lib/ext/*.jar load ${maven.home}/lib/*.jar diff --git a/apache-maven/src/bin/mvn b/apache-maven/src/bin/mvn index 2a88df23eae2..e79507325064 100755 --- a/apache-maven/src/bin/mvn +++ b/apache-maven/src/bin/mvn @@ -121,7 +121,7 @@ fi # first directory with .mvn subdirectory is considered project base directory find_maven_basedir() { ( - basedir="`pwd`" + basedir=`find_file_argument_basedir "$@"` wdir="`pwd`" while [ "$wdir" != '/' ] ; do if [ -d "$wdir"/.mvn ] ; then @@ -134,6 +134,33 @@ find_maven_basedir() { ) } +find_file_argument_basedir() { +( + basedir="`pwd`" + + found_file_switch=0 + for arg in "$@"; do + if [ ${found_file_switch} -eq 1 ]; then + if [ -f ${arg} ]; then + basedir=$(dirname $(readlink -f "${arg}")) + 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 @@ -141,7 +168,7 @@ concat_lines() { fi } -MAVEN_PROJECTBASEDIR="${MAVEN_BASEDIR:-`find_maven_basedir`}" +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 @@ -164,4 +191,5 @@ exec "$JAVACMD" \ -classpath "${CLASSWORLDS_JAR}" \ "-Dclassworlds.conf=${MAVEN_HOME}/bin/m2.conf" \ "-Dmaven.home=${MAVEN_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \ + "-Dlibrary.jansi.path=${MAVEN_HOME}/lib" \ ${CLASSWORLDS_LAUNCHER} "$@" diff --git a/apache-maven/src/bin/mvn.cmd b/apache-maven/src/bin/mvn.cmd index c8ad237ef614..6271f179a8c5 100644 --- a/apache-maven/src/bin/mvn.cmd +++ b/apache-maven/src/bin/mvn.cmd @@ -86,19 +86,69 @@ set MAVEN_CMD_LINE_ARGS=%* set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR% if not "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir -set "EXEC_DIR=%CD%" -set "WDIR=%EXEC_DIR%" +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 +) +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 findBaseDir +goto findBaseDirLoop :baseDirFound set "MAVEN_PROJECTBASEDIR=%WDIR%" -cd "%EXEC_DIR%" +cd /d "%EXEC_DIR%" goto endDetectBaseDir :baseDirNotFound @@ -128,6 +178,7 @@ for %%i in ("%MAVEN_HOME%"\boot\plexus-classworlds-*) do set CLASSWORLDS_JAR="%% "-Dclassworlds.conf=%MAVEN_HOME%\bin\m2.conf" ^ "-Dmaven.home=%MAVEN_HOME%" ^ "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" ^ + "-Dlibrary.jansi.path=%MAVEN_HOME%\lib" ^ %CLASSWORLDS_LAUNCHER% %MAVEN_CMD_LINE_ARGS% if ERRORLEVEL 1 goto error goto end diff --git a/apache-maven/src/conf/settings.xml b/apache-maven/src/conf/settings.xml index 3fa2f14bb388..41db3ba7c48e 100644 --- a/apache-maven/src/conf/settings.xml +++ b/apache-maven/src/conf/settings.xml @@ -32,7 +32,7 @@ under the License. | 2. Global Level. This settings.xml file provides configuration for all Maven | users on a machine (assuming they're all using the same Maven | installation). It's normally provided in - | ${maven.home}/conf/settings.xml. + | ${maven.conf}/settings.xml. | | NOTE: This location can be overridden with the CLI option: | @@ -244,47 +244,6 @@ under the License. --> - - - - - f06abaa7-178e-441e-bb0d-10a92d7ce014 - - - - central - Central Repository - https://repo.maven.apache.org/maven2 - default - - false - - - never - - - - - - - central - Central Repository - https://repo.maven.apache.org/maven2 - default - - false - - - never - - - - - f06abaa7-178e-441e-bb0d-10a92d7ce014 diff --git a/apache-maven/src/conf/toolchains.xml b/apache-maven/src/conf/toolchains.xml index 14ef3fedd740..75862b4fd099 100644 --- a/apache-maven/src/conf/toolchains.xml +++ b/apache-maven/src/conf/toolchains.xml @@ -32,7 +32,7 @@ under the License. | 2. Global Level. This toolchains.xml file provides configuration for all Maven | users on a machine (assuming they're all using the same Maven | installation). It's normally provided in - | ${maven.home}/conf/toolchains.xml. + | ${maven.conf}/toolchains.xml. | | NOTE: This location can be overridden with the CLI option: | @@ -44,24 +44,24 @@ under the License. - \ No newline at end of file diff --git a/apache-maven/src/main/appended-resources/META-INF/LICENSE.vm b/apache-maven/src/main/appended-resources/META-INF/LICENSE.vm index 390fa425304f..d18c638fa657 100644 --- a/apache-maven/src/main/appended-resources/META-INF/LICENSE.vm +++ b/apache-maven/src/main/appended-resources/META-INF/LICENSE.vm @@ -17,15 +17,15 @@ ## 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. +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) ) +#if ( ! ($apacheTxt == $license.name) ) #set ( $artId = $project.artifact.artifactId) #set ( $lf = $locator ) #set ( $url = $license.url ) @@ -33,7 +33,7 @@ subject to the terms and conditions of the following licenses. #if ($url == "https://glassfish.dev.java.net/public/CDDLv1.0.html") #set ( $url = 'https://glassfish.java.net/public/CDDLv1.0.html' ) #end -#if ($url) +#if ($url) #set ( $licFile = 'lib/' + $artId + '.license' ) #set ( $downloaded = $lf.getResourceAsFile($url, "licenses/${licFile}") ) #end diff --git a/apache-maven/src/main/assembly/component.xml b/apache-maven/src/main/assembly/component.xml index 8ccf02a61aee..ca4dcb69a375 100644 --- a/apache-maven/src/main/assembly/component.xml +++ b/apache-maven/src/main/assembly/component.xml @@ -68,7 +68,6 @@ under the License. src/bin bin - m2 mvn mvnDebug diff --git a/doap_Maven.rdf b/doap_Maven.rdf index 88bf82af259c..86fbd1d31291 100644 --- a/doap_Maven.rdf +++ b/doap_Maven.rdf @@ -201,6 +201,12 @@ under the License. + + + + + + Apache Maven PMC diff --git a/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/ArtifactDescriptorReaderDelegate.java b/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/ArtifactDescriptorReaderDelegate.java index 184c32770036..284ee861a068 100644 --- a/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/ArtifactDescriptorReaderDelegate.java +++ b/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/ArtifactDescriptorReaderDelegate.java @@ -45,7 +45,7 @@ /** * Populates Aether {@link ArtifactDescriptorResult} from Maven project {@link Model}. - * + * * @since 3.2.4 * @provisional This class is part of work in progress and can be changed or removed without notice. */ diff --git a/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/MavenRepositorySystemUtils.java b/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/MavenRepositorySystemUtils.java index 877c27777bb4..8567439f6269 100644 --- a/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/MavenRepositorySystemUtils.java +++ b/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/MavenRepositorySystemUtils.java @@ -19,9 +19,6 @@ * under the License. */ -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.IOException; import java.util.Properties; import org.eclipse.aether.DefaultRepositorySystemSession; @@ -130,22 +127,14 @@ public static DefaultRepositorySystemSession newSession() session.setArtifactDescriptorPolicy( new SimpleArtifactDescriptorPolicy( true, true ) ); - // MNG-5670 guard against ConcurrentModificationException - // MNG-6053 guard against key without value final Properties systemProperties = new Properties(); - // This relies on the fact that load/store are synchronized internally. - try ( final ByteArrayOutputStream out = new ByteArrayOutputStream() ) - { - System.getProperties().store( out, null ); - try ( final ByteArrayInputStream in = new ByteArrayInputStream( out.toByteArray() ) ) - { - systemProperties.load( in ); - } - } - catch ( final IOException e ) + // MNG-5670 guard against ConcurrentModificationException + // MNG-6053 guard against key without value + Properties sysProp = System.getProperties(); + synchronized ( sysProp ) { - throw new AssertionError( "Unexpected IO error copying system properties.", e ); + systemProperties.putAll( sysProp ); } session.setSystemProperties( systemProperties ); diff --git a/maven-artifact/src/main/java/org/apache/maven/artifact/versioning/ArtifactVersion.java b/maven-artifact/src/main/java/org/apache/maven/artifact/versioning/ArtifactVersion.java index 5b516a91d016..c60bff6092e1 100644 --- a/maven-artifact/src/main/java/org/apache/maven/artifact/versioning/ArtifactVersion.java +++ b/maven-artifact/src/main/java/org/apache/maven/artifact/versioning/ArtifactVersion.java @@ -25,6 +25,7 @@ * * @author Brett Porter */ +@Deprecated public interface ArtifactVersion extends Comparable { diff --git a/maven-artifact/src/main/java/org/apache/maven/artifact/versioning/ComparableVersion.java b/maven-artifact/src/main/java/org/apache/maven/artifact/versioning/ComparableVersion.java index f434ef0693a9..628e35dcd1e9 100644 --- a/maven-artifact/src/main/java/org/apache/maven/artifact/versioning/ComparableVersion.java +++ b/maven-artifact/src/main/java/org/apache/maven/artifact/versioning/ComparableVersion.java @@ -146,10 +146,8 @@ public String toString() 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 List QUALIFIERS = + Arrays.asList( "alpha", "beta", "milestone", "rc", "snapshot", "", "sp" ); private static final Properties ALIASES = new Properties(); static @@ -163,7 +161,7 @@ private static class StringItem * 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 static final String RELEASE_VERSION_INDEX = String.valueOf( QUALIFIERS.indexOf( "" ) ); private String value; @@ -214,9 +212,9 @@ public boolean isNull() */ public static String comparableQualifier( String qualifier ) { - int i = _QUALIFIERS.indexOf( qualifier ); + int i = QUALIFIERS.indexOf( qualifier ); - return i == -1 ? ( _QUALIFIERS.size() + "-" + qualifier ) : String.valueOf( i ); + return i == -1 ? ( QUALIFIERS.size() + "-" + qualifier ) : String.valueOf( i ); } public int compareTo( Item item ) diff --git a/maven-artifact/src/main/java/org/apache/maven/artifact/versioning/DefaultArtifactVersion.java b/maven-artifact/src/main/java/org/apache/maven/artifact/versioning/DefaultArtifactVersion.java index 7fcbce83a000..0aa7af8d2bb6 100644 --- a/maven-artifact/src/main/java/org/apache/maven/artifact/versioning/DefaultArtifactVersion.java +++ b/maven-artifact/src/main/java/org/apache/maven/artifact/versioning/DefaultArtifactVersion.java @@ -28,6 +28,7 @@ * * @author Brett Porter */ +@Deprecated public class DefaultArtifactVersion implements ArtifactVersion { diff --git a/maven-artifact/src/test/java/org/apache/maven/artifact/versioning/ComparableVersionTest.java b/maven-artifact/src/test/java/org/apache/maven/artifact/versioning/ComparableVersionTest.java index aea98dd16e0d..322cba0912b0 100644 --- a/maven-artifact/src/test/java/org/apache/maven/artifact/versioning/ComparableVersionTest.java +++ b/maven-artifact/src/test/java/org/apache/maven/artifact/versioning/ComparableVersionTest.java @@ -28,11 +28,10 @@ * * @author Hervé Boutemy */ -@SuppressWarnings( "unchecked" ) public class ComparableVersionTest extends TestCase { - private Comparable newComparable( String version ) + private ComparableVersion newComparable( String version ) { ComparableVersion ret = new ComparableVersion( version ); String canonical = ret.getCanonical(); @@ -56,7 +55,7 @@ private Comparable newComparable( String version ) private void checkVersionsOrder( String[] versions ) { - Comparable[] c = new Comparable[versions.length]; + ComparableVersion[] c = new ComparableVersion[versions.length]; for ( int i = 0; i < versions.length; i++ ) { c[i] = newComparable( versions[i] ); @@ -64,10 +63,10 @@ private void checkVersionsOrder( String[] versions ) for ( int i = 1; i < versions.length; i++ ) { - Comparable low = c[i - 1]; + ComparableVersion low = c[i - 1]; for ( int j = i; j < versions.length; j++ ) { - Comparable high = c[j]; + ComparableVersion high = c[j]; assertTrue( "expected " + low + " < " + high, low.compareTo( high ) < 0 ); assertTrue( "expected " + high + " > " + low, high.compareTo( low ) > 0 ); } @@ -76,8 +75,8 @@ private void checkVersionsOrder( String[] versions ) private void checkVersionsEqual( String v1, String v2 ) { - Comparable c1 = newComparable( v1 ); - Comparable c2 = newComparable( v2 ); + ComparableVersion c1 = newComparable( v1 ); + ComparableVersion 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() ); @@ -87,8 +86,8 @@ private void checkVersionsEqual( String v1, String v2 ) private void checkVersionsOrder( String v1, String v2 ) { - Comparable c1 = newComparable( v1 ); - Comparable c2 = newComparable( v2 ); + ComparableVersion c1 = newComparable( v1 ); + ComparableVersion c2 = newComparable( v2 ); assertTrue( "expected " + v1 + " < " + v2, c1.compareTo( c2 ) < 0 ); assertTrue( "expected " + v2 + " > " + v1, c2.compareTo( c1 ) > 0 ); } @@ -224,7 +223,7 @@ public void testReuse() ComparableVersion c1 = new ComparableVersion( "1" ); c1.parseVersion( "2" ); - Comparable c2 = newComparable( "2" ); + ComparableVersion c2 = newComparable( "2" ); assertEquals( "reused instance should be equivalent to new instance", c1, c2 ); } diff --git a/maven-builder-support/src/main/java/org/apache/maven/building/ProblemCollector.java b/maven-builder-support/src/main/java/org/apache/maven/building/ProblemCollector.java index e7015676ce2d..8439fef5c0f1 100644 --- a/maven-builder-support/src/main/java/org/apache/maven/building/ProblemCollector.java +++ b/maven-builder-support/src/main/java/org/apache/maven/building/ProblemCollector.java @@ -41,17 +41,17 @@ public interface ProblemCollector * @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(); diff --git a/maven-builder-support/src/main/java/org/apache/maven/building/ProblemCollectorFactory.java b/maven-builder-support/src/main/java/org/apache/maven/building/ProblemCollectorFactory.java index c1c23737ecb1..43c9bd3838c4 100644 --- a/maven-builder-support/src/main/java/org/apache/maven/building/ProblemCollectorFactory.java +++ b/maven-builder-support/src/main/java/org/apache/maven/building/ProblemCollectorFactory.java @@ -22,7 +22,7 @@ import java.util.List; /** - * + * * @author Robert Scholte * @since 3.3.0 */ @@ -30,8 +30,8 @@ public class ProblemCollectorFactory { /** - * The default implementation is not visible, create it with this factory - * + * 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 */ diff --git a/maven-builder-support/src/test/java/org/apache/maven/building/DefaultProblemCollectorTest.java b/maven-builder-support/src/test/java/org/apache/maven/building/DefaultProblemCollectorTest.java index bf0f84771015..57ddcfa1f86a 100644 --- a/maven-builder-support/src/test/java/org/apache/maven/building/DefaultProblemCollectorTest.java +++ b/maven-builder-support/src/test/java/org/apache/maven/building/DefaultProblemCollectorTest.java @@ -35,10 +35,10 @@ public void testGetProblems() 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); @@ -47,7 +47,7 @@ public void testGetProblems() 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() ); @@ -60,7 +60,7 @@ public void testGetProblems() public void testSetSource() { DefaultProblemCollector collector = new DefaultProblemCollector( null ); - + collector.add( null, "PROBLEM1", -1, -1, null ); collector.setSource( "SOURCE_PROBLEM2" ); diff --git a/maven-builder-support/src/test/java/org/apache/maven/building/DefaultProblemTest.java b/maven-builder-support/src/test/java/org/apache/maven/building/DefaultProblemTest.java index 80a20da99979..1615fc3751ff 100644 --- a/maven-builder-support/src/test/java/org/apache/maven/building/DefaultProblemTest.java +++ b/maven-builder-support/src/test/java/org/apache/maven/building/DefaultProblemTest.java @@ -36,14 +36,14 @@ public void testGetSeverity() 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() { @@ -52,7 +52,7 @@ public void testGetLineNumber() 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() ); @@ -60,7 +60,7 @@ public void testGetLineNumber() problem = new DefaultProblem( null, null, null, Integer.MIN_VALUE, -1, null ); assertEquals( Integer.MIN_VALUE, problem.getLineNumber() ); } - + @Test public void testGetColumnNumber() { @@ -69,7 +69,7 @@ public void testGetColumnNumber() 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() ); @@ -77,13 +77,13 @@ public void testGetColumnNumber() 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() ); @@ -94,7 +94,7 @@ 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() ); @@ -107,7 +107,7 @@ 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() ); @@ -120,7 +120,7 @@ public void testGetLocation() problem = new DefaultProblem( null, null, "SOURCE", 42, 127, null ); assertEquals( "SOURCE, line 42, column 127", problem.getLocation() ); } - + @Test public void testGetMessage() { diff --git a/maven-builder-support/src/test/java/org/apache/maven/building/ProblemCollectorFactoryTest.java b/maven-builder-support/src/test/java/org/apache/maven/building/ProblemCollectorFactoryTest.java index 44c7906c7c6d..2fdcbb70c4cc 100644 --- a/maven-builder-support/src/test/java/org/apache/maven/building/ProblemCollectorFactoryTest.java +++ b/maven-builder-support/src/test/java/org/apache/maven/building/ProblemCollectorFactoryTest.java @@ -33,10 +33,10 @@ public class ProblemCollectorFactoryTest 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() ); diff --git a/maven-compat/src/main/java/org/apache/maven/artifact/resolver/DebugResolutionListener.java b/maven-compat/src/main/java/org/apache/maven/artifact/resolver/DebugResolutionListener.java index 43806b1e596e..bd1ed9ae8024 100644 --- a/maven-compat/src/main/java/org/apache/maven/artifact/resolver/DebugResolutionListener.java +++ b/maven-compat/src/main/java/org/apache/maven/artifact/resolver/DebugResolutionListener.java @@ -71,7 +71,7 @@ public void omitForNearer( Artifact omitted, Artifact kept ) if ( omittedVersion != null ? !omittedVersion.equals( keptVersion ) : keptVersion != null ) { - logger.debug( indent + omitted + " (removed - nearer found: " + kept.getVersion() + ")" ); + logger.debug( indent + omitted + " (removed - nearer found: " + keptVersion + ")" ); } } @@ -164,4 +164,4 @@ public void manageArtifactSystemPath( Artifact artifact, Artifact replacement ) } } -} \ No newline at end of file +} diff --git a/maven-compat/src/main/java/org/apache/maven/project/MavenProjectBuilder.java b/maven-compat/src/main/java/org/apache/maven/project/MavenProjectBuilder.java index c44d8dbc9476..816b4a9eb06e 100644 --- a/maven-compat/src/main/java/org/apache/maven/project/MavenProjectBuilder.java +++ b/maven-compat/src/main/java/org/apache/maven/project/MavenProjectBuilder.java @@ -39,7 +39,8 @@ public interface MavenProjectBuilder MavenProject build( File pom, ProjectBuilderConfiguration configuration ) throws ProjectBuildingException; - //TODO maven-site-plugin -- Vincent, Dennis and Lukas are checking but this doesn't appear to be required anymore. + //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; diff --git a/maven-compat/src/main/java/org/apache/maven/repository/legacy/DefaultWagonManager.java b/maven-compat/src/main/java/org/apache/maven/repository/legacy/DefaultWagonManager.java index b8835b51434c..4998f950956d 100644 --- a/maven-compat/src/main/java/org/apache/maven/repository/legacy/DefaultWagonManager.java +++ b/maven-compat/src/main/java/org/apache/maven/repository/legacy/DefaultWagonManager.java @@ -435,7 +435,7 @@ public void getRemoteFile( ArtifactRepository repository, File destination, Stri } catch ( ChecksumFailedException e ) { - // if we catch a ChecksumFailedException, it means the transfer/read succeeded, but the + // 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. diff --git a/maven-compat/src/main/java/org/apache/maven/repository/legacy/resolver/DefaultLegacyArtifactCollector.java b/maven-compat/src/main/java/org/apache/maven/repository/legacy/resolver/DefaultLegacyArtifactCollector.java index 4601eee5dc52..96a9dfddf31d 100644 --- a/maven-compat/src/main/java/org/apache/maven/repository/legacy/resolver/DefaultLegacyArtifactCollector.java +++ b/maven-compat/src/main/java/org/apache/maven/repository/legacy/resolver/DefaultLegacyArtifactCollector.java @@ -692,7 +692,7 @@ boolean checkScopeUpdate( ResolutionNode farthest, ResolutionNode nearest, List< fireEvent( ResolutionListener.UPDATE_SCOPE, listeners, nearest, farthestArtifact ); // previously we cloned the artifact, but it is more effecient to just update the artifactScope - // if problems are later discovered that the original object needs its original artifactScope value, + // if problems are later discovered that the original object needs its original artifactScope value, // cloning may // again be appropriate nearestArtifact.setScope( farthestArtifact.getScope() ); diff --git a/maven-compat/src/test/java/org/apache/maven/repository/legacy/DefaultWagonManagerTest.java b/maven-compat/src/test/java/org/apache/maven/repository/legacy/DefaultWagonManagerTest.java index b9bcf9b2f488..aa5dd68ee8ed 100644 --- a/maven-compat/src/test/java/org/apache/maven/repository/legacy/DefaultWagonManagerTest.java +++ b/maven-compat/src/test/java/org/apache/maven/repository/legacy/DefaultWagonManagerTest.java @@ -138,7 +138,7 @@ public void testGetMissingJarForced() throws TransferFailedException, Unsupporte try { - wagonManager.getArtifact( artifact, repo, null, false ); + wagonManager.getArtifact( artifact, repo, null, true ); fail(); } diff --git a/maven-compat/src/test/remote-repo/org/apache/maven/its/a/0.1/a-0.1.pom b/maven-compat/src/test/remote-repo/org/apache/maven/its/a/0.1/a-0.1.pom index f45141885647..03caa12ee830 100644 --- a/maven-compat/src/test/remote-repo/org/apache/maven/its/a/0.1/a-0.1.pom +++ b/maven-compat/src/test/remote-repo/org/apache/maven/its/a/0.1/a-0.1.pom @@ -29,7 +29,7 @@ under the License. Maven Integration Test :: Dummy Artifact - + diff --git a/maven-compat/src/test/remote-repo/org/apache/maven/its/b/0.1/b-0.1.pom b/maven-compat/src/test/remote-repo/org/apache/maven/its/b/0.1/b-0.1.pom index ca20cbf5a9a5..149a2410888d 100644 --- a/maven-compat/src/test/remote-repo/org/apache/maven/its/b/0.1/b-0.1.pom +++ b/maven-compat/src/test/remote-repo/org/apache/maven/its/b/0.1/b-0.1.pom @@ -29,7 +29,7 @@ under the License. Maven Integration Test :: Dummy Artifact - + diff --git a/maven-compat/src/test/resources/inheritance-repo/t12scm/maven/p0/1.0/p0-1.0.pom b/maven-compat/src/test/resources/inheritance-repo/t12scm/maven/p0/1.0/p0-1.0.pom index 97bf7ccc22fb..a22df68eac12 100644 --- a/maven-compat/src/test/resources/inheritance-repo/t12scm/maven/p0/1.0/p0-1.0.pom +++ b/maven-compat/src/test/resources/inheritance-repo/t12scm/maven/p0/1.0/p0-1.0.pom @@ -4,13 +4,13 @@ p0 pom 1.0 - + scm:svn:http://host/p0 scm:svn:https://host/p0 http://host/viewer?path=/p0 - + modules/p1 diff --git a/maven-compat/src/test/resources/inheritance-repo/t12scm/maven/p1/1.0/p1-1.0.pom b/maven-compat/src/test/resources/inheritance-repo/t12scm/maven/p1/1.0/p1-1.0.pom index e9ddf0d78cfc..736b51539b45 100644 --- a/maven-compat/src/test/resources/inheritance-repo/t12scm/maven/p1/1.0/p1-1.0.pom +++ b/maven-compat/src/test/resources/inheritance-repo/t12scm/maven/p1/1.0/p1-1.0.pom @@ -7,5 +7,5 @@ 4.0.0 p1 - + diff --git a/maven-core/project-builder.txt b/maven-core/project-builder.txt deleted file mode 100644 index a9aab65be9fd..000000000000 --- a/maven-core/project-builder.txt +++ /dev/null @@ -1 +0,0 @@ -Maven Project Builder and Maven Model Builder diff --git a/maven-core/src/main/java/org/apache/maven/ArtifactFilterManager.java b/maven-core/src/main/java/org/apache/maven/ArtifactFilterManager.java index 2cf9f9963dc0..546f1b25cea4 100644 --- a/maven-core/src/main/java/org/apache/maven/ArtifactFilterManager.java +++ b/maven-core/src/main/java/org/apache/maven/ArtifactFilterManager.java @@ -27,7 +27,7 @@ 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. */ @@ -40,7 +40,7 @@ public interface ArtifactFilterManager /** * 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. */ diff --git a/maven-core/src/main/java/org/apache/maven/DefaultMaven.java b/maven-core/src/main/java/org/apache/maven/DefaultMaven.java index da17830a643a..6954e9bf6e0f 100644 --- a/maven-core/src/main/java/org/apache/maven/DefaultMaven.java +++ b/maven-core/src/main/java/org/apache/maven/DefaultMaven.java @@ -42,6 +42,7 @@ 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; @@ -111,7 +112,7 @@ public MavenExecutionResult execute( MavenExecutionRequest request ) } catch ( RuntimeException e ) { - //TODO Hack to make the cycle detection the same for the new graph builder + // 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() ); @@ -160,7 +161,7 @@ public MavenExecutionResult execute( MavenExecutionRequest request ) // @SuppressWarnings( "checkstyle:methodlength" ) private MavenExecutionResult doExecute( MavenExecutionRequest request ) - { + { request.setStartTime( new Date() ); MavenExecutionResult result = new DefaultMavenExecutionResult(); @@ -192,6 +193,10 @@ private MavenExecutionResult doExecute( MavenExecutionRequest request ) return doExecute( request, session, result, repoSession ); } + catch ( MavenExecutionException e ) + { + return addExceptionToResult( result, e ); + } finally { sessionScope.exit(); @@ -200,29 +205,18 @@ private MavenExecutionResult doExecute( MavenExecutionRequest request ) private MavenExecutionResult doExecute( MavenExecutionRequest request, MavenSession session, MavenExecutionResult result, DefaultRepositorySystemSession repoSession ) + throws MavenExecutionException { - try - { - for ( AbstractMavenLifecycleParticipant listener : getLifecycleParticipants( Collections - .emptyList() ) ) - { - listener.afterSessionStart( session ); - } - } - catch ( MavenExecutionException e ) - { - return addExceptionToResult( result, e ); - } + afterSessionStart( session ); 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() ); + return addExceptionToResult( result, Iterables.toArray( graphResult.getProblems(), + ModelProblem.class )[0].getException() ); } try @@ -256,24 +250,7 @@ private MavenExecutionResult doExecute( MavenExecutionRequest request, MavenSess 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 ); - } + afterProjectRead( session ); // // The projects need to be topologically after the participants have run their afterProjectsRead(session) @@ -283,14 +260,13 @@ private MavenExecutionResult doExecute( MavenExecutionRequest request, MavenSess // 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() ); + return addExceptionToResult( result, Iterables.toArray( graphResult.getProblems(), + ModelProblem.class )[0].getException() ); } try @@ -304,6 +280,8 @@ private MavenExecutionResult doExecute( MavenExecutionRequest request, MavenSess result.setProject( session.getTopLevelProject() ); + validatePrerequisitesForNonMavenPluginProjects( session.getProjects() ); + lifecycleStarter.execute( session ); validateActivatedProfiles( session.getProjects(), request.getActiveProfiles() ); @@ -328,6 +306,35 @@ private MavenExecutionResult doExecute( MavenExecutionRequest request, MavenSess return result; } + @SuppressWarnings( "checkstyle:linelength" ) + private void afterSessionStart( MavenSession session ) + throws MavenExecutionException + { + for ( AbstractMavenLifecycleParticipant listener : getLifecycleParticipants( Collections.emptyList() ) ) + { + listener.afterSessionStart( session ); + } + } + + private void afterProjectRead( MavenSession session ) + throws MavenExecutionException + { + ClassLoader originalClassLoader = Thread.currentThread().getContextClassLoader(); + try + { + for ( AbstractMavenLifecycleParticipant listener : getLifecycleParticipants( session.getProjects() ) ) + { + Thread.currentThread().setContextClassLoader( listener.getClass().getClassLoader() ); + + listener.afterProjectsRead( session ); + } + } + finally + { + Thread.currentThread().setContextClassLoader( originalClassLoader ); + } + } + private void afterSessionEnd( Collection projects, MavenSession session ) throws MavenExecutionException { @@ -346,7 +353,7 @@ private void afterSessionEnd( Collection projects, MavenSession se Thread.currentThread().setContextClassLoader( originalClassLoader ); } } - + public RepositorySystemSession newRepositorySession( MavenExecutionRequest request ) { return repositorySessionFactory.newRepositorySession( request ); @@ -369,8 +376,7 @@ private void validateLocalRepository( MavenExecutionRequest request ) private Collection getLifecycleParticipants( Collection projects ) { - Collection lifecycleListeners = - new LinkedHashSet<>(); + Collection lifecycleListeners = new LinkedHashSet<>(); ClassLoader originalClassLoader = Thread.currentThread().getContextClassLoader(); try @@ -425,6 +431,25 @@ private MavenExecutionResult addExceptionToResult( MavenExecutionResult result, 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 ); @@ -486,7 +511,7 @@ private Map getProjectMap( Collection projec return index; } - private Result buildGraph( MavenSession session, MavenExecutionResult result ) + private Result buildGraph( MavenSession session, MavenExecutionResult result ) { Result graphResult = graphBuilder.build( session ); for ( ModelProblem problem : graphResult.getProblems() ) @@ -506,12 +531,12 @@ private Result buildGraph( MavenSession sessio ProjectDependencyGraph projectDependencyGraph = graphResult.get(); session.setProjects( projectDependencyGraph.getSortedProjects() ); session.setAllProjects( projectDependencyGraph.getSortedProjects() ); - session.setProjectDependencyGraph( projectDependencyGraph ); + session.setProjectDependencyGraph( projectDependencyGraph ); } - - return graphResult; + + return graphResult; } - + @Deprecated // 5 January 2014 protected Logger getLogger() diff --git a/maven-core/src/main/java/org/apache/maven/DefaultProjectDependenciesResolver.java b/maven-core/src/main/java/org/apache/maven/DefaultProjectDependenciesResolver.java index be7c97a8cc8a..3c6b4ab0cacb 100644 --- a/maven-core/src/main/java/org/apache/maven/DefaultProjectDependenciesResolver.java +++ b/maven-core/src/main/java/org/apache/maven/DefaultProjectDependenciesResolver.java @@ -127,7 +127,7 @@ private Set resolveImpl( Collection projects, if ( ! exclusions.isEmpty() ) { - filter = new AndArtifactFilter( Arrays.asList( new ArtifactFilter[]{ + filter = new AndArtifactFilter( Arrays.asList( new ArtifactFilter[]{ new ExcludesArtifactFilter( exclusions ), scopeFilter } ) ); } else diff --git a/maven-core/src/main/java/org/apache/maven/Maven.java b/maven-core/src/main/java/org/apache/maven/Maven.java index 85638476c634..69f9fcaed5f8 100644 --- a/maven-core/src/main/java/org/apache/maven/Maven.java +++ b/maven-core/src/main/java/org/apache/maven/Maven.java @@ -23,7 +23,10 @@ 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 { diff --git a/maven-core/src/main/java/org/apache/maven/ProjectCycleException.java b/maven-core/src/main/java/org/apache/maven/ProjectCycleException.java index ecd8ecacd7e1..b4a6fd0bf3e7 100644 --- a/maven-core/src/main/java/org/apache/maven/ProjectCycleException.java +++ b/maven-core/src/main/java/org/apache/maven/ProjectCycleException.java @@ -31,7 +31,7 @@ public ProjectCycleException( String message ) { super( message ); } - + public ProjectCycleException( String message, CycleDetectedException cause ) { super( message, cause ); diff --git a/maven-core/src/main/java/org/apache/maven/SessionScoped.java b/maven-core/src/main/java/org/apache/maven/SessionScoped.java index 63b1eb77ad08..7738938c06f4 100644 --- a/maven-core/src/main/java/org/apache/maven/SessionScoped.java +++ b/maven-core/src/main/java/org/apache/maven/SessionScoped.java @@ -28,8 +28,8 @@ import com.google.inject.ScopeAnnotation; /** - * Indicates that annotated component should be instantiated before session starts and discarded after session execution - * completes. + * 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 diff --git a/maven-core/src/main/java/org/apache/maven/bridge/MavenRepositorySystem.java b/maven-core/src/main/java/org/apache/maven/bridge/MavenRepositorySystem.java index 428ade02ad01..40574e8e8279 100644 --- a/maven-core/src/main/java/org/apache/maven/bridge/MavenRepositorySystem.java +++ b/maven-core/src/main/java/org/apache/maven/bridge/MavenRepositorySystem.java @@ -568,15 +568,13 @@ else if ( Artifact.SCOPE_COMPILE.equals( scope ) && Artifact.SCOPE_COMPILE.equal // // Code taken from LegacyRepositorySystem // - /** - * @deprecation As of 3.4, Maven no longer falls back to a hard-coded default repository with identifier - * {@code central} if such a repository is not provided in the settings or the POM. - */ - @Deprecated public ArtifactRepository createDefaultRemoteRepository( MavenExecutionRequest request ) throws Exception { - throw new UnsupportedOperationException(); + return createRepository( RepositorySystem.DEFAULT_REMOTE_REPO_URL, RepositorySystem.DEFAULT_REMOTE_REPO_ID, + true, ArtifactRepositoryPolicy.UPDATE_POLICY_NEVER, false, + ArtifactRepositoryPolicy.UPDATE_POLICY_NEVER, + ArtifactRepositoryPolicy.CHECKSUM_POLICY_WARN ); } public ArtifactRepository createRepository( String url, String repositoryId, boolean releases, diff --git a/maven-core/src/main/java/org/apache/maven/execution/DefaultMavenExecutionRequest.java b/maven-core/src/main/java/org/apache/maven/execution/DefaultMavenExecutionRequest.java index 71a6894c690b..d67061f94848 100644 --- a/maven-core/src/main/java/org/apache/maven/execution/DefaultMavenExecutionRequest.java +++ b/maven-core/src/main/java/org/apache/maven/execution/DefaultMavenExecutionRequest.java @@ -33,6 +33,7 @@ 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; @@ -535,8 +536,7 @@ public MavenExecutionRequest setSystemProperties( Properties properties ) { if ( properties != null ) { - this.systemProperties = new Properties(); - this.systemProperties.putAll( properties ); + this.systemProperties = SystemProperties.copyProperties( properties ); } else { diff --git a/maven-core/src/main/java/org/apache/maven/execution/DefaultMavenExecutionRequestPopulator.java b/maven-core/src/main/java/org/apache/maven/execution/DefaultMavenExecutionRequestPopulator.java index 2bed92f4b27c..9312b32489d0 100644 --- a/maven-core/src/main/java/org/apache/maven/execution/DefaultMavenExecutionRequestPopulator.java +++ b/maven-core/src/main/java/org/apache/maven/execution/DefaultMavenExecutionRequestPopulator.java @@ -24,6 +24,7 @@ import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.Set; import javax.inject.Inject; import javax.inject.Named; @@ -32,12 +33,18 @@ 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; @@ -89,6 +96,10 @@ public MavenExecutionRequest populateDefaults( MavenExecutionRequest request ) populateDefaultPluginGroups( request ); + injectDefaultRepositories( request ); + + injectDefaultPluginRepositories( request ); + return request; } @@ -102,6 +113,42 @@ private void populateDefaultPluginGroups( MavenExecutionRequest request ) 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 { diff --git a/maven-core/src/main/java/org/apache/maven/execution/MavenExecutionRequest.java b/maven-core/src/main/java/org/apache/maven/execution/MavenExecutionRequest.java index 1ec896635b4d..203b2b749891 100644 --- a/maven-core/src/main/java/org/apache/maven/execution/MavenExecutionRequest.java +++ b/maven-core/src/main/java/org/apache/maven/execution/MavenExecutionRequest.java @@ -356,15 +356,15 @@ public interface MavenExecutionRequest 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 @@ -404,15 +404,15 @@ public interface MavenExecutionRequest String getBuilderId(); /** - * - * @param toolchains all toolchains grouped by type - * @return this request + * + * @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 */ @@ -430,9 +430,9 @@ public interface MavenExecutionRequest /** * @since 3.3.0 - */ + */ MavenExecutionRequest setEventSpyDispatcher( EventSpyDispatcher eventSpyDispatcher ); - + /** * @since 3.3.0 */ diff --git a/maven-core/src/main/java/org/apache/maven/execution/MavenExecutionRequestPopulator.java b/maven-core/src/main/java/org/apache/maven/execution/MavenExecutionRequestPopulator.java index 4f254f7a04f1..c2d4c845fd40 100644 --- a/maven-core/src/main/java/org/apache/maven/execution/MavenExecutionRequestPopulator.java +++ b/maven-core/src/main/java/org/apache/maven/execution/MavenExecutionRequestPopulator.java @@ -54,7 +54,7 @@ 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 diff --git a/maven-core/src/main/java/org/apache/maven/execution/MavenSession.java b/maven-core/src/main/java/org/apache/maven/execution/MavenSession.java index 864c49ad5325..e59edc66a54c 100644 --- a/maven-core/src/main/java/org/apache/maven/execution/MavenSession.java +++ b/maven-core/src/main/java/org/apache/maven/execution/MavenSession.java @@ -39,6 +39,8 @@ import org.eclipse.aether.RepositorySystemSession; /** + * A Maven execution session. + * * @author Jason van Zyl */ public class MavenSession @@ -271,7 +273,7 @@ public void setProjectMap( Map projectMap ) { this.projectMap = projectMap; } - + /** This is a provisional method and may be removed */ public List getAllProjects() { @@ -283,24 +285,24 @@ public void setAllProjects( List allProjects ) { this.allProjects = allProjects; } - + /*if_not[MAVEN4]*/ // - // Deprecated + // Deprecated // - - private PlexusContainer container; - + + 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() + public Map getProjectMap() { return projectMap; } - + @Deprecated public MavenSession( PlexusContainer container, RepositorySystemSession repositorySession, MavenExecutionRequest request, MavenExecutionResult result ) @@ -311,7 +313,7 @@ public MavenSession( PlexusContainer container, RepositorySystemSession reposito this.settings = new SettingsAdapter( request ); this.repositorySession = repositorySession; } - + @Deprecated public MavenSession( PlexusContainer container, MavenExecutionRequest request, MavenExecutionResult result, MavenProject project ) @@ -361,7 +363,7 @@ 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 @@ -399,7 +401,7 @@ public Properties getExecutionProperties() return executionProperties; } - + @Deprecated public PlexusContainer getContainer() { @@ -432,7 +434,7 @@ public Map lookupMap( String role ) throws ComponentLookupException { return container.lookupMap( role ); - } - + } + /*end[MAVEN4]*/ } diff --git a/maven-core/src/main/java/org/apache/maven/execution/ProjectDependencyGraph.java b/maven-core/src/main/java/org/apache/maven/execution/ProjectDependencyGraph.java index 1db277db53c7..0d5584b8afc8 100644 --- a/maven-core/src/main/java/org/apache/maven/execution/ProjectDependencyGraph.java +++ b/maven-core/src/main/java/org/apache/maven/execution/ProjectDependencyGraph.java @@ -27,6 +27,7 @@ * Describes the inter-dependencies between projects in the reactor. * * @author Benjamin Bentmann + * @since 3.0-alpha */ public interface ProjectDependencyGraph { diff --git a/maven-core/src/main/java/org/apache/maven/extension/internal/CoreExports.java b/maven-core/src/main/java/org/apache/maven/extension/internal/CoreExports.java index e253e9fd81ad..1203371d319b 100644 --- a/maven-core/src/main/java/org/apache/maven/extension/internal/CoreExports.java +++ b/maven-core/src/main/java/org/apache/maven/extension/internal/CoreExports.java @@ -31,7 +31,7 @@ /** * 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 diff --git a/maven-core/src/main/java/org/apache/maven/graph/DefaultGraphBuilder.java b/maven-core/src/main/java/org/apache/maven/graph/DefaultGraphBuilder.java index 680d58469393..5be4d5ef5344 100644 --- a/maven-core/src/main/java/org/apache/maven/graph/DefaultGraphBuilder.java +++ b/maven-core/src/main/java/org/apache/maven/graph/DefaultGraphBuilder.java @@ -73,7 +73,7 @@ public Result build( MavenSession session ) { return dependencyGraph( session, session.getProjects(), false ); } - + List projects = session.getProjects(); if ( projects == null ) @@ -96,7 +96,7 @@ public Result build( MavenSession session ) return dependencyGraph( session, projects, false ); } } - + private Result dependencyGraph( MavenSession session, List projects, boolean applyMakeBehaviour ) { diff --git a/maven-core/src/main/java/org/apache/maven/graph/GraphBuilder.java b/maven-core/src/main/java/org/apache/maven/graph/GraphBuilder.java index fb7c4f2a1eaf..0f584d9203b7 100644 --- a/maven-core/src/main/java/org/apache/maven/graph/GraphBuilder.java +++ b/maven-core/src/main/java/org/apache/maven/graph/GraphBuilder.java @@ -23,6 +23,11 @@ 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"; diff --git a/maven-core/src/main/java/org/apache/maven/internal/aether/DefaultRepositorySystemSessionFactory.java b/maven-core/src/main/java/org/apache/maven/internal/aether/DefaultRepositorySystemSessionFactory.java index a0c54442a3df..248a3b6dd120 100644 --- a/maven-core/src/main/java/org/apache/maven/internal/aether/DefaultRepositorySystemSessionFactory.java +++ b/maven-core/src/main/java/org/apache/maven/internal/aether/DefaultRepositorySystemSessionFactory.java @@ -121,8 +121,10 @@ else if ( request.isUpdateSnapshots() ) } int errorPolicy = 0; - errorPolicy |= request.isCacheNotFound() ? ResolutionErrorPolicy.CACHE_NOT_FOUND : 0; - errorPolicy |= request.isCacheTransferError() ? ResolutionErrorPolicy.CACHE_TRANSFER_ERROR : 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 ) ); diff --git a/maven-core/src/main/java/org/apache/maven/lifecycle/Lifecycle.java b/maven-core/src/main/java/org/apache/maven/lifecycle/Lifecycle.java index 5fc99d532c55..8115bf89840f 100644 --- a/maven-core/src/main/java/org/apache/maven/lifecycle/Lifecycle.java +++ b/maven-core/src/main/java/org/apache/maven/lifecycle/Lifecycle.java @@ -72,7 +72,7 @@ public Map getDefaultLifecyclePhases() { return defaultPhases; } - + @Deprecated public Map getDefaultPhases() { diff --git a/maven-core/src/main/java/org/apache/maven/lifecycle/MojoExecutionConfigurator.java b/maven-core/src/main/java/org/apache/maven/lifecycle/MojoExecutionConfigurator.java index b85bac77c4a9..ee299f40cb80 100644 --- a/maven-core/src/main/java/org/apache/maven/lifecycle/MojoExecutionConfigurator.java +++ b/maven-core/src/main/java/org/apache/maven/lifecycle/MojoExecutionConfigurator.java @@ -25,7 +25,7 @@ /** * 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. - * + * * @provisional * @author Jason van Zyl * @since 3.3.1, MNG-5753 @@ -35,7 +35,7 @@ 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 diff --git a/maven-core/src/main/java/org/apache/maven/lifecycle/internal/LifecycleDependencyResolver.java b/maven-core/src/main/java/org/apache/maven/lifecycle/internal/LifecycleDependencyResolver.java index d83a8f41de75..e6ca6b67748a 100644 --- a/maven-core/src/main/java/org/apache/maven/lifecycle/internal/LifecycleDependencyResolver.java +++ b/maven-core/src/main/java/org/apache/maven/lifecycle/internal/LifecycleDependencyResolver.java @@ -76,7 +76,7 @@ public class LifecycleDependencyResolver @Inject private EventSpyDispatcher eventSpyDispatcher; - + @Inject private ProjectArtifactsCache projectArtifactsCache; @@ -127,13 +127,13 @@ public void resolveProjectDependencies( MavenProject project, Collection throw new LifecycleExecutionException( e ); } } - + Set artifacts; - ProjectArtifactsCache.Key cacheKey = projectArtifactsCache.createKey( project, scopesToCollect, + ProjectArtifactsCache.Key cacheKey = projectArtifactsCache.createKey( project, scopesToCollect, scopesToResolve, aggregating, session.getRepositorySession() ); ProjectArtifactsCache.CacheRecord recordArtifacts; recordArtifacts = projectArtifactsCache.get( cacheKey ); - + if ( recordArtifacts != null ) { artifacts = recordArtifacts.artifacts; @@ -142,7 +142,7 @@ public void resolveProjectDependencies( MavenProject project, Collection { try { - artifacts = getDependencies( project, scopesToCollect, scopesToResolve, session, aggregating, + artifacts = getDependencies( project, scopesToCollect, scopesToResolve, session, aggregating, projectArtifacts ); recordArtifacts = projectArtifactsCache.put( cacheKey, artifacts ); } diff --git a/maven-core/src/main/java/org/apache/maven/lifecycle/internal/LifecyclePluginResolver.java b/maven-core/src/main/java/org/apache/maven/lifecycle/internal/LifecyclePluginResolver.java index 956e71723c9b..f02552aec9f0 100644 --- a/maven-core/src/main/java/org/apache/maven/lifecycle/internal/LifecyclePluginResolver.java +++ b/maven-core/src/main/java/org/apache/maven/lifecycle/internal/LifecyclePluginResolver.java @@ -19,6 +19,9 @@ * 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; @@ -30,9 +33,6 @@ import org.codehaus.plexus.component.annotations.Component; import org.codehaus.plexus.component.annotations.Requirement; -import java.util.HashMap; -import java.util.Map; - /** * @since 3.0 * @author Benjamin Bentmann @@ -46,7 +46,6 @@ public class LifecyclePluginResolver @Requirement private PluginVersionResolver pluginVersionResolver; - public LifecyclePluginResolver( PluginVersionResolver pluginVersionResolver ) { this.pluginVersionResolver = pluginVersionResolver; @@ -65,9 +64,8 @@ public void resolveMissingPluginVersions( MavenProject project, MavenSession ses { if ( plugin.getVersion() == null ) { - PluginVersionRequest request = - new DefaultPluginVersionRequest( plugin, session.getRepositorySession(), - project.getRemotePluginRepositories() ); + PluginVersionRequest request = new DefaultPluginVersionRequest( plugin, session.getRepositorySession(), + project.getRemotePluginRepositories() ); plugin.setVersion( pluginVersionResolver.resolve( request ).getVersion() ); } versions.put( plugin.getKey(), plugin.getVersion() ); diff --git a/maven-core/src/main/java/org/apache/maven/lifecycle/internal/LifecycleStarter.java b/maven-core/src/main/java/org/apache/maven/lifecycle/internal/LifecycleStarter.java index cee80739234d..137715805d8b 100644 --- a/maven-core/src/main/java/org/apache/maven/lifecycle/internal/LifecycleStarter.java +++ b/maven-core/src/main/java/org/apache/maven/lifecycle/internal/LifecycleStarter.java @@ -65,7 +65,7 @@ public class LifecycleStarter @Requirement private Map builders; - + @Requirement private SessionScope sessionScope; diff --git a/maven-core/src/main/java/org/apache/maven/lifecycle/internal/ProjectArtifactFactory.java b/maven-core/src/main/java/org/apache/maven/lifecycle/internal/ProjectArtifactFactory.java index b4a810750907..2c3ac353d675 100644 --- a/maven-core/src/main/java/org/apache/maven/lifecycle/internal/ProjectArtifactFactory.java +++ b/maven-core/src/main/java/org/apache/maven/lifecycle/internal/ProjectArtifactFactory.java @@ -27,7 +27,7 @@ /** * Component interface responsible for creation of MavenProject#dependencyArtifacts instances. - * + * * @since 3.2.4 * @provisional This interface is part of work in progress and can be changed or removed without notice. */ diff --git a/maven-core/src/main/java/org/apache/maven/lifecycle/internal/builder/multithreaded/MultiThreadedBuilder.java b/maven-core/src/main/java/org/apache/maven/lifecycle/internal/builder/multithreaded/MultiThreadedBuilder.java index b3e35e0f6a14..14bf13b0892f 100644 --- a/maven-core/src/main/java/org/apache/maven/lifecycle/internal/builder/multithreaded/MultiThreadedBuilder.java +++ b/maven-core/src/main/java/org/apache/maven/lifecycle/internal/builder/multithreaded/MultiThreadedBuilder.java @@ -44,7 +44,11 @@ import org.codehaus.plexus.logging.Logger; /** - * Builds the full lifecycle in weave-mode (phase by phase as opposed to project-by-project) + * 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. * * @since 3.0 * @author Kristian Rosenvold @@ -73,9 +77,15 @@ public void build( MavenSession session, ReactorContext reactorContext, ProjectB List taskSegments, ReactorBuildStatus reactorBuildStatus ) throws ExecutionException, InterruptedException { - ExecutorService executor = - Executors.newFixedThreadPool( Math.min( session.getRequest().getDegreeOfConcurrency(), - session.getProjects().size() ), new BuildThreadFactory() ); + 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() ); @@ -150,7 +160,7 @@ private void multiThreadedProjectTaskSegmentBuild( ConcurrencyDependencyGraph an } catch ( ExecutionException e ) { - // TODO MNG-5766 changes likely made this redundant + // TODO MNG-5766 changes likely made this redundant rootSession.getResult().addException( e ); break; } diff --git a/maven-core/src/main/java/org/apache/maven/lifecycle/mapping/DefaultLifecycleMapping.java b/maven-core/src/main/java/org/apache/maven/lifecycle/mapping/DefaultLifecycleMapping.java index e6845a36e3b6..e33b9b2cfc0a 100644 --- a/maven-core/src/main/java/org/apache/maven/lifecycle/mapping/DefaultLifecycleMapping.java +++ b/maven-core/src/main/java/org/apache/maven/lifecycle/mapping/DefaultLifecycleMapping.java @@ -107,7 +107,7 @@ else if ( "default".equals( lifecycle ) ) return null; } } - + @Deprecated public Map getPhases( String lifecycle ) { diff --git a/maven-core/src/main/java/org/apache/maven/lifecycle/mapping/Lifecycle.java b/maven-core/src/main/java/org/apache/maven/lifecycle/mapping/Lifecycle.java index ad3e486eb1bf..afc82ae10077 100644 --- a/maven-core/src/main/java/org/apache/maven/lifecycle/mapping/Lifecycle.java +++ b/maven-core/src/main/java/org/apache/maven/lifecycle/mapping/Lifecycle.java @@ -62,7 +62,7 @@ public Map getLifecyclePhases() { return this.lifecyclePhases; } - + /** * Method setId * @@ -89,12 +89,12 @@ public Map getPhases() { return null; } - + if ( lphases.isEmpty() ) { return Collections.emptyMap(); } - + Map phases = new LinkedHashMap<>(); for ( Map.Entry e: lphases.entrySet() ) { diff --git a/maven-core/src/main/java/org/apache/maven/lifecycle/mapping/LifecycleMojo.java b/maven-core/src/main/java/org/apache/maven/lifecycle/mapping/LifecycleMojo.java index f2af879516c2..8d8fc18066dd 100644 --- a/maven-core/src/main/java/org/apache/maven/lifecycle/mapping/LifecycleMojo.java +++ b/maven-core/src/main/java/org/apache/maven/lifecycle/mapping/LifecycleMojo.java @@ -26,36 +26,36 @@ 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; diff --git a/maven-core/src/main/java/org/apache/maven/lifecycle/mapping/LifecyclePhase.java b/maven-core/src/main/java/org/apache/maven/lifecycle/mapping/LifecyclePhase.java index 295e6421d4d7..963c3b14b749 100644 --- a/maven-core/src/main/java/org/apache/maven/lifecycle/mapping/LifecyclePhase.java +++ b/maven-core/src/main/java/org/apache/maven/lifecycle/mapping/LifecyclePhase.java @@ -29,36 +29,36 @@ 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(); @@ -67,7 +67,7 @@ public void set( String goals ) } } } - + @Override public String toString() { @@ -91,7 +91,7 @@ public String toString() } return sb.toString(); } - + @Deprecated public static Map toLegacyMap( Map lifecyclePhases ) { @@ -99,12 +99,12 @@ public static Map toLegacyMap( Map lifec { return null; } - + if ( lifecyclePhases.isEmpty() ) { return Collections.emptyMap(); } - + Map phases = new LinkedHashMap<>(); for ( Map.Entry e: lifecyclePhases.entrySet() ) { @@ -112,5 +112,5 @@ public static Map toLegacyMap( Map lifec } return phases; } - + } diff --git a/maven-core/src/main/java/org/apache/maven/plugin/DefaultProjectArtifactsCache.java b/maven-core/src/main/java/org/apache/maven/plugin/DefaultProjectArtifactsCache.java index 1eaa627e741e..78a1765b16f4 100644 --- a/maven-core/src/main/java/org/apache/maven/plugin/DefaultProjectArtifactsCache.java +++ b/maven-core/src/main/java/org/apache/maven/plugin/DefaultProjectArtifactsCache.java @@ -54,11 +54,11 @@ protected static class CacheKey { private final String groupId; - + private final String artifactId; - + private final String version; - + private final Set dependencyArtifacts; private final WorkspaceRepository workspace; @@ -66,11 +66,11 @@ protected static class CacheKey private final LocalRepository localRepo; private final List repositories; - + private final Set collect; - + private final Set resolve; - + private boolean aggregating; private final int hashCode; @@ -79,11 +79,11 @@ 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 ) { @@ -93,7 +93,7 @@ public CacheKey( MavenProject project, List repositories, } } dependencyArtifacts = Collections.unmodifiableSet( deps ); - + workspace = CacheUtils.getWorkspace( session ); this.localRepo = session.getLocalRepository(); this.repositories = new ArrayList<>( repositories.size() ); @@ -109,10 +109,10 @@ public CacheKey( MavenProject project, List repositories, } } collect = scopesToCollect == null - ? Collections.emptySet() + ? Collections.emptySet() : Collections.unmodifiableSet( new HashSet<>( scopesToCollect ) ); - resolve = scopesToResolve == null - ? Collections.emptySet() + resolve = scopesToResolve == null + ? Collections.emptySet() : Collections.unmodifiableSet( new HashSet<>( scopesToResolve ) ); this.aggregating = aggregating; @@ -162,10 +162,10 @@ public boolean equals( Object o ) CacheKey that = (CacheKey) o; - return eq( groupId, that.groupId ) && eq( artifactId, that.artifactId ) && eq( version, that.version ) + 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( workspace, that.workspace ) && eq( localRepo, that.localRepo ) + && CacheUtils.repositoriesEquals( repositories, that.repositories ) && eq( collect, that.collect ) && eq( resolve, that.resolve ) && aggregating == that.aggregating; } @@ -181,7 +181,7 @@ private static boolean eq( T s1, T s2 ) public Key createKey( MavenProject project, Collection scopesToCollect, Collection scopesToResolve, boolean aggregating, RepositorySystemSession session ) { - return new CacheKey( project, project.getRemoteProjectRepositories(), scopesToCollect, scopesToResolve, + return new CacheKey( project, project.getRemoteProjectRepositories(), scopesToCollect, scopesToResolve, aggregating, session ); } diff --git a/maven-core/src/main/java/org/apache/maven/plugin/MavenPluginManager.java b/maven-core/src/main/java/org/apache/maven/plugin/MavenPluginManager.java index b228a1b4b7cf..c1ef63e7f4c5 100644 --- a/maven-core/src/main/java/org/apache/maven/plugin/MavenPluginManager.java +++ b/maven-core/src/main/java/org/apache/maven/plugin/MavenPluginManager.java @@ -95,7 +95,7 @@ void setupPluginRealm( PluginDescriptor pluginDescriptor, MavenSession session, /** * Sets up class realm for the specified build extensions plugin. - * + * * @since 3.3.0 */ ExtensionRealmCache.CacheRecord setupExtensionsRealm( MavenProject project, Plugin plugin, diff --git a/maven-core/src/main/java/org/apache/maven/plugin/PluginParameterExpressionEvaluator.java b/maven-core/src/main/java/org/apache/maven/plugin/PluginParameterExpressionEvaluator.java index a7eeb4e307c0..558908dbe839 100644 --- a/maven-core/src/main/java/org/apache/maven/plugin/PluginParameterExpressionEvaluator.java +++ b/maven-core/src/main/java/org/apache/maven/plugin/PluginParameterExpressionEvaluator.java @@ -52,7 +52,7 @@ * settings {@link MavenSession#getSettings()} * settings.* * basedir - * {@link MavenSession#getExecutionRootDirectory()} or + * {@link MavenSession#getExecutionRootDirectory()} or * System.getProperty( "user.dir" ) if null * mojoExecution the actual {@link MojoExecution} * mojo (since Maven 3)same as mojoExecution @@ -104,12 +104,12 @@ public PluginParameterExpressionEvaluator( MavenSession session, MojoExecution m this.project = session.getCurrentProject(); // - // Maven4: We may want to evaluate how this is used but we add these separate as the + // 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 ) diff --git a/maven-core/src/main/java/org/apache/maven/plugin/ProjectArtifactsCache.java b/maven-core/src/main/java/org/apache/maven/plugin/ProjectArtifactsCache.java index 42a95e509b07..2e564bad1ace 100644 --- a/maven-core/src/main/java/org/apache/maven/plugin/ProjectArtifactsCache.java +++ b/maven-core/src/main/java/org/apache/maven/plugin/ProjectArtifactsCache.java @@ -66,7 +66,7 @@ public CacheRecord( LifecycleExecutionException exception ) } } - Key createKey( MavenProject project, Collection scopesToCollect, Collection scopesToResolve, + Key createKey( MavenProject project, Collection scopesToCollect, Collection scopesToResolve, boolean aggregating, RepositorySystemSession session ); CacheRecord get( Key key ) throws LifecycleExecutionException; diff --git a/maven-core/src/main/java/org/apache/maven/plugin/version/internal/DefaultPluginVersionResolver.java b/maven-core/src/main/java/org/apache/maven/plugin/version/internal/DefaultPluginVersionResolver.java index f11ee956a34e..2275b7af6576 100644 --- a/maven-core/src/main/java/org/apache/maven/plugin/version/internal/DefaultPluginVersionResolver.java +++ b/maven-core/src/main/java/org/apache/maven/plugin/version/internal/DefaultPluginVersionResolver.java @@ -87,8 +87,6 @@ public class DefaultPluginVersionResolver public PluginVersionResult resolve( PluginVersionRequest request ) throws PluginVersionResolutionException { - logger.debug( "Resolving plugin version for " + request.getGroupId() + ":" + request.getArtifactId() ); - PluginVersionResult result = resolveFromProject( request ); if ( result == null ) @@ -103,8 +101,8 @@ public PluginVersionResult resolve( PluginVersionRequest request ) } else if ( logger.isDebugEnabled() ) { - logger.debug( "Resolved plugin version for " + request.getGroupId() + ":" + request.getArtifactId() - + " to " + result.getVersion() + " from POM " + request.getPom() ); + logger.debug( "Resolved plugin version for " + request.getGroupId() + ":" + request.getArtifactId() + " to " + + result.getVersion() + " from POM " + request.getPom() ); } return result; @@ -156,6 +154,7 @@ private void selectVersion( DefaultPluginVersionResult result, PluginVersionRequ String version = null; ArtifactRepository repo = null; + logger.info( "selectVersion:" + request.getGroupId() ); if ( StringUtils.isNotEmpty( versions.releaseVersion ) ) { version = versions.releaseVersion; @@ -351,6 +350,7 @@ private PluginVersionResult resolveFromProject( PluginVersionRequest request ) { PluginVersionResult result = null; + logger.info( "resolveFromProject:" + request.getGroupId() ); if ( request.getPom() != null && request.getPom().getBuild() != null ) { Build build = request.getPom().getBuild(); diff --git a/maven-core/src/main/java/org/apache/maven/project/DefaultProjectBuilder.java b/maven-core/src/main/java/org/apache/maven/project/DefaultProjectBuilder.java index 2406ff90e1ba..25124e42d1a8 100644 --- a/maven-core/src/main/java/org/apache/maven/project/DefaultProjectBuilder.java +++ b/maven-core/src/main/java/org/apache/maven/project/DefaultProjectBuilder.java @@ -895,7 +895,7 @@ class InternalConfig public final List repositories; public final ReactorModelPool modelPool; - + public final ReactorModelCache modelCache; InternalConfig( ProjectBuildingRequest request, ReactorModelPool modelPool, ReactorModelCache modelCache ) diff --git a/maven-core/src/main/java/org/apache/maven/project/DefaultProjectBuildingRequest.java b/maven-core/src/main/java/org/apache/maven/project/DefaultProjectBuildingRequest.java index 97eb2762c552..dafbefd3700a 100644 --- a/maven-core/src/main/java/org/apache/maven/project/DefaultProjectBuildingRequest.java +++ b/maven-core/src/main/java/org/apache/maven/project/DefaultProjectBuildingRequest.java @@ -28,6 +28,7 @@ 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 @@ -166,11 +167,7 @@ public ProjectBuildingRequest setSystemProperties( Properties systemProperties ) { if ( systemProperties != null ) { - this.systemProperties = new Properties(); - synchronized ( systemProperties ) - { // avoid concurrentmodification if someone else sets/removes an unrelated system property - this.systemProperties.putAll( systemProperties ); - } + this.systemProperties = SystemProperties.copyProperties( systemProperties ); } else { diff --git a/maven-core/src/main/java/org/apache/maven/project/MavenProject.java b/maven-core/src/main/java/org/apache/maven/project/MavenProject.java index d7d6ce8e8553..3e31c7cc1378 100644 --- a/maven-core/src/main/java/org/apache/maven/project/MavenProject.java +++ b/maven-core/src/main/java/org/apache/maven/project/MavenProject.java @@ -260,7 +260,7 @@ public void setFile( File file ) /** * Sets project {@code file} without changing project {@code basedir}. - * + * * @since 3.2.4 */ public void setPomFile( File file ) diff --git a/maven-core/src/main/java/org/apache/maven/project/RepositorySessionDecorator.java b/maven-core/src/main/java/org/apache/maven/project/RepositorySessionDecorator.java index 679ee008856e..1b297336c4ad 100644 --- a/maven-core/src/main/java/org/apache/maven/project/RepositorySessionDecorator.java +++ b/maven-core/src/main/java/org/apache/maven/project/RepositorySessionDecorator.java @@ -23,7 +23,7 @@ /** * Component interface that allows per-project customization of Aether repository system sessions. - * + * * @since 3.2.4 * @provisional This interface is part of work in progress and can be changed or removed without notice. */ diff --git a/maven-core/src/main/java/org/apache/maven/properties/internal/SystemProperties.java b/maven-core/src/main/java/org/apache/maven/properties/internal/SystemProperties.java index 037255819862..16cf82808055 100644 --- a/maven-core/src/main/java/org/apache/maven/properties/internal/SystemProperties.java +++ b/maven-core/src/main/java/org/apache/maven/properties/internal/SystemProperties.java @@ -33,19 +33,33 @@ public class SystemProperties */ public static void addSystemProperties( Properties props ) { - for ( String key : System.getProperties().stringPropertyNames() ) - { - props.put( key, System.getProperty( key ) ); - } + props.putAll( getSystemProperties() ); } /** - * Returns System.properties copy. + * 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() { - Properties systemProperties = new Properties(); - addSystemProperties( systemProperties ); - return systemProperties; + 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; + } + } diff --git a/maven-core/src/main/java/org/apache/maven/repository/RepositorySystem.java b/maven-core/src/main/java/org/apache/maven/repository/RepositorySystem.java index 5766b9886ce6..fcc0f7770c4d 100644 --- a/maven-core/src/main/java/org/apache/maven/repository/RepositorySystem.java +++ b/maven-core/src/main/java/org/apache/maven/repository/RepositorySystem.java @@ -50,18 +50,8 @@ public interface RepositorySystem File defaultUserLocalRepository = new File( userMavenConfigurationHome, "repository" ); - /** - * @deprecation As of 3.4, Maven no longer falls back to a hard-coded default repository with identifier - * {@code central} if such a repository is not provided in the settings or the POM. - */ - @Deprecated String DEFAULT_REMOTE_REPO_ID = "central"; - /** - * @deprecation As of 3.4, Maven no longer falls back to a hard-coded default repository with identifier - * {@code central} if such a repository is not provided in the settings or the POM. - */ - @Deprecated String DEFAULT_REMOTE_REPO_URL = "https://repo.maven.apache.org/maven2"; Artifact createArtifact( String groupId, String artifactId, String version, String packaging ); @@ -80,11 +70,6 @@ Artifact createArtifactWithClassifier( String groupId, String artifactId, String ArtifactRepository buildArtifactRepository( Repository repository ) throws InvalidRepositoryException; - /** - * @deprecation As of 3.4, Maven no longer falls back to a hard-coded default repository with identifier - * {@code central} if such a repository is not provided in the settings or the POM. - */ - @Deprecated ArtifactRepository createDefaultRemoteRepository() throws InvalidRepositoryException; diff --git a/maven-core/src/main/java/org/apache/maven/settings/DefaultMavenSettingsBuilder.java b/maven-core/src/main/java/org/apache/maven/settings/DefaultMavenSettingsBuilder.java index 820d886e29b9..ec499cabfe9f 100644 --- a/maven-core/src/main/java/org/apache/maven/settings/DefaultMavenSettingsBuilder.java +++ b/maven-core/src/main/java/org/apache/maven/settings/DefaultMavenSettingsBuilder.java @@ -66,7 +66,7 @@ public Settings buildSettings( File userSettingsFile ) throws IOException, XmlPullParserException { File globalSettingsFile = - getFile( "${maven.home}/conf/settings.xml", "maven.home", + getFile( "${maven.conf}/settings.xml", "maven.home", MavenSettingsBuilder.ALT_GLOBAL_SETTINGS_XML_LOCATION ); SettingsBuildingRequest request = new DefaultSettingsBuildingRequest(); diff --git a/maven-core/src/main/java/org/apache/maven/toolchain/DefaultToolchain.java b/maven-core/src/main/java/org/apache/maven/toolchain/DefaultToolchain.java index 59f5e13fbb98..8e5359dbb1d8 100644 --- a/maven-core/src/main/java/org/apache/maven/toolchain/DefaultToolchain.java +++ b/maven-core/src/main/java/org/apache/maven/toolchain/DefaultToolchain.java @@ -49,7 +49,7 @@ public abstract class DefaultToolchain // should have been AbstractToolchain... private Logger logger; /** - * + * * @param model the model, must not be {@code null} * @param logger the logger, must not be {@code null} */ @@ -61,7 +61,7 @@ protected DefaultToolchain( ToolchainModel model, Logger logger ) } /** - * + * * @param model the model, must not be {@code null} * @param type the type * @param logger the logger, must not be {@code null} @@ -164,7 +164,7 @@ public int hashCode() } return hashCode; } - + @Override public String toString() { @@ -182,9 +182,9 @@ public String toString() builder.append( ';' ); } } - + builder.append( '}' ); - + return builder.toString(); } } diff --git a/maven-core/src/main/java/org/apache/maven/toolchain/DefaultToolchainManager.java b/maven-core/src/main/java/org/apache/maven/toolchain/DefaultToolchainManager.java index 9f7a26b4ed6b..e36f9b0c7558 100644 --- a/maven-core/src/main/java/org/apache/maven/toolchain/DefaultToolchainManager.java +++ b/maven-core/src/main/java/org/apache/maven/toolchain/DefaultToolchainManager.java @@ -45,7 +45,7 @@ public class DefaultToolchainManager @Requirement( role = ToolchainFactory.class ) Map factories; - + @Override public Toolchain getToolchainFromBuildContext( String type, MavenSession session ) { @@ -56,7 +56,7 @@ public Toolchain getToolchainFromBuildContext( String type, MavenSession session if ( model != null ) { List toolchains = selectToolchains( Collections.singletonList( model ), type, null ); - + if ( !toolchains.isEmpty() ) { return toolchains.get( 0 ); @@ -109,7 +109,7 @@ private List selectToolchains( List models, String ty } return toolchains; } - + Map retrieveContext( MavenSession session ) { Map context = null; diff --git a/maven-core/src/main/java/org/apache/maven/toolchain/DefaultToolchainManagerPrivate.java b/maven-core/src/main/java/org/apache/maven/toolchain/DefaultToolchainManagerPrivate.java index 40db38994d98..d33ef9bc1224 100644 --- a/maven-core/src/main/java/org/apache/maven/toolchain/DefaultToolchainManagerPrivate.java +++ b/maven-core/src/main/java/org/apache/maven/toolchain/DefaultToolchainManagerPrivate.java @@ -60,7 +60,7 @@ public ToolchainPrivate[] getToolchainsForType( String type, MavenSession contex toRet.add( fact.createToolchain( toolchainModel ) ); } } - + // add default toolchain ToolchainPrivate tool = fact.createDefaultToolchain(); if ( tool != null ) diff --git a/maven-core/src/main/java/org/apache/maven/toolchain/RequirementMatcherFactory.java b/maven-core/src/main/java/org/apache/maven/toolchain/RequirementMatcherFactory.java index 3d6917bd82f3..02f5cc0a4200 100644 --- a/maven-core/src/main/java/org/apache/maven/toolchain/RequirementMatcherFactory.java +++ b/maven-core/src/main/java/org/apache/maven/toolchain/RequirementMatcherFactory.java @@ -59,7 +59,7 @@ public boolean matches( String requirement ) { return provides.equalsIgnoreCase( requirement ); } - + @Override public String toString() { @@ -99,7 +99,7 @@ public boolean matches( String requirement ) return false; } } - + @Override public String toString() { diff --git a/maven-core/src/main/java/org/apache/maven/toolchain/ToolchainManager.java b/maven-core/src/main/java/org/apache/maven/toolchain/ToolchainManager.java index bc0a91dd4c75..134c24da0a52 100644 --- a/maven-core/src/main/java/org/apache/maven/toolchain/ToolchainManager.java +++ b/maven-core/src/main/java/org/apache/maven/toolchain/ToolchainManager.java @@ -49,11 +49,11 @@ public interface ToolchainManager * @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} diff --git a/maven-core/src/main/java/org/apache/maven/toolchain/ToolchainManagerPrivate.java b/maven-core/src/main/java/org/apache/maven/toolchain/ToolchainManagerPrivate.java index 6836bf1c7985..ed50bd46abf5 100644 --- a/maven-core/src/main/java/org/apache/maven/toolchain/ToolchainManagerPrivate.java +++ b/maven-core/src/main/java/org/apache/maven/toolchain/ToolchainManagerPrivate.java @@ -37,7 +37,7 @@ 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) diff --git a/maven-core/src/main/java/org/apache/maven/toolchain/ToolchainPrivate.java b/maven-core/src/main/java/org/apache/maven/toolchain/ToolchainPrivate.java index 756cd957c95d..d935661e1e55 100644 --- a/maven-core/src/main/java/org/apache/maven/toolchain/ToolchainPrivate.java +++ b/maven-core/src/main/java/org/apache/maven/toolchain/ToolchainPrivate.java @@ -40,7 +40,7 @@ public interface ToolchainPrivate boolean matchesRequirements( Map requirements ); /** - * + * * @return the original model wrapped by this interface */ ToolchainModel getModel(); diff --git a/maven-core/src/main/java/org/apache/maven/toolchain/building/DefaultToolchainsBuilder.java b/maven-core/src/main/java/org/apache/maven/toolchain/building/DefaultToolchainsBuilder.java index 7983388bd289..7abd0fe79cae 100644 --- a/maven-core/src/main/java/org/apache/maven/toolchain/building/DefaultToolchainsBuilder.java +++ b/maven-core/src/main/java/org/apache/maven/toolchain/building/DefaultToolchainsBuilder.java @@ -39,7 +39,7 @@ import org.apache.maven.toolchain.model.TrackableBase; /** - * + * * @author Robert Scholte * @since 3.3.0 */ @@ -49,7 +49,7 @@ public class DefaultToolchainsBuilder implements ToolchainsBuilder { private MavenToolchainMerger toolchainsMerger = new MavenToolchainMerger(); - + @Inject private ToolchainsReader toolchainsReader; @@ -58,21 +58,21 @@ 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() ); } @@ -119,7 +119,7 @@ private PersistedToolchains readToolchains( Source toolchainsSource, ToolchainsB return toolchains; } - + private boolean hasErrors( List problems ) { if ( problems != null ) diff --git a/maven-core/src/main/java/org/apache/maven/toolchain/building/DefaultToolchainsBuildingRequest.java b/maven-core/src/main/java/org/apache/maven/toolchain/building/DefaultToolchainsBuildingRequest.java index 144d724cffa2..3c0e65d4779d 100644 --- a/maven-core/src/main/java/org/apache/maven/toolchain/building/DefaultToolchainsBuildingRequest.java +++ b/maven-core/src/main/java/org/apache/maven/toolchain/building/DefaultToolchainsBuildingRequest.java @@ -33,7 +33,7 @@ public class DefaultToolchainsBuildingRequest private Source globalToolchainsSource; private Source userToolchainsSource; - + @Override public Source getGlobalToolchainsSource() { diff --git a/maven-core/src/main/java/org/apache/maven/toolchain/building/DefaultToolchainsBuildingResult.java b/maven-core/src/main/java/org/apache/maven/toolchain/building/DefaultToolchainsBuildingResult.java index 60ca24410ec0..d06650c29822 100644 --- a/maven-core/src/main/java/org/apache/maven/toolchain/building/DefaultToolchainsBuildingResult.java +++ b/maven-core/src/main/java/org/apache/maven/toolchain/building/DefaultToolchainsBuildingResult.java @@ -27,7 +27,7 @@ /** * Holds the result of the merged toolchains and holds the problems during this build, if any. - * + * * @author Robert Scholte * @since 3.3.0 */ @@ -36,12 +36,12 @@ public class DefaultToolchainsBuildingResult { 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. */ @@ -56,7 +56,7 @@ public PersistedToolchains getEffectiveToolchains() { return effectiveToolchains; } - + @Override public List getProblems() { diff --git a/maven-core/src/main/java/org/apache/maven/toolchain/building/ToolchainsBuildingResult.java b/maven-core/src/main/java/org/apache/maven/toolchain/building/ToolchainsBuildingResult.java index 592fb98c3bb1..f7c5f71554a8 100644 --- a/maven-core/src/main/java/org/apache/maven/toolchain/building/ToolchainsBuildingResult.java +++ b/maven-core/src/main/java/org/apache/maven/toolchain/building/ToolchainsBuildingResult.java @@ -42,7 +42,7 @@ public interface ToolchainsBuildingResult /** * Return a list of problems, if any. - * + * * @return a list of problems, never {@code null}. */ List getProblems(); diff --git a/maven-core/src/main/java/org/apache/maven/toolchain/java/DefaultJavaToolChain.java b/maven-core/src/main/java/org/apache/maven/toolchain/java/DefaultJavaToolChain.java index 9cfcff385554..ac29f1f6d682 100644 --- a/maven-core/src/main/java/org/apache/maven/toolchain/java/DefaultJavaToolChain.java +++ b/maven-core/src/main/java/org/apache/maven/toolchain/java/DefaultJavaToolChain.java @@ -26,7 +26,7 @@ * 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. */ diff --git a/maven-core/src/main/java/org/apache/maven/toolchain/merge/MavenToolchainMerger.java b/maven-core/src/main/java/org/apache/maven/toolchain/merge/MavenToolchainMerger.java index ca910d8749c1..43888eda1a18 100644 --- a/maven-core/src/main/java/org/apache/maven/toolchain/merge/MavenToolchainMerger.java +++ b/maven-core/src/main/java/org/apache/maven/toolchain/merge/MavenToolchainMerger.java @@ -28,7 +28,7 @@ import org.codehaus.plexus.util.xml.Xpp3Dom; /** - * + * * @author Robert Scholte * @since 3.2.4 */ @@ -55,14 +55,14 @@ private void shallowMerge( List dominant, List r 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 ) { diff --git a/maven-core/src/main/mdo/toolchains.mdo b/maven-core/src/main/mdo/toolchains.mdo index 4740d1b96c60..161e5a4d37b4 100644 --- a/maven-core/src/main/mdo/toolchains.mdo +++ b/maven-core/src/main/mdo/toolchains.mdo @@ -182,7 +182,7 @@ diff --git a/maven-core/src/site/apt/index.apt b/maven-core/src/site/apt/index.apt index 966b57c518ba..1e7a68ee68f6 100644 --- a/maven-core/src/site/apt/index.apt +++ b/maven-core/src/site/apt/index.apt @@ -27,14 +27,25 @@ Maven Core Maven Core classes managing the whole build process. -* Useful entry points +* 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}}), + 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 @@ -47,14 +58,6 @@ Maven Core * {{{./apidocs/org/apache/maven/plugin/PluginParameterExpressionEvaluator.html}PluginParameterExpressionEvaluator}}, used to evaluate plugin parameters values during Mojo configuration, - * {{{/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}}, - - * {{{./extension.html}extension descriptor}} and {{{./core-extensions.html}core extensions}}, - * <<>> 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. diff --git a/maven-core/src/site/apt/scripting-support/marmalade-support.apt b/maven-core/src/site/apt/scripting-support/marmalade-support.apt deleted file mode 100644 index 7a8096620a43..000000000000 --- a/maven-core/src/site/apt/scripting-support/marmalade-support.apt +++ /dev/null @@ -1,196 +0,0 @@ -~~ Licensed to the Apache Software Foundation (ASF) under one -~~ or more contributor license agreements. See the NOTICE file -~~ distributed with this work for additional information -~~ regarding copyright ownership. The ASF licenses this file -~~ to you under the Apache License, Version 2.0 (the -~~ "License"); you may not use this file except in compliance -~~ with the License. You may obtain a copy of the License at -~~ -~~ http://www.apache.org/licenses/LICENSE-2.0 -~~ -~~ Unless required by applicable law or agreed to in writing, -~~ software distributed under the License is distributed on an -~~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -~~ KIND, either express or implied. See the License for the -~~ specific language governing permissions and limitations -~~ under the License. - - --- - Marmalade Mojo Support - Notes - --- - John Casey - --- - 07-Feb-2005 - --- - -Marmalade Support - -*Abstract - - This document will track the design and implementation issues involved in - adding support to m2 for marmalade-based mojos. - -*Design Notes - - [[1]] <> - - As in all mojo specifications, it is ideal that the descriptor for - a marmalade-based mojo be inline with the source code. This centralizes - all maintenance related to a single mojo to a single point of maintenance. - - The following is what I'm thinking as of now: - - - a marmalade-based mojo should look something like: - -+---+ - - - - mmld - mmldCompile - compile - Used to compile marmalade scripts into java beans. - - - - - - - - - classpath - The compilation classpath - java.util.List - #pom.artifacts - - - - - - - - - - - - - - - - -+---+ -[NOTE] All empty elements above signify optional elements, usage specification. - - [[2]] <> - - The marmalade mojo packager will: - - [[a]] Locate all *.mmld files within the scripts directory of the project. - - The scripts directory should be tied to the script language within - the POM. Until we have multiple language support in the POM, we'll - use something like: <<>>. - - [[b]] For each script found: - - [[i]] Execute the script with "gatherMetadata=true" in the context. - - [[ii]] Retrieve the mojo descriptor from the resulting "metadata" - variable in the context. - - [[iii]] Cache the mojo descriptor in aggregator for subsequent - output to plugin descriptor file. - - [[c]] Copy all scripts to the target directory. Preserve relative paths. - - [[d]] <> - - [[e]] Use the project's dependencies and other info to form the plugin - descriptor's header (non-mojo-specific info). - - [[f]] Use the PluginGenerator from maven-plugin-tools to generate a - META-INF/plexus/plugin.xml to the target directory. - - [[g]] Continue with lifecycle. - - This may include compilation of java helper classes, etc. and - plugin-artifact packaging, presumably via 'jar:jar' or similar. - - [[3]] <> - - The marmalade mojo loader will: - - [[a]] Retrieve the implementation spec (this is the path of the script, - relative to the root of the plugin filesystem...jar, etc.) to - $path. - - [[b]] Use the context classloader to retrieve a reader to $path. - - [[c]] Build the ScriptBuilder corresponding to the script. - - [[d]] Create a new MarmaladeMojo instance which adapts the mojo calling - semantics to the creation/execution of a marmalade script. - - Execution involves: - - [[i]] Creating a new MarmaladeScript instance. - - [[ii]] Creating an execution context which references all I/O - from the main Maven execution thread, and embeds: - - - #request == MavenExecutionRequest - - - #response == MavenExecutionResponse - - - Any globally configured environmental constraints, such - as a global preserve-whitespace setting - - [[iii]] Execution of the script using the execution context. - - [[iv]] Export of the resulting context, minus any surviving input - variables, to the MavenExecutionResponse's out-params. - -*Implementation Issues - - [[1]] How do we make Maven smart enough to switch loader implementations based - on some sub-type of maven-plugin? - - This is important, since the default mojo loader will not be smart - enough to do the job, and embedding this behavior in that loader is not - scalable or extensible enough to accommodate future expansion into the - realms of jython, groovy, etc... - - <> - - We'll plan on using some sort of language specification in the mojo - descriptor to determine which mojo loader to use, then we'll populate - the PluginLoader/PluginManager with a map of known languages->loaders. - - [[2]] How do we make the plugin:install process smart enough to switch - generator implementations based on some sub-type of maven-plugin? - - This is closely related to [1] above. - - <> - - See update in [3]. - - [[3]] Do we want to allow mixed-bag plugin implementations? - - These might include a mix of standard-java and marmalade mojos. It - strikes me that many marmalade-based mojos may use beans/tags that are - actually adapter classes for other third-party APIs (why they wouldn't - implement everything as java mojos in this cases is beyond me). If they - have java source inside the plugin source directory, we should probably - compile it and bundle it with the plugin scripts; but what if this source - also has mojo annotations? This will have implications for [1] and [2] - above. - - <> - - We will plan on allowing this sort of implementation, and simply start - by applying all known generators which have a source directory set in - the POM (or later, have a section, maybe). At any rate, - helper classes will be allowed for script-based mojos. diff --git a/maven-core/src/test/java/org/apache/maven/execution/DefaultMavenExecutionRequestPopulatorTest.java b/maven-core/src/test/java/org/apache/maven/execution/DefaultMavenExecutionRequestPopulatorTest.java index 15a7a7b3b6a8..bcc5895b7b9d 100644 --- a/maven-core/src/test/java/org/apache/maven/execution/DefaultMavenExecutionRequestPopulatorTest.java +++ b/maven-core/src/test/java/org/apache/maven/execution/DefaultMavenExecutionRequestPopulatorTest.java @@ -34,7 +34,7 @@ public class DefaultMavenExecutionRequestPopulatorTest { @Inject MavenExecutionRequestPopulator testee; - + public void testPluginRepositoryInjection() throws Exception { diff --git a/maven-core/src/test/java/org/apache/maven/lifecycle/LifecycleExecutorTest.java b/maven-core/src/test/java/org/apache/maven/lifecycle/LifecycleExecutorTest.java index 951f133df42b..dfa1817b8f4d 100644 --- a/maven-core/src/test/java/org/apache/maven/lifecycle/LifecycleExecutorTest.java +++ b/maven-core/src/test/java/org/apache/maven/lifecycle/LifecycleExecutorTest.java @@ -409,7 +409,7 @@ public List getDownstreamProjects( MavenProject project, boolean t { return Collections.emptyList(); } - + public java.util.List getAllSortedProjects() { return Collections.emptyList(); diff --git a/maven-core/src/test/java/org/apache/maven/lifecycle/internal/stub/AboutTheStubs.html b/maven-core/src/test/java/org/apache/maven/lifecycle/internal/stub/AboutTheStubs.html index 8ad74b96bcbe..02332822bd53 100644 --- a/maven-core/src/test/java/org/apache/maven/lifecycle/internal/stub/AboutTheStubs.html +++ b/maven-core/src/test/java/org/apache/maven/lifecycle/internal/stub/AboutTheStubs.html @@ -36,7 +36,7 @@

Design

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 diff --git a/maven-core/src/test/java/org/apache/maven/lifecycle/mapping/LifecyclePhaseTest.java b/maven-core/src/test/java/org/apache/maven/lifecycle/mapping/LifecyclePhaseTest.java index 0d8cbdc68936..f60eace0a8dd 100644 --- a/maven-core/src/test/java/org/apache/maven/lifecycle/mapping/LifecyclePhaseTest.java +++ b/maven-core/src/test/java/org/apache/maven/lifecycle/mapping/LifecyclePhaseTest.java @@ -33,38 +33,38 @@ 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() ); diff --git a/maven-core/src/test/java/org/apache/maven/plugin/PluginManagerTest.java b/maven-core/src/test/java/org/apache/maven/plugin/PluginManagerTest.java index 025e77255b39..ed7f56c7a9e6 100644 --- a/maven-core/src/test/java/org/apache/maven/plugin/PluginManagerTest.java +++ b/maven-core/src/test/java/org/apache/maven/plugin/PluginManagerTest.java @@ -336,7 +336,7 @@ public void testBuildExtensionsPluginLoading() pluginManager.loadPlugin( plugin, session.getCurrentProject().getRemotePluginRepositories(), session.getRepositorySession() ); ClassRealm pluginRealm = pluginManager.getPluginRealm( session, pluginDescriptor ); - + assertEquals(pluginRealm, pluginDescriptor.getComponents().get(0).getRealm()); } } diff --git a/maven-core/src/test/java/org/apache/maven/project/AbstractMavenProjectTestCase.java b/maven-core/src/test/java/org/apache/maven/project/AbstractMavenProjectTestCase.java index 68f02199547b..147aa9d96e7f 100644 --- a/maven-core/src/test/java/org/apache/maven/project/AbstractMavenProjectTestCase.java +++ b/maven-core/src/test/java/org/apache/maven/project/AbstractMavenProjectTestCase.java @@ -23,10 +23,7 @@ import java.util.Arrays; 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.model.building.ModelBuildingException; import org.apache.maven.model.building.ModelBuildingRequest; import org.apache.maven.model.building.ModelProblem; @@ -176,17 +173,9 @@ protected MavenProject getProject( File pom ) protected MavenProject getProjectFromRemoteRepository( final File pom ) throws Exception { - final ArtifactRepository testRepository = - new MavenArtifactRepository( "test", - "file://" + new File( System.getProperty( "basedir", "" ), - "src/test/remote-repo" ).toURI().getPath(), - new DefaultRepositoryLayout(), - new ArtifactRepositoryPolicy(), - new ArtifactRepositoryPolicy() ); - final ProjectBuildingRequest configuration = new DefaultProjectBuildingRequest(); configuration.setLocalRepository( this.getLocalRepository() ); - configuration.setRemoteRepositories( Arrays.asList( testRepository ) ); + configuration.setRemoteRepositories( Arrays.asList( this.repositorySystem.createDefaultRemoteRepository() ) ); initRepoSession( configuration ); return projectBuilder.build( pom, configuration ).getProject(); diff --git a/maven-core/src/test/java/org/apache/maven/project/PomConstructionTest.java b/maven-core/src/test/java/org/apache/maven/project/PomConstructionTest.java index 988df76b2b66..23b1a1bc48f0 100644 --- a/maven-core/src/test/java/org/apache/maven/project/PomConstructionTest.java +++ b/maven-core/src/test/java/org/apache/maven/project/PomConstructionTest.java @@ -1482,7 +1482,7 @@ public void testPluginManagementDuplicate() throws Exception { PomTestWrapper pom = this.buildPom( "plugin-management-duplicate/sub" ); - assertEquals( 12, ( (List) pom.getValue( "build/pluginManagement/plugins" ) ).size() ); + assertEquals( 8, ( (List) pom.getValue( "build/pluginManagement/plugins" ) ).size() ); } public void testDistributionManagement() diff --git a/maven-core/src/test/java/org/apache/maven/project/artifact/DefaultMavenMetadataCacheTest.java b/maven-core/src/test/java/org/apache/maven/project/artifact/DefaultMavenMetadataCacheTest.java index dde864a326df..6b103b2c9fbb 100644 --- a/maven-core/src/test/java/org/apache/maven/project/artifact/DefaultMavenMetadataCacheTest.java +++ b/maven-core/src/test/java/org/apache/maven/project/artifact/DefaultMavenMetadataCacheTest.java @@ -19,15 +19,11 @@ * under the License. */ -import java.io.File; 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.repository.ArtifactRepositoryPolicy; -import org.apache.maven.artifact.repository.MavenArtifactRepository; -import org.apache.maven.artifact.repository.layout.DefaultRepositoryLayout; import org.apache.maven.artifact.resolver.filter.ExcludesArtifactFilter; import org.apache.maven.project.artifact.DefaultMavenMetadataCache.CacheKey; import org.apache.maven.repository.DelegatingLocalArtifactRepository; @@ -57,36 +53,19 @@ protected void tearDown() super.tearDown(); } - @SuppressWarnings( "deprecation" ) public void testCacheKey() throws Exception { Artifact a1 = repositorySystem.createArtifact( "testGroup", "testArtifact", "1.2.3", "jar" ); - ArtifactRepository lr1 = - new DelegatingLocalArtifactRepository( repositorySystem.createDefaultLocalRepository() ); - - ArtifactRepository rr1 = new MavenArtifactRepository( "test", - "file://" + new File( System.getProperty( "basedir", "" ), - "src/test/remote-repo" ).toURI(). - getPath(), - new DefaultRepositoryLayout(), - new ArtifactRepositoryPolicy(), - new ArtifactRepositoryPolicy() ); - + @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" ); - ArtifactRepository lr2 = - new DelegatingLocalArtifactRepository( repositorySystem.createDefaultLocalRepository() ); - - ArtifactRepository rr2 = new MavenArtifactRepository( "test", - "file://" + new File( System.getProperty( "basedir", "" ), - "src/test/remote-repo" ).toURI(). - getPath(), - new DefaultRepositoryLayout(), - new ArtifactRepositoryPolicy(), - new ArtifactRepositoryPolicy() ); - + @SuppressWarnings( "deprecation" ) + ArtifactRepository lr2 = new DelegatingLocalArtifactRepository( repositorySystem.createDefaultLocalRepository() ); + ArtifactRepository rr2 = repositorySystem.createDefaultRemoteRepository(); a2.setDependencyFilter( new ExcludesArtifactFilter( Arrays.asList( "foo" ) ) ); // sanity checks @@ -97,7 +76,6 @@ public void testCacheKey() 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() ); + assertEquals(k1.hashCode(), k2.hashCode()); } - } diff --git a/maven-core/src/test/java/org/apache/maven/repository/TestRepositorySystem.java b/maven-core/src/test/java/org/apache/maven/repository/TestRepositorySystem.java index 5a76b2640ec3..0e054c6a76f5 100644 --- a/maven-core/src/test/java/org/apache/maven/repository/TestRepositorySystem.java +++ b/maven-core/src/test/java/org/apache/maven/repository/TestRepositorySystem.java @@ -106,15 +106,13 @@ public ArtifactRepository createDefaultLocalRepository() return createLocalRepository( new File( System.getProperty( "basedir", "" ), "target/local-repo" ).getAbsoluteFile() ); } - /** - * @deprecation As of 3.4, Maven no longer falls back to a hard-coded default repository with identifier - * {@code central} if such a repository is not provided in the settings or the POM. - */ - @Deprecated public ArtifactRepository createDefaultRemoteRepository() throws InvalidRepositoryException { - throw new UnsupportedOperationException(); + 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 ) diff --git a/maven-core/src/test/java/org/apache/maven/toolchain/DefaultToolchainManagerPrivateTest.java b/maven-core/src/test/java/org/apache/maven/toolchain/DefaultToolchainManagerPrivateTest.java index 1e4844154545..9b647cd4982b 100644 --- a/maven-core/src/test/java/org/apache/maven/toolchain/DefaultToolchainManagerPrivateTest.java +++ b/maven-core/src/test/java/org/apache/maven/toolchain/DefaultToolchainManagerPrivateTest.java @@ -54,7 +54,7 @@ public class DefaultToolchainManagerPrivateTest @Mock private ToolchainFactory toolchainFactory_basicType; - + @Mock private ToolchainFactory toolchainFactory_rareType; @@ -113,7 +113,7 @@ public void testToolchainsForUnknownType() verify( logger ).error( "Missing toolchain factory for type: unknown. Possibly caused by misconfigured project." ); assertEquals( 0, toolchains.length ); } - + @Test public void testToolchainsForConfiguredType() throws Exception @@ -145,7 +145,7 @@ public void testToolchainsForConfiguredType() verify( logger, never() ).error( anyString() ); assertEquals( 2, toolchains.length ); } - + @SuppressWarnings( "unchecked" ) @Test( expected = MisconfiguredToolchainException.class ) public void testMisconfiguredToolchain() @@ -159,7 +159,7 @@ public void testMisconfiguredToolchain() // execute toolchainManager.getToolchainsForType( "basic", session ); - + // verify fail( "Should exit with a MisconfiguredToolchainException" ); } diff --git a/maven-core/src/test/java/org/apache/maven/toolchain/building/DefaultToolchainsBuilderTest.java b/maven-core/src/test/java/org/apache/maven/toolchain/building/DefaultToolchainsBuilderTest.java index 80fca0942b66..ff6b8b54cb4b 100644 --- a/maven-core/src/test/java/org/apache/maven/toolchain/building/DefaultToolchainsBuilderTest.java +++ b/maven-core/src/test/java/org/apache/maven/toolchain/building/DefaultToolchainsBuilderTest.java @@ -42,7 +42,7 @@ public class DefaultToolchainsBuilderTest { private static final String LS = System.getProperty( "line.separator" ); - + @Mock private ToolchainsReader toolchainsReader; @@ -143,7 +143,7 @@ public void testBuildRequestWithBothToolchains() assertNotNull( result.getProblems() ); assertEquals( 0, result.getProblems().size() ); } - + @Test public void testStrictToolchainsParseException() throws Exception { @@ -151,18 +151,18 @@ public void testStrictToolchainsParseException() throws Exception 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 + + 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 { @@ -170,16 +170,16 @@ public void testIOException() throws Exception 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 + + assertEquals( "1 problem was encountered while building the effective toolchains" + LS + "[FATAL] Non-readable toolchains LOCATION: MESSAGE" + LS, e.getMessage() ); } } - + } diff --git a/maven-core/src/test/remote-repo/org/apache/maven/its/a/0.1/a-0.1.pom b/maven-core/src/test/remote-repo/org/apache/maven/its/a/0.1/a-0.1.pom index f45141885647..03caa12ee830 100644 --- a/maven-core/src/test/remote-repo/org/apache/maven/its/a/0.1/a-0.1.pom +++ b/maven-core/src/test/remote-repo/org/apache/maven/its/a/0.1/a-0.1.pom @@ -29,7 +29,7 @@ under the License. Maven Integration Test :: Dummy Artifact - + diff --git a/maven-core/src/test/remote-repo/org/apache/maven/its/b/0.1/b-0.1.pom b/maven-core/src/test/remote-repo/org/apache/maven/its/b/0.1/b-0.1.pom index ca20cbf5a9a5..149a2410888d 100644 --- a/maven-core/src/test/remote-repo/org/apache/maven/its/b/0.1/b-0.1.pom +++ b/maven-core/src/test/remote-repo/org/apache/maven/its/b/0.1/b-0.1.pom @@ -29,7 +29,7 @@ under the License. Maven Integration Test :: Dummy Artifact - + diff --git a/maven-core/src/test/resources/org/apache/maven/extension/test-extension-repo/junit/junit/3.8.1/junit-3.8.1.pom b/maven-core/src/test/resources/org/apache/maven/extension/test-extension-repo/junit/junit/3.8.1/junit-3.8.1.pom index 2169a65d766d..d5167fc7de31 100644 --- a/maven-core/src/test/resources/org/apache/maven/extension/test-extension-repo/junit/junit/3.8.1/junit-3.8.1.pom +++ b/maven-core/src/test/resources/org/apache/maven/extension/test-extension-repo/junit/junit/3.8.1/junit-3.8.1.pom @@ -1,5 +1,5 @@ - 4.0.0 diff --git a/maven-core/src/test/resources/org/apache/maven/extension/test-extension-repo/org/apache/maven/artifact/maven-artifact/3.0-SNAPSHOT/maven-artifact-3.0-SNAPSHOT.pom b/maven-core/src/test/resources/org/apache/maven/extension/test-extension-repo/org/apache/maven/artifact/maven-artifact/3.0-SNAPSHOT/maven-artifact-3.0-SNAPSHOT.pom index 8de3ce6d02c6..324ec347b58e 100644 --- a/maven-core/src/test/resources/org/apache/maven/extension/test-extension-repo/org/apache/maven/artifact/maven-artifact/3.0-SNAPSHOT/maven-artifact-3.0-SNAPSHOT.pom +++ b/maven-core/src/test/resources/org/apache/maven/extension/test-extension-repo/org/apache/maven/artifact/maven-artifact/3.0-SNAPSHOT/maven-artifact-3.0-SNAPSHOT.pom @@ -31,11 +31,11 @@ under the License. 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 - + + 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 @@ -56,7 +56,7 @@ under the License. org.apache.maven.wagon wagon-provider-api 1.0-beta-2 - +
org.apache.maven.wagon wagon-file @@ -68,7 +68,7 @@ under the License. easymock 1.2_Java1.3 test - + @@ -80,25 +80,25 @@ under the License. 1.0.0 src/main/mdo/metadata.mdo - - - site-docs - pre-site - - xdoc - xsd - - - - standard - - java - xpp3-reader - xpp3-writer - - - - + + + site-docs + pre-site + + xdoc + xsd + + + + standard + + java + xpp3-reader + xpp3-writer + + + + maven-surefire-plugin diff --git a/maven-core/src/test/resources/org/apache/maven/extension/test-extension-repo/org/apache/maven/core/test/test-extension/1/test-extension-1.pom b/maven-core/src/test/resources/org/apache/maven/extension/test-extension-repo/org/apache/maven/core/test/test-extension/1/test-extension-1.pom index 70114e72b601..764a5ca006eb 100644 --- a/maven-core/src/test/resources/org/apache/maven/extension/test-extension-repo/org/apache/maven/core/test/test-extension/1/test-extension-1.pom +++ b/maven-core/src/test/resources/org/apache/maven/extension/test-extension-repo/org/apache/maven/core/test/test-extension/1/test-extension-1.pom @@ -35,7 +35,7 @@ 1.0-alpha-16 - + @@ -62,12 +62,12 @@ - + dummy file:///tmp/dummy-repo - + diff --git a/maven-core/src/test/resources/org/apache/maven/extension/test-extension-repo/org/apache/maven/core/test/test-lifecycle-and-artifactHandler/1/test-lifecycle-and-artifactHandler-1.pom b/maven-core/src/test/resources/org/apache/maven/extension/test-extension-repo/org/apache/maven/core/test/test-lifecycle-and-artifactHandler/1/test-lifecycle-and-artifactHandler-1.pom index d9e4cde9a18a..ea7fbb83cc5b 100644 --- a/maven-core/src/test/resources/org/apache/maven/extension/test-extension-repo/org/apache/maven/core/test/test-lifecycle-and-artifactHandler/1/test-lifecycle-and-artifactHandler-1.pom +++ b/maven-core/src/test/resources/org/apache/maven/extension/test-extension-repo/org/apache/maven/core/test/test-lifecycle-and-artifactHandler/1/test-lifecycle-and-artifactHandler-1.pom @@ -33,12 +33,12 @@ - + dummy file:///tmp/dummy-repo - + diff --git a/maven-core/src/test/resources/org/apache/maven/extension/test-extension-repo/org/apache/maven/maven-parent/5/maven-parent-5.pom b/maven-core/src/test/resources/org/apache/maven/extension/test-extension-repo/org/apache/maven/maven-parent/5/maven-parent-5.pom index b33504011a2d..11300948b040 100644 --- a/maven-core/src/test/resources/org/apache/maven/extension/test-extension-repo/org/apache/maven/maven-parent/5/maven-parent-5.pom +++ b/maven-core/src/test/resources/org/apache/maven/extension/test-extension-repo/org/apache/maven/maven-parent/5/maven-parent-5.pom @@ -291,9 +291,9 @@ under the License. - org.apache.maven.plugins + org.apache.maven.plugins maven-release-plugin - 2.0-beta-4 + 2.0-beta-4 https://svn.apache.org/repos/asf/maven/pom/tags @@ -379,7 +379,7 @@ under the License. - + release @@ -451,10 +451,10 @@ under the License. - + - + diff --git a/maven-core/src/test/resources/org/apache/maven/extension/test-extension-repo/org/codehaus/plexus/plexus-classworlds/1.2-alpha-10/plexus-classworlds-1.2-alpha-10.pom b/maven-core/src/test/resources/org/apache/maven/extension/test-extension-repo/org/codehaus/plexus/plexus-classworlds/1.2-alpha-10/plexus-classworlds-1.2-alpha-10.pom index be71f49f618f..60254181c97c 100644 --- a/maven-core/src/test/resources/org/apache/maven/extension/test-extension-repo/org/codehaus/plexus/plexus-classworlds/1.2-alpha-10/plexus-classworlds-1.2-alpha-10.pom +++ b/maven-core/src/test/resources/org/apache/maven/extension/test-extension-repo/org/codehaus/plexus/plexus-classworlds/1.2-alpha-10/plexus-classworlds-1.2-alpha-10.pom @@ -88,7 +88,7 @@ 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 + 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 diff --git a/maven-core/src/test/resources/org/apache/maven/extension/test-extension-repo/org/codehaus/plexus/plexus-components/1.1.6/plexus-components-1.1.6.pom b/maven-core/src/test/resources/org/apache/maven/extension/test-extension-repo/org/codehaus/plexus/plexus-components/1.1.6/plexus-components-1.1.6.pom index 0afa80217fba..2adef07e6e46 100644 --- a/maven-core/src/test/resources/org/apache/maven/extension/test-extension-repo/org/codehaus/plexus/plexus-components/1.1.6/plexus-components-1.1.6.pom +++ b/maven-core/src/test/resources/org/apache/maven/extension/test-extension-repo/org/codehaus/plexus/plexus-components/1.1.6/plexus-components-1.1.6.pom @@ -21,7 +21,7 @@ pom 1.1.6 Plexus Components Parent Project - @@ -35,25 +35,25 @@ plexus-action plexus-archiver - plexus-bayesian + plexus-bayesian plexus-command plexus-compiler - plexus-drools + plexus-drools plexus-formica plexus-formica-web plexus-hibernate - plexus-i18n - plexus-interactivity - plexus-ircbot + plexus-i18n + plexus-interactivity + plexus-ircbot plexus-jdo - plexus-jetty-httpd + plexus-jetty-httpd plexus-jetty - plexus-mimetyper + plexus-mimetyper plexus-notification plexus-resource plexus-security plexus-summit - plexus-taskqueue + plexus-taskqueue plexus-velocity plexus-xmlrpc diff --git a/maven-core/src/test/resources/org/apache/maven/extension/test-extension-repo/org/codehaus/plexus/plexus-container-default/1.0-alpha-32/plexus-container-default-1.0-alpha-32.pom b/maven-core/src/test/resources/org/apache/maven/extension/test-extension-repo/org/codehaus/plexus/plexus-container-default/1.0-alpha-32/plexus-container-default-1.0-alpha-32.pom index fbfdb2bac77c..bcfc8894c408 100644 --- a/maven-core/src/test/resources/org/apache/maven/extension/test-extension-repo/org/codehaus/plexus/plexus-container-default/1.0-alpha-32/plexus-container-default-1.0-alpha-32.pom +++ b/maven-core/src/test/resources/org/apache/maven/extension/test-extension-repo/org/codehaus/plexus/plexus-container-default/1.0-alpha-32/plexus-container-default-1.0-alpha-32.pom @@ -36,8 +36,8 @@ classworlds:classworlds junit:junit jmock:jmock - org.codehaus.plexus:plexus-classworlds - org.codehaus.plexus:plexus-utils + org.codehaus.plexus:plexus-classworlds + org.codehaus.plexus:plexus-utils diff --git a/maven-core/src/test/resources/org/apache/maven/extension/test-extension-repo/org/codehaus/plexus/plexus/1.0.10/plexus-1.0.10.pom b/maven-core/src/test/resources/org/apache/maven/extension/test-extension-repo/org/codehaus/plexus/plexus/1.0.10/plexus-1.0.10.pom index bc94e24bd71c..a7c40286e811 100644 --- a/maven-core/src/test/resources/org/apache/maven/extension/test-extension-repo/org/codehaus/plexus/plexus/1.0.10/plexus-1.0.10.pom +++ b/maven-core/src/test/resources/org/apache/maven/extension/test-extension-repo/org/codehaus/plexus/plexus/1.0.10/plexus-1.0.10.pom @@ -20,7 +20,7 @@ 6667 #plexus - + 2001 diff --git a/maven-core/src/test/resources/org/apache/maven/extension/test-extension-repo/org/codehaus/plexus/plexus/1.0.11/plexus-1.0.11.pom b/maven-core/src/test/resources/org/apache/maven/extension/test-extension-repo/org/codehaus/plexus/plexus/1.0.11/plexus-1.0.11.pom index 28ee5744c726..e939ed13cad6 100644 --- a/maven-core/src/test/resources/org/apache/maven/extension/test-extension-repo/org/codehaus/plexus/plexus/1.0.11/plexus-1.0.11.pom +++ b/maven-core/src/test/resources/org/apache/maven/extension/test-extension-repo/org/codehaus/plexus/plexus/1.0.11/plexus-1.0.11.pom @@ -20,7 +20,7 @@ 6667 #plexus - + 2001 @@ -30,7 +30,7 @@ http://www.apache.org/licenses/LICENSE-2.0.txt repo - + Plexus User List @@ -88,7 +88,7 @@ - + jvanzyl @@ -303,6 +303,6 @@ - + diff --git a/maven-core/src/test/resources/org/apache/maven/extension/test-extension-repo/org/codehaus/plexus/plexus/1.0.4/plexus-1.0.4.pom b/maven-core/src/test/resources/org/apache/maven/extension/test-extension-repo/org/codehaus/plexus/plexus/1.0.4/plexus-1.0.4.pom index 2cf5d5696377..6bcb8e3c9ef0 100644 --- a/maven-core/src/test/resources/org/apache/maven/extension/test-extension-repo/org/codehaus/plexus/plexus/1.0.4/plexus-1.0.4.pom +++ b/maven-core/src/test/resources/org/apache/maven/extension/test-extension-repo/org/codehaus/plexus/plexus/1.0.4/plexus-1.0.4.pom @@ -20,7 +20,7 @@ 6667 #plexus - + 2001 diff --git a/maven-core/src/test/resources/org/apache/maven/extension/test-extension-repo/org/codehaus/plexus/plexus/1.0.8/plexus-1.0.8.pom b/maven-core/src/test/resources/org/apache/maven/extension/test-extension-repo/org/codehaus/plexus/plexus/1.0.8/plexus-1.0.8.pom index cba2014f9622..2e040736e021 100644 --- a/maven-core/src/test/resources/org/apache/maven/extension/test-extension-repo/org/codehaus/plexus/plexus/1.0.8/plexus-1.0.8.pom +++ b/maven-core/src/test/resources/org/apache/maven/extension/test-extension-repo/org/codehaus/plexus/plexus/1.0.8/plexus-1.0.8.pom @@ -23,7 +23,7 @@ 6667 #plexus - + 2001 @@ -223,7 +223,7 @@ - + jdk diff --git a/maven-embedder/src/main/java/org/apache/maven/cli/CLIReportingUtils.java b/maven-embedder/src/main/java/org/apache/maven/cli/CLIReportingUtils.java index 75da4f37323f..c5faef5b4748 100644 --- a/maven-embedder/src/main/java/org/apache/maven/cli/CLIReportingUtils.java +++ b/maven-embedder/src/main/java/org/apache/maven/cli/CLIReportingUtils.java @@ -28,7 +28,7 @@ import java.util.Locale; import java.util.Properties; -import org.apache.commons.lang3.SystemUtils; +import org.codehaus.plexus.util.Os; import org.slf4j.Logger; /** @@ -70,19 +70,8 @@ public static String showVersion() 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( SystemUtils.OS_NAME ). - append( "\", version: \"" ).append( SystemUtils.OS_VERSION ). - append( "\", arch: \"" ).append( SystemUtils.OS_ARCH ); - String osFamily = ""; - if ( SystemUtils.IS_OS_WINDOWS ) - { - osFamily = "Windows"; - } - else if ( SystemUtils.IS_OS_UNIX ) - { - osFamily = "Unix"; - } - version.append( "\", family: \"" ).append( osFamily ).append( '\"' ); + 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(); } diff --git a/maven-embedder/src/main/java/org/apache/maven/cli/CliRequest.java b/maven-embedder/src/main/java/org/apache/maven/cli/CliRequest.java index 4656dd3776a8..25c5aa59cba2 100644 --- a/maven-embedder/src/main/java/org/apache/maven/cli/CliRequest.java +++ b/maven-embedder/src/main/java/org/apache/maven/cli/CliRequest.java @@ -113,8 +113,8 @@ public MavenExecutionRequest getRequest() return request; } - public void setUserProperties( Properties properties ) + public void setUserProperties( Properties properties ) { - this.userProperties.putAll( properties ); + this.userProperties.putAll( properties ); } } \ No newline at end of file diff --git a/maven-embedder/src/main/java/org/apache/maven/cli/MavenCli.java b/maven-embedder/src/main/java/org/apache/maven/cli/MavenCli.java index 8f9546c9130e..90ff92743637 100644 --- a/maven-embedder/src/main/java/org/apache/maven/cli/MavenCli.java +++ b/maven-embedder/src/main/java/org/apache/maven/cli/MavenCli.java @@ -38,6 +38,8 @@ import java.util.List; import java.util.Map; import java.util.Map.Entry; +import java.util.regex.Matcher; +import java.util.regex.Pattern; import java.util.Properties; import java.util.Set; import java.util.StringTokenizer; @@ -156,7 +158,7 @@ public class MavenCli public static final File DEFAULT_USER_TOOLCHAINS_FILE = new File( userMavenConfigurationHome, "toolchains.xml" ); public static final File DEFAULT_GLOBAL_TOOLCHAINS_FILE = - new File( System.getProperty( "maven.home", System.getProperty( "user.dir", "" ) ), "conf/toolchains.xml" ); + new File( System.getProperty( "maven.conf" ), "toolchains.xml" ); private static final String EXT_CLASS_PATH = "maven.ext.class.path"; @@ -1111,19 +1113,37 @@ private void logSummary( ExceptionSummary summary, Map reference { if ( msg.indexOf( '\n' ) < 0 ) { - msg += " -> " + referenceKey; + msg += " -> " + buffer().strong( referenceKey ); } else { - msg += "\n-> " + referenceKey; + msg += "\n-> " + buffer().strong( referenceKey ); } } String[] lines = msg.split( "(\r\n)|(\r)|(\n)" ); + String currentColor = ""; for ( int i = 0; i < lines.length; i++ ) { - String line = indent + lines[i].trim(); + // add eventual current color inherited from previous line + String line = currentColor + lines[i]; + + // look for last ANSI escape sequence to check if nextColor + Matcher matcher = LAST_ANSI_SEQUENCE.matcher( line ); + String nextColor = ""; + if ( matcher.find() ) + { + nextColor = matcher.group( 1 ); + if ( ANSI_RESET.equals( nextColor ) ) + { + // last ANSI escape code is reset: no next color + nextColor = ""; + } + } + + // effective line, with indent and reset if end is colored + line = indent + line + ( "".equals( nextColor ) ? "" : ANSI_RESET ); if ( ( i == lines.length - 1 ) && ( showErrors || ( summary.getException() instanceof InternalErrorException ) ) ) @@ -1134,6 +1154,8 @@ private void logSummary( ExceptionSummary summary, Map reference { slf4jLogger.error( line ); } + + currentColor = nextColor; } indent += " "; @@ -1144,7 +1166,10 @@ private void logSummary( ExceptionSummary summary, Map reference } } - @SuppressWarnings( "checkstyle:methodlength" ) + private static final Pattern LAST_ANSI_SEQUENCE = Pattern.compile( "(\u001B\\[[;\\d]*[ -/]*[@-~])[^\u001B]*$" ); + + private static final String ANSI_RESET = "\u001B\u005Bm"; + private void configure( CliRequest cliRequest ) throws Exception { @@ -1210,7 +1235,6 @@ else if ( userSuppliedConfigurationProcessorCount > 1 ) } } - @SuppressWarnings( "checkstyle:methodlength" ) private void toolchains( CliRequest cliRequest ) throws Exception { diff --git a/maven-embedder/src/main/java/org/apache/maven/cli/configuration/SettingsXmlConfigurationProcessor.java b/maven-embedder/src/main/java/org/apache/maven/cli/configuration/SettingsXmlConfigurationProcessor.java index 7ba219465001..1008d4e88862 100644 --- a/maven-embedder/src/main/java/org/apache/maven/cli/configuration/SettingsXmlConfigurationProcessor.java +++ b/maven-embedder/src/main/java/org/apache/maven/cli/configuration/SettingsXmlConfigurationProcessor.java @@ -56,7 +56,7 @@ public class SettingsXmlConfigurationProcessor public static final File DEFAULT_USER_SETTINGS_FILE = new File( USER_MAVEN_CONFIGURATION_HOME, "settings.xml" ); public static final File DEFAULT_GLOBAL_SETTINGS_FILE = - new File( System.getProperty( "maven.home", System.getProperty( "user.dir", "" ) ), "conf/settings.xml" ); + new File( System.getProperty( "maven.conf" ), "settings.xml" ); @Requirement private Logger logger; diff --git a/maven-embedder/src/main/resources/META-INF/maven/slf4j-configuration.properties b/maven-embedder/src/main/resources/META-INF/maven/slf4j-configuration.properties index e385dcb2b6c7..42b39c068e8d 100644 --- a/maven-embedder/src/main/resources/META-INF/maven/slf4j-configuration.properties +++ b/maven-embedder/src/main/resources/META-INF/maven/slf4j-configuration.properties @@ -18,6 +18,7 @@ # key = Slf4j effective logger factory implementation # value = corresponding o.a.m.cli.logging.Slf4jConfiguration class org.slf4j.impl.SimpleLoggerFactory org.apache.maven.cli.logging.impl.Slf4jSimpleConfiguration +org.slf4j.impl.MavenSimpleLoggerFactory org.apache.maven.cli.logging.impl.Slf4jSimpleConfiguration org.apache.logging.slf4j.Log4jLoggerFactory org.apache.maven.cli.logging.impl.Log4j2Configuration ch.qos.logback.classic.LoggerContext org.apache.maven.cli.logging.impl.LogbackConfiguration com.planet57.gossip.Gossip org.apache.maven.cli.logging.impl.gossip.GossipConfiguration diff --git a/maven-embedder/src/site/apt/index.apt.vm b/maven-embedder/src/site/apt/index.apt.vm index 9b8daff3c955..24e39052e998 100644 --- a/maven-embedder/src/site/apt/index.apt.vm +++ b/maven-embedder/src/site/apt/index.apt.vm @@ -20,7 +20,7 @@ ----- Hervé Boutemy ----- - 2015-03-12 + 2016-11-14 ----- ${project.name} @@ -33,13 +33,14 @@ ${project.name} * {{{./logging.html}logging API}}. - * since 3.3.0, per project settings can be defined by files in <<<.mvn/>>> directory: + * since 3.3.1 (see {{{/docs/3.3.1/release-notes.html#Core_Extensions}3.3.1 release notes}} for more details), + per project settings can be defined by files in <<<.mvn/>>> directory: * <<<.mvn/jvm.config>>> containing jvm options, * <<<.mvn/maven.config>>> containing Maven command-line parameter, - * <<<.mvn/extensions.xml>>> containing {{{./core-extensions.html}a list of extensions}}. + * <<<.mvn/extensions.xml>>> containing {{{./core-extensions.html}a list of extensions}}, * since 3.4.0, output is colorized by default, with color disabled in batch mode: see {{{/shared/maven-shared-utils/apidocs/org/apache/maven/shared/utils/logging/package-summary.html}styled message API}} diff --git a/maven-embedder/src/site/apt/logging.apt b/maven-embedder/src/site/apt/logging.apt index 340580a80e7e..800857c4f262 100644 --- a/maven-embedder/src/site/apt/logging.apt +++ b/maven-embedder/src/site/apt/logging.apt @@ -54,7 +54,7 @@ Maven Logging Logging configuration loading is actually done by logging implementation, without any Maven extensions to support merging Maven installation configuration with per-user configuration for example: - <<<$\{maven.home}/conf/logging>>> directory was added to core's classpath (see <<<$\{maven.home}/bin/m2.conf>>>). See your implementation + <<<$\{maven.conf}/logging>>> directory was added to core's classpath (see <<<$\{maven.home}/bin/m2.conf>>>). See your implementation documentation for details on file names, formats, and so on. During Maven initialization, Maven tweaks default root logging level to match CLI verbosity choice. Since such feature isn't available diff --git a/maven-embedder/src/test/error-reporting-projects/bad-ext-direct-deps/local-repo/org/apache/maven/errortest/test-maven-ext/1/test-maven-ext-1.pom b/maven-embedder/src/test/error-reporting-projects/bad-ext-direct-deps/local-repo/org/apache/maven/errortest/test-maven-ext/1/test-maven-ext-1.pom index dcaf397e55d1..7e4415c5faa6 100644 --- a/maven-embedder/src/test/error-reporting-projects/bad-ext-direct-deps/local-repo/org/apache/maven/errortest/test-maven-ext/1/test-maven-ext-1.pom +++ b/maven-embedder/src/test/error-reporting-projects/bad-ext-direct-deps/local-repo/org/apache/maven/errortest/test-maven-ext/1/test-maven-ext-1.pom @@ -22,7 +22,7 @@ under the License. org.apache.maven.errortest test-maven-ext 1 - + junit @@ -30,5 +30,5 @@ under the License. [3.8, - + diff --git a/maven-embedder/src/test/error-reporting-projects/bad-ext-plugin-dep-ver/local-repo/org/apache/maven/errortest/bad-ext-plugin-dep-ver-maven-plugin/1/bad-ext-plugin-dep-ver-maven-plugin-1.pom b/maven-embedder/src/test/error-reporting-projects/bad-ext-plugin-dep-ver/local-repo/org/apache/maven/errortest/bad-ext-plugin-dep-ver-maven-plugin/1/bad-ext-plugin-dep-ver-maven-plugin-1.pom index 3c7f3f3fb294..225c5f9d15ed 100644 --- a/maven-embedder/src/test/error-reporting-projects/bad-ext-plugin-dep-ver/local-repo/org/apache/maven/errortest/bad-ext-plugin-dep-ver-maven-plugin/1/bad-ext-plugin-dep-ver-maven-plugin-1.pom +++ b/maven-embedder/src/test/error-reporting-projects/bad-ext-plugin-dep-ver/local-repo/org/apache/maven/errortest/bad-ext-plugin-dep-ver-maven-plugin/1/bad-ext-plugin-dep-ver-maven-plugin-1.pom @@ -5,7 +5,7 @@ bad-ext-plugin-dep-ver-maven-plugin maven-plugin 1 - + org.apache.maven diff --git a/maven-embedder/src/test/error-reporting-projects/bad-ext-plugin-maven-ver/local-repo/org/apache/maven/errortest/bad-ext-plugin-maven-ver-maven-plugin/1/bad-ext-plugin-maven-ver-maven-plugin-1.pom b/maven-embedder/src/test/error-reporting-projects/bad-ext-plugin-maven-ver/local-repo/org/apache/maven/errortest/bad-ext-plugin-maven-ver-maven-plugin/1/bad-ext-plugin-maven-ver-maven-plugin-1.pom index ffe6141e4a0e..807d53ff594b 100644 --- a/maven-embedder/src/test/error-reporting-projects/bad-ext-plugin-maven-ver/local-repo/org/apache/maven/errortest/bad-ext-plugin-maven-ver-maven-plugin/1/bad-ext-plugin-maven-ver-maven-plugin-1.pom +++ b/maven-embedder/src/test/error-reporting-projects/bad-ext-plugin-maven-ver/local-repo/org/apache/maven/errortest/bad-ext-plugin-maven-ver-maven-plugin/1/bad-ext-plugin-maven-ver-maven-plugin-1.pom @@ -5,11 +5,11 @@ bad-ext-plugin-maven-ver-maven-plugin maven-plugin 1 - + 10 - + org.apache.maven diff --git a/maven-embedder/src/test/error-reporting-projects/err-loading-plugin/local-repo/org/apache/maven/errortest/err-loading-plugin-maven-plugin/1/err-loading-plugin-maven-plugin-1.pom b/maven-embedder/src/test/error-reporting-projects/err-loading-plugin/local-repo/org/apache/maven/errortest/err-loading-plugin-maven-plugin/1/err-loading-plugin-maven-plugin-1.pom index 7ac049095d96..1172857cd811 100644 --- a/maven-embedder/src/test/error-reporting-projects/err-loading-plugin/local-repo/org/apache/maven/errortest/err-loading-plugin-maven-plugin/1/err-loading-plugin-maven-plugin-1.pom +++ b/maven-embedder/src/test/error-reporting-projects/err-loading-plugin/local-repo/org/apache/maven/errortest/err-loading-plugin-maven-plugin/1/err-loading-plugin-maven-plugin-1.pom @@ -5,7 +5,7 @@ err-loading-plugin-maven-plugin maven-plugin 1 - + org.apache.maven diff --git a/maven-embedder/src/test/error-reporting-projects/err-resolving-ext-plugin/local-repo/org/apache/maven/errortest/dep/1/dep-1.pom b/maven-embedder/src/test/error-reporting-projects/err-resolving-ext-plugin/local-repo/org/apache/maven/errortest/dep/1/dep-1.pom index e6dd7a2be681..960fbf676da6 100644 --- a/maven-embedder/src/test/error-reporting-projects/err-resolving-ext-plugin/local-repo/org/apache/maven/errortest/dep/1/dep-1.pom +++ b/maven-embedder/src/test/error-reporting-projects/err-resolving-ext-plugin/local-repo/org/apache/maven/errortest/dep/1/dep-1.pom @@ -5,7 +5,7 @@ dep 1 pom - + junit diff --git a/maven-embedder/src/test/error-reporting-projects/err-resolving-ext-plugin/local-repo/org/apache/maven/errortest/err-resolving-ext-plugin-maven-plugin/1/err-resolving-ext-plugin-maven-plugin-1.pom b/maven-embedder/src/test/error-reporting-projects/err-resolving-ext-plugin/local-repo/org/apache/maven/errortest/err-resolving-ext-plugin-maven-plugin/1/err-resolving-ext-plugin-maven-plugin-1.pom index e520ccc9ac81..422e8fabad7f 100644 --- a/maven-embedder/src/test/error-reporting-projects/err-resolving-ext-plugin/local-repo/org/apache/maven/errortest/err-resolving-ext-plugin-maven-plugin/1/err-resolving-ext-plugin-maven-plugin-1.pom +++ b/maven-embedder/src/test/error-reporting-projects/err-resolving-ext-plugin/local-repo/org/apache/maven/errortest/err-resolving-ext-plugin-maven-plugin/1/err-resolving-ext-plugin-maven-plugin-1.pom @@ -5,7 +5,7 @@ err-resolving-ext-plugin-maven-plugin maven-plugin 1 - + org.apache.maven diff --git a/maven-embedder/src/test/error-reporting-projects/err-resolving-project-dep/project/local-repo/org/apache/maven/errortest/dep/1/dep-1.pom b/maven-embedder/src/test/error-reporting-projects/err-resolving-project-dep/project/local-repo/org/apache/maven/errortest/dep/1/dep-1.pom index e6dd7a2be681..960fbf676da6 100644 --- a/maven-embedder/src/test/error-reporting-projects/err-resolving-project-dep/project/local-repo/org/apache/maven/errortest/dep/1/dep-1.pom +++ b/maven-embedder/src/test/error-reporting-projects/err-resolving-project-dep/project/local-repo/org/apache/maven/errortest/dep/1/dep-1.pom @@ -5,7 +5,7 @@ dep 1 pom - + junit diff --git a/maven-embedder/src/test/error-reporting-projects/ext-deps-resolve-err/local-repo/org/apache/maven/errortest/test-maven-ext-dep/1/test-maven-ext-dep-1.pom b/maven-embedder/src/test/error-reporting-projects/ext-deps-resolve-err/local-repo/org/apache/maven/errortest/test-maven-ext-dep/1/test-maven-ext-dep-1.pom index 71edcf4df546..020fb07cf504 100644 --- a/maven-embedder/src/test/error-reporting-projects/ext-deps-resolve-err/local-repo/org/apache/maven/errortest/test-maven-ext-dep/1/test-maven-ext-dep-1.pom +++ b/maven-embedder/src/test/error-reporting-projects/ext-deps-resolve-err/local-repo/org/apache/maven/errortest/test-maven-ext-dep/1/test-maven-ext-dep-1.pom @@ -22,5 +22,5 @@ under the License. org.apache.maven.errortest test-maven-ext-dep 1 - + diff --git a/maven-embedder/src/test/error-reporting-projects/ext-deps-resolve-err/local-repo/org/apache/maven/errortest/test-maven-ext/1/test-maven-ext-1.pom b/maven-embedder/src/test/error-reporting-projects/ext-deps-resolve-err/local-repo/org/apache/maven/errortest/test-maven-ext/1/test-maven-ext-1.pom index cd40200d5908..72c2b45578fb 100644 --- a/maven-embedder/src/test/error-reporting-projects/ext-deps-resolve-err/local-repo/org/apache/maven/errortest/test-maven-ext/1/test-maven-ext-1.pom +++ b/maven-embedder/src/test/error-reporting-projects/ext-deps-resolve-err/local-repo/org/apache/maven/errortest/test-maven-ext/1/test-maven-ext-1.pom @@ -22,7 +22,7 @@ under the License. org.apache.maven.errortest test-maven-ext 1 - + org.apache.maven.errortest @@ -30,5 +30,5 @@ under the License. 1 - + diff --git a/maven-embedder/src/test/error-reporting-projects/ext-plugin-artifact-missing/local-repo/org/apache/maven/errortest/ext-plugin-artifact-missing-maven-plugin/1/ext-plugin-artifact-missing-maven-plugin-1.pom b/maven-embedder/src/test/error-reporting-projects/ext-plugin-artifact-missing/local-repo/org/apache/maven/errortest/ext-plugin-artifact-missing-maven-plugin/1/ext-plugin-artifact-missing-maven-plugin-1.pom index b7f7d52993df..c9361ea8e72e 100644 --- a/maven-embedder/src/test/error-reporting-projects/ext-plugin-artifact-missing/local-repo/org/apache/maven/errortest/ext-plugin-artifact-missing-maven-plugin/1/ext-plugin-artifact-missing-maven-plugin-1.pom +++ b/maven-embedder/src/test/error-reporting-projects/ext-plugin-artifact-missing/local-repo/org/apache/maven/errortest/ext-plugin-artifact-missing-maven-plugin/1/ext-plugin-artifact-missing-maven-plugin-1.pom @@ -5,7 +5,7 @@ ext-plugin-artifact-missing-maven-plugin maven-plugin 1 - + org.apache.maven diff --git a/maven-embedder/src/test/error-reporting-projects/ext-plugin-version-err/local-repo/org/apache/maven/errortest/ext-plugin-version-err-maven-plugin/1/ext-plugin-version-err-maven-plugin-1.pom b/maven-embedder/src/test/error-reporting-projects/ext-plugin-version-err/local-repo/org/apache/maven/errortest/ext-plugin-version-err-maven-plugin/1/ext-plugin-version-err-maven-plugin-1.pom index 5aab61d99c03..cfbb8fed6daa 100644 --- a/maven-embedder/src/test/error-reporting-projects/ext-plugin-version-err/local-repo/org/apache/maven/errortest/ext-plugin-version-err-maven-plugin/1/ext-plugin-version-err-maven-plugin-1.pom +++ b/maven-embedder/src/test/error-reporting-projects/ext-plugin-version-err/local-repo/org/apache/maven/errortest/ext-plugin-version-err-maven-plugin/1/ext-plugin-version-err-maven-plugin-1.pom @@ -5,7 +5,7 @@ ext-plugin-version-err-maven-plugin maven-plugin 1 - + org.apache.maven diff --git a/maven-embedder/src/test/error-reporting-projects/interp-from-project/project/local-repo/org/test/bad-pom/1/bad-pom-1.pom b/maven-embedder/src/test/error-reporting-projects/interp-from-project/project/local-repo/org/test/bad-pom/1/bad-pom-1.pom index b1f29c49a978..40ae3b15ebc5 100644 --- a/maven-embedder/src/test/error-reporting-projects/interp-from-project/project/local-repo/org/test/bad-pom/1/bad-pom-1.pom +++ b/maven-embedder/src/test/error-reporting-projects/interp-from-project/project/local-repo/org/test/bad-pom/1/bad-pom-1.pom @@ -3,7 +3,7 @@ org.test bad-pom 1 - + ${packaging} \ No newline at end of file diff --git a/maven-embedder/src/test/java/org/apache/maven/cli/MavenCliTest.java b/maven-embedder/src/test/java/org/apache/maven/cli/MavenCliTest.java index d92662494dc7..d5db8fb76ead 100644 --- a/maven-embedder/src/test/java/org/apache/maven/cli/MavenCliTest.java +++ b/maven-embedder/src/test/java/org/apache/maven/cli/MavenCliTest.java @@ -107,7 +107,7 @@ public void testMavenConfigInvalid() } } - + /** * Read .mvn/maven.config with the following definitions: *
@@ -125,10 +125,10 @@ public void testMVNConfigurationThreadCanBeOverwrittenViaCommandLine() throws Ex
         cli.initialize( request );
         // read .mvn/maven.config
         cli.cli( request );
-        
+
         assertEquals( "5", request.commandLine.getOptionValue( CLIManager.THREADS ) );
     }
-    
+
     /**
      * Read .mvn/maven.config with the following definitions:
      * 
@@ -147,7 +147,7 @@ public void testMVNConfigurationDefinedPropertiesCanBeOverwrittenViaCommandLine(
         // read .mvn/maven.config
         cli.cli( request );
         cli.properties( request );
-        
+
         String revision = System.getProperty( "revision" );
         assertEquals( "8.1.0", revision );
 
diff --git a/maven-embedder/src/test/projects/config/.mvn/maven.config b/maven-embedder/src/test/projects/config/.mvn/maven.config
index 3d0f13b2cd5c..495dab8a7ba6 100644
--- a/maven-embedder/src/test/projects/config/.mvn/maven.config
+++ b/maven-embedder/src/test/projects/config/.mvn/maven.config
@@ -1,2 +1,2 @@
--T8 --builder  
+-T8 --builder
   multithreaded
diff --git a/maven-model-builder/src/main/java/org/apache/maven/model/building/DefaultModelBuilder.java b/maven-model-builder/src/main/java/org/apache/maven/model/building/DefaultModelBuilder.java
index 89c989f76e34..fb401eedbdd8 100644
--- a/maven-model-builder/src/main/java/org/apache/maven/model/building/DefaultModelBuilder.java
+++ b/maven-model-builder/src/main/java/org/apache/maven/model/building/DefaultModelBuilder.java
@@ -73,7 +73,6 @@
 import org.apache.maven.model.resolution.WorkspaceModelResolver;
 import org.apache.maven.model.superpom.SuperPomProvider;
 import org.apache.maven.model.validation.ModelValidator;
-import org.apache.maven.model.versioning.ModelVersions;
 import org.codehaus.plexus.component.annotations.Component;
 import org.codehaus.plexus.component.annotations.Requirement;
 import org.codehaus.plexus.interpolation.MapBasedValueSource;
@@ -144,6 +143,26 @@ public class DefaultModelBuilder
     @Requirement( optional = true )
     private List modelFinalizers;
 
+    // [MNG-4463] Dependency management import should support version ranges.
+    private static final boolean DEPENDENCY_MANAGEMENT_IMPORT_VERSION_RANGES =
+        System.getProperty( DefaultModelBuilder.class.getName()
+                                + ".disableDependencyManagementImportVersionRanges" ) == null;
+
+    // [MNG-5600] Dependency management import should support exclusions.
+    private static final boolean DEPENDENCY_MANAGEMENT_IMPORT_EXCLUSIONS =
+        System.getProperty( DefaultModelBuilder.class.getName()
+                                + ".disableDependencyManagementImportExclusions" ) == null;
+
+    // [MNG-5527] Dependency management import should support relocations.
+    private static final boolean DEPENDENCY_MANAGEMENT_IMPORT_RELOCATIONS =
+        System.getProperty( DefaultModelBuilder.class.getName()
+                                + ".disableDependencyManagementImportRelocations" ) == null;
+
+    // [MNG-5971] Imported dependencies should be available to inheritance processing.
+    private static final boolean DEPENDENCY_MANAGEMENT_IMPORT_INHERITANCE_PROCESSING =
+        System.getProperty( DefaultModelBuilder.class.getName()
+                                + ".disableDependencyManagementImportInheritanceProcessing" ) == null;
+
     public DefaultModelBuilder setModelProcessor( ModelProcessor modelProcessor )
     {
         this.modelProcessor = modelProcessor;
@@ -468,10 +487,10 @@ public ModelBuildingResult build( ModelBuildingRequest request, ModelBuildingRes
             lineage.add( result.getEffectiveModel( modelId ) );
         }
 
-        if ( ModelVersions.supportsDependencyManagementImportInheritanceProcessing( resultModel ) )
+        if ( DEPENDENCY_MANAGEMENT_IMPORT_INHERITANCE_PROCESSING )
         {
-            // [MNG-5971] Imported dependencies should be available to inheritance processing
-            processImports( lineage, request, problems );
+            // [MNG-5971] Imported dependencies should be available to inheritance processing.
+            this.processImports( lineage, request, problems );
         }
 
         problems.setSource( resultModel );
@@ -506,7 +525,7 @@ public ModelBuildingResult build( ModelBuildingRequest request, ModelBuildingRes
             lifecycleBindingsInjector.injectLifecycleBindings( resultModel, request, problems );
         }
 
-        if ( !ModelVersions.supportsDependencyManagementImportInheritanceProcessing( resultModel ) )
+        if ( !DEPENDENCY_MANAGEMENT_IMPORT_INHERITANCE_PROCESSING )
         {
             this.importDependencyManagement( resultModel, "import", request, problems, new HashSet() );
         }
@@ -790,7 +809,7 @@ private void checkModelVersions( final List lineage, final ModelBuild
             final Model model = lineage.get( 0 ).getModel();
             // [MNG-666] need to be able to operate on a Maven 1 repository
             final String modelVersion = model.getModelVersion() == null
-                                            ? ModelVersions.V4_0_0
+                                            ? "4.0.0"
                                             : model.getModelVersion();
 
             for ( int i = 1, s0 = lineage.size(); i < s0; i++ )
@@ -798,7 +817,7 @@ private void checkModelVersions( final List lineage, final ModelBuild
                 final Model parent = lineage.get( i ).getModel();
                 // [MNG-666] need to be able to operate on a Maven 1 repository
                 final String parentModelVersion = parent.getModelVersion() == null
-                                                      ? ModelVersions.V4_0_0
+                                                      ? "4.0.0"
                                                       : parent.getModelVersion();
 
                 if ( !parentModelVersion.equals( modelVersion ) )
@@ -1462,7 +1481,7 @@ private void importDependencyManagement( Model model, String scope, ModelBuildin
                                      ? importModel.getDependencyManagement().clone()
                                      : new DependencyManagement();
 
-                    if ( ModelVersions.supportsDependencyManagementImportExclusions( model ) )
+                    if ( DEPENDENCY_MANAGEMENT_IMPORT_EXCLUSIONS )
                     {
                         if ( !dependency.getExclusions().isEmpty() )
                         {
@@ -1530,11 +1549,11 @@ private Model buildImportModelFromRepository( final Model model,
             final Dependency resolvedDependency = dependency.clone();
 
             final ModelSource importSource =
-                ModelVersions.supportsDependencyManagementImportVersionRanges( model )
+                DEPENDENCY_MANAGEMENT_IMPORT_VERSION_RANGES
                     ? targetModelBuildingRequest.getModelResolver().resolveModel( resolvedDependency )
                     : targetModelBuildingRequest.getModelResolver().resolveModel(
-                    resolvedDependency.getGroupId(), resolvedDependency.getArtifactId(),
-                    resolvedDependency.getVersion() );
+                        resolvedDependency.getGroupId(), resolvedDependency.getArtifactId(),
+                        resolvedDependency.getVersion() );
 
             final String resolvedId =
                 String.format( "%s:%s:%s", resolvedDependency.getGroupId(), resolvedDependency.getArtifactId(),
@@ -1569,7 +1588,7 @@ private Model buildImportModelFromRepository( final Model model,
 
                 if ( importModel.getDistributionManagement() != null
                          && importModel.getDistributionManagement().getRelocation() != null
-                         && ModelVersions.supportsDependencyManagementImportRelocations( model ) )
+                         && DEPENDENCY_MANAGEMENT_IMPORT_RELOCATIONS )
                 {
                     final Dependency relocated = dependency.clone();
                     relocated.setGroupId( importModel.getDistributionManagement().getRelocation().getGroupId() );
diff --git a/maven-model-builder/src/main/java/org/apache/maven/model/building/DefaultModelBuildingRequest.java b/maven-model-builder/src/main/java/org/apache/maven/model/building/DefaultModelBuildingRequest.java
index a3505c9db465..84a68f74c8fb 100644
--- a/maven-model-builder/src/main/java/org/apache/maven/model/building/DefaultModelBuildingRequest.java
+++ b/maven-model-builder/src/main/java/org/apache/maven/model/building/DefaultModelBuildingRequest.java
@@ -286,7 +286,10 @@ public DefaultModelBuildingRequest setSystemProperties( Properties systemPropert
         if ( systemProperties != null )
         {
             this.systemProperties = new Properties();
-            this.systemProperties.putAll( systemProperties );
+            synchronized ( systemProperties )
+            { // avoid concurrentmodification if someone else sets/removes an unrelated system property
+                this.systemProperties.putAll( systemProperties );
+            }
         }
         else
         {
diff --git a/maven-model-builder/src/main/java/org/apache/maven/model/building/FileModelSource.java b/maven-model-builder/src/main/java/org/apache/maven/model/building/FileModelSource.java
index a2e114176950..42bc06581503 100644
--- a/maven-model-builder/src/main/java/org/apache/maven/model/building/FileModelSource.java
+++ b/maven-model-builder/src/main/java/org/apache/maven/model/building/FileModelSource.java
@@ -41,11 +41,11 @@ public FileModelSource( File pomFile )
     {
         super( pomFile );
     }
-    
+
     /**
-     * 
+     *
      * @return the file of this source
-     * 
+     *
      * @deprecated instead use {@link #getFile()}
      */
     @Deprecated
@@ -53,7 +53,7 @@ public File getPomFile()
     {
         return getFile();
     }
-    
+
     @Override
     public ModelSource2 getRelatedSource( String relPath )
     {
diff --git a/maven-model-builder/src/main/java/org/apache/maven/model/building/Result.java b/maven-model-builder/src/main/java/org/apache/maven/model/building/Result.java
index 041b0d6c0f85..99876252e46a 100644
--- a/maven-model-builder/src/main/java/org/apache/maven/model/building/Result.java
+++ b/maven-model-builder/src/main/java/org/apache/maven/model/building/Result.java
@@ -46,7 +46,7 @@
  * 
  • error - (partial) model and diagnostics * * Could encode these variants as subclasses, but kept in one for now - * + * * @author bbusjaeger * @param */ diff --git a/maven-model-builder/src/main/java/org/apache/maven/model/building/StringModelSource.java b/maven-model-builder/src/main/java/org/apache/maven/model/building/StringModelSource.java index cf9c4ce19b1e..409714669b11 100644 --- a/maven-model-builder/src/main/java/org/apache/maven/model/building/StringModelSource.java +++ b/maven-model-builder/src/main/java/org/apache/maven/model/building/StringModelSource.java @@ -25,7 +25,7 @@ * Wraps an ordinary {@link CharSequence} as a model source. * * @author Benjamin Bentmann - * + * * @deprecated instead use {@link StringSource} */ @Deprecated diff --git a/maven-model-builder/src/main/java/org/apache/maven/model/building/UrlModelSource.java b/maven-model-builder/src/main/java/org/apache/maven/model/building/UrlModelSource.java index e41d74b384a4..dcbbc52f4faa 100644 --- a/maven-model-builder/src/main/java/org/apache/maven/model/building/UrlModelSource.java +++ b/maven-model-builder/src/main/java/org/apache/maven/model/building/UrlModelSource.java @@ -27,7 +27,7 @@ * Wraps an ordinary {@link URL} as a model source. * * @author Benjamin Bentmann - * + * * @deprecated instead use {@link UrlSource} */ @Deprecated diff --git a/maven-model-builder/src/main/java/org/apache/maven/model/composition/DefaultDependencyManagementImporter.java b/maven-model-builder/src/main/java/org/apache/maven/model/composition/DefaultDependencyManagementImporter.java index c3a0201b34be..ad5513d71048 100644 --- a/maven-model-builder/src/main/java/org/apache/maven/model/composition/DefaultDependencyManagementImporter.java +++ b/maven-model-builder/src/main/java/org/apache/maven/model/composition/DefaultDependencyManagementImporter.java @@ -27,6 +27,8 @@ import org.apache.maven.model.Dependency; import org.apache.maven.model.DependencyManagement; import org.apache.maven.model.Exclusion; +import org.apache.maven.model.InputLocation; +import org.apache.maven.model.InputSource; import org.apache.maven.model.Model; import org.apache.maven.model.building.ModelBuildingRequest; import org.apache.maven.model.building.ModelProblem; @@ -100,7 +102,17 @@ public void importManagement( final Model target, final List 0 + ? "(" + conflictsBuilder.substring( 2 ) + ")" + : "" ) ) ); } } diff --git a/maven-model-builder/src/main/java/org/apache/maven/model/superpom/DefaultSuperPomProvider.java b/maven-model-builder/src/main/java/org/apache/maven/model/superpom/DefaultSuperPomProvider.java index 2338c62d17ca..0c720d1a92e5 100644 --- a/maven-model-builder/src/main/java/org/apache/maven/model/superpom/DefaultSuperPomProvider.java +++ b/maven-model-builder/src/main/java/org/apache/maven/model/superpom/DefaultSuperPomProvider.java @@ -28,7 +28,6 @@ import org.apache.maven.model.Model; import org.apache.maven.model.building.ModelProcessor; -import org.apache.maven.model.versioning.ModelVersions; import org.codehaus.plexus.component.annotations.Component; import org.codehaus.plexus.component.annotations.Requirement; @@ -62,7 +61,7 @@ public Model getSuperModel( final String version ) { // [MNG-666] need to be able to operate on a Maven 1 repository // Instead of throwing an exception if version == null, we return a version "4.0.0" super pom. - final String effectiveVersion = version == null ? ModelVersions.V4_0_0 : version; + final String effectiveVersion = version == null ? "4.0.0" : version; final String resource = "/org/apache/maven/model/pom-" + effectiveVersion + ".xml"; try diff --git a/maven-model-builder/src/main/java/org/apache/maven/model/validation/DefaultModelValidator.java b/maven-model-builder/src/main/java/org/apache/maven/model/validation/DefaultModelValidator.java index 89bd94b162b6..cea2a743e44b 100644 --- a/maven-model-builder/src/main/java/org/apache/maven/model/validation/DefaultModelValidator.java +++ b/maven-model-builder/src/main/java/org/apache/maven/model/validation/DefaultModelValidator.java @@ -53,7 +53,6 @@ import org.apache.maven.model.building.ModelProblem.Version; import org.apache.maven.model.building.ModelProblemCollector; import org.apache.maven.model.building.ModelProblemCollectorRequest; -import org.apache.maven.model.versioning.ModelVersions; import org.codehaus.plexus.component.annotations.Component; import org.codehaus.plexus.util.StringUtils; @@ -84,17 +83,18 @@ public void validateRawModel( Model m, ModelBuildingRequest request, ModelProble validateStringNotEmpty( "parent.groupId", problems, Severity.FATAL, Version.BASE, parent.getGroupId(), parent ); - validateStringNotEmpty( "parent.artifactId", problems, Severity.FATAL, Version.BASE, - parent.getArtifactId(), parent ); + validateStringNotEmpty( "parent.artifactId", problems, Severity.FATAL, Version.BASE, parent.getArtifactId(), + parent ); validateStringNotEmpty( "parent.version", problems, Severity.FATAL, Version.BASE, parent.getVersion(), parent ); - if ( equals( parent.getGroupId(), m.getGroupId() ) - && equals( parent.getArtifactId(), m.getArtifactId() ) ) + if ( equals( parent.getGroupId(), m.getGroupId() ) && equals( parent.getArtifactId(), m.getArtifactId() ) ) { - addViolation( problems, Severity.FATAL, Version.BASE, "parent.artifactId", null, "must be changed" - + ", the parent element cannot have the same groupId:artifactId as the project.", parent ); + addViolation( problems, Severity.FATAL, Version.BASE, "parent.artifactId", null, + "must be changed" + + ", the parent element cannot have the same groupId:artifactId as the project.", + parent ); } } @@ -103,7 +103,7 @@ && equals( parent.getArtifactId(), m.getArtifactId() ) ) Severity errOn30 = getSeverity( request, ModelBuildingRequest.VALIDATION_LEVEL_MAVEN_3_0 ); // [MNG-6074] Maven should produce an error if no model version has been set in a POM file used to build an - // effective model. + // effective model. // // As of 3.4, the model version is mandatory even in raw models. The XML element still is optional in the // XML schema and this will not change anytime soon. We do not want to build effective models based on @@ -111,7 +111,7 @@ && equals( parent.getArtifactId(), m.getArtifactId() ) ) validateStringNotEmpty( "modelVersion", problems, Severity.ERROR, Version.V20, m.getModelVersion(), m ); validateEnum( "modelVersion", problems, Severity.ERROR, Version.V20, m.getModelVersion(), null, m, - ModelVersions.V4_0_0, ModelVersions.V4_1_0 ); + "4.0.0" ); validateStringNoExpression( "groupId", problems, Severity.WARNING, Version.V20, m.getGroupId(), m ); if ( parent == null ) @@ -166,23 +166,23 @@ && equals( parent.getArtifactId(), m.getArtifactId() ) ) "must be unique but found duplicate profile with id " + profile.getId(), profile ); } - validate30RawProfileActivation( problems, profile.getActivation(), profile.getId(), prefix - + ".activation", request ); + validate30RawProfileActivation( problems, profile.getActivation(), profile.getId(), + prefix + ".activation", request ); validate20RawDependencies( problems, profile.getDependencies(), prefix + ".dependencies.dependency", - request ); + request ); if ( profile.getDependencyManagement() != null ) { - validate20RawDependencies( problems, profile.getDependencyManagement().getDependencies(), prefix - + ".dependencyManagement.dependencies.dependency", request ); + validate20RawDependencies( problems, profile.getDependencyManagement().getDependencies(), + prefix + ".dependencyManagement.dependencies.dependency", request ); } validateRawRepositories( problems, profile.getRepositories(), prefix + ".repositories.repository", - request ); + request ); - validateRawRepositories( problems, profile.getPluginRepositories(), prefix - + ".pluginRepositories.pluginRepository", request ); + validateRawRepositories( problems, profile.getPluginRepositories(), + prefix + ".pluginRepositories.pluginRepository", request ); BuildBase buildBase = profile.getBuild(); if ( buildBase != null ) @@ -193,7 +193,7 @@ && equals( parent.getArtifactId(), m.getArtifactId() ) ) if ( mngt != null ) { validate20RawPlugins( problems, mngt.getPlugins(), prefix + ".pluginManagement.plugins.plugin", - request ); + request ); } } } @@ -232,11 +232,8 @@ else if ( StringUtils.isNotEmpty( file.getMissing() ) ) if ( path.contains( "${project.basedir}" ) ) { - addViolation( problems, - Severity.WARNING, - Version.V30, - prefix + ( missing ? ".file.missing" : ".file.exists" ), - null, + addViolation( problems, Severity.WARNING, Version.V30, + prefix + ( missing ? ".file.missing" : ".file.exists" ), null, "Failed to interpolate file location " + path + " for profile " + sourceHint + ": ${project.basedir} expression not supported during profile activation, " + "use ${basedir} instead", @@ -244,15 +241,9 @@ else if ( StringUtils.isNotEmpty( file.getMissing() ) ) } else if ( hasProjectExpression( path ) ) { - addViolation( problems, - Severity.WARNING, - Version.V30, - prefix + ( missing ? ".file.missing" : ".file.exists" ), - null, - "Failed to interpolate file location " - + path - + " for profile " - + sourceHint + addViolation( problems, Severity.WARNING, Version.V30, + prefix + ( missing ? ".file.missing" : ".file.exists" ), null, + "Failed to interpolate file location " + path + " for profile " + sourceHint + ": ${project.*} expressions are not supported during profile activation", file.getLocation( missing ? "missing" : "exists" ) ); } @@ -260,7 +251,7 @@ else if ( hasProjectExpression( path ) ) } private void validate20RawPlugins( ModelProblemCollector problems, List plugins, String prefix, - ModelBuildingRequest request ) + ModelBuildingRequest request ) { Severity errOn31 = getSeverity( request, ModelBuildingRequest.VALIDATION_LEVEL_MAVEN_3_1 ); @@ -268,6 +259,27 @@ private void validate20RawPlugins( ModelProblemCollector problems, List for ( Plugin plugin : plugins ) { + if ( plugin.getGroupId() == null + || ( plugin.getGroupId() != null && plugin.getGroupId().trim().isEmpty() ) ) + { + addViolation( problems, Severity.FATAL, Version.V20, prefix + ".(groupId:artifactId)", null, + "groupId of a plugin must be defined. ", plugin ); + } + + if ( plugin.getArtifactId() == null + || ( plugin.getArtifactId() != null && plugin.getArtifactId().trim().isEmpty() ) ) + { + addViolation( problems, Severity.FATAL, Version.V20, prefix + ".(groupId:artifactId)", null, + "artifactId of a plugin must be defined. ", plugin ); + } + + // This will catch cases like or + if ( plugin.getVersion() != null && plugin.getVersion().trim().isEmpty() ) + { + addViolation( problems, Severity.FATAL, Version.V20, prefix + ".(groupId:artifactId)", null, + "version of a plugin must be defined. ", plugin ); + } + String key = plugin.getKey(); Plugin existing = index.get( key ); @@ -288,9 +300,9 @@ private void validate20RawPlugins( ModelProblemCollector problems, List { if ( !executionIds.add( exec.getId() ) ) { - addViolation( problems, Severity.ERROR, Version.V20, prefix + "[" + plugin.getKey() - + "].executions.execution.id", null, "must be unique but found duplicate execution with id " - + exec.getId(), exec ); + addViolation( problems, Severity.ERROR, Version.V20, + prefix + "[" + plugin.getKey() + "].executions.execution.id", null, + "must be unique but found duplicate execution with id " + exec.getId(), exec ); } } } @@ -311,9 +323,8 @@ public void validateEffectiveModel( Model m, ModelBuildingRequest request, Model { if ( !"pom".equals( m.getPackaging() ) ) { - addViolation( problems, Severity.ERROR, Version.BASE, "packaging", null, - "with value '" + m.getPackaging() + "' is invalid. Aggregator projects " - + "require 'pom' as packaging.", m ); + addViolation( problems, Severity.ERROR, Version.BASE, "packaging", null, "with value '" + + m.getPackaging() + "' is invalid. Aggregator projects " + "require 'pom' as packaging.", m ); } for ( int i = 0, n = m.getModules().size(); i < n; i++ ) @@ -373,8 +384,8 @@ public void validateEffectiveModel( Model m, ModelBuildingRequest request, Model validate20PluginVersion( "build.plugins.plugin.version", problems, p.getVersion(), p.getKey(), p, request ); - validateBoolean( "build.plugins.plugin.inherited", problems, errOn30, Version.V20, - p.getInherited(), p.getKey(), p ); + validateBoolean( "build.plugins.plugin.inherited", problems, errOn30, Version.V20, p.getInherited(), + p.getKey(), p ); validateBoolean( "build.plugins.plugin.extensions", problems, errOn30, Version.V20, p.getExtensions(), p.getKey(), p ); @@ -423,7 +434,7 @@ public void validateEffectiveModel( Model m, ModelBuildingRequest request, Model validate20EffectiveRepository( problems, distMgmt.getRepository(), "distributionManagement.repository", request ); validate20EffectiveRepository( problems, distMgmt.getSnapshotRepository(), - "distributionManagement.snapshotRepository", request ); + "distributionManagement.snapshotRepository", request ); } } } @@ -467,7 +478,8 @@ else if ( sysPath.contains( "${basedir}" ) || sysPath.contains( "${project.based { addViolation( problems, Severity.WARNING, Version.V20, prefix + ".systemPath", key, "should not point at files within the project directory, " + sysPath - + " will be unresolvable by dependent projects", dependency ); + + " will be unresolvable by dependent projects", + dependency ); } } } @@ -479,15 +491,13 @@ else if ( sysPath.contains( "${basedir}" ) || sysPath.contains( "${project.based String msg; if ( equals( existing.getVersion(), dependency.getVersion() ) ) { - msg = - "duplicate declaration of version " - + StringUtils.defaultString( dependency.getVersion(), "(?)" ); + msg = "duplicate declaration of version " + + StringUtils.defaultString( dependency.getVersion(), "(?)" ); } else { - msg = - "version " + StringUtils.defaultString( existing.getVersion(), "(?)" ) + " vs " - + StringUtils.defaultString( dependency.getVersion(), "(?)" ); + msg = "version " + StringUtils.defaultString( existing.getVersion(), "(?)" ) + " vs " + + StringUtils.defaultString( dependency.getVersion(), "(?)" ); } addViolation( problems, errOn31, Version.V20, prefix + ".(groupId:artifactId:type:classifier)", null, @@ -522,8 +532,8 @@ private void validateEffectiveDependencies( ModelProblemCollector problems, List d.getManagementKey(), d ); /* - * TODO: Extensions like Flex Mojos use custom scopes like "merged", "internal", "external", etc. - * In order to don't break backward-compat with those, only warn but don't error out. + * TODO: Extensions like Flex Mojos use custom scopes like "merged", "internal", "external", etc. In + * order to don't break backward-compat with those, only warn but don't error out. */ validateEnum( prefix + "scope", problems, Severity.WARNING, Version.V20, d.getScope(), d.getManagementKey(), d, "provided", "compile", "runtime", "test", "system" ); @@ -600,8 +610,8 @@ else if ( !sysFile.isFile() ) { msg += ". Please verify that you run Maven using a JDK and not just a JRE."; } - addViolation( problems, Severity.WARNING, Version.BASE, prefix + "systemPath", - d.getManagementKey(), msg, d ); + addViolation( problems, Severity.WARNING, Version.BASE, prefix + "systemPath", d.getManagementKey(), + msg, d ); } } } @@ -637,7 +647,7 @@ else if ( StringUtils.isNotEmpty( d.getSystemPath() ) ) } /** - * @since 3.2.4 + * @since 3.2.4 */ protected void validateDependencyVersion( ModelProblemCollector problems, Dependency d, String prefix ) { @@ -646,7 +656,7 @@ protected void validateDependencyVersion( ModelProblemCollector problems, Depend } private void validateRawRepositories( ModelProblemCollector problems, List repositories, String prefix, - ModelBuildingRequest request ) + ModelBuildingRequest request ) { Map index = new HashMap<>(); @@ -666,9 +676,8 @@ private void validateRawRepositories( ModelProblemCollector problems, List " + existing.getUrl() + " vs " - + repository.getUrl(), repository ); + addViolation( problems, errOn30, Version.V20, prefix + ".id", null, "must be unique: " + + repository.getId() + " -> " + existing.getUrl() + " vs " + repository.getUrl(), repository ); } else { @@ -678,7 +687,7 @@ private void validateRawRepositories( ModelProblemCollector problems, List resources, String prefix, - ModelBuildingRequest request ) + ModelBuildingRequest request ) { Severity errOn30 = getSeverity( request, ModelBuildingRequest.VALIDATION_LEVEL_MAVEN_3_0 ); @@ -739,8 +749,8 @@ private boolean validateId( String fieldName, ModelProblemCollector problems, Se boolean match = ID_REGEX.matcher( id ).matches(); if ( !match ) { - addViolation( problems, severity, version, fieldName, sourceHint, "with value '" + id - + "' does not match a valid id pattern.", tracker ); + addViolation( problems, severity, version, fieldName, sourceHint, + "with value '" + id + "' does not match a valid id pattern.", tracker ); } return match; } @@ -759,14 +769,13 @@ private boolean validateIdWithWildcards( String fieldName, ModelProblemCollector boolean match = ID_WITH_WILDCARDS_REGEX.matcher( id ).matches(); if ( !match ) { - addViolation( problems, severity, version, fieldName, sourceHint, "with value '" + id - + "' does not match a valid id pattern.", tracker ); + addViolation( problems, severity, version, fieldName, sourceHint, + "with value '" + id + "' does not match a valid id pattern.", tracker ); } return match; } } - private boolean validateStringNoExpression( String fieldName, ModelProblemCollector problems, Severity severity, Version version, String string, InputLocationTracker tracker ) { @@ -885,8 +894,8 @@ private boolean validateBoolean( String fieldName, ModelProblemCollector problem return true; } - addViolation( problems, severity, version, fieldName, sourceHint, "must be 'true' or 'false' but is '" + string - + "'.", tracker ); + addViolation( problems, severity, version, fieldName, sourceHint, + "must be 'true' or 'false' but is '" + string + "'.", tracker ); return false; } @@ -907,8 +916,8 @@ private boolean validateEnum( String fieldName, ModelProblemCollector problems, return true; } - addViolation( problems, severity, version, fieldName, sourceHint, "must be one of " + values + " but is '" - + string + "'.", tracker ); + addViolation( problems, severity, version, fieldName, sourceHint, + "must be one of " + values + " but is '" + string + "'.", tracker ); return false; } @@ -925,7 +934,8 @@ private boolean validateBannedCharacters( String fieldName, ModelProblemCollecto { addViolation( problems, severity, version, fieldName, sourceHint, "must not contain any of these characters " + banned + " but found " - + string.charAt( i ), tracker ); + + string.charAt( i ), + tracker ); return false; } } @@ -992,8 +1002,8 @@ private boolean validate20PluginVersion( String fieldName, ModelProblemCollector if ( string.length() <= 0 || "RELEASE".equals( string ) || "LATEST".equals( string ) ) { - addViolation( problems, errOn30, Version.V20, fieldName, sourceHint, "must be a valid version but is '" - + string + "'.", tracker ); + addViolation( problems, errOn30, Version.V20, fieldName, sourceHint, + "must be a valid version but is '" + string + "'.", tracker ); return false; } @@ -1014,8 +1024,11 @@ private static void addViolation( ModelProblemCollector problems, Severity sever buffer.append( ' ' ).append( message ); - problems.add( new ModelProblemCollectorRequest( severity, version ) - .setMessage( buffer.toString() ).setLocation( getLocation( fieldName, tracker ) ) ); + // CHECKSTYLE_OFF: LineLength + problems.add( new ModelProblemCollectorRequest( severity, + version ).setMessage( buffer.toString() ).setLocation( getLocation( fieldName, + tracker ) ) ); + // CHECKSTYLE_ON: LineLength } private static InputLocation getLocation( String fieldName, InputLocationTracker tracker ) diff --git a/maven-model-builder/src/main/java/org/apache/maven/model/versioning/ModelVersions.java b/maven-model-builder/src/main/java/org/apache/maven/model/versioning/ModelVersions.java deleted file mode 100644 index 6b527ca8666c..000000000000 --- a/maven-model-builder/src/main/java/org/apache/maven/model/versioning/ModelVersions.java +++ /dev/null @@ -1,132 +0,0 @@ -package org.apache.maven.model.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.Objects; - -import org.apache.maven.model.Model; - -/** - * Gathers model version information. - * - * @author Christian Schulte - * @since 3.4 - */ -public final class ModelVersions -{ - - /** - * Creates a new {@code ModelVersions} instance. - */ - private ModelVersions() - { - super(); - } - - /** - * Constant for model version {@code 4.0.0}. - */ - public static final String V4_0_0 = "4.0.0"; - - /** - * Constant for model version {@code 4.1.0}. - */ - public static final String V4_1_0 = "4.1.0"; - - /** - * Tests whether dependency management import version ranges are supported for a given {@code Model}. - * - * @param model The {@code Model} to test. - * - * @return {@code true}, if dependency management import version ranges are supported for {@code model}; - * {@code false}, if dependency management import version ranges are not supported for {@code model}. - */ - public static boolean supportsDependencyManagementImportVersionRanges( final Model model ) - { - // [MNG-4463] Version ranges cannot be used for artifacts with 'import' scope - return isGreaterOrEqual( model, V4_1_0 ); - } - - /** - * Tests whether dependency management import exclusions are supported for a given {@code Model}. - * - * @param model The {@code Model} to test. - * - * @return {@code true}, if dependency management import exclusions are supported for {@code model}; - * {@code false}, if dependency management import exclusions are not supported for {@code model}. - */ - public static boolean supportsDependencyManagementImportExclusions( final Model model ) - { - // [MNG-5600] Dependency management import should support exclusions. - return isGreaterOrEqual( model, V4_1_0 ); - } - - /** - * Tests whether dependency management import relocations are supported for a given {@code Model}. - * - * @param model The {@code Model} to test. - * - * @return {@code true}, if dependency management import relocations are supported for {@code model}; - * {@code false}, if dependency management import relocations are not supported for {@code model}. - */ - public static boolean supportsDependencyManagementImportRelocations( final Model model ) - { - // [MNG-5527] Dependency management import should support relocations. - return isGreaterOrEqual( model, V4_1_0 ); - } - - /** - * Tests whether dependency management import inheritance processing is supported for a given {@code Model}. - * - * @param model The {@code Model} to test. - * - * @return {@code true}, if dependency management import inheritance processing is supported for {@code model}; - * {@code false}, if dependency management import inheritance processing is not supported for {@code model}. - */ - public static boolean supportsDependencyManagementImportInheritanceProcessing( final Model model ) - { - // [MNG-5971] Imported dependencies should be available to inheritance processing - return isGreaterOrEqual( model, V4_1_0 ); - } - - private static boolean isGreaterOrEqual( final Model model, final String version ) - { - Objects.requireNonNull( model, "model" ); - Objects.requireNonNull( version, "version" ); - - if ( null != model.getModelVersion() ) - { - switch ( model.getModelVersion() ) - { - case V4_0_0: - return V4_0_0.equals( version ); - case V4_1_0: - return V4_0_0.equals( version ) || V4_1_0.equals( version ); - default: - throw new AssertionError( String.format( "Unsupported model version '%s'.", version ) ); - } - } - - // [MNG-666] need to be able to operate on a Maven 1 repository - // Handles null as the lowest version possible. - return false; - } - -} diff --git a/maven-model-builder/src/main/resources/org/apache/maven/model/pom-4.0.0.xml b/maven-model-builder/src/main/resources/org/apache/maven/model/pom-4.0.0.xml index 91492a92f22e..b12096207707 100644 --- a/maven-model-builder/src/main/resources/org/apache/maven/model/pom-4.0.0.xml +++ b/maven-model-builder/src/main/resources/org/apache/maven/model/pom-4.0.0.xml @@ -26,19 +26,22 @@ under the License. central - Central Repository + Maven Central Repository https://repo.maven.apache.org/maven2 default false + + never + central - Central Repository + Maven Central Repository https://repo.maven.apache.org/maven2 default @@ -62,34 +65,20 @@ under the License. ${project.basedir}/src/main/resources + + ${project.basedir}/src/main/resources-filtered + true + ${project.basedir}/src/test/resources + + ${project.basedir}/src/test/resources-filtered + true + - - - - - - maven-antrun-plugin - 1.3 - - - maven-assembly-plugin - 2.2-beta-5 - - - maven-dependency-plugin - 2.8 - - - maven-release-plugin - 2.3.2 - - - @@ -117,7 +106,7 @@ under the License. attach-sources - jar + jar-no-fork diff --git a/maven-model-builder/src/main/resources/org/apache/maven/model/pom-4.1.0.xml b/maven-model-builder/src/main/resources/org/apache/maven/model/pom-4.1.0.xml deleted file mode 100644 index 39a5d5d69069..000000000000 --- a/maven-model-builder/src/main/resources/org/apache/maven/model/pom-4.1.0.xml +++ /dev/null @@ -1,109 +0,0 @@ - - - - - - - 4.1.0 - - - ${project.basedir}/target - ${project.build.directory}/classes - ${project.artifactId}-${project.version} - ${project.build.directory}/test-classes - ${project.basedir}/src/main/java - ${project.basedir}/src/main/scripts - ${project.basedir}/src/test/java - - - ${project.basedir}/src/main/resources - - - ${project.basedir}/src/main/resources-filtered - true - - - - - ${project.basedir}/src/test/resources - - - ${project.basedir}/src/test/resources-filtered - true - - - - - - ${project.build.directory}/site - - - - - - release-profile - - - - performRelease - true - - - - - - - true - maven-source-plugin - - - attach-sources - - jar-no-fork - - - - - - true - maven-javadoc-plugin - - - attach-javadocs - - jar - - - - - - true - maven-deploy-plugin - - true - - - - - - - - - diff --git a/maven-model-builder/src/site/apt/index.apt b/maven-model-builder/src/site/apt/index.apt index 74fa041679ce..a5b42b4b84e8 100644 --- a/maven-model-builder/src/site/apt/index.apt +++ b/maven-model-builder/src/site/apt/index.apt @@ -126,7 +126,7 @@ Maven Model Builder Notice that the 5 urls from the model (<<>>, <<>>, <<>>, <<>> and <<>>) have a special inheritance handling: - + ** if not configured in current model, the inherited value is parent's one with current artifact id appended, ** since Maven 3.4.0, if <<>> POM property value is defined, it is used instead of artifact id: diff --git a/maven-model-builder/src/test/java/org/apache/maven/model/inheritance/DefaultInheritanceAssemblerTest.java b/maven-model-builder/src/test/java/org/apache/maven/model/inheritance/DefaultInheritanceAssemblerTest.java index d49e8df33d05..53ce958d88ca 100644 --- a/maven-model-builder/src/test/java/org/apache/maven/model/inheritance/DefaultInheritanceAssemblerTest.java +++ b/maven-model-builder/src/test/java/org/apache/maven/model/inheritance/DefaultInheritanceAssemblerTest.java @@ -149,12 +149,12 @@ public void testFlatTrickyUrls() } } - public void testWithEmptyUrl() + public void testWithEmptyUrl() throws Exception { testInheritance( "empty-urls", false ); } - + public void testInheritance( String baseName ) throws Exception { @@ -195,7 +195,7 @@ public void testInheritance( String baseName, boolean fromRepo ) XMLUnit.setIgnoreWhitespace( true ); XMLAssert.assertXMLEqual( control, test ); } - } + } public void testModulePathNotArtifactId() throws Exception diff --git a/maven-model-builder/src/test/java/org/apache/maven/model/merge/MavenModelMergerTest.java b/maven-model-builder/src/test/java/org/apache/maven/model/merge/MavenModelMergerTest.java index 3832b0c2d945..c23be0fdf5c8 100644 --- a/maven-model-builder/src/test/java/org/apache/maven/model/merge/MavenModelMergerTest.java +++ b/maven-model-builder/src/test/java/org/apache/maven/model/merge/MavenModelMergerTest.java @@ -73,7 +73,7 @@ public void testMergeModel_Prerequisites() Model model = new Model(); modelMerger.mergeModel_Prerequisites( model, parent, false, null ); assertNull( model.getPrerequisites() ); - + Prerequisites modelPrerequisites = new Prerequisites(); modelPrerequisites.setMaven( "3.0" ); model.setPrerequisites( modelPrerequisites ); @@ -90,7 +90,7 @@ public void testMergeModel_Profiles() Model model = new Model(); modelMerger.mergeModel_Profiles( model, parent, false, null ); assertEquals( 0, model.getProfiles().size() ); - + Profile modelProfile = new Profile(); modelProfile.setId( "MODEL" ); model.setProfiles( Collections.singletonList( modelProfile ) ); diff --git a/maven-model-builder/src/test/java/org/apache/maven/model/validation/DefaultModelValidatorTest.java b/maven-model-builder/src/test/java/org/apache/maven/model/validation/DefaultModelValidatorTest.java index 3f44634da111..a7b0c9a16281 100644 --- a/maven-model-builder/src/test/java/org/apache/maven/model/validation/DefaultModelValidatorTest.java +++ b/maven-model-builder/src/test/java/org/apache/maven/model/validation/DefaultModelValidatorTest.java @@ -163,7 +163,8 @@ public void testInvalidIds() assertEquals( "'groupId' with value 'o/a/m' does not match a valid id pattern.", result.getErrors().get( 0 ) ); - assertEquals( "'artifactId' with value 'm$-do$' does not match a valid id pattern.", result.getErrors().get( 1 ) ); + assertEquals( "'artifactId' with value 'm$-do$' does not match a valid id pattern.", + result.getErrors().get( 1 ) ); } public void testMissingType() @@ -203,8 +204,7 @@ public void testMissingDependencyArtifactId() assertViolations( result, 0, 1, 0 ); - assertTrue( result.getErrors().get( 0 ).contains( - "'dependencies.dependency.artifactId' for groupId:null:jar is missing" ) ); + assertTrue( result.getErrors().get( 0 ).contains( "'dependencies.dependency.artifactId' for groupId:null:jar is missing" ) ); } public void testMissingDependencyGroupId() @@ -214,8 +214,7 @@ public void testMissingDependencyGroupId() assertViolations( result, 0, 1, 0 ); - assertTrue( result.getErrors().get( 0 ).contains( - "'dependencies.dependency.groupId' for null:artifactId:jar is missing" ) ); + assertTrue( result.getErrors().get( 0 ).contains( "'dependencies.dependency.groupId' for null:artifactId:jar is missing" ) ); } public void testMissingDependencyVersion() @@ -225,8 +224,7 @@ public void testMissingDependencyVersion() assertViolations( result, 0, 1, 0 ); - assertTrue( result.getErrors().get( 0 ).contains( - "'dependencies.dependency.version' for groupId:artifactId:jar is missing" ) ); + assertTrue( result.getErrors().get( 0 ).contains( "'dependencies.dependency.version' for groupId:artifactId:jar is missing" ) ); } public void testMissingDependencyManagementArtifactId() @@ -236,8 +234,7 @@ public void testMissingDependencyManagementArtifactId() assertViolations( result, 0, 1, 0 ); - assertTrue( result.getErrors().get( 0 ).contains( - "'dependencyManagement.dependencies.dependency.artifactId' for groupId:null:jar is missing" ) ); + assertTrue( result.getErrors().get( 0 ).contains( "'dependencyManagement.dependencies.dependency.artifactId' for groupId:null:jar is missing" ) ); } public void testMissingDependencyManagementGroupId() @@ -247,8 +244,7 @@ public void testMissingDependencyManagementGroupId() assertViolations( result, 0, 1, 0 ); - assertTrue( result.getErrors().get( 0 ).contains( - "'dependencyManagement.dependencies.dependency.groupId' for null:artifactId:jar is missing" ) ); + assertTrue( result.getErrors().get( 0 ).contains( "'dependencyManagement.dependencies.dependency.groupId' for null:artifactId:jar is missing" ) ); } public void testMissingAll() @@ -555,7 +551,8 @@ public void testBadRepositoryId() public void testBadDependencyExclusionId() throws Exception { - SimpleProblemCollector result = validateEffective( "bad-dependency-exclusion-id.xml", ModelBuildingRequest.VALIDATION_LEVEL_MAVEN_2_0 ); + SimpleProblemCollector result = + validateEffective( "bad-dependency-exclusion-id.xml", ModelBuildingRequest.VALIDATION_LEVEL_MAVEN_2_0 ); assertViolations( result, 0, 0, 2 ); @@ -620,6 +617,57 @@ public void testSystemPathRefersToProjectBasedir() + "should not point at files within the project directory" ); } + public void testInvalidVersionInPluginManagement() + throws Exception + { + SimpleProblemCollector result = validateRaw( "raw-model/missing-plugin-version-pluginManagement.xml" ); + + assertViolations( result, 1, 0, 0 ); + + assertEquals( "'build.pluginManagement.plugins.plugin.(groupId:artifactId)' version of a plugin must be defined. ", + result.getFatals().get( 0 ) ); + + } + + public void testInvalidGroupIdInPluginManagement() + throws Exception + { + SimpleProblemCollector result = validateRaw( "raw-model/missing-groupId-pluginManagement.xml" ); + + assertViolations( result, 1, 0, 0 ); + + assertEquals( "'build.pluginManagement.plugins.plugin.(groupId:artifactId)' groupId of a plugin must be defined. ", + result.getFatals().get( 0 ) ); + + } + + public void testInvalidArtifactIdInPluginManagement() + throws Exception + { + SimpleProblemCollector result = validateRaw( "raw-model/missing-artifactId-pluginManagement.xml" ); + + assertViolations( result, 1, 0, 0 ); + + assertEquals( "'build.pluginManagement.plugins.plugin.(groupId:artifactId)' artifactId of a plugin must be defined. ", + result.getFatals().get( 0 ) ); + + } + + public void testInvalidGroupAndArtifactIdInPluginManagement() + throws Exception + { + SimpleProblemCollector result = validateRaw( "raw-model/missing-ga-pluginManagement.xml" ); + + assertViolations( result, 2, 0, 0 ); + + assertEquals( "'build.pluginManagement.plugins.plugin.(groupId:artifactId)' groupId of a plugin must be defined. ", + result.getFatals().get( 0 ) ); + + assertEquals( "'build.pluginManagement.plugins.plugin.(groupId:artifactId)' artifactId of a plugin must be defined. ", + result.getFatals().get( 1 ) ); + + } + public void testMissingReportPluginVersion() throws Exception { @@ -627,4 +675,5 @@ public void testMissingReportPluginVersion() assertViolations( result, 0, 0, 0 ); } + } diff --git a/maven-model-builder/src/test/resources/poms/inheritance/module-path-not-artifactId-child.xml b/maven-model-builder/src/test/resources/poms/inheritance/module-path-not-artifactId-child.xml index 7031f448e131..d051a7cc566e 100644 --- a/maven-model-builder/src/test/resources/poms/inheritance/module-path-not-artifactId-child.xml +++ b/maven-model-builder/src/test/resources/poms/inheritance/module-path-not-artifactId-child.xml @@ -34,7 +34,7 @@ under the License. artifactId == "child-artifact-id" but expect path on SCM and site == "child" - feature: support "project.directory" property, ressembling future model addition of "directory" element along "artifactId" + feature: support "project.directory" property, ressembling future model addition of "directory" element along "artifactId" diff --git a/maven-model-builder/src/test/resources/poms/inheritance/module-path-not-artifactId-expected.xml b/maven-model-builder/src/test/resources/poms/inheritance/module-path-not-artifactId-expected.xml index e82f2894b745..fd2ff9695705 100644 --- a/maven-model-builder/src/test/resources/poms/inheritance/module-path-not-artifactId-expected.xml +++ b/maven-model-builder/src/test/resources/poms/inheritance/module-path-not-artifactId-expected.xml @@ -36,7 +36,7 @@ under the License. artifactId == "child-artifact-id" but expect path on SCM and site == "child" - feature: support "project.directory" property, ressembling future model addition of "directory" element along "artifactId" + feature: support "project.directory" property, ressembling future model addition of "directory" element along "artifactId" diff --git a/maven-model-builder/src/test/resources/poms/validation/raw-model/missing-artifactId-pluginManagement.xml b/maven-model-builder/src/test/resources/poms/validation/raw-model/missing-artifactId-pluginManagement.xml new file mode 100644 index 000000000000..194abf86e123 --- /dev/null +++ b/maven-model-builder/src/test/resources/poms/validation/raw-model/missing-artifactId-pluginManagement.xml @@ -0,0 +1,39 @@ + + + + 4.0.0 + com.example.group + testinvalidpom + 0.0.1-SNAPSHOT + + + + + + the.groupId.Of.This.Plugin + + + + + + \ No newline at end of file diff --git a/maven-model-builder/src/test/resources/poms/validation/raw-model/missing-ga-pluginManagement.xml b/maven-model-builder/src/test/resources/poms/validation/raw-model/missing-ga-pluginManagement.xml new file mode 100644 index 000000000000..4058dd64888b --- /dev/null +++ b/maven-model-builder/src/test/resources/poms/validation/raw-model/missing-ga-pluginManagement.xml @@ -0,0 +1,39 @@ + + + + 4.0.0 + com.example.group + testinvalidpom + 0.0.1-SNAPSHOT + + + + + + + + + + + + \ No newline at end of file diff --git a/maven-model-builder/src/test/resources/poms/validation/raw-model/missing-groupId-pluginManagement.xml b/maven-model-builder/src/test/resources/poms/validation/raw-model/missing-groupId-pluginManagement.xml new file mode 100644 index 000000000000..f3f23e6c2af8 --- /dev/null +++ b/maven-model-builder/src/test/resources/poms/validation/raw-model/missing-groupId-pluginManagement.xml @@ -0,0 +1,39 @@ + + + + 4.0.0 + com.example.group + testinvalidpom + 0.0.1-SNAPSHOT + + + + + + + this-is-the-artifact + + + + + \ No newline at end of file diff --git a/maven-model-builder/src/test/resources/poms/validation/raw-model/missing-plugin-version-pluginManagement.xml b/maven-model-builder/src/test/resources/poms/validation/raw-model/missing-plugin-version-pluginManagement.xml new file mode 100644 index 000000000000..94b1777a6c11 --- /dev/null +++ b/maven-model-builder/src/test/resources/poms/validation/raw-model/missing-plugin-version-pluginManagement.xml @@ -0,0 +1,40 @@ + + + + 4.0.0 + com.example.group + testinvalidpom + 0.0.1-SNAPSHOT + + + + + + the.group.id + the.artifact + + + + + + \ No newline at end of file diff --git a/maven-model/src/main/mdo/maven.mdo b/maven-model/src/main/mdo/maven.mdo index 908beb36c63a..351fc45a24ba 100644 --- a/maven-model/src/main/mdo/maven.mdo +++ b/maven-model/src/main/mdo/maven.mdo @@ -245,7 +245,7 @@ Default value is: parent value [+ path adjustment] + (artifactId or project.directory property), or just parent value if +
    Default value is: parent value [+ path adjustment] + (artifactId or project.directory property), or just parent value if project's child.project.url.inherit.append.path="false" ]]>
    @@ -2175,7 +2175,7 @@ URL format and list of supported SCMs. This connection is read-only. -
    Default value is: parent value [+ path adjustment] + (artifactId or project.directory property), or just parent value if +
    Default value is: parent value [+ path adjustment] + (artifactId or project.directory property), or just parent value if scm's child.scm.connection.inherit.append.path="false" ]]> @@ -2188,7 +2188,7 @@ connection, but for developers, i.e. this scm connection will not be read only. -
    Default value is: parent value [+ path adjustment] + (artifactId or project.directory property), or just parent value if +
    Default value is: parent value [+ path adjustment] + (artifactId or project.directory property), or just parent value if scm's child.scm.developerConnection.inherit.append.path="false" ]]> @@ -2207,7 +2207,7 @@ Default value is: parent value [+ path adjustment] + (artifactId or project.directory property), or just parent value if +
    Default value is: parent value [+ path adjustment] + (artifactId or project.directory property), or just parent value if scm's child.scm.url.inherit.append.path="false" ]]>
    @@ -2723,7 +2723,7 @@ protocol://hostname/path. -
    Default value is: parent value [+ path adjustment] + (artifactId or project.directory property), or just parent value if +
    Default value is: parent value [+ path adjustment] + (artifactId or project.directory property), or just parent value if site's child.site.url.inherit.append.path="false" ]]>
    @@ -3636,12 +3636,12 @@ String 2.0 - For specifying the minimum version of Maven required to build a - project, this element is deprecated. Use the Maven Enforcer - Plugin's requireMavenVersion - rule instead. + For a plugin project (packaging is maven-plugin), the minimum version of + Maven required to use the resulting plugin.
    + In Maven 2, this was also specifying the minimum version of Maven required to build a + project, but this usage is deprecated in Maven 3 and not checked any more: use + the Maven Enforcer Plugin's + requireMavenVersion rule instead. ]]>
    false diff --git a/maven-plugin-api/src/main/java/org/apache/maven/plugin/descriptor/PluginDescriptorBuilder.java b/maven-plugin-api/src/main/java/org/apache/maven/plugin/descriptor/PluginDescriptorBuilder.java index 7224554d5087..9508c5136dbb 100644 --- a/maven-plugin-api/src/main/java/org/apache/maven/plugin/descriptor/PluginDescriptorBuilder.java +++ b/maven-plugin-api/src/main/java/org/apache/maven/plugin/descriptor/PluginDescriptorBuilder.java @@ -299,6 +299,8 @@ public MojoDescriptor buildComponentDescriptor( PlexusConfiguration c, PluginDes parameter.setImplementation( d.getChild( "implementation" ).getValue() ); + parameter.setSince( d.getChild( "since" ).getValue() ); + PlexusConfiguration paramConfig = mojoConfig.getChild( parameter.getName(), false ); if ( paramConfig != null ) { diff --git a/maven-plugin-api/src/test/java/org/apache/maven/plugin/descriptor/PluginDescriptorBuilderTest.java b/maven-plugin-api/src/test/java/org/apache/maven/plugin/descriptor/PluginDescriptorBuilderTest.java index 799e3af0e2c1..b9f5ab9e9e94 100644 --- a/maven-plugin-api/src/test/java/org/apache/maven/plugin/descriptor/PluginDescriptorBuilderTest.java +++ b/maven-plugin-api/src/test/java/org/apache/maven/plugin/descriptor/PluginDescriptorBuilderTest.java @@ -108,6 +108,7 @@ public void testBuildReader() assertEquals( "deprecated-parameter", mp.getDeprecated() ); assertEquals( "${jar.finalName}", mp.getExpression() ); assertEquals( "${project.build.finalName}", mp.getDefaultValue() ); + assertEquals( "3.0.0", mp.getSince() ); ComponentRequirement cr = md.getRequirements().get( 0 ); diff --git a/maven-plugin-api/src/test/resources/plugin.xml b/maven-plugin-api/src/test/resources/plugin.xml index 6b972113a7bd..add46dcf872e 100644 --- a/maven-plugin-api/src/test/resources/plugin.xml +++ b/maven-plugin-api/src/test/resources/plugin.xml @@ -60,6 +60,7 @@ under the License. true parameter-description deprecated-parameter + 3.0.0 diff --git a/maven-settings-builder/src/main/java/org/apache/maven/settings/building/DefaultSettingsBuildingRequest.java b/maven-settings-builder/src/main/java/org/apache/maven/settings/building/DefaultSettingsBuildingRequest.java index 5a4824e0efa4..4bb691b4bae2 100644 --- a/maven-settings-builder/src/main/java/org/apache/maven/settings/building/DefaultSettingsBuildingRequest.java +++ b/maven-settings-builder/src/main/java/org/apache/maven/settings/building/DefaultSettingsBuildingRequest.java @@ -116,10 +116,9 @@ public DefaultSettingsBuildingRequest setSystemProperties( Properties systemProp if ( systemProperties != null ) { this.systemProperties = new Properties(); - // MNG-5670 guard against ConcurrentModificationException - for ( String key : System.getProperties().stringPropertyNames() ) - { - this.systemProperties.put( key, System.getProperty( key ) ); + synchronized ( systemProperties ) + { // avoid concurrentmodification if someone else sets/removes an unrelated system property + this.systemProperties.putAll( systemProperties ); } } else diff --git a/maven-settings-builder/src/main/java/org/apache/maven/settings/building/FileSettingsSource.java b/maven-settings-builder/src/main/java/org/apache/maven/settings/building/FileSettingsSource.java index 3c2d32acb9d4..711261d51112 100644 --- a/maven-settings-builder/src/main/java/org/apache/maven/settings/building/FileSettingsSource.java +++ b/maven-settings-builder/src/main/java/org/apache/maven/settings/building/FileSettingsSource.java @@ -27,7 +27,7 @@ * Wraps an ordinary {@link File} as a settings source. * * @author Benjamin Bentmann - * + * * @deprecated instead use {@link FileSource} */ @Deprecated diff --git a/maven-settings-builder/src/main/java/org/apache/maven/settings/building/SettingsSource.java b/maven-settings-builder/src/main/java/org/apache/maven/settings/building/SettingsSource.java index 413a3570af9d..a933b097c9c6 100644 --- a/maven-settings-builder/src/main/java/org/apache/maven/settings/building/SettingsSource.java +++ b/maven-settings-builder/src/main/java/org/apache/maven/settings/building/SettingsSource.java @@ -25,7 +25,7 @@ * Provides access to the contents of settings independently of the backing store (e.g. file system, database, memory). * * @author Benjamin Bentmann - * + * * @deprecated instead use {@link Source} */ @Deprecated diff --git a/maven-settings-builder/src/main/java/org/apache/maven/settings/building/StringSettingsSource.java b/maven-settings-builder/src/main/java/org/apache/maven/settings/building/StringSettingsSource.java index dbe9758069bb..989fc0ef87bb 100644 --- a/maven-settings-builder/src/main/java/org/apache/maven/settings/building/StringSettingsSource.java +++ b/maven-settings-builder/src/main/java/org/apache/maven/settings/building/StringSettingsSource.java @@ -25,7 +25,7 @@ * Wraps an ordinary {@link CharSequence} as a settings source. * * @author Benjamin Bentmann - * + * * @deprecated instead use {@link StringSource} */ @Deprecated diff --git a/maven-settings-builder/src/main/java/org/apache/maven/settings/building/UrlSettingsSource.java b/maven-settings-builder/src/main/java/org/apache/maven/settings/building/UrlSettingsSource.java index 2b40f648b8f0..1adc4bf07d4b 100644 --- a/maven-settings-builder/src/main/java/org/apache/maven/settings/building/UrlSettingsSource.java +++ b/maven-settings-builder/src/main/java/org/apache/maven/settings/building/UrlSettingsSource.java @@ -27,7 +27,7 @@ * Wraps an ordinary {@link URL} as a settings source. * * @author Benjamin Bentmann - * + * * @deprecated instead use {@link UrlSource} */ @Deprecated @@ -56,5 +56,5 @@ public URL getSettingsUrl() { return getUrl(); } - + } diff --git a/maven-settings-builder/src/main/java/org/apache/maven/settings/merge/MavenSettingsMerger.java b/maven-settings-builder/src/main/java/org/apache/maven/settings/merge/MavenSettingsMerger.java index 8d9f67b1fcbe..cb5f6c166f1f 100644 --- a/maven-settings-builder/src/main/java/org/apache/maven/settings/merge/MavenSettingsMerger.java +++ b/maven-settings-builder/src/main/java/org/apache/maven/settings/merge/MavenSettingsMerger.java @@ -111,6 +111,7 @@ private static void shallowMergeById( List domin String recessiveSourceLevel ) { Map dominantById = mapById( dominant ); + final List identifiables = new ArrayList<>( recessive.size() ); for ( T identifiable : recessive ) { @@ -118,9 +119,11 @@ private static void shallowMergeById( List domin { identifiable.setSourceLevel( recessiveSourceLevel ); - dominant.add( identifiable ); + identifiables.add( identifiable ); } } + + dominant.addAll( 0, identifiables ); } /** diff --git a/maven-settings-builder/src/main/java/org/apache/maven/settings/validation/DefaultSettingsValidator.java b/maven-settings-builder/src/main/java/org/apache/maven/settings/validation/DefaultSettingsValidator.java index 1e31f504ff0d..e33dc49a6114 100644 --- a/maven-settings-builder/src/main/java/org/apache/maven/settings/validation/DefaultSettingsValidator.java +++ b/maven-settings-builder/src/main/java/org/apache/maven/settings/validation/DefaultSettingsValidator.java @@ -148,7 +148,7 @@ else if ( !pluginGroup.matches( ID_REGEX ) ) if ( proxies != null ) { Set proxyIds = new HashSet<>(); - + for ( Proxy proxy : proxies ) { if ( !proxyIds.add( proxy.getId() ) ) diff --git a/maven-slf4j-provider/pom.xml b/maven-slf4j-provider/pom.xml new file mode 100644 index 000000000000..ecb93e852d93 --- /dev/null +++ b/maven-slf4j-provider/pom.xml @@ -0,0 +1,116 @@ + + + + + + 4.0.0 + + + org.apache.maven + maven + 3.4.0-SNAPSHOT + + + maven-slf4j-provider + + Maven SLF4J Simple Provider + + Maven SLF4J provider based on SLF4J's simple provider, monkey-patched to support Maven styled colors + for levels and stacktraces rendering. + + + + + org.slf4j + slf4j-api + + + org.apache.maven.shared + maven-shared-utils + + + + + + + org.apache.maven.plugins + maven-dependency-plugin + + + + org.slf4j + slf4j-simple + ${slf4jVersion} + jar + sources + false + ${project.build.directory}/generated-sources/slf4j-simple + org/slf4j/impl/*.java + + + + + + unzip-slf4j-simple + + unpack + + + + + + org.codehaus.mojo + build-helper-maven-plugin + 1.12 + + + add-slf4j-simple + generate-sources + + add-source + + + + ${project.build.directory}/generated-sources/slf4j-simple + + + + + + + org.codehaus.gmaven + groovy-maven-plugin + 2.0 + + + patch-slf4j-simple + process-sources + + execute + + + ${project.basedir}/src/main/script/patch-slf4j-simple.groovy + + + + + + + \ No newline at end of file diff --git a/maven-slf4j-provider/src/main/java/org/slf4j/impl/MavenSimpleLogger.java b/maven-slf4j-provider/src/main/java/org/slf4j/impl/MavenSimpleLogger.java new file mode 100644 index 000000000000..0715ed0a90c5 --- /dev/null +++ b/maven-slf4j-provider/src/main/java/org/slf4j/impl/MavenSimpleLogger.java @@ -0,0 +1,117 @@ +package org.slf4j.impl; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES 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.PrintStream; + +/** + * Logger for Maven, that support colorization of levels and stacktraces. + * This class implements 2 methods introduced in slf4j-simple provider local copy. + * @since 3.4.0 + */ +public class MavenSimpleLogger + extends SimpleLogger +{ + private static final String NEWLINE = System.getProperty( "line.separator" ); + + MavenSimpleLogger( String name ) + { + super( name ); + } + + @Override + protected String renderLevel( int level ) + { + switch ( level ) + { + case LOG_LEVEL_TRACE: + return buffer().debug( "TRACE" ).toString(); + case LOG_LEVEL_DEBUG: + return buffer().debug( "DEBUG" ).toString(); + case LOG_LEVEL_INFO: + return buffer().info( "INFO" ).toString(); + case LOG_LEVEL_WARN: + return buffer().warning( "WARNING" ).toString(); + case LOG_LEVEL_ERROR: + default: + return buffer().error( "ERROR" ).toString(); + } + } + + @Override + protected void renderThrowable( Throwable t, PrintStream stream ) + { + stream.append( buffer().failure( t.getClass().getName() ).toString() ); + if ( t.getMessage() != null ) + { + stream.append( ": " ); + stream.append( buffer().failure( t.getMessage() ).toString() ); + } + stream.append( NEWLINE ); + + while ( t != null ) + { + for ( StackTraceElement e : t.getStackTrace() ) + { + stream.append( " " ); + stream.append( buffer().strong( "at" ).toString() ); + stream.append( " " + e.getClassName() + "." + e.getMethodName() ); + stream.append( buffer().a( " (" ).strong( getLocation( e ) ).a( ")" ).toString() ); + stream.append( NEWLINE ); + } + + t = t.getCause(); + if ( t != null ) + { + stream.append( buffer().strong( "Caused by" ).a( ": " ).a( t.getClass().getName() ).toString() ); + if ( t.getMessage() != null ) + { + stream.append( ": " ); + stream.append( buffer().failure( t.getMessage() ).toString() ); + } + stream.append( NEWLINE ); + } + } + } + + protected String getLocation( final StackTraceElement e ) + { + assert e != null; + + if ( e.isNativeMethod() ) + { + return "Native Method"; + } + else if ( e.getFileName() == null ) + { + return "Unknown Source"; + } + else if ( e.getLineNumber() >= 0 ) + { + return String.format( "%s:%s", e.getFileName(), e.getLineNumber() ); + } + else + { + return e.getFileName(); + } + } +} diff --git a/maven-slf4j-provider/src/main/java/org/slf4j/impl/MavenSimpleLoggerFactory.java b/maven-slf4j-provider/src/main/java/org/slf4j/impl/MavenSimpleLoggerFactory.java new file mode 100644 index 000000000000..d56e3461812a --- /dev/null +++ b/maven-slf4j-provider/src/main/java/org/slf4j/impl/MavenSimpleLoggerFactory.java @@ -0,0 +1,44 @@ +package org.slf4j.impl; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES 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.slf4j.Logger; + +public class MavenSimpleLoggerFactory + extends SimpleLoggerFactory +{ + /** + * Return an appropriate {@link MavenSimpleLogger} instance by name. + */ + public Logger getLogger( String name ) + { + Logger simpleLogger = loggerMap.get( name ); + if ( simpleLogger != null ) + { + return simpleLogger; + } + else + { + Logger newInstance = new MavenSimpleLogger( name ); + Logger oldInstance = loggerMap.putIfAbsent( name, newInstance ); + return oldInstance == null ? newInstance : oldInstance; + } + } +} diff --git a/maven-slf4j-provider/src/main/script/patch-slf4j-simple.groovy b/maven-slf4j-provider/src/main/script/patch-slf4j-simple.groovy new file mode 100644 index 000000000000..bba864662f70 --- /dev/null +++ b/maven-slf4j-provider/src/main/script/patch-slf4j-simple.groovy @@ -0,0 +1,53 @@ + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +dir = new File( basedir, 'target/generated-sources/slf4j-simple/org/slf4j/impl' ); + +file = new File( dir, 'StaticLoggerBinder.java' ); +content = file.text; + +// check if already patched +if ( content.contains( 'MavenSimpleLoggerFactory' ) ) +{ + println ' slf4j-simple already patched'; + return; +} + + +println ' patching StaticLoggerBinder.java'; +content = content.replaceAll( 'SimpleLoggerFactory', 'MavenSimpleLoggerFactory' ); +file.write( content ); + + +println ' patching SimpleLogger.java'; +file = new File( dir, 'SimpleLogger.java' ); +content = file.text; +content = content.replaceAll( 'private static final int LOG_LEVEL_', 'protected static final int LOG_LEVEL_' ); +content = content.replaceAll( 't.printStackTrace(TARGET_STREAM)', 'renderThrowable(t, TARGET_STREAM);' ); + +index = content.indexOf( 'switch (level) {' ); +end = content.indexOf( '}', index ) + 1; +content = content.substring( 0, index ) + 'buf.append(renderLevel(level));' + content.substring( end ); + +content = content.substring( 0, content.lastIndexOf( '}' ) ); +content += ' protected void renderThrowable(Throwable t, PrintStream stream) {}\n'; +content += ' protected String renderLevel(int level) { return ""; }\n}\n'; + +file.write( content ); diff --git a/maven-slf4j-provider/src/site/site.xml b/maven-slf4j-provider/src/site/site.xml new file mode 100644 index 000000000000..3a16bf98b567 --- /dev/null +++ b/maven-slf4j-provider/src/site/site.xml @@ -0,0 +1,36 @@ + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/pom.xml b/pom.xml index 24c7df619713..a23683de0cb6 100644 --- a/pom.xml +++ b/pom.xml @@ -51,12 +51,12 @@ under the License. 1.7 2.5.2 1.3.1 - 3.4 + 3.5 4.12 - 1.7 - 1.22 + 1.7.1 + 1.24 3.0.24 - 19.0 + 20.0 4.1.0 0.3.3 2.10 @@ -91,6 +91,7 @@ under the License. maven-artifact maven-aether-provider maven-repository-metadata + maven-slf4j-provider maven-embedder maven-compat apache-maven @@ -227,6 +228,11 @@ under the License. maven-builder-support ${project.version} + + org.apache.maven + maven-slf4j-provider + ${project.version} + @@ -475,6 +481,11 @@ under the License. + + org.apache.maven.plugins + maven-assembly-plugin + 3.0.0 + org.apache.maven.plugins maven-release-plugin diff --git a/src/site/xdoc/index.xml b/src/site/xdoc/index.xml index 61b105d3062e..eda684f1ba1c 100644 --- a/src/site/xdoc/index.xml +++ b/src/site/xdoc/index.xml @@ -55,6 +55,7 @@ maven-settings maven-model-builder maven-model + maven-slf4j-provider slf4j-api commons-cli maven-shared-utils