diff --git a/.gitattributes b/.gitattributes index 225f8f119c..3bb3b5ea8a 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,2 +1,8 @@ -*.jar -text -crlf -*.graffle -text -crlf +# Auto detect text files and perform LF normalization +* text=auto + +*.java text diff=java +*.html text diff=html +*.css text +*.js text +*.sql text diff --git a/.gitignore b/.gitignore index e52bf75326..5221f06d09 100644 --- a/.gitignore +++ b/.gitignore @@ -13,3 +13,5 @@ bin/ >>>>>>> 4fdcdbd26244ff81e242054fd38cf415d92499be .DS_Store +/bootstrap +/dependencies.xml diff --git a/apache-maven/NOTICE.txt b/apache-maven/NOTICE.txt index 62abffbfa3..e744352531 100644 --- a/apache-maven/NOTICE.txt +++ b/apache-maven/NOTICE.txt @@ -5,7 +5,7 @@ ========================================================================= Apache Maven -Copyright 2001-2011 The Apache Software Foundation +Copyright 2001-2012 The Apache Software Foundation This product includes software developed by The Apache Software Foundation (http://www.apache.org/). diff --git a/apache-maven/README.txt b/apache-maven/README.txt index c337ce8e6d..dc55c01f4f 100644 --- a/apache-maven/README.txt +++ b/apache-maven/README.txt @@ -40,18 +40,18 @@ 1) Unpack the archive where you would like to store the binaries, eg: Unix-based Operating Systems (Linux, Solaris and Mac OS X) - tar zxvf apache-maven-3.0.x.tar.gz + tar zxvf apache-maven-3.x.y.tar.gz Windows 2000/XP - unzip apache-maven-3.0.x.zip + unzip apache-maven-3.x.y.zip - 2) A directory called "apache-maven-3.0.x" will be created. + 2) A directory called "apache-maven-3.x.y" will be created. 3) Add the bin directory to your PATH, eg: Unix-based Operating Systems (Linux, Solaris and Mac OS X) - export PATH=/usr/local/apache-maven-3.0.x/bin:$PATH + export PATH=/usr/local/apache-maven-3.x.y/bin:$PATH Windows 2000/XP - set PATH="c:\program files\apache-maven-3.0.x\bin";%PATH% + set PATH="c:\program files\apache-maven-3.x.y\bin";%PATH% 4) Make sure JAVA_HOME is set to the location of your JDK @@ -71,7 +71,7 @@ Downloads: http://maven.apache.org/download.html Release Notes: http://maven.apache.org/release-notes.html Mailing Lists: http://maven.apache.org/mail-lists.html - Source Code: http://svn.apache.org/repos/asf/maven/ + Source Code: https://git-wip-us.apache.org/repos/asf/maven.git/apache-maven Issue Tracking: http://jira.codehaus.org/browse/MNG - Wiki: http://docs.codehaus.org/display/MAVENUSER/ + Wiki: https://cwiki.apache.org/confluence/display/MAVEN/ Available Plugins: http://maven.apache.org/plugins/index.html diff --git a/build.xml b/build.xml index 2322be3c84..6b93808323 100644 --- a/build.xml +++ b/build.xml @@ -36,6 +36,9 @@ END SNIPPET: ant-bootstrap --> + + + Building ${distributionName} ... @@ -247,8 +250,9 @@ Do you want to continue? - + + diff --git a/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/DefaultVersionRangeResolver.java b/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/DefaultVersionRangeResolver.java index 3e04755493..a7ff573bbc 100644 --- a/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/DefaultVersionRangeResolver.java +++ b/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/DefaultVersionRangeResolver.java @@ -319,4 +319,4 @@ public class DefaultVersionRangeResolver repositoryEventDispatcher.dispatch( event.build() ); } -} +} \ No newline at end of file diff --git a/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/DefaultVersionResolver.java b/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/DefaultVersionResolver.java index 5af7121907..9fcfc996bc 100644 --- a/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/DefaultVersionResolver.java +++ b/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/DefaultVersionResolver.java @@ -631,4 +631,4 @@ public class DefaultVersionResolver } } -} +} \ No newline at end of file diff --git a/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/LocalSnapshotMetadata.java b/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/LocalSnapshotMetadata.java index 944f2ed5a4..a22d07d27a 100644 --- a/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/LocalSnapshotMetadata.java +++ b/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/LocalSnapshotMetadata.java @@ -160,4 +160,4 @@ final class LocalSnapshotMetadata return Nature.SNAPSHOT; } -} +} \ No newline at end of file diff --git a/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/MavenMetadata.java b/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/MavenMetadata.java index 329f99cb77..bdf287831b 100644 --- a/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/MavenMetadata.java +++ b/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/MavenMetadata.java @@ -45,6 +45,8 @@ abstract class MavenMetadata implements MergeableMetadata { + static final String MAVEN_METADATA_XML = "maven-metadata.xml"; + private final File file; protected Metadata metadata; @@ -59,7 +61,7 @@ abstract class MavenMetadata public String getType() { - return "maven-metadata.xml"; + return MAVEN_METADATA_XML; } public File getFile() @@ -86,7 +88,7 @@ abstract class MavenMetadata protected abstract void merge( Metadata recessive ); - private Metadata read( File metadataFile ) + static Metadata read( File metadataFile ) throws RepositoryException { if ( metadataFile.length() <= 0 ) diff --git a/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/MavenSnapshotMetadata.java b/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/MavenSnapshotMetadata.java new file mode 100644 index 0000000000..1e6f9097d4 --- /dev/null +++ b/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/MavenSnapshotMetadata.java @@ -0,0 +1,100 @@ +package org.apache.maven.repository.internal; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import java.io.File; +import java.util.ArrayList; +import java.util.Collection; + +import org.apache.maven.artifact.repository.metadata.Metadata; +import org.eclipse.aether.artifact.Artifact; + +/** + * @author Hervé Boutemy + */ +abstract class MavenSnapshotMetadata + extends MavenMetadata +{ + static final String SNAPSHOT = "SNAPSHOT"; + + protected final Collection artifacts = new ArrayList(); + + protected final boolean legacyFormat; + + protected MavenSnapshotMetadata( Metadata metadata, File file, boolean legacyFormat ) + { + super( metadata, file ); + this.legacyFormat = legacyFormat; + } + + protected static Metadata createRepositoryMetadata( Artifact artifact, boolean legacyFormat ) + { + Metadata metadata = new Metadata(); + if ( !legacyFormat ) + { + metadata.setModelVersion( "1.1.0" ); + } + metadata.setGroupId( artifact.getGroupId() ); + metadata.setArtifactId( artifact.getArtifactId() ); + metadata.setVersion( artifact.getBaseVersion() ); + + return metadata; + } + + public void bind( Artifact artifact ) + { + artifacts.add( artifact ); + } + + public Object getKey() + { + return getGroupId() + ':' + getArtifactId() + ':' + getVersion(); + } + + public static Object getKey( Artifact artifact ) + { + return artifact.getGroupId() + ':' + artifact.getArtifactId() + ':' + artifact.getBaseVersion(); + } + + protected String getKey( String classifier, String extension ) + { + return classifier + ':' + extension; + } + + public String getGroupId() + { + return metadata.getGroupId(); + } + + public String getArtifactId() + { + return metadata.getArtifactId(); + } + + public String getVersion() + { + return metadata.getVersion(); + } + + public Nature getNature() + { + return Nature.SNAPSHOT; + } +} diff --git a/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/RemoteSnapshotMetadata.java b/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/RemoteSnapshotMetadata.java index c8c091ad32..60b8749a6f 100644 --- a/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/RemoteSnapshotMetadata.java +++ b/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/RemoteSnapshotMetadata.java @@ -23,7 +23,6 @@ import java.io.File; import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.ArrayList; -import java.util.Collection; import java.util.Date; import java.util.LinkedHashMap; import java.util.Map; @@ -39,46 +38,19 @@ import org.eclipse.aether.artifact.Artifact; * @author Benjamin Bentmann */ final class RemoteSnapshotMetadata - extends MavenMetadata + extends MavenSnapshotMetadata { - private static final String SNAPSHOT = "SNAPSHOT"; - - private final Collection artifacts = new ArrayList(); - private final Map versions = new LinkedHashMap(); - private final boolean legacyFormat; - public RemoteSnapshotMetadata( Artifact artifact, boolean legacyFormat ) { - super( createMetadata( artifact, legacyFormat ), null ); - this.legacyFormat = legacyFormat; + super( createRepositoryMetadata( artifact, legacyFormat ), null, legacyFormat ); } private RemoteSnapshotMetadata( Metadata metadata, File file, boolean legacyFormat ) { - super( metadata, file ); - this.legacyFormat = legacyFormat; - } - - private static Metadata createMetadata( Artifact artifact, boolean legacyFormat ) - { - Metadata metadata = new Metadata(); - if ( !legacyFormat ) - { - metadata.setModelVersion( "1.1.0" ); - } - metadata.setGroupId( artifact.getGroupId() ); - metadata.setArtifactId( artifact.getArtifactId() ); - metadata.setVersion( artifact.getBaseVersion() ); - - return metadata; - } - - public void bind( Artifact artifact ) - { - artifacts.add( artifact ); + super( metadata, file, legacyFormat ); } public MavenMetadata setFile( File file ) @@ -86,16 +58,6 @@ final class RemoteSnapshotMetadata return new RemoteSnapshotMetadata( metadata, file, legacyFormat ); } - public Object getKey() - { - return getGroupId() + ':' + getArtifactId() + ':' + getVersion(); - } - - public static Object getKey( Artifact artifact ) - { - return artifact.getGroupId() + ':' + artifact.getArtifactId() + ':' + artifact.getBaseVersion(); - } - public String getExpandedVersion( Artifact artifact ) { String key = getKey( artifact.getClassifier(), artifact.getExtension() ); @@ -136,7 +98,7 @@ final class RemoteSnapshotMetadata if ( version.endsWith( SNAPSHOT ) ) { - String qualifier = snapshot.getTimestamp() + "-" + snapshot.getBuildNumber(); + String qualifier = snapshot.getTimestamp() + '-' + snapshot.getBuildNumber(); version = version.substring( 0, version.length() - SNAPSHOT.length() ) + qualifier; } @@ -145,6 +107,7 @@ final class RemoteSnapshotMetadata sv.setExtension( artifact.getExtension() ); sv.setVersion( version ); sv.setUpdated( lastUpdated ); + versions.put( getKey( sv.getClassifier(), sv.getExtension() ), sv ); } @@ -169,11 +132,6 @@ final class RemoteSnapshotMetadata } } - private String getKey( String classifier, String extension ) - { - return classifier + ':' + extension; - } - private static int getBuildNumber( Metadata metadata ) { int number = 0; @@ -191,24 +149,4 @@ final class RemoteSnapshotMetadata return number; } - public String getGroupId() - { - return metadata.getGroupId(); - } - - public String getArtifactId() - { - return metadata.getArtifactId(); - } - - public String getVersion() - { - return metadata.getVersion(); - } - - public Nature getNature() - { - return Nature.SNAPSHOT; - } - } diff --git a/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/VersionsMetadata.java b/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/VersionsMetadata.java index e1be302d58..adaca9dbc7 100644 --- a/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/VersionsMetadata.java +++ b/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/VersionsMetadata.java @@ -40,18 +40,22 @@ final class VersionsMetadata public VersionsMetadata( Artifact artifact ) { - super( createMetadata( artifact ), null ); + super( createRepositoryMetadata( artifact ), null ); this.artifact = artifact; } public VersionsMetadata( Artifact artifact, File file ) { - super( createMetadata( artifact ), file ); + super( createRepositoryMetadata( artifact ), file ); this.artifact = artifact; } - private static Metadata createMetadata( Artifact artifact ) + private static Metadata createRepositoryMetadata( Artifact artifact ) { + Metadata metadata = new Metadata(); + metadata.setGroupId( artifact.getGroupId() ); + metadata.setArtifactId( artifact.getArtifactId() ); + Versioning versioning = new Versioning(); versioning.addVersion( artifact.getBaseVersion() ); if ( !artifact.isSnapshot() ) @@ -63,10 +67,7 @@ final class VersionsMetadata versioning.setLatest( artifact.getBaseVersion() ); } - Metadata metadata = new Metadata(); metadata.setVersioning( versioning ); - metadata.setGroupId( artifact.getGroupId() ); - metadata.setArtifactId( artifact.getArtifactId() ); return metadata; } diff --git a/maven-aether-provider/src/test/resources/repo/org/apache/maven/its/dep-mng5324/07.20.3-SNAPSHOT/maven-metadata.xml b/maven-aether-provider/src/test/resources/repo/org/apache/maven/its/dep-mng5324/07.20.3-SNAPSHOT/maven-metadata.xml index db26c6eb30..9f0a7fedd6 100644 --- a/maven-aether-provider/src/test/resources/repo/org/apache/maven/its/dep-mng5324/07.20.3-SNAPSHOT/maven-metadata.xml +++ b/maven-aether-provider/src/test/resources/repo/org/apache/maven/its/dep-mng5324/07.20.3-SNAPSHOT/maven-metadata.xml @@ -1,49 +1,49 @@ - - - - - - org.apache.maven.its - dep-mng5324 - 07.20.3-SNAPSHOT - - - 20120809.112920 - 97 - - 20120809112920 - - - classifierA - jar - 07.20.3-20120809.112124-88 - 20120809112124 - - - classifierB - jar - 07.20.3-20120809.112920-97 - 20120809112920 - - - + + + + + + org.apache.maven.its + dep-mng5324 + 07.20.3-SNAPSHOT + + + 20120809.112920 + 97 + + 20120809112920 + + + classifierA + jar + 07.20.3-20120809.112124-88 + 20120809112124 + + + classifierB + jar + 07.20.3-20120809.112920-97 + 20120809112920 + + + \ No newline at end of file diff --git a/maven-artifact/src/main/java/org/apache/maven/artifact/Artifact.java b/maven-artifact/src/main/java/org/apache/maven/artifact/Artifact.java index 338c612d05..b26ad9f42b 100644 --- a/maven-artifact/src/main/java/org/apache/maven/artifact/Artifact.java +++ b/maven-artifact/src/main/java/org/apache/maven/artifact/Artifact.java @@ -32,6 +32,10 @@ import org.apache.maven.artifact.versioning.ArtifactVersion; import org.apache.maven.artifact.versioning.OverConstrainedVersionException; import org.apache.maven.artifact.versioning.VersionRange; +/** + * Maven Artifact interface. Notice that it mixes artifact definition concepts (groupId, artifactId, version) + * with dependency information (version range, scope). + */ public interface Artifact extends Comparable { diff --git a/maven-artifact/src/main/java/org/apache/maven/artifact/repository/ArtifactRepositoryPolicy.java b/maven-artifact/src/main/java/org/apache/maven/artifact/repository/ArtifactRepositoryPolicy.java index 306c90b965..f76e2c1377 100644 --- a/maven-artifact/src/main/java/org/apache/maven/artifact/repository/ArtifactRepositoryPolicy.java +++ b/maven-artifact/src/main/java/org/apache/maven/artifact/repository/ArtifactRepositoryPolicy.java @@ -21,7 +21,6 @@ package org.apache.maven.artifact.repository; import java.util.Calendar; import java.util.Date; -import java.util.TimeZone; /** * Describes a set of policies for a repository to use under certain conditions. 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 da654c8492..6f066140dc 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 @@ -69,9 +69,9 @@ public class ComparableVersion private interface Item { - final int INTEGER_ITEM = 0; - final int STRING_ITEM = 1; - final int LIST_ITEM = 2; + int INTEGER_ITEM = 0; + int STRING_ITEM = 1; + int LIST_ITEM = 2; int compareTo( Item item ); @@ -86,7 +86,7 @@ public class ComparableVersion private static class IntegerItem implements Item { - private static final BigInteger BigInteger_ZERO = new BigInteger( "0" ); + private static final BigInteger BIG_INTEGER_ZERO = new BigInteger( "0" ); private final BigInteger value; @@ -94,7 +94,7 @@ public class ComparableVersion private IntegerItem() { - this.value = BigInteger_ZERO; + this.value = BIG_INTEGER_ZERO; } public IntegerItem( String str ) @@ -109,14 +109,14 @@ public class ComparableVersion public boolean isNull() { - return BigInteger_ZERO.equals( value ); + return BIG_INTEGER_ZERO.equals( value ); } public int compareTo( Item item ) { if ( item == null ) { - return BigInteger_ZERO.equals( value ) ? 0 : 1; // 1.0 == 1, 1.1 > 1 + return BIG_INTEGER_ZERO.equals( value ) ? 0 : 1; // 1.0 == 1, 1.1 > 1 } switch ( item.getType() ) @@ -266,7 +266,7 @@ public class ComparableVersion void normalize() { - for( ListIterator iterator = listIterator( size() ); iterator.hasPrevious(); ) + for ( ListIterator iterator = listIterator( size() ); iterator.hasPrevious(); ) { Item item = iterator.previous(); if ( item.isNull() ) @@ -327,7 +327,7 @@ public class ComparableVersion public String toString() { StringBuilder buffer = new StringBuilder( "(" ); - for( Iterator iter = iterator(); iter.hasNext(); ) + for ( Iterator iter = iterator(); iter.hasNext(); ) { buffer.append( iter.next() ); if ( iter.hasNext() ) 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 b588340937..db71dc700c 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 @@ -72,7 +72,7 @@ public class DefaultArtifactVersion { if ( otherVersion instanceof DefaultArtifactVersion ) { - return this.comparable.compareTo( ( (DefaultArtifactVersion) otherVersion).comparable ); + return this.comparable.compareTo( ( (DefaultArtifactVersion) otherVersion ).comparable ); } else { diff --git a/maven-compat/src/main/java/org/apache/maven/artifact/ArtifactScopeEnum.java b/maven-compat/src/main/java/org/apache/maven/artifact/ArtifactScopeEnum.java index 574f7d6d55..c6d02c6fde 100644 --- a/maven-compat/src/main/java/org/apache/maven/artifact/ArtifactScopeEnum.java +++ b/maven-compat/src/main/java/org/apache/maven/artifact/ArtifactScopeEnum.java @@ -108,7 +108,7 @@ public enum ArtifactScopeEnum { final ArtifactScopeEnum s = checkScope( scope ); - // system scope is historic only - and simple + // system scope is historic only - and simple if ( id == system.id ) { return scope.id == system.id; diff --git a/maven-compat/src/main/java/org/apache/maven/artifact/repository/metadata/DefaultRepositoryMetadataManager.java b/maven-compat/src/main/java/org/apache/maven/artifact/repository/metadata/DefaultRepositoryMetadataManager.java index 0f1030b2e6..cbdcf07bee 100644 --- a/maven-compat/src/main/java/org/apache/maven/artifact/repository/metadata/DefaultRepositoryMetadataManager.java +++ b/maven-compat/src/main/java/org/apache/maven/artifact/repository/metadata/DefaultRepositoryMetadataManager.java @@ -1,18 +1,22 @@ package org.apache.maven.artifact.repository.metadata; /* - * Licensed to the Apache Software Foundation (ASF) under one or more contributor license - * agreements. See the NOTICE file distributed with this work for additional information regarding - * copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance with the License. You may obtain a - * copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License - * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express - * or implied. See the License for the specific language governing permissions and limitations under - * the License. + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. */ import java.io.File; @@ -47,7 +51,7 @@ import org.codehaus.plexus.util.xml.pull.XmlPullParserException; /** * @author Jason van Zyl */ -@Component(role=RepositoryMetadataManager.class) +@Component( role = RepositoryMetadataManager.class ) public class DefaultRepositoryMetadataManager extends AbstractLogEnabled implements RepositoryMetadataManager diff --git a/maven-compat/src/main/java/org/apache/maven/artifact/repository/metadata/MetadataBridge.java b/maven-compat/src/main/java/org/apache/maven/artifact/repository/metadata/MetadataBridge.java index 7d9935c11e..4ee80ec2b3 100644 --- a/maven-compat/src/main/java/org/apache/maven/artifact/repository/metadata/MetadataBridge.java +++ b/maven-compat/src/main/java/org/apache/maven/artifact/repository/metadata/MetadataBridge.java @@ -26,7 +26,6 @@ import java.util.Map; import org.apache.maven.artifact.metadata.ArtifactMetadata; import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.repository.DefaultArtifactRepository; -import org.apache.maven.artifact.repository.metadata.RepositoryMetadata; import org.codehaus.plexus.util.FileUtils; import org.eclipse.aether.RepositoryException; import org.eclipse.aether.metadata.AbstractMetadata; diff --git a/maven-compat/src/main/java/org/apache/maven/artifact/resolver/DefaultArtifactResolver.java b/maven-compat/src/main/java/org/apache/maven/artifact/resolver/DefaultArtifactResolver.java index d8b80fc19e..36e59e77a1 100644 --- a/maven-compat/src/main/java/org/apache/maven/artifact/resolver/DefaultArtifactResolver.java +++ b/maven-compat/src/main/java/org/apache/maven/artifact/resolver/DefaultArtifactResolver.java @@ -1,18 +1,22 @@ package org.apache.maven.artifact.resolver; /* - * Licensed to the Apache Software Foundation (ASF) under one or more contributor license - * agreements. See the NOTICE file distributed with this work for additional information regarding - * copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance with the License. You may obtain a - * copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License - * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express - * or implied. See the License for the specific language governing permissions and limitations under - * the License. + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. */ import java.io.File; @@ -65,7 +69,7 @@ import org.eclipse.aether.resolution.ArtifactResult; /** * @author Jason van Zyl */ -@Component(role = ArtifactResolver.class) +@Component( role = ArtifactResolver.class ) public class DefaultArtifactResolver implements ArtifactResolver { @@ -111,7 +115,8 @@ public class DefaultArtifactResolver else { executor = - new ThreadPoolExecutor( threads, threads, 3, TimeUnit.SECONDS, new LinkedBlockingQueue(), new DaemonThreadCreator()); + new ThreadPoolExecutor( 0, threads, 3, TimeUnit.SECONDS, new LinkedBlockingQueue(), + new DaemonThreadCreator() ); } } @@ -151,19 +156,22 @@ public class DefaultArtifactResolver } } - public void resolve( Artifact artifact, List remoteRepositories, ArtifactRepository localRepository, TransferListener resolutionListener ) + public void resolve( Artifact artifact, List remoteRepositories, + ArtifactRepository localRepository, TransferListener resolutionListener ) throws ArtifactResolutionException, ArtifactNotFoundException { resolve( artifact, remoteRepositories, getSession( localRepository ) ); } - public void resolveAlways( Artifact artifact, List remoteRepositories, ArtifactRepository localRepository ) + public void resolveAlways( Artifact artifact, List remoteRepositories, + ArtifactRepository localRepository ) throws ArtifactResolutionException, ArtifactNotFoundException { resolve( artifact, remoteRepositories, getSession( localRepository ) ); } - private void resolve( Artifact artifact, List remoteRepositories, RepositorySystemSession session ) + private void resolve( Artifact artifact, List remoteRepositories, + RepositorySystemSession session ) throws ArtifactResolutionException, ArtifactNotFoundException { if ( artifact == null ) @@ -249,52 +257,73 @@ public class DefaultArtifactResolver } } - public ArtifactResolutionResult resolveTransitively( Set artifacts, Artifact originatingArtifact, ArtifactRepository localRepository, List remoteRepositories, + public ArtifactResolutionResult resolveTransitively( Set artifacts, Artifact originatingArtifact, + ArtifactRepository localRepository, + List remoteRepositories, ArtifactMetadataSource source, ArtifactFilter filter ) throws ArtifactResolutionException, ArtifactNotFoundException { - return resolveTransitively( artifacts, originatingArtifact, Collections.EMPTY_MAP, localRepository, remoteRepositories, source, filter ); + return resolveTransitively( artifacts, originatingArtifact, Collections.EMPTY_MAP, localRepository, + remoteRepositories, source, filter ); } - public ArtifactResolutionResult resolveTransitively( Set artifacts, Artifact originatingArtifact, Map managedVersions, ArtifactRepository localRepository, - List remoteRepositories, ArtifactMetadataSource source ) + public ArtifactResolutionResult resolveTransitively( Set artifacts, Artifact originatingArtifact, + Map managedVersions, ArtifactRepository localRepository, + List remoteRepositories, + ArtifactMetadataSource source ) throws ArtifactResolutionException, ArtifactNotFoundException { - return resolveTransitively( artifacts, originatingArtifact, managedVersions, localRepository, remoteRepositories, source, null ); + return resolveTransitively( artifacts, originatingArtifact, managedVersions, localRepository, + remoteRepositories, source, null ); } - public ArtifactResolutionResult resolveTransitively( Set artifacts, Artifact originatingArtifact, Map managedVersions, ArtifactRepository localRepository, - List remoteRepositories, ArtifactMetadataSource source, ArtifactFilter filter ) + public ArtifactResolutionResult resolveTransitively( Set artifacts, Artifact originatingArtifact, + Map managedVersions, ArtifactRepository localRepository, + List remoteRepositories, + ArtifactMetadataSource source, ArtifactFilter filter ) throws ArtifactResolutionException, ArtifactNotFoundException { - return resolveTransitively( artifacts, originatingArtifact, managedVersions, localRepository, remoteRepositories, source, filter, null ); + return resolveTransitively( artifacts, originatingArtifact, managedVersions, localRepository, + remoteRepositories, source, filter, null ); } - public ArtifactResolutionResult resolveTransitively( Set artifacts, Artifact originatingArtifact, List remoteRepositories, ArtifactRepository localRepository, + public ArtifactResolutionResult resolveTransitively( Set artifacts, Artifact originatingArtifact, + List remoteRepositories, + ArtifactRepository localRepository, ArtifactMetadataSource source ) throws ArtifactResolutionException, ArtifactNotFoundException { return resolveTransitively( artifacts, originatingArtifact, localRepository, remoteRepositories, source, null ); } - public ArtifactResolutionResult resolveTransitively( Set artifacts, Artifact originatingArtifact, List remoteRepositories, ArtifactRepository localRepository, - ArtifactMetadataSource source, List listeners ) + public ArtifactResolutionResult resolveTransitively( Set artifacts, Artifact originatingArtifact, + List remoteRepositories, + ArtifactRepository localRepository, + ArtifactMetadataSource source, + List listeners ) throws ArtifactResolutionException, ArtifactNotFoundException { return resolveTransitively( artifacts, originatingArtifact, Collections.EMPTY_MAP, localRepository, remoteRepositories, source, null, listeners ); } - public ArtifactResolutionResult resolveTransitively( Set artifacts, Artifact originatingArtifact, Map managedVersions, ArtifactRepository localRepository, - List remoteRepositories, ArtifactMetadataSource source, ArtifactFilter filter, List listeners ) + public ArtifactResolutionResult resolveTransitively( Set artifacts, Artifact originatingArtifact, + Map managedVersions, ArtifactRepository localRepository, + List remoteRepositories, + ArtifactMetadataSource source, ArtifactFilter filter, + List listeners ) throws ArtifactResolutionException, ArtifactNotFoundException { - return resolveTransitively( artifacts, originatingArtifact, managedVersions, localRepository, remoteRepositories, source, filter, listeners, null ); + return resolveTransitively( artifacts, originatingArtifact, managedVersions, localRepository, + remoteRepositories, source, filter, listeners, null ); } - public ArtifactResolutionResult resolveTransitively( Set artifacts, Artifact originatingArtifact, Map managedVersions, ArtifactRepository localRepository, - List remoteRepositories, ArtifactMetadataSource source, ArtifactFilter filter, List listeners, + public ArtifactResolutionResult resolveTransitively( Set artifacts, Artifact originatingArtifact, + Map managedVersions, ArtifactRepository localRepository, + List remoteRepositories, + ArtifactMetadataSource source, ArtifactFilter filter, + List listeners, List conflictResolvers ) throws ArtifactResolutionException, ArtifactNotFoundException { @@ -336,7 +365,7 @@ public class DefaultArtifactResolver { Artifact rootArtifact = request.getArtifact(); Set artifacts = request.getArtifactDependencies(); - Map managedVersions = request.getManagedVersionMap(); + Map managedVersions = request.getManagedVersionMap(); List listeners = request.getListeners(); ArtifactFilter collectionFilter = request.getCollectionFilter(); ArtifactFilter resolutionFilter = request.getResolutionFilter(); @@ -528,18 +557,18 @@ public class DefaultArtifactResolver /** * ThreadCreator for creating daemon threads with fixed ThreadGroup-name. */ - final static class DaemonThreadCreator + static final class DaemonThreadCreator implements ThreadFactory { static final String THREADGROUP_NAME = "org.apache.maven.artifact.resolver.DefaultArtifactResolver"; - final static ThreadGroup group = new ThreadGroup( THREADGROUP_NAME ); + static final ThreadGroup GROUP = new ThreadGroup( THREADGROUP_NAME ); - final static AtomicInteger threadNumber = new AtomicInteger( 1 ); + static final AtomicInteger THREAD_NUMBER = new AtomicInteger( 1 ); public Thread newThread( Runnable r ) { - Thread newThread = new Thread( group, r, "resolver-" + threadNumber.getAndIncrement() ); + Thread newThread = new Thread( GROUP, r, "resolver-" + THREAD_NUMBER.getAndIncrement() ); newThread.setDaemon( true ); return newThread; } @@ -574,6 +603,7 @@ public class DefaultArtifactResolver public void run() { + ClassLoader old = Thread.currentThread().getContextClassLoader(); try { Thread.currentThread().setContextClassLoader( classLoader ); @@ -602,6 +632,8 @@ public class DefaultArtifactResolver finally { latch.countDown(); + Thread.currentThread().setContextClassLoader( old ); + } } diff --git a/maven-compat/src/main/java/org/apache/maven/profiles/DefaultProfileManager.java b/maven-compat/src/main/java/org/apache/maven/profiles/DefaultProfileManager.java index ae3d2c51c1..740c2cd93a 100644 --- a/maven-compat/src/main/java/org/apache/maven/profiles/DefaultProfileManager.java +++ b/maven-compat/src/main/java/org/apache/maven/profiles/DefaultProfileManager.java @@ -20,13 +20,10 @@ package org.apache.maven.profiles; */ import org.apache.maven.model.Activation; -import org.apache.maven.model.InputLocation; import org.apache.maven.model.Profile; import org.apache.maven.model.building.ModelProblem; import org.apache.maven.model.building.ModelProblemCollector; -import org.apache.maven.model.building.ModelProblem.Severity; import org.apache.maven.model.profile.DefaultProfileActivationContext; -import org.apache.maven.model.profile.ProfileActivationContext; import org.apache.maven.model.profile.ProfileSelector; import org.apache.maven.profiles.activation.ProfileActivationException; import org.codehaus.plexus.MutablePlexusContainer; @@ -36,13 +33,11 @@ import org.codehaus.plexus.component.repository.exception.ComponentLookupExcepti import org.codehaus.plexus.logging.Logger; import java.util.ArrayList; -import java.util.Collections; import java.util.Iterator; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import java.util.Properties; -import org.apache.maven.model.building.ModelProblem.Version; import org.apache.maven.model.building.ModelProblemCollectorRequest; @Deprecated diff --git a/maven-compat/src/main/java/org/apache/maven/profiles/activation/SystemPropertyProfileActivator.java b/maven-compat/src/main/java/org/apache/maven/profiles/activation/SystemPropertyProfileActivator.java index 4186415418..a03267dc2d 100644 --- a/maven-compat/src/main/java/org/apache/maven/profiles/activation/SystemPropertyProfileActivator.java +++ b/maven-compat/src/main/java/org/apache/maven/profiles/activation/SystemPropertyProfileActivator.java @@ -63,7 +63,7 @@ public class SystemPropertyProfileActivator + profile.getId() + "'" ); } - if ( name.startsWith("!") ) + if ( name.startsWith( "!" ) ) { reverseName = true; name = name.substring( 1 ); diff --git a/maven-compat/src/main/java/org/apache/maven/project/interpolation/AbstractStringBasedModelInterpolator.java b/maven-compat/src/main/java/org/apache/maven/project/interpolation/AbstractStringBasedModelInterpolator.java index aff88e0a03..f4a1b5c41a 100644 --- a/maven-compat/src/main/java/org/apache/maven/project/interpolation/AbstractStringBasedModelInterpolator.java +++ b/maven-compat/src/main/java/org/apache/maven/project/interpolation/AbstractStringBasedModelInterpolator.java @@ -283,7 +283,7 @@ public abstract class AbstractStringBasedModelInterpolator pathTranslator ) ); } - @SuppressWarnings("unchecked") + @SuppressWarnings( "unchecked" ) protected String interpolateInternal( String src, List valueSources, List postProcessors, boolean debug ) throws ModelInterpolationException @@ -296,7 +296,7 @@ public abstract class AbstractStringBasedModelInterpolator Logger logger = getLogger(); String result = src; - synchronized( this ) + synchronized ( this ) { for ( ValueSource vs : valueSources ) @@ -315,7 +315,7 @@ public abstract class AbstractStringBasedModelInterpolator { result = interpolator.interpolate( result, recursionInterceptor ); } - catch( InterpolationException e ) + catch ( InterpolationException e ) { throw new ModelInterpolationException( e.getMessage(), e ); } diff --git a/maven-compat/src/main/java/org/apache/maven/project/validation/DefaultModelValidator.java b/maven-compat/src/main/java/org/apache/maven/project/validation/DefaultModelValidator.java index a6782d69f0..0095f80382 100644 --- a/maven-compat/src/main/java/org/apache/maven/project/validation/DefaultModelValidator.java +++ b/maven-compat/src/main/java/org/apache/maven/project/validation/DefaultModelValidator.java @@ -19,15 +19,11 @@ package org.apache.maven.project.validation; * under the License. */ -import java.util.List; -import org.apache.maven.model.InputLocation; import org.apache.maven.model.Model; import org.apache.maven.model.building.DefaultModelBuildingRequest; import org.apache.maven.model.building.ModelBuildingRequest; import org.apache.maven.model.building.ModelProblem; import org.apache.maven.model.building.ModelProblemCollector; -import org.apache.maven.model.building.ModelProblem.Severity; -import org.apache.maven.model.building.ModelProblem.Version; import org.apache.maven.model.building.ModelProblemCollectorRequest; import org.codehaus.plexus.component.annotations.Component; import org.codehaus.plexus.component.annotations.Requirement; diff --git a/maven-compat/src/main/java/org/apache/maven/repository/MetadataGraphNode.java b/maven-compat/src/main/java/org/apache/maven/repository/MetadataGraphNode.java index 3940cf336d..22394e7078 100644 --- a/maven-compat/src/main/java/org/apache/maven/repository/MetadataGraphNode.java +++ b/maven-compat/src/main/java/org/apache/maven/repository/MetadataGraphNode.java @@ -41,8 +41,8 @@ public class MetadataGraphNode public MetadataGraphNode() { - inNodes = new ArrayList(4); - exNodes = new ArrayList(8); + inNodes = new ArrayList( 4 ); + exNodes = new ArrayList( 8 ); } public MetadataGraphNode( MavenArtifactMetadata metadata ) diff --git a/maven-compat/src/main/java/org/apache/maven/repository/legacy/repository/DefaultArtifactRepositoryFactory.java b/maven-compat/src/main/java/org/apache/maven/repository/legacy/repository/DefaultArtifactRepositoryFactory.java index 85a6bc45da..4bc911673d 100644 --- a/maven-compat/src/main/java/org/apache/maven/repository/legacy/repository/DefaultArtifactRepositoryFactory.java +++ b/maven-compat/src/main/java/org/apache/maven/repository/legacy/repository/DefaultArtifactRepositoryFactory.java @@ -43,7 +43,7 @@ public class DefaultArtifactRepositoryFactory private String globalChecksumPolicy; @Requirement( role = ArtifactRepositoryLayout.class ) - private Map repositoryLayouts; + private Map repositoryLayouts; public ArtifactRepositoryLayout getLayout( String layoutId ) throws UnknownRepositoryLayoutException 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 651d46e8ce..d69e8125f8 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 @@ -63,10 +63,10 @@ import org.codehaus.plexus.logging.Logger; public class DefaultLegacyArtifactCollector implements LegacyArtifactCollector { - @Requirement(hint="nearest") + @Requirement( hint = "nearest" ) private ConflictResolver defaultConflictResolver; - @Requirement + @Requirement private Logger logger; @Requirement diff --git a/maven-compat/src/main/java/org/apache/maven/repository/legacy/resolver/transform/ArtifactTransformation.java b/maven-compat/src/main/java/org/apache/maven/repository/legacy/resolver/transform/ArtifactTransformation.java index 1a5606f2fa..42604d7549 100644 --- a/maven-compat/src/main/java/org/apache/maven/repository/legacy/resolver/transform/ArtifactTransformation.java +++ b/maven-compat/src/main/java/org/apache/maven/repository/legacy/resolver/transform/ArtifactTransformation.java @@ -38,18 +38,17 @@ public interface ArtifactTransformation /** * Take in a artifact and return the transformed artifact for locating in the remote repository. If no - * transformation has occured the original artifact is returned. + * transformation has occurred the original artifact is returned. * * @param artifact Artifact to be transformed. * @param request the repositories to check - * @param localRepository the local repository */ void transformForResolve( Artifact artifact, RepositoryRequest request ) throws ArtifactResolutionException, ArtifactNotFoundException; /** * Take in a artifact and return the transformed artifact for locating in the remote repository. If no - * transformation has occured the original artifact is returned. + * transformation has occurred the original artifact is returned. * * @param artifact Artifact to be transformed. * @param remoteRepositories the repositories to check @@ -62,7 +61,7 @@ public interface ArtifactTransformation /** * Take in a artifact and return the transformed artifact for locating in the local repository. If no - * transformation has occured the original artifact is returned. + * transformation has occurred the original artifact is returned. * * @param artifact Artifact to be transformed. * @param localRepository the local repository it will be stored in @@ -72,8 +71,8 @@ public interface ArtifactTransformation throws ArtifactInstallationException; /** - * Take in a artifact and return the transformed artifact for distributing toa remote repository. If no - * transformation has occured the original artifact is returned. + * Take in a artifact and return the transformed artifact for distributing to remote repository. If no + * transformation has occurred the original artifact is returned. * * @param artifact Artifact to be transformed. * @param remoteRepository the repository to deploy to diff --git a/maven-compat/src/main/java/org/apache/maven/repository/legacy/resolver/transform/ArtifactTransformationManager.java b/maven-compat/src/main/java/org/apache/maven/repository/legacy/resolver/transform/ArtifactTransformationManager.java index 9137261532..f0ac9c89c8 100644 --- a/maven-compat/src/main/java/org/apache/maven/repository/legacy/resolver/transform/ArtifactTransformationManager.java +++ b/maven-compat/src/main/java/org/apache/maven/repository/legacy/resolver/transform/ArtifactTransformationManager.java @@ -40,7 +40,6 @@ public interface ArtifactTransformationManager * * @param artifact Artifact to be transformed. * @param request the repositories to check - * @param localRepository the local repository */ void transformForResolve( Artifact artifact, RepositoryRequest request ) throws ArtifactResolutionException, ArtifactNotFoundException; diff --git a/maven-compat/src/main/java/org/apache/maven/repository/metadata/ArtifactMetadata.java b/maven-compat/src/main/java/org/apache/maven/repository/metadata/ArtifactMetadata.java index 00749470d5..2666eafb62 100644 --- a/maven-compat/src/main/java/org/apache/maven/repository/metadata/ArtifactMetadata.java +++ b/maven-compat/src/main/java/org/apache/maven/repository/metadata/ArtifactMetadata.java @@ -28,7 +28,6 @@ import org.apache.maven.artifact.ArtifactScopeEnum; * Artifact Metadata that is resolved independent of Artifact itself. * * @author Oleg Gusakov - * */ public class ArtifactMetadata { @@ -291,7 +290,7 @@ public class ArtifactMetadata return artifactExists; } - public void setArtifactExists(boolean artifactExists) + public void setArtifactExists( boolean artifactExists ) { this.artifactExists = artifactExists; } @@ -302,7 +301,7 @@ public class ArtifactMetadata return dependencies; } - public void setDependencies(Collection dependencies) + public void setDependencies( Collection dependencies ) { this.dependencies = dependencies; } @@ -312,7 +311,7 @@ public class ArtifactMetadata return artifactUri; } - public void setArtifactUri(String artifactUri) + public void setArtifactUri( String artifactUri ) { this.artifactUri = artifactUri; } @@ -322,23 +321,28 @@ public class ArtifactMetadata { return why; } - public void setWhy(String why) + + public void setWhy( String why ) { this.why = why; } + //------------------------------------------------------------------- public String getError() { return error; } - public void setError(String error) + + public void setError( String error ) { this.error = error; } + public boolean isError() { return error == null; } + //------------------------------------------------------------------ public String getDependencyConflictId() { diff --git a/maven-compat/src/main/java/org/apache/maven/repository/metadata/MetadataGraph.java b/maven-compat/src/main/java/org/apache/maven/repository/metadata/MetadataGraph.java index d898739275..b116c69f06 100644 --- a/maven-compat/src/main/java/org/apache/maven/repository/metadata/MetadataGraph.java +++ b/maven-compat/src/main/java/org/apache/maven/repository/metadata/MetadataGraph.java @@ -294,7 +294,7 @@ public class MetadataGraph //------------------------------------------------------------------------ public List getEdgesBetween( MetadataGraphVertex vFrom, MetadataGraphVertex vTo ) { - List edges = getIncidentEdges(vTo); + List edges = getIncidentEdges( vTo ); if ( edges == null || edges.isEmpty() ) { return null; diff --git a/maven-compat/src/main/java/org/apache/maven/repository/metadata/MetadataGraphEdge.java b/maven-compat/src/main/java/org/apache/maven/repository/metadata/MetadataGraphEdge.java index 4a50b207b7..9d86933ab2 100644 --- a/maven-compat/src/main/java/org/apache/maven/repository/metadata/MetadataGraphEdge.java +++ b/maven-compat/src/main/java/org/apache/maven/repository/metadata/MetadataGraphEdge.java @@ -125,10 +125,10 @@ public class MetadataGraphEdge this.depth = depth; } - public boolean isResolved() - { - return resolved; - } + public boolean isResolved() + { + return resolved; + } public void setResolved( boolean resolved ) { @@ -175,7 +175,7 @@ public class MetadataGraphEdge this.target = target; } - @Override + @Override public String toString() { return "[ " + "FROM:(" diff --git a/maven-compat/src/main/java/org/apache/maven/repository/metadata/MetadataResolution.java b/maven-compat/src/main/java/org/apache/maven/repository/metadata/MetadataResolution.java index 770ae79d2f..9a9130b2fa 100644 --- a/maven-compat/src/main/java/org/apache/maven/repository/metadata/MetadataResolution.java +++ b/maven-compat/src/main/java/org/apache/maven/repository/metadata/MetadataResolution.java @@ -62,7 +62,7 @@ public class MetadataResolution return artifactMetadata; } - public void setArtifactMetadata(ArtifactMetadata artifactMetadata) + public void setArtifactMetadata( ArtifactMetadata artifactMetadata ) { this.artifactMetadata = artifactMetadata; } diff --git a/maven-core/pom.xml b/maven-core/pom.xml index 346e37e909..c065f5df40 100644 --- a/maven-core/pom.xml +++ b/maven-core/pom.xml @@ -124,73 +124,62 @@ + + org.codehaus.mojo + buildnumber-maven-plugin + + + create-noncanonicalrev + + create-timestamp + + + 'NON-CANONICAL_'yyyy-MM-dd_HH-mm_'${user.name}' + nonCanonicalRevision + + + + create-buildnumber + + create + + + false + false + ${nonCanonicalRevision} + + + + + + + + + org.eclipse.m2e + lifecycle-mapping + 1.0.0 + + + + + + org.codehaus.mojo + buildnumber-maven-plugin + [1.2,) + + create-timestamp + + + + + + + + + + + + - - - - svn-buildnumber - - - .svn - - - - - - org.codehaus.mojo - buildnumber-maven-plugin - - - generate-resources - - create - - - - - false - false - - javasvn - - - - - - - - non-canonical-buildnumber - - - .svn - - - - - - org.codehaus.mojo - buildnumber-maven-plugin - - - generate-resources - - create - - - - - false - false - NON-CANONICAL_{0,date,yyyy-MM-dd_HH-mm}_{1} - - timestamp - ${user.name} - - - - - - - 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 0f8f6f693a..083515386f 100644 --- a/maven-core/src/main/java/org/apache/maven/DefaultMaven.java +++ b/maven-core/src/main/java/org/apache/maven/DefaultMaven.java @@ -88,9 +88,11 @@ import org.eclipse.aether.collection.DependencyManager; import org.eclipse.aether.collection.DependencySelector; import org.eclipse.aether.collection.DependencyTraverser; import org.eclipse.aether.repository.LocalRepository; +import org.eclipse.aether.repository.NoLocalRepositoryManagerException; import org.eclipse.aether.repository.RepositoryPolicy; import org.eclipse.aether.repository.WorkspaceReader; import org.eclipse.aether.resolution.ResolutionErrorPolicy; +import org.eclipse.aether.spi.localrepo.LocalRepositoryManagerFactory; import org.eclipse.aether.util.graph.manager.ClassicDependencyManager; import org.eclipse.aether.util.graph.selector.AndDependencySelector; import org.eclipse.aether.util.graph.selector.ExclusionDependencySelector; @@ -147,6 +149,9 @@ public class DefaultMaven @Requirement private RepositorySystem repoSystem; + @Requirement( optional = true, hint = "simple" ) + private LocalRepositoryManagerFactory simpleLocalRepositoryManagerFactory; + @Requirement private SettingsDecrypter settingsDecrypter; @@ -378,7 +383,25 @@ public class DefaultMaven session.setArtifactTypeRegistry( RepositoryUtils.newArtifactTypeRegistry( artifactHandlerManager ) ); LocalRepository localRepo = new LocalRepository( request.getLocalRepository().getBasedir() ); - session.setLocalRepositoryManager( repoSystem.newLocalRepositoryManager( localRepo ) ); + + if ( request.isUseLegacyLocalRepository() ) + { + logger.warn( "Disabling enhanced local repository: using legacy is stronlgy discouraged to ensure build reproducibility." ); + try + { + session.setLocalRepositoryManager( simpleLocalRepositoryManagerFactory.newInstance( localRepo ) ); + } + catch ( NoLocalRepositoryManagerException e ) + { + + logger.warn( "Failed to configure legacy local repository: back to default" ); + session.setLocalRepositoryManager( repoSystem.newLocalRepositoryManager( localRepo ) ); + } + } + else + { + session.setLocalRepositoryManager( repoSystem.newLocalRepositoryManager( localRepo ) ); + } if ( request.getWorkspaceReader() != null ) { 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 53adcab049..ef769d9f46 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 @@ -143,6 +143,8 @@ public class DefaultMavenExecutionRequest */ private boolean noSnapshotUpdates; + private boolean useSimpleLocalRepositoryManager = false; + public DefaultMavenExecutionRequest() { } @@ -1076,4 +1078,14 @@ public class DefaultMavenExecutionRequest return this; } + public boolean isUseLegacyLocalRepository() + { + return this.useSimpleLocalRepositoryManager; + } + + public MavenExecutionRequest setUseLegacyLocalRepository( boolean useSimpleLocalRepositoryManager ) + { + this.useSimpleLocalRepositoryManager = useSimpleLocalRepositoryManager; + return this; + } } diff --git a/maven-core/src/main/java/org/apache/maven/execution/DefaultMavenExecutionResult.java b/maven-core/src/main/java/org/apache/maven/execution/DefaultMavenExecutionResult.java index d2f8111fb7..cb22b3872c 100644 --- a/maven-core/src/main/java/org/apache/maven/execution/DefaultMavenExecutionResult.java +++ b/maven-core/src/main/java/org/apache/maven/execution/DefaultMavenExecutionResult.java @@ -19,7 +19,6 @@ package org.apache.maven.execution; * under the License. */ -import java.util.ArrayList; import java.util.Collections; import java.util.IdentityHashMap; import java.util.List; @@ -39,7 +38,7 @@ public class DefaultMavenExecutionResult private DependencyResolutionResult dependencyResolutionResult; - private List exceptions = new CopyOnWriteArrayList( ); + private List exceptions = new CopyOnWriteArrayList(); private Map buildSummaries; 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 91e6c9cda1..3db67953dd 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 @@ -45,45 +45,45 @@ public interface MavenExecutionRequest // Logging // ---------------------------------------------------------------------- - final int LOGGING_LEVEL_DEBUG = Logger.LEVEL_DEBUG; + int LOGGING_LEVEL_DEBUG = Logger.LEVEL_DEBUG; - final int LOGGING_LEVEL_INFO = Logger.LEVEL_INFO; + int LOGGING_LEVEL_INFO = Logger.LEVEL_INFO; - final int LOGGING_LEVEL_WARN = Logger.LEVEL_WARN; + int LOGGING_LEVEL_WARN = Logger.LEVEL_WARN; - final int LOGGING_LEVEL_ERROR = Logger.LEVEL_ERROR; + int LOGGING_LEVEL_ERROR = Logger.LEVEL_ERROR; - final int LOGGING_LEVEL_FATAL = Logger.LEVEL_FATAL; + int LOGGING_LEVEL_FATAL = Logger.LEVEL_FATAL; - final int LOGGING_LEVEL_DISABLED = Logger.LEVEL_DISABLED; + int LOGGING_LEVEL_DISABLED = Logger.LEVEL_DISABLED; // ---------------------------------------------------------------------- // Reactor Failure Mode // ---------------------------------------------------------------------- - final String REACTOR_FAIL_FAST = "FAIL_FAST"; + String REACTOR_FAIL_FAST = "FAIL_FAST"; - final String REACTOR_FAIL_AT_END = "FAIL_AT_END"; + String REACTOR_FAIL_AT_END = "FAIL_AT_END"; - final String REACTOR_FAIL_NEVER = "FAIL_NEVER"; + String REACTOR_FAIL_NEVER = "FAIL_NEVER"; // ---------------------------------------------------------------------- // Reactor Make Mode // ---------------------------------------------------------------------- - final String REACTOR_MAKE_UPSTREAM = "make-upstream"; + String REACTOR_MAKE_UPSTREAM = "make-upstream"; - final String REACTOR_MAKE_DOWNSTREAM = "make-downstream"; + String REACTOR_MAKE_DOWNSTREAM = "make-downstream"; - final String REACTOR_MAKE_BOTH = "make-both"; + String REACTOR_MAKE_BOTH = "make-both"; // ---------------------------------------------------------------------- // Artifact repository policies // ---------------------------------------------------------------------- - final String CHECKSUM_POLICY_FAIL = ArtifactRepositoryPolicy.CHECKSUM_POLICY_FAIL; + String CHECKSUM_POLICY_FAIL = ArtifactRepositoryPolicy.CHECKSUM_POLICY_FAIL; - final String CHECKSUM_POLICY_WARN = ArtifactRepositoryPolicy.CHECKSUM_POLICY_WARN; + String CHECKSUM_POLICY_WARN = ArtifactRepositoryPolicy.CHECKSUM_POLICY_WARN; // ---------------------------------------------------------------------- // @@ -283,4 +283,14 @@ public interface MavenExecutionRequest ProjectBuildingRequest getProjectBuildingRequest(); + /** + * @since 3.1 + */ + boolean isUseLegacyLocalRepository(); + + /** + * @since 3.1 + */ + MavenExecutionRequest setUseLegacyLocalRepository( boolean useLegacyLocalRepository ); + } diff --git a/maven-core/src/main/java/org/apache/maven/lifecycle/internal/BuilderCommon.java b/maven-core/src/main/java/org/apache/maven/lifecycle/internal/BuilderCommon.java index 2e63647487..2c228ba645 100644 --- a/maven-core/src/main/java/org/apache/maven/lifecycle/internal/BuilderCommon.java +++ b/maven-core/src/main/java/org/apache/maven/lifecycle/internal/BuilderCommon.java @@ -48,7 +48,7 @@ import java.util.Set; /** * Common code that is shared by the LifecycleModuleBuilder and the LifeCycleWeaveBuilder - * + * * @since 3.0 * @author Kristian Rosenvold * Builds one or more lifecycles for a full module @@ -134,7 +134,8 @@ public class BuilderCommon } public void handleBuildError( final ReactorContext buildContext, final MavenSession rootSession, - final MavenProject mavenProject, Exception e, final long buildStartTime ) + final MavenSession currentSession, final MavenProject mavenProject, Exception e, + final long buildStartTime ) { if ( e instanceof RuntimeException ) { @@ -147,7 +148,7 @@ public class BuilderCommon buildContext.getResult().addBuildSummary( new BuildFailure( mavenProject, buildEndTime - buildStartTime, e ) ); - eventCatapult.fire( ExecutionEvent.Type.ProjectFailed, rootSession, null, e ); + eventCatapult.fire( ExecutionEvent.Type.ProjectFailed, currentSession, null, e ); if ( MavenExecutionRequest.REACTOR_FAIL_NEVER.equals( rootSession.getReactorFailureBehavior() ) ) { @@ -186,5 +187,4 @@ public class BuilderCommon return project.getGroupId() + ':' + project.getArtifactId() + ':' + project.getVersion(); } - -} \ No newline at end of file +} diff --git a/maven-core/src/main/java/org/apache/maven/lifecycle/internal/CurrentPhaseForThread.java b/maven-core/src/main/java/org/apache/maven/lifecycle/internal/CurrentPhaseForThread.java index 548bfcab65..f05425336e 100644 --- a/maven-core/src/main/java/org/apache/maven/lifecycle/internal/CurrentPhaseForThread.java +++ b/maven-core/src/main/java/org/apache/maven/lifecycle/internal/CurrentPhaseForThread.java @@ -29,17 +29,16 @@ package org.apache.maven.lifecycle.internal; */ class CurrentPhaseForThread { - private static final InheritableThreadLocal threadPhase = new InheritableThreadLocal(); - + private static final InheritableThreadLocal THREAD_PHASE = new InheritableThreadLocal(); public static void setPhase( String phase ) { - threadPhase.set( phase ); + THREAD_PHASE.set( phase ); } public static boolean isPhase( String phase ) { - return phase.equals( threadPhase.get() ); + return phase.equals( THREAD_PHASE.get() ); } } diff --git a/maven-core/src/main/java/org/apache/maven/lifecycle/internal/DefaultLifecycleExecutionPlanCalculator.java b/maven-core/src/main/java/org/apache/maven/lifecycle/internal/DefaultLifecycleExecutionPlanCalculator.java index b28e6c0132..58a7a624af 100644 --- a/maven-core/src/main/java/org/apache/maven/lifecycle/internal/DefaultLifecycleExecutionPlanCalculator.java +++ b/maven-core/src/main/java/org/apache/maven/lifecycle/internal/DefaultLifecycleExecutionPlanCalculator.java @@ -1,19 +1,24 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more contributor license - * agreements. See the NOTICE file distributed with this work for additional information regarding - * copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance with the License. You may obtain a - * copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License - * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express - * or implied. See the License for the specific language governing permissions and limitations under - * the License. - */ package org.apache.maven.lifecycle.internal; +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + import java.io.IOException; import java.util.ArrayList; import java.util.Collection; @@ -219,11 +224,10 @@ public class DefaultLifecycleExecutionPlanCalculator if ( lifecycle == null ) { - throw new LifecyclePhaseNotFoundException( - "Unknown lifecycle phase \"" + lifecyclePhase + "\". You must specify a valid lifecycle phase" + - " or a goal in the format : or" + - " :[:]:. Available lifecycle phases are: " + - defaultLifeCycles.getLifecyclePhaseList() + ".", lifecyclePhase ); + throw new LifecyclePhaseNotFoundException( "Unknown lifecycle phase \"" + lifecyclePhase + + "\". You must specify a valid lifecycle phase" + " or a goal in the format : or" + + " :[:]:. Available lifecycle phases are: " + + defaultLifeCycles.getLifecyclePhaseList() + ".", lifecyclePhase ); } /* @@ -432,8 +436,8 @@ public class DefaultLifecycleExecutionPlanCalculator { parameterConfiguration = new Xpp3Dom( parameterConfiguration, parameter.getName() ); - if ( StringUtils.isEmpty( parameterConfiguration.getAttribute( "implementation" ) ) && - StringUtils.isNotEmpty( parameter.getImplementation() ) ) + if ( StringUtils.isEmpty( parameterConfiguration.getAttribute( "implementation" ) ) + && StringUtils.isNotEmpty( parameter.getImplementation() ) ) { parameterConfiguration.setAttribute( "implementation", parameter.getImplementation() ); } diff --git a/maven-core/src/main/java/org/apache/maven/lifecycle/internal/DefaultLifecyclePluginAnalyzer.java b/maven-core/src/main/java/org/apache/maven/lifecycle/internal/DefaultLifecyclePluginAnalyzer.java index afd0034119..a5e6a34c2e 100644 --- a/maven-core/src/main/java/org/apache/maven/lifecycle/internal/DefaultLifecyclePluginAnalyzer.java +++ b/maven-core/src/main/java/org/apache/maven/lifecycle/internal/DefaultLifecyclePluginAnalyzer.java @@ -80,8 +80,8 @@ public class DefaultLifecyclePluginAnalyzer { if ( logger.isDebugEnabled() ) { - logger.debug( "Looking up lifecyle mappings for packaging " + packaging + " from " + - Thread.currentThread().getContextClassLoader() ); + logger.debug( "Looking up lifecyle mappings for packaging " + packaging + " from " + + Thread.currentThread().getContextClassLoader() ); } LifecycleMapping lifecycleMappingForPackaging = lifecycleMappings.get( packaging ); diff --git a/maven-core/src/main/java/org/apache/maven/lifecycle/internal/ExecutionPlanItem.java b/maven-core/src/main/java/org/apache/maven/lifecycle/internal/ExecutionPlanItem.java index 075524a632..027b241196 100644 --- a/maven-core/src/main/java/org/apache/maven/lifecycle/internal/ExecutionPlanItem.java +++ b/maven-core/src/main/java/org/apache/maven/lifecycle/internal/ExecutionPlanItem.java @@ -94,8 +94,8 @@ public class ExecutionPlanItem @Override public String toString() { - return "ExecutionPlanItem{" + ", mojoExecution=" + mojoExecution + ", schedule=" + schedule + '}' + - super.toString(); + return "ExecutionPlanItem{" + ", mojoExecution=" + mojoExecution + ", schedule=" + schedule + '}' + + super.toString(); } } 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 32e43bf3ec..a76461d523 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 @@ -1,20 +1,33 @@ package org.apache.maven.lifecycle.internal; /* - * Licensed to the Apache Software Foundation (ASF) under one or more contributor license - * agreements. See the NOTICE file distributed with this work for additional information regarding - * copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance with the License. You may obtain a - * copy of the License at + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software distributed under the License - * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express - * or implied. See the License for the specific language governing permissions and limitations under - * the License. + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. */ +import java.util.Collection; +import java.util.Collections; +import java.util.HashMap; +import java.util.HashSet; +import java.util.LinkedHashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + import org.apache.maven.RepositoryUtils; import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.ArtifactUtils; @@ -37,8 +50,6 @@ import org.eclipse.aether.graph.DependencyNode; import org.eclipse.aether.util.filter.AndDependencyFilter; import org.eclipse.aether.util.filter.ScopeDependencyFilter; -import java.util.*; - /** * Resolves dependencies for the artifacts in context of the lifecycle build * @@ -49,7 +60,7 @@ import java.util.*; *

* NOTE: This class is not part of any public api and can be changed or deleted without prior notice. */ -@Component(role = LifecycleDependencyResolver.class) +@Component( role = LifecycleDependencyResolver.class ) public class LifecycleDependencyResolver { diff --git a/maven-core/src/main/java/org/apache/maven/lifecycle/internal/LifecycleModuleBuilder.java b/maven-core/src/main/java/org/apache/maven/lifecycle/internal/LifecycleModuleBuilder.java index fe69c0a120..c8a3cf4a2d 100644 --- a/maven-core/src/main/java/org/apache/maven/lifecycle/internal/LifecycleModuleBuilder.java +++ b/maven-core/src/main/java/org/apache/maven/lifecycle/internal/LifecycleModuleBuilder.java @@ -32,7 +32,7 @@ import java.util.HashSet; /** * Builds one or more lifecycles for a full module - * + * * @since 3.0 * @author Benjamin Bentmann * @author Jason van Zyl @@ -92,7 +92,7 @@ public class LifecycleModuleBuilder } catch ( Exception e ) { - builderCommon.handleBuildError( reactorContext, rootSession, currentProject, e, buildStartTime ); + builderCommon.handleBuildError( reactorContext, rootSession, session, currentProject, e, buildStartTime ); } finally { @@ -101,4 +101,4 @@ public class LifecycleModuleBuilder Thread.currentThread().setContextClassLoader( reactorContext.getOriginalContextClassLoader() ); } } -} \ No newline at end of file +} diff --git a/maven-core/src/main/java/org/apache/maven/lifecycle/internal/LifecycleWeaveBuilder.java b/maven-core/src/main/java/org/apache/maven/lifecycle/internal/LifecycleWeaveBuilder.java index 12058e5307..4cfae7317c 100644 --- a/maven-core/src/main/java/org/apache/maven/lifecycle/internal/LifecycleWeaveBuilder.java +++ b/maven-core/src/main/java/org/apache/maven/lifecycle/internal/LifecycleWeaveBuilder.java @@ -212,7 +212,8 @@ public class LifecycleWeaveBuilder { Iterator planItems = executionPlan.iterator(); ExecutionPlanItem current = planItems.hasNext() ? planItems.next() : null; - ThreadLockedArtifact threadLockedArtifact = (ThreadLockedArtifact)projectBuild.getProject().getArtifact(); + ThreadLockedArtifact threadLockedArtifact = + (ThreadLockedArtifact) projectBuild.getProject().getArtifact(); if ( threadLockedArtifact != null ) { threadLockedArtifact.attachToThread(); @@ -277,8 +278,8 @@ public class LifecycleWeaveBuilder } catch ( Exception e ) { - builderCommon.handleBuildError( reactorContext, rootSession, projectBuild.getProject(), e, - buildStartTime ); + builderCommon.handleBuildError( reactorContext, rootSession, projectBuild.getSession(), + projectBuild.getProject(), e, buildStartTime ); } finally { @@ -375,13 +376,14 @@ public class LifecycleWeaveBuilder return null; } - private static boolean isThreadLockedAndEmpty(Artifact artifact){ - return artifact instanceof ThreadLockedArtifact && !((ThreadLockedArtifact) artifact).hasReal(); + private static boolean isThreadLockedAndEmpty( Artifact artifact ) + { + return artifact instanceof ThreadLockedArtifact && !( (ThreadLockedArtifact) artifact ).hasReal(); } private static Artifact findDependency( MavenProject project, Artifact upStreamArtifact ) { - if ( upStreamArtifact == null || isThreadLockedAndEmpty(upStreamArtifact)) + if ( upStreamArtifact == null || isThreadLockedAndEmpty( upStreamArtifact ) ) { return null; } @@ -483,8 +485,6 @@ public class LifecycleWeaveBuilder artifactInThis.setFile( upstream.getFile() ); artifactInThis.setRepository( upstream.getRepository() ); artifactInThis.setResolved( true ); // Or maybe upstream.isResolved().... - } } - -} \ No newline at end of file +} diff --git a/maven-core/src/main/java/org/apache/maven/lifecycle/internal/ThreadLockedArtifact.java b/maven-core/src/main/java/org/apache/maven/lifecycle/internal/ThreadLockedArtifact.java index b566e641d8..9c6cf40119 100644 --- a/maven-core/src/main/java/org/apache/maven/lifecycle/internal/ThreadLockedArtifact.java +++ b/maven-core/src/main/java/org/apache/maven/lifecycle/internal/ThreadLockedArtifact.java @@ -52,8 +52,8 @@ class ThreadLockedArtifact public boolean hasReal() { - return real != null && - ( !( real instanceof ThreadLockedArtifact ) || ( (ThreadLockedArtifact) real ).hasReal() ); + return real != null + && ( !( real instanceof ThreadLockedArtifact ) || ( (ThreadLockedArtifact) real ).hasReal() ); } public String getGroupId() @@ -96,17 +96,17 @@ class ThreadLockedArtifact return real.hasClassifier(); } - private static final InheritableThreadLocal threadArtifact = + private static final InheritableThreadLocal THREAD_ARTIFACT = new InheritableThreadLocal(); public void attachToThread() { - threadArtifact.set( this ); + THREAD_ARTIFACT.set( this ); } public File getFile() { - final ThreadLockedArtifact lockedArtifact = threadArtifact.get(); + final ThreadLockedArtifact lockedArtifact = THREAD_ARTIFACT.get(); if ( lockedArtifact != null && this != lockedArtifact && mustLock() ) { try diff --git a/maven-core/src/main/java/org/apache/maven/model/plugin/DefaultLifecycleBindingsInjector.java b/maven-core/src/main/java/org/apache/maven/model/plugin/DefaultLifecycleBindingsInjector.java index d2486b480f..46aeb0b6af 100644 --- a/maven-core/src/main/java/org/apache/maven/model/plugin/DefaultLifecycleBindingsInjector.java +++ b/maven-core/src/main/java/org/apache/maven/model/plugin/DefaultLifecycleBindingsInjector.java @@ -66,9 +66,9 @@ public class DefaultLifecycleBindingsInjector if ( defaultPlugins == null ) { - problems.add( new ModelProblemCollectorRequest( Severity.ERROR, Version.BASE) + problems.add( new ModelProblemCollectorRequest( Severity.ERROR, Version.BASE ) .setMessage( "Unknown packaging: " + packaging ) - .setLocation( model.getLocation( "packaging" ))); + .setLocation( model.getLocation( "packaging" ) ) ); } else if ( !defaultPlugins.isEmpty() ) { @@ -80,7 +80,7 @@ public class DefaultLifecycleBindingsInjector } } - private static class LifecycleBindingsMerger + protected static class LifecycleBindingsMerger extends MavenModelMerger { diff --git a/maven-core/src/main/java/org/apache/maven/plugin/BuildPluginManager.java b/maven-core/src/main/java/org/apache/maven/plugin/BuildPluginManager.java index b079f6be48..6c1b9cbf4d 100644 --- a/maven-core/src/main/java/org/apache/maven/plugin/BuildPluginManager.java +++ b/maven-core/src/main/java/org/apache/maven/plugin/BuildPluginManager.java @@ -1,18 +1,22 @@ package org.apache.maven.plugin; /* - * Licensed to the Apache Software Foundation (ASF) under one or more contributor license - * agreements. See the NOTICE file distributed with this work for additional information regarding - * copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance with the License. You may obtain a - * copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License - * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express - * or implied. See the License for the specific language governing permissions and limitations under - * the License. + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. */ import java.util.List; diff --git a/maven-core/src/main/java/org/apache/maven/plugin/DefaultBuildPluginManager.java b/maven-core/src/main/java/org/apache/maven/plugin/DefaultBuildPluginManager.java index af96b6d71a..5caba5a2de 100644 --- a/maven-core/src/main/java/org/apache/maven/plugin/DefaultBuildPluginManager.java +++ b/maven-core/src/main/java/org/apache/maven/plugin/DefaultBuildPluginManager.java @@ -1,18 +1,22 @@ package org.apache.maven.plugin; /* - * Licensed to the Apache Software Foundation (ASF) under one or more contributor license - * agreements. See the NOTICE file distributed with this work for additional information regarding - * copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance with the License. You may obtain a - * copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License - * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express - * or implied. See the License for the specific language governing permissions and limitations under - * the License. + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. */ import java.io.ByteArrayOutputStream; @@ -33,7 +37,7 @@ import org.eclipse.aether.repository.RemoteRepository; // TODO: the antrun plugin has its own configurator, the only plugin that does. might need to think about how that works // TODO: remove the coreArtifactFilterManager -@Component(role = BuildPluginManager.class) +@Component( role = BuildPluginManager.class ) public class DefaultBuildPluginManager implements BuildPluginManager { 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 6d8051a28e..5c703ce5bb 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 @@ -53,8 +53,8 @@ import org.codehaus.plexus.util.introspection.ReflectionValueExtractor; * mojo.* (since Maven 3) * plugin (since Maven 3){@link MojoExecution#getMojoDescriptor()}.{@link MojoDescriptor#getPluginDescriptor() getPluginDescriptor()} * plugin.* - * system properties - * project properties + * * system properties + * * project properties * * Notice: reports was supported in Maven 2.x but was removed in Maven 3 * diff --git a/maven-core/src/main/java/org/apache/maven/plugin/internal/DefaultLegacySupport.java b/maven-core/src/main/java/org/apache/maven/plugin/internal/DefaultLegacySupport.java index ead0f212ea..59047eb1ee 100644 --- a/maven-core/src/main/java/org/apache/maven/plugin/internal/DefaultLegacySupport.java +++ b/maven-core/src/main/java/org/apache/maven/plugin/internal/DefaultLegacySupport.java @@ -19,6 +19,7 @@ package org.apache.maven.plugin.internal; * under the License. */ +import java.util.concurrent.atomic.AtomicReference; import org.apache.maven.execution.MavenSession; import org.apache.maven.plugin.LegacySupport; import org.codehaus.plexus.component.annotations.Component; @@ -37,29 +38,30 @@ public class DefaultLegacySupport implements LegacySupport { - private static final ThreadLocal session = new InheritableThreadLocal(); + private static final ThreadLocal> SESSION = new InheritableThreadLocal>(); public void setSession( MavenSession session ) { - if ( session == null ) + AtomicReference reference = DefaultLegacySupport.SESSION.get(); + if ( reference != null ) { - MavenSession[] oldSession = DefaultLegacySupport.session.get(); - if ( oldSession != null ) - { - oldSession[0] = null; - DefaultLegacySupport.session.remove(); - } + reference.set( null ); + } + + if ( session == null && reference != null ) + { + DefaultLegacySupport.SESSION.remove(); } else { - DefaultLegacySupport.session.set( new MavenSession[] { session } ); + DefaultLegacySupport.SESSION.set( new AtomicReference( session ) ); } } public MavenSession getSession() { - MavenSession[] currentSession = DefaultLegacySupport.session.get(); - return currentSession != null ? currentSession[0] : null; + AtomicReference currentSession = DefaultLegacySupport.SESSION.get(); + return currentSession != null ? currentSession.get() : null; } public RepositorySystemSession getRepositorySession() diff --git a/maven-core/src/main/java/org/apache/maven/plugin/internal/DefaultMavenPluginManager.java b/maven-core/src/main/java/org/apache/maven/plugin/internal/DefaultMavenPluginManager.java index c36bd55c2e..8f22abe20a 100644 --- a/maven-core/src/main/java/org/apache/maven/plugin/internal/DefaultMavenPluginManager.java +++ b/maven-core/src/main/java/org/apache/maven/plugin/internal/DefaultMavenPluginManager.java @@ -83,6 +83,7 @@ import org.codehaus.plexus.configuration.PlexusConfiguration; import org.codehaus.plexus.configuration.PlexusConfigurationException; import org.codehaus.plexus.configuration.xml.XmlPlexusConfiguration; import org.codehaus.plexus.logging.Logger; +import org.codehaus.plexus.logging.LoggerManager; import org.codehaus.plexus.util.IOUtil; import org.codehaus.plexus.util.ReaderFactory; import org.codehaus.plexus.util.StringUtils; @@ -110,6 +111,9 @@ public class DefaultMavenPluginManager @Requirement private Logger logger; + @Requirement + private LoggerManager loggerManager; + @Requirement private PlexusContainer container; @@ -508,7 +512,8 @@ public class DefaultMavenPluginManager if ( mojo instanceof Mojo ) { - ( (Mojo) mojo ).setLog( new DefaultLog( logger ) ); + Logger mojoLogger = loggerManager.getLoggerForComponent( mojoDescriptor.getImplementation() ); + ( (Mojo) mojo ).setLog( new DefaultLog( mojoLogger ) ); } Xpp3Dom dom = mojoExecution.getConfiguration(); diff --git a/maven-core/src/main/java/org/apache/maven/plugin/internal/PluginDependenciesResolver.java b/maven-core/src/main/java/org/apache/maven/plugin/internal/PluginDependenciesResolver.java index 16bbd2e115..632d1d5918 100644 --- a/maven-core/src/main/java/org/apache/maven/plugin/internal/PluginDependenciesResolver.java +++ b/maven-core/src/main/java/org/apache/maven/plugin/internal/PluginDependenciesResolver.java @@ -50,7 +50,7 @@ public interface PluginDependenciesResolver * @return The resolved plugin artifact, never {@code null}. * @throws PluginResolutionException If the plugin artifact could not be resolved. */ - public Artifact resolve( Plugin plugin, List repositories, RepositorySystemSession session ) + Artifact resolve( Plugin plugin, List repositories, RepositorySystemSession session ) throws PluginResolutionException; /** diff --git a/maven-core/src/main/java/org/apache/maven/plugin/prefix/PluginPrefixResult.java b/maven-core/src/main/java/org/apache/maven/plugin/prefix/PluginPrefixResult.java index ab5c3dfd8e..6fe1f728b9 100644 --- a/maven-core/src/main/java/org/apache/maven/plugin/prefix/PluginPrefixResult.java +++ b/maven-core/src/main/java/org/apache/maven/plugin/prefix/PluginPrefixResult.java @@ -1,7 +1,5 @@ package org.apache.maven.plugin.prefix; -import org.eclipse.aether.repository.ArtifactRepository; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -11,7 +9,7 @@ import org.eclipse.aether.repository.ArtifactRepository; * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -21,6 +19,8 @@ import org.eclipse.aether.repository.ArtifactRepository; * under the License. */ +import org.eclipse.aether.repository.ArtifactRepository; + /** * Describes the result of a plugin prefix resolution request. * diff --git a/maven-core/src/main/java/org/apache/maven/project/DefaultModelBuildingListener.java b/maven-core/src/main/java/org/apache/maven/project/DefaultModelBuildingListener.java index 30423ce4ab..3aebe9b4b7 100644 --- a/maven-core/src/main/java/org/apache/maven/project/DefaultModelBuildingListener.java +++ b/maven-core/src/main/java/org/apache/maven/project/DefaultModelBuildingListener.java @@ -97,9 +97,9 @@ class DefaultModelBuildingListener } catch ( Exception e ) { - event.getProblems().add( new ModelProblemCollectorRequest( Severity.ERROR, Version.BASE) + event.getProblems().add( new ModelProblemCollectorRequest( Severity.ERROR, Version.BASE ) .setMessage( "Invalid plugin repository: " + e.getMessage() ) - .setException( e )); + .setException( e ) ); } project.setPluginArtifactRepositories( pluginRepositories ); @@ -115,15 +115,15 @@ class DefaultModelBuildingListener } catch ( PluginResolutionException e ) { - event.getProblems().add( new ModelProblemCollectorRequest( Severity.ERROR, Version.BASE) - .setMessage( "Unresolveable build extension: " + e.getMessage()) - .setException( e )); + event.getProblems().add( new ModelProblemCollectorRequest( Severity.ERROR, Version.BASE ) + .setMessage( "Unresolveable build extension: " + e.getMessage() ) + .setException( e ) ); } catch ( PluginVersionResolutionException e ) { - event.getProblems().add( new ModelProblemCollectorRequest( Severity.ERROR, Version.BASE) + event.getProblems().add( new ModelProblemCollectorRequest( Severity.ERROR, Version.BASE ) .setMessage( "Unresolveable build extension: " + e.getMessage() ) - .setException( e )); + .setException( e ) ); } projectBuildingHelper.selectProjectRealm( project ); @@ -138,9 +138,9 @@ class DefaultModelBuildingListener } catch ( Exception e ) { - event.getProblems().add( new ModelProblemCollectorRequest( Severity.ERROR, Version.BASE) + event.getProblems().add( new ModelProblemCollectorRequest( Severity.ERROR, Version.BASE ) .setMessage( "Invalid artifact repository: " + e.getMessage() ) - .setException( e )); + .setException( e ) ); } project.setRemoteArtifactRepositories( remoteRepositories ); } 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 3a26f9ddf0..744d231d06 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 @@ -1,18 +1,22 @@ package org.apache.maven.project; /* - * Licensed to the Apache Software Foundation (ASF) under one or more contributor license - * agreements. See the NOTICE file distributed with this work for additional information regarding - * copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance with the License. You may obtain a - * copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License - * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express - * or implied. See the License for the specific language governing permissions and limitations under - * the License. + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. */ import java.io.File; 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 f4ec8a4142..c3f214f4c3 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 @@ -1,18 +1,22 @@ package org.apache.maven.project; /* - * Licensed to the Apache Software Foundation (ASF) under one or more contributor license - * agreements. See the NOTICE file distributed with this work for additional information regarding - * copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance with the License. You may obtain a - * copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License - * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express - * or implied. See the License for the specific language governing permissions and limitations under - * the License. + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. */ import org.apache.maven.RepositoryUtils; @@ -1477,7 +1481,7 @@ public class MavenProject for ( int ax = 0; ax < attachedArtifacts.size(); ax++ ) { Artifact a = attachedArtifacts.get( ax ); - if ( a.equals( artifact )) + if ( a.equals( artifact ) ) { if ( logger != null ) { diff --git a/maven-core/src/main/java/org/apache/maven/project/ProjectBuildingRequest.java b/maven-core/src/main/java/org/apache/maven/project/ProjectBuildingRequest.java index 6b7259102c..9ed113dad4 100644 --- a/maven-core/src/main/java/org/apache/maven/project/ProjectBuildingRequest.java +++ b/maven-core/src/main/java/org/apache/maven/project/ProjectBuildingRequest.java @@ -79,7 +79,7 @@ public interface ProjectBuildingRequest */ Properties getUserProperties(); - void setProject(MavenProject mavenProject); + void setProject( MavenProject mavenProject ); MavenProject getProject(); 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 da22838f67..0f3cd56be1 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 @@ -42,17 +42,17 @@ import org.eclipse.aether.RepositorySystemSession; */ public interface RepositorySystem { - final String DEFAULT_LOCAL_REPO_ID = "local"; + String DEFAULT_LOCAL_REPO_ID = "local"; - final String userHome = System.getProperty( "user.home" ); + String userHome = System.getProperty( "user.home" ); - final File userMavenConfigurationHome = new File( userHome, ".m2" ); + File userMavenConfigurationHome = new File( userHome, ".m2" ); - final File defaultUserLocalRepository = new File( userMavenConfigurationHome, "repository" ); + File defaultUserLocalRepository = new File( userMavenConfigurationHome, "repository" ); - final String DEFAULT_REMOTE_REPO_ID = "central"; + String DEFAULT_REMOTE_REPO_ID = "central"; - final String DEFAULT_REMOTE_REPO_URL = "http://repo.maven.apache.org/maven2"; + String DEFAULT_REMOTE_REPO_URL = "http://repo.maven.apache.org/maven2"; Artifact createArtifact( String groupId, String artifactId, String version, String packaging ); diff --git a/maven-core/src/main/resources/META-INF/plexus/components.xml b/maven-core/src/main/resources/META-INF/plexus/components.xml index 07515533e5..6282ba0971 100644 --- a/maven-core/src/main/resources/META-INF/plexus/components.xml +++ b/maven-core/src/main/resources/META-INF/plexus/components.xml @@ -129,10 +129,10 @@ under the License. - org.apache.maven.plugins:maven-site-plugin:3.1:site + org.apache.maven.plugins:maven-site-plugin:3.2:site - org.apache.maven.plugins:maven-site-plugin:3.1:deploy + org.apache.maven.plugins:maven-site-plugin:3.2:deploy diff --git a/maven-core/src/main/resources/META-INF/plexus/default-bindings.xml b/maven-core/src/main/resources/META-INF/plexus/default-bindings.xml index 39fe4bb8a3..09ecba441e 100644 --- a/maven-core/src/main/resources/META-INF/plexus/default-bindings.xml +++ b/maven-core/src/main/resources/META-INF/plexus/default-bindings.xml @@ -258,7 +258,7 @@ Mappings to default lifecycle, specific for each packaging. org.apache.maven.plugins:maven-surefire-plugin:2.12.4:test - org.apache.maven.plugins:maven-war-plugin:2.3:war + org.apache.maven.plugins:maven-war-plugin:2.2:war org.apache.maven.plugins:maven-install-plugin:2.4:install diff --git a/maven-core/src/site/apt/artifact-handlers.apt b/maven-core/src/site/apt/artifact-handlers.apt index 7f211a6ac7..3eea01785f 100644 --- a/maven-core/src/site/apt/artifact-handlers.apt +++ b/maven-core/src/site/apt/artifact-handlers.apt @@ -1,41 +1,41 @@ - --- - Default Artifact Handlers Reference - --- - Hervé Boutemy - --- - 2012-08-13 - --- - -Default Artifact Handlers Reference - - Some artifact handlers are defined by default: - -*--------------------+------------+------------+---------------+-----------+---------------------+-----------------------+ -|| type || extension || packaging || classifier || language || added to classpath || includesDependencies || -*--------------------+------------+------------+---------------+-----------+---------------------+-----------------------+ -| <<>> | <= type> | <= type> | | none | | | -*--------------------+------------+------------+---------------+-----------+---------------------+-----------------------+ -| <<>> | <= type> | <= type> | | java | <<>> | | -*--------------------+------------+------------+---------------+-----------+---------------------+-----------------------+ -| <<>> | <<>> | <= type> | | java | <<>> | | -*--------------------+------------+------------+---------------+-----------+---------------------+-----------------------+ -| <<>> | <<>> | <= type> | | java | <<>> | | -*--------------------+------------+------------+---------------+-----------+---------------------+-----------------------+ -| <<>> | <= type> | <= type> | | java | | <<>> | -*--------------------+------------+------------+---------------+-----------+---------------------+-----------------------+ -| <<>> | <= type> | <= type> | | java | | <<>> | -*--------------------+------------+------------+---------------+-----------+---------------------+-----------------------+ -| <<>> | <= type> | <= type> | | java | | <<>> | -*--------------------+------------+------------+---------------+-----------+---------------------+-----------------------+ -| <<>> | <= type> | <= type> | | java | | <<>> | -*--------------------+------------+------------+---------------+-----------+---------------------+-----------------------+ -| <<>> | <= type> | <= type> | | java | | <<>> | -*--------------------+------------+------------+---------------+-----------+---------------------+-----------------------+ -| <<>> | <<>> | <= type> | <<>> | java | | | -*--------------------+------------+------------+---------------+-----------+---------------------+-----------------------+ -| <<>> | <<>> | <= type> | <<>> | java | <<>> | | -*--------------------+------------+------------+---------------+-----------+---------------------+-----------------------+ -| <<>> | <<>> | <<>> | <<>> | java | <<>> | | -*--------------------+------------+------------+---------------+-----------+---------------------+-----------------------+ -| <<>> | <<>> | <<>> | <<>> | java | <<>> | | -*--------------------+------------+------------+---------------+-----------+---------------------+-----------------------+ + --- + Default Artifact Handlers Reference + --- + Hervé Boutemy + --- + 2012-08-13 + --- + +Default Artifact Handlers Reference + + Some artifact handlers are defined by default: + +*--------------------+------------+------------+---------------+-----------+---------------------+-----------------------+ +|| type || extension || packaging || classifier || language || added to classpath || includesDependencies || +*--------------------+------------+------------+---------------+-----------+---------------------+-----------------------+ +| <<>> | <= type> | <= type> | | none | | | +*--------------------+------------+------------+---------------+-----------+---------------------+-----------------------+ +| <<>> | <= type> | <= type> | | java | <<>> | | +*--------------------+------------+------------+---------------+-----------+---------------------+-----------------------+ +| <<>> | <<>> | <= type> | | java | <<>> | | +*--------------------+------------+------------+---------------+-----------+---------------------+-----------------------+ +| <<>> | <<>> | <= type> | | java | <<>> | | +*--------------------+------------+------------+---------------+-----------+---------------------+-----------------------+ +| <<>> | <= type> | <= type> | | java | | <<>> | +*--------------------+------------+------------+---------------+-----------+---------------------+-----------------------+ +| <<>> | <= type> | <= type> | | java | | <<>> | +*--------------------+------------+------------+---------------+-----------+---------------------+-----------------------+ +| <<>> | <= type> | <= type> | | java | | <<>> | +*--------------------+------------+------------+---------------+-----------+---------------------+-----------------------+ +| <<>> | <= type> | <= type> | | java | | <<>> | +*--------------------+------------+------------+---------------+-----------+---------------------+-----------------------+ +| <<>> | <= type> | <= type> | | java | | <<>> | +*--------------------+------------+------------+---------------+-----------+---------------------+-----------------------+ +| <<>> | <<>> | <= type> | <<>> | java | | | +*--------------------+------------+------------+---------------+-----------+---------------------+-----------------------+ +| <<>> | <<>> | <= type> | <<>> | java | <<>> | | +*--------------------+------------+------------+---------------+-----------+---------------------+-----------------------+ +| <<>> | <<>> | <<>> | <<>> | java | <<>> | | +*--------------------+------------+------------+---------------+-----------+---------------------+-----------------------+ +| <<>> | <<>> | <<>> | <<>> | java | <<>> | | +*--------------------+------------+------------+---------------+-----------+---------------------+-----------------------+ diff --git a/maven-core/src/site/apt/index.apt b/maven-core/src/site/apt/index.apt index 72d4696a7d..f1c63294ce 100644 --- a/maven-core/src/site/apt/index.apt +++ b/maven-core/src/site/apt/index.apt @@ -26,4 +26,10 @@ Maven Core ({{{./xref/org/apache/maven/plugin/internal/DefaultMavenPluginManager.html}source}}), * {{{./apidocs/org/apache/maven/plugin/PluginParameterExpressionEvaluator.html}PluginParameterExpressionEvaluator}}, used to - evaluate plugin parameters values during Mojo configuration. + 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 + {{{http://plexus.codehaus.org/plexus-classworlds/}Plexus Classworlds}}. diff --git a/maven-core/src/test/java/org/apache/maven/artifact/handler/ArtifactHandlerTest.java b/maven-core/src/test/java/org/apache/maven/artifact/handler/ArtifactHandlerTest.java index 2edbcf4410..ac02e106d3 100644 --- a/maven-core/src/test/java/org/apache/maven/artifact/handler/ArtifactHandlerTest.java +++ b/maven-core/src/test/java/org/apache/maven/artifact/handler/ArtifactHandlerTest.java @@ -1,89 +1,89 @@ -package org.apache.maven.artifact.handler; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import java.io.File; -import java.util.List; - -import org.codehaus.plexus.PlexusTestCase; -import org.codehaus.plexus.util.FileUtils; - -public class ArtifactHandlerTest - extends PlexusTestCase -{ - public void testAptConsistency() - throws Exception - { - File apt = getTestFile( "src/site/apt/artifact-handlers.apt" ); - - @SuppressWarnings( "unchecked" ) - List lines = FileUtils.loadFile( apt ); - - for ( String line : lines ) - { - if ( line.startsWith( "||" ) ) - { - String[] cols = line.split( "\\|\\|" ); - String[] expected = - new String[] { "", "type", "extension", "packaging", "classifier", "language", "added to classpath", - "includesDependencies", "" }; - - int i = 0; - for ( String col : cols ) - { - assertEquals( "Wrong column header", expected[i++], col.trim() ); - } - } - else if ( line.startsWith( "|" ) ) - { - String[] cols = line.split( "\\|" ); - - String type = trimApt( cols[1] ); - String extension = trimApt( cols[2], type ); - String packaging = trimApt( cols[3], type ); - String classifier = trimApt( cols[4] ); - String language = trimApt( cols[5] ); - String addedToClasspath = trimApt( cols[6] ); - String includesDependencies = trimApt( cols[7] ); - - ArtifactHandler handler = lookup( ArtifactHandler.class, type ); - assertEquals( type + " extension", handler.getExtension(), extension ); - assertEquals( type + " packaging", handler.getPackaging(), packaging ); - assertEquals( type + " classifier", handler.getClassifier(), classifier ); - assertEquals( type + " language", handler.getLanguage(), language ); - assertEquals( type + " addedToClasspath", handler.isAddedToClasspath() ? "true" : null, addedToClasspath ); - assertEquals( type + " includesDependencies", handler.isIncludesDependencies() ? "true" : null, includesDependencies ); - } - } - } - - private String trimApt( String content, String type ) - { - String value = trimApt( content ); - return "= type".equals( value ) ? type : value; - } - - private String trimApt( String content ) - { - content = content.replace( '<', ' ' ).replace( '>', ' ' ).trim(); - - return ( content.length() == 0 ) ? null : content; - } -} +package org.apache.maven.artifact.handler; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import java.io.File; +import java.util.List; + +import org.codehaus.plexus.PlexusTestCase; +import org.codehaus.plexus.util.FileUtils; + +public class ArtifactHandlerTest + extends PlexusTestCase +{ + public void testAptConsistency() + throws Exception + { + File apt = getTestFile( "src/site/apt/artifact-handlers.apt" ); + + @SuppressWarnings( "unchecked" ) + List lines = FileUtils.loadFile( apt ); + + for ( String line : lines ) + { + if ( line.startsWith( "||" ) ) + { + String[] cols = line.split( "\\|\\|" ); + String[] expected = + new String[] { "", "type", "extension", "packaging", "classifier", "language", "added to classpath", + "includesDependencies", "" }; + + int i = 0; + for ( String col : cols ) + { + assertEquals( "Wrong column header", expected[i++], col.trim() ); + } + } + else if ( line.startsWith( "|" ) ) + { + String[] cols = line.split( "\\|" ); + + String type = trimApt( cols[1] ); + String extension = trimApt( cols[2], type ); + String packaging = trimApt( cols[3], type ); + String classifier = trimApt( cols[4] ); + String language = trimApt( cols[5] ); + String addedToClasspath = trimApt( cols[6] ); + String includesDependencies = trimApt( cols[7] ); + + ArtifactHandler handler = lookup( ArtifactHandler.class, type ); + assertEquals( type + " extension", handler.getExtension(), extension ); + assertEquals( type + " packaging", handler.getPackaging(), packaging ); + assertEquals( type + " classifier", handler.getClassifier(), classifier ); + assertEquals( type + " language", handler.getLanguage(), language ); + assertEquals( type + " addedToClasspath", handler.isAddedToClasspath() ? "true" : null, addedToClasspath ); + assertEquals( type + " includesDependencies", handler.isIncludesDependencies() ? "true" : null, includesDependencies ); + } + } + } + + private String trimApt( String content, String type ) + { + String value = trimApt( content ); + return "= type".equals( value ) ? type : value; + } + + private String trimApt( String content ) + { + content = content.replace( '<', ' ' ).replace( '>', ' ' ).trim(); + + return ( content.length() == 0 ) ? null : content; + } +} diff --git a/maven-core/src/test/java/org/apache/maven/exception/DefaultExceptionHandlerTest.java b/maven-core/src/test/java/org/apache/maven/exception/DefaultExceptionHandlerTest.java index aa81f4642e..9727bdf8a2 100644 --- a/maven-core/src/test/java/org/apache/maven/exception/DefaultExceptionHandlerTest.java +++ b/maven-core/src/test/java/org/apache/maven/exception/DefaultExceptionHandlerTest.java @@ -1,60 +1,60 @@ -package org.apache.maven.exception; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import java.io.IOException; -import java.net.ConnectException; - -import org.apache.maven.plugin.MojoExecutionException; - -import junit.framework.TestCase; - -/** - * @author Barrie Treloar - */ -public class DefaultExceptionHandlerTest - extends TestCase -{ - /** - * Running Maven under JDK7 may cause connection issues because IPv6 is used by default. - *

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

- *

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

- */ - public void testJdk7ipv6() - { - ConnectException connEx = new ConnectException( "Connection refused: connect" ); - IOException ioEx = new IOException( "Unable to establish loopback connection" ); - ioEx.initCause( connEx ); - MojoExecutionException mojoEx = - new MojoExecutionException( "Error executing Jetty: Unable to establish loopback connection", ioEx ); - - ExceptionHandler exceptionHandler = new DefaultExceptionHandler(); - ExceptionSummary exceptionSummary = exceptionHandler.handleException( mojoEx ); - - String expectedReference = "http://cwiki.apache.org/confluence/display/MAVEN/ConnectException"; - assertEquals( expectedReference, exceptionSummary.getReference() ); - - } -} +package org.apache.maven.exception; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import java.io.IOException; +import java.net.ConnectException; + +import org.apache.maven.plugin.MojoExecutionException; + +import junit.framework.TestCase; + +/** + * @author Barrie Treloar + */ +public class DefaultExceptionHandlerTest + extends TestCase +{ + /** + * Running Maven under JDK7 may cause connection issues because IPv6 is used by default. + *

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

+ *

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

+ */ + public void testJdk7ipv6() + { + ConnectException connEx = new ConnectException( "Connection refused: connect" ); + IOException ioEx = new IOException( "Unable to establish loopback connection" ); + ioEx.initCause( connEx ); + MojoExecutionException mojoEx = + new MojoExecutionException( "Error executing Jetty: Unable to establish loopback connection", ioEx ); + + ExceptionHandler exceptionHandler = new DefaultExceptionHandler(); + ExceptionSummary exceptionSummary = exceptionHandler.handleException( mojoEx ); + + String expectedReference = "http://cwiki.apache.org/confluence/display/MAVEN/ConnectException"; + assertEquals( expectedReference, exceptionSummary.getReference() ); + + } +} diff --git a/maven-core/src/test/java/org/apache/maven/plugin/internal/DefaultLegacySupportTest.java b/maven-core/src/test/java/org/apache/maven/plugin/internal/DefaultLegacySupportTest.java new file mode 100644 index 0000000000..d350770cbc --- /dev/null +++ b/maven-core/src/test/java/org/apache/maven/plugin/internal/DefaultLegacySupportTest.java @@ -0,0 +1,74 @@ +package org.apache.maven.plugin.internal; +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import junit.framework.TestCase; +import org.apache.maven.execution.DefaultMavenExecutionRequest; +import org.apache.maven.execution.MavenExecutionRequest; +import org.apache.maven.execution.MavenSession; + +import java.util.concurrent.CountDownLatch; + +/** + * @author Kristian Rosenvold + */ +public class DefaultLegacySupportTest extends TestCase { + final CountDownLatch latch = new CountDownLatch(1); + final DefaultLegacySupport defaultLegacySupport = new DefaultLegacySupport(); + + public void testSetSession() throws Exception { + + MavenExecutionRequest mavenExecutionRequest = new DefaultMavenExecutionRequest(); + MavenSession m1 = new MavenSession(null, null, mavenExecutionRequest, null); + defaultLegacySupport.setSession(m1); + + MyRunnable myRunnable = new MyRunnable(); + Thread thread = new Thread(myRunnable); + thread.start(); + + MavenSession m2 = new MavenSession(null, null, mavenExecutionRequest, null); + defaultLegacySupport.setSession(m2); + latch.countDown(); + thread.join(); + assertNull( myRunnable.getSession()); + } + + + class MyRunnable implements Runnable { + + private volatile MavenSession session; + + public void run() { + try + { + latch.await(); + } + catch (InterruptedException ingore) + { + // Test may fail if we get interrupted + } + session = defaultLegacySupport.getSession(); + } + + public MavenSession getSession() { + return session; + } + } + +} diff --git a/maven-embedder/pom.xml b/maven-embedder/pom.xml index 587398f371..49a7b57629 100644 --- a/maven-embedder/pom.xml +++ b/maven-embedder/pom.xml @@ -74,6 +74,16 @@ org.slf4j slf4j-api + + org.slf4j + slf4j-simple + true + + + ch.qos.logback + logback-classic + true + commons-cli diff --git a/maven-embedder/src/main/java/org/apache/maven/cli/CLIManager.java b/maven-embedder/src/main/java/org/apache/maven/cli/CLIManager.java index 0e7f2b622a..d30a16dcae 100644 --- a/maven-embedder/src/main/java/org/apache/maven/cli/CLIManager.java +++ b/maven-embedder/src/main/java/org/apache/maven/cli/CLIManager.java @@ -97,6 +97,8 @@ public class CLIManager public static final String THREADS = "T"; + public static final String LEGACY_LOCAL_REPOSITORY ="llr"; + protected Options options; @SuppressWarnings( "static-access" ) @@ -133,9 +135,9 @@ public class CLIManager options.addOption( OptionBuilder.withLongOpt( "encrypt-master-password" ).hasArg().withDescription( "Encrypt master security password" ).create( ENCRYPT_MASTER_PASSWORD ) ); options.addOption( OptionBuilder.withLongOpt( "encrypt-password" ).hasArg().withDescription( "Encrypt server password" ).create( ENCRYPT_PASSWORD ) ); options.addOption( OptionBuilder.withLongOpt( "threads" ).hasArg().withDescription( "Thread count, for instance 2.0C where C is core multiplied" ).create( THREADS ) ); + options.addOption( OptionBuilder.withLongOpt( "legacy-local-repository" ).withDescription( "Use Maven 2 Legacy Local Repository behaviour, ie no use of _maven.repositories. Can also be activated by using -Dmaven.legacyLocalRepo=true" ).create( LEGACY_LOCAL_REPOSITORY ) ); // Adding this back in for compatibility with the verifier that hard codes this option. - options.addOption( OptionBuilder.withLongOpt( "no-plugin-registry" ).withDescription( "Ineffective, only kept for backward compatibility" ).create( "npr" ) ); options.addOption( OptionBuilder.withLongOpt( "check-plugin-updates" ).withDescription( "Ineffective, only kept for backward compatibility" ).create( "cpu" ) ); options.addOption( OptionBuilder.withLongOpt( "update-plugins" ).withDescription( "Ineffective, only kept for backward compatibility" ).create( "up" ) ); 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 0f8262b102..6173959a1f 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 @@ -53,11 +53,15 @@ public final class CLIReportingUtils Properties properties = getBuildProperties(); StringBuffer version = new StringBuffer(); version.append( createMavenVersionString( properties ) ).append( LS ); - version.append( reduce( properties.getProperty( "distributionShortName" ) + " home: " + System.getProperty( "maven.home", "" ) ) ).append( LS ); - version.append( "Java version: " + System.getProperty( "java.version", "" ) + ", vendor: " + System.getProperty( "java.vendor", "" ) ).append( LS ); + version.append( reduce( properties.getProperty( "distributionShortName" ) + " home: " + + System.getProperty( "maven.home", "" ) ) ).append( LS ); + version.append( "Java version: " + System.getProperty( "java.version", "" ) + + ", vendor: " + System.getProperty( "java.vendor", "" ) ).append( LS ); version.append( "Java home: " + System.getProperty( "java.home", "" ) ).append( LS ); - version.append( "Default locale: " + Locale.getDefault() + ", platform encoding: " + System.getProperty( "file.encoding", "" ) ).append( LS ); - version.append( "OS name: \"" + Os.OS_NAME + "\", version: \"" + Os.OS_VERSION + "\", arch: \"" + Os.OS_ARCH + "\", family: \"" + Os.OS_FAMILY + "\"" ); + version.append( "Default locale: " + Locale.getDefault() + ", platform encoding: " + + System.getProperty( "file.encoding", "" ) ).append( LS ); + version.append( "OS name: \"" + Os.OS_NAME + "\", version: \"" + Os.OS_VERSION + "\", arch: \"" + Os.OS_ARCH + + "\", family: \"" + Os.OS_FAMILY + "\"" ); return version.toString(); } @@ -79,7 +83,7 @@ public final class CLIReportingUtils if ( rev != null || timestamp != null ) { msg += " ("; - msg += ( rev != null ? "r" + rev : "" ); + msg += ( rev != null ? rev : "" ); if ( timestamp != null ) { SimpleDateFormat fmt = new SimpleDateFormat( "yyyy-MM-dd HH:mm:ssZ" ); 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 e2b0e21d12..62999f5a23 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 @@ -39,7 +39,10 @@ import org.apache.maven.InternalErrorException; import org.apache.maven.Maven; import org.apache.maven.cli.event.DefaultEventSpyContext; import org.apache.maven.cli.event.ExecutionEventLogger; +import org.apache.maven.cli.logging.Slf4jConfiguration; +import org.apache.maven.cli.logging.Slf4jConfigurationFactory; import org.apache.maven.cli.logging.Slf4jLoggerManager; +import org.apache.maven.cli.logging.Slf4jStdoutLogger; import org.apache.maven.cli.transfer.ConsoleMavenTransferListener; import org.apache.maven.cli.transfer.QuietMavenTransferListener; import org.apache.maven.cli.transfer.Slf4jMavenTransferListener; @@ -207,6 +210,7 @@ public class MavenCli settings( cliRequest ); populateRequest( cliRequest ); encryption( cliRequest ); + repository( cliRequest ); return execute( cliRequest ); } catch ( ExitException e ) @@ -232,7 +236,7 @@ public class MavenCli } finally { - if (localContainer != null) + if ( localContainer != null ) { localContainer.dispose(); } @@ -261,6 +265,12 @@ public class MavenCli private void cli( CliRequest cliRequest ) throws Exception { + // + // Parsing errors can happen during the processing of the arguments and we prefer not having to check if the logger is null + // and construct this so we can use an SLF4J logger everywhere. + // + slf4jLogger = new Slf4jStdoutLogger(); + CLIManager cliManager = new CLIManager(); try @@ -287,36 +297,40 @@ public class MavenCli } } - // - // All logging is handled by SFL4J - // + /** + * configure logging + */ private void logging( CliRequest cliRequest ) { cliRequest.debug = cliRequest.commandLine.hasOption( CLIManager.DEBUG ); cliRequest.quiet = !cliRequest.debug && cliRequest.commandLine.hasOption( CLIManager.QUIET ); cliRequest.showErrors = cliRequest.debug || cliRequest.commandLine.hasOption( CLIManager.ERRORS ); + slf4jLoggerFactory = LoggerFactory.getILoggerFactory(); + Slf4jConfiguration slf4jConfiguration = Slf4jConfigurationFactory.getConfiguration( slf4jLoggerFactory ); + if ( cliRequest.debug ) { cliRequest.request.setLoggingLevel( MavenExecutionRequest.LOGGING_LEVEL_DEBUG ); - System.setProperty( "org.slf4j.simpleLogger.defaultLogLevel", "debug" ); + slf4jConfiguration.setRootLoggerLevel( Slf4jConfiguration.Level.DEBUG ); } else if ( cliRequest.quiet ) { cliRequest.request.setLoggingLevel( MavenExecutionRequest.LOGGING_LEVEL_ERROR ); - System.setProperty( "org.slf4j.simpleLogger.defaultLogLevel", "error" ); + slf4jConfiguration.setRootLoggerLevel( Slf4jConfiguration.Level.ERROR ); } else { cliRequest.request.setLoggingLevel( MavenExecutionRequest.LOGGING_LEVEL_INFO ); - System.setProperty( "org.slf4j.simpleLogger.defaultLogLevel", "info" ); + slf4jConfiguration.setRootLoggerLevel( Slf4jConfiguration.Level.INFO ); } if ( cliRequest.commandLine.hasOption( CLIManager.LOG_FILE ) ) { File logFile = new File( cliRequest.commandLine.getOptionValue( CLIManager.LOG_FILE ) ); logFile = resolveFile( logFile, cliRequest.workingDirectory ); - System.setProperty( "org.slf4j.simpleLogger.logFile", logFile.getAbsolutePath() ); + + // redirect stdout and stderr to file try { PrintStream ps = new PrintStream( new FileOutputStream( logFile ) ); @@ -331,8 +345,9 @@ public class MavenCli } } + slf4jConfiguration.activate(); + plexusLoggerManager = new Slf4jLoggerManager(); - slf4jLoggerFactory = LoggerFactory.getILoggerFactory(); slf4jLogger = slf4jLoggerFactory.getLogger( this.getClass().getName() ); } @@ -376,29 +391,27 @@ public class MavenCli DefaultPlexusContainer container = null; - ContainerConfiguration cc = new DefaultContainerConfiguration() - .setClassWorld( cliRequest.classWorld ) - .setRealm( setupContainerRealm( cliRequest ) ) - .setClassPathScanning( PlexusConstants.SCANNING_INDEX ) - .setAutoWiring( true ) - .setName( "maven" ); + ContainerConfiguration cc = new DefaultContainerConfiguration() + .setClassWorld( cliRequest.classWorld ) + .setRealm( setupContainerRealm( cliRequest ) ) + .setClassPathScanning( PlexusConstants.SCANNING_INDEX ) + .setAutoWiring( true ) + .setName( "maven" ); - container = new DefaultPlexusContainer( cc, new AbstractModule() + container = new DefaultPlexusContainer( cc, new AbstractModule() + { + protected void configure() { + bind( ILoggerFactory.class ).toInstance( slf4jLoggerFactory ); + } + } ); - protected void configure() - { - bind( ILoggerFactory.class ).toInstance( slf4jLoggerFactory ); - } + // NOTE: To avoid inconsistencies, we'll use the TCCL exclusively for lookups + container.setLookupRealm( null ); - } ); + container.setLoggerManager( plexusLoggerManager ); - // NOTE: To avoid inconsistencies, we'll use the TCCL exclusively for lookups - container.setLookupRealm( null ); - - container.setLoggerManager( plexusLoggerManager ); - - customizeContainer( container ); + customizeContainer( container ); container.getLoggerManager().setThresholds( cliRequest.request.getLoggingLevel() ); @@ -526,6 +539,15 @@ public class MavenCli } } + private void repository( CliRequest cliRequest ) + throws Exception + { + if ( cliRequest.commandLine.hasOption( CLIManager.LEGACY_LOCAL_REPOSITORY ) || Boolean.getBoolean( "maven.legacyLocalRepo" ) ) + { + cliRequest.request.setUseLegacyLocalRepository( true ); + } + } + private int execute( CliRequest cliRequest ) { eventSpyDispatcher.onEvent( cliRequest.request ); @@ -887,7 +909,7 @@ public class MavenCli transferListener = getBatchTransferListener(); } - ExecutionListener executionListener = new ExecutionEventLogger( slf4jLogger ); + ExecutionListener executionListener = new ExecutionEventLogger(); executionListener = eventSpyDispatcher.chainListener( executionListener ); String alternatePomFile = null; @@ -1153,7 +1175,7 @@ public class MavenCli protected TransferListener getBatchTransferListener() { - return new Slf4jMavenTransferListener( slf4jLogger ); + return new Slf4jMavenTransferListener(); } protected void customizeContainer( PlexusContainer container ) diff --git a/maven-embedder/src/main/java/org/apache/maven/cli/event/ExecutionEventLogger.java b/maven-embedder/src/main/java/org/apache/maven/cli/event/ExecutionEventLogger.java index 819f179e12..f55141d4c3 100644 --- a/maven-embedder/src/main/java/org/apache/maven/cli/event/ExecutionEventLogger.java +++ b/maven-embedder/src/main/java/org/apache/maven/cli/event/ExecutionEventLogger.java @@ -31,9 +31,10 @@ import org.apache.maven.execution.MavenSession; import org.apache.maven.plugin.MojoExecution; import org.apache.maven.project.MavenProject; import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** - * Logs execution events to a user-supplied logger. + * Logs execution events to logger, eventually user-supplied. * * @author Benjamin Bentmann */ @@ -44,6 +45,12 @@ public class ExecutionEventLogger private static final int LINE_LENGTH = 72; + public ExecutionEventLogger() + { + logger = LoggerFactory.getLogger( ExecutionEventLogger.class ); + } + + // TODO should we deprecate? public ExecutionEventLogger( Logger logger ) { if ( logger == null ) diff --git a/maven-embedder/src/main/java/org/apache/maven/cli/logging/BaseSlf4jConfiguration.java b/maven-embedder/src/main/java/org/apache/maven/cli/logging/BaseSlf4jConfiguration.java new file mode 100644 index 0000000000..a6961848db --- /dev/null +++ b/maven-embedder/src/main/java/org/apache/maven/cli/logging/BaseSlf4jConfiguration.java @@ -0,0 +1,44 @@ +package org.apache.maven.cli.logging; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES 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; +import org.slf4j.LoggerFactory; + +/** + * Abstract implementation. + * + * @author Hervé Boutemy + */ +public class BaseSlf4jConfiguration + implements Slf4jConfiguration +{ + private final Logger logger = LoggerFactory.getLogger( BaseSlf4jConfiguration.class ); + + public void setRootLoggerLevel( Level level ) + { + logger.warn( "setRootLoggerLevel: operation not supported" ); + } + + public void activate() + { + logger.warn( "reset(): operation not supported" ); + } +} diff --git a/maven-embedder/src/main/java/org/apache/maven/cli/logging/PrintStreamLogger.java b/maven-embedder/src/main/java/org/apache/maven/cli/logging/PrintStreamLogger.java deleted file mode 100644 index 53025a0daa..0000000000 --- a/maven-embedder/src/main/java/org/apache/maven/cli/logging/PrintStreamLogger.java +++ /dev/null @@ -1,187 +0,0 @@ -package org.apache.maven.cli.logging; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import java.io.PrintStream; - -import org.apache.maven.Maven; -import org.codehaus.plexus.logging.AbstractLogger; -import org.codehaus.plexus.logging.Logger; - -/** - * Logs to a user-supplied {@link PrintStream}. - * - * @author Benjamin Bentmann - */ -public class PrintStreamLogger - extends AbstractLogger -{ - - public interface Provider - { - PrintStream getStream(); - } - - private Provider provider; - - private static final String FATAL_ERROR = "[FATAL] "; - - private static final String ERROR = "[ERROR] "; - - private static final String WARNING = "[WARNING] "; - - private static final String INFO = "[INFO] "; - - private static final String DEBUG = "[DEBUG] "; - - public PrintStreamLogger( Provider provider ) - { - super( Logger.LEVEL_INFO, Maven.class.getName() ); - - if ( provider == null ) - { - throw new IllegalArgumentException( "output stream provider missing" ); - } - this.provider = provider; - } - - public PrintStreamLogger( PrintStream out ) - { - super( Logger.LEVEL_INFO, Maven.class.getName() ); - - setStream( out ); - } - - public void setStream( final PrintStream out ) - { - if ( out == null ) - { - throw new IllegalArgumentException( "output stream missing" ); - } - - this.provider = new Provider() - { - public PrintStream getStream() - { - return out; - } - }; - } - - public void debug( String message, Throwable throwable ) - { - if ( isDebugEnabled() ) - { - PrintStream out = provider.getStream(); - - out.print( DEBUG ); - out.println( message ); - - if ( null != throwable ) - { - throwable.printStackTrace( out ); - } - } - } - - public void info( String message, Throwable throwable ) - { - if ( isInfoEnabled() ) - { - PrintStream out = provider.getStream(); - - out.print( INFO ); - out.println( message ); - - if ( null != throwable ) - { - throwable.printStackTrace( out ); - } - } - } - - public void warn( String message, Throwable throwable ) - { - if ( isWarnEnabled() ) - { - PrintStream out = provider.getStream(); - - out.print( WARNING ); - out.println( message ); - - if ( null != throwable ) - { - throwable.printStackTrace( out ); - } - } - } - - public void error( String message, Throwable throwable ) - { - if ( isErrorEnabled() ) - { - PrintStream out = provider.getStream(); - - out.print( ERROR ); - out.println( message ); - - if ( null != throwable ) - { - throwable.printStackTrace( out ); - } - } - } - - public void fatalError( String message, Throwable throwable ) - { - if ( isFatalErrorEnabled() ) - { - PrintStream out = provider.getStream(); - - out.print( FATAL_ERROR ); - out.println( message ); - - if ( null != throwable ) - { - throwable.printStackTrace( out ); - } - } - } - - public void close() - { - PrintStream out = provider.getStream(); - - if ( out == System.out || out == System.err ) - { - out.flush(); - } - else - { - out.close(); - } - } - - public Logger getChildLogger( String arg0 ) - { - return this; - } - -} diff --git a/maven-embedder/src/main/java/org/apache/maven/cli/logging/Slf4jConfiguration.java b/maven-embedder/src/main/java/org/apache/maven/cli/logging/Slf4jConfiguration.java new file mode 100644 index 0000000000..661c9e3eb4 --- /dev/null +++ b/maven-embedder/src/main/java/org/apache/maven/cli/logging/Slf4jConfiguration.java @@ -0,0 +1,43 @@ +package org.apache.maven.cli.logging; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +/** + * Interface for configuration operations on loggers, which are not available in slf4j, then require per-slf4f-binding + * implementation. + * + * @author Hervé Boutemy + */ +public interface Slf4jConfiguration +{ + public static enum Level { DEBUG, INFO, ERROR } + + /** + * Set root logging level. + * + * @param level the level + */ + void setRootLoggerLevel( Level level ); + + /** + * Activate logging implementation configuration (if necessary). + */ + void activate(); +} diff --git a/maven-embedder/src/main/java/org/apache/maven/cli/logging/Slf4jConfigurationFactory.java b/maven-embedder/src/main/java/org/apache/maven/cli/logging/Slf4jConfigurationFactory.java new file mode 100644 index 0000000000..2442a835f5 --- /dev/null +++ b/maven-embedder/src/main/java/org/apache/maven/cli/logging/Slf4jConfigurationFactory.java @@ -0,0 +1,81 @@ +package org.apache.maven.cli.logging; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import java.io.IOException; +import java.net.URL; +import java.util.Enumeration; +import java.util.Properties; + +import org.codehaus.plexus.util.PropertyUtils; +import org.slf4j.ILoggerFactory; + +/** + * Slf4jConfiguration factory, loading implementations from META-INF/maven/slf4j-configuration.properties + * configuration files in class loader. + * + * @author Hervé Boutemy + */ +public class Slf4jConfigurationFactory +{ + public static final String RESOURCE = "META-INF/maven/slf4j-configuration.properties"; + + public static Slf4jConfiguration getConfiguration( ILoggerFactory loggerFactory ) + { + try + { + Enumeration resources = Slf4jConfigurationFactory.class.getClassLoader().getResources( RESOURCE ); + + String key = loggerFactory.getClass().getCanonicalName(); + + while ( resources.hasMoreElements() ) + { + URL resource = resources.nextElement(); + + Properties conf = PropertyUtils.loadProperties( resource.openStream() ); + + String impl = conf.getProperty( key ); + + if ( impl != null ) + { + return (Slf4jConfiguration) Class.forName( impl ).newInstance(); + } + } + } + catch ( IOException e ) + { + e.printStackTrace(); + } + catch ( InstantiationException e ) + { + e.printStackTrace(); + } + catch ( IllegalAccessException e ) + { + e.printStackTrace(); + } + catch ( ClassNotFoundException e ) + { + e.printStackTrace(); + } + + return new BaseSlf4jConfiguration(); + } +} diff --git a/maven-embedder/src/main/java/org/apache/maven/cli/logging/Slf4jLogger.java b/maven-embedder/src/main/java/org/apache/maven/cli/logging/Slf4jLogger.java index a2b9bca5be..fa59a1275a 100644 --- a/maven-embedder/src/main/java/org/apache/maven/cli/logging/Slf4jLogger.java +++ b/maven-embedder/src/main/java/org/apache/maven/cli/logging/Slf4jLogger.java @@ -114,7 +114,7 @@ public class Slf4jLogger } /** - * Warning: ignored (always return 0). + * Warning: ignored (always return 0 == Logger.LEVEL_DEBUG). */ public int getThreshold() { @@ -129,7 +129,7 @@ public class Slf4jLogger } /** - * Warning: ignored (always return 0). + * Warning: ignored (always return null). */ public Logger getChildLogger( String name ) { diff --git a/maven-embedder/src/main/java/org/apache/maven/cli/logging/Slf4jStdoutLogger.java b/maven-embedder/src/main/java/org/apache/maven/cli/logging/Slf4jStdoutLogger.java new file mode 100644 index 0000000000..2b1d782c31 --- /dev/null +++ b/maven-embedder/src/main/java/org/apache/maven/cli/logging/Slf4jStdoutLogger.java @@ -0,0 +1,303 @@ +package org.apache.maven.cli.logging; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import java.io.PrintStream; + +import org.slf4j.Logger; +import org.slf4j.Marker; + +public class Slf4jStdoutLogger + implements Logger +{ + private static final String ERROR = "[ERROR] "; + + private PrintStream out = System.out; + + // + // These are the only methods we need in our primordial logger + // + public void error( String msg ) + { + out.print( ERROR ); + out.println( msg ); + } + + public void error( String msg, Throwable t ) + { + error( msg ); + + if ( null != t ) + { + t.printStackTrace( out ); + } + } + + // + // Don't need any of this + // + public String getName() + { + return null; + } + + public boolean isTraceEnabled() + { + return false; + } + + public void trace( String msg ) + { + } + + public void trace( String format, Object arg ) + { + } + + public void trace( String format, Object arg1, Object arg2 ) + { + } + + public void trace( String format, Object... arguments ) + { + } + + public void trace( String msg, Throwable t ) + { + } + + public boolean isTraceEnabled( Marker marker ) + { + return false; + } + + public void trace( Marker marker, String msg ) + { + } + + public void trace( Marker marker, String format, Object arg ) + { + } + + public void trace( Marker marker, String format, Object arg1, Object arg2 ) + { + } + + public void trace( Marker marker, String format, Object... argArray ) + { + } + + public void trace( Marker marker, String msg, Throwable t ) + { + } + + public boolean isDebugEnabled() + { + return false; + } + + public void debug( String msg ) + { + } + + public void debug( String format, Object arg ) + { + } + + public void debug( String format, Object arg1, Object arg2 ) + { + } + + public void debug( String format, Object... arguments ) + { + } + + public void debug( String msg, Throwable t ) + { + } + + public boolean isDebugEnabled( Marker marker ) + { + return false; + } + + public void debug( Marker marker, String msg ) + { + } + + public void debug( Marker marker, String format, Object arg ) + { + } + + public void debug( Marker marker, String format, Object arg1, Object arg2 ) + { + } + + public void debug( Marker marker, String format, Object... arguments ) + { + } + + public void debug( Marker marker, String msg, Throwable t ) + { + } + + public boolean isInfoEnabled() + { + return false; + } + + public void info( String msg ) + { + } + + public void info( String format, Object arg ) + { + } + + public void info( String format, Object arg1, Object arg2 ) + { + } + + public void info( String format, Object... arguments ) + { + } + + public void info( String msg, Throwable t ) + { + } + + public boolean isInfoEnabled( Marker marker ) + { + return false; + } + + public void info( Marker marker, String msg ) + { + } + + public void info( Marker marker, String format, Object arg ) + { + } + + public void info( Marker marker, String format, Object arg1, Object arg2 ) + { + } + + public void info( Marker marker, String format, Object... arguments ) + { + } + + public void info( Marker marker, String msg, Throwable t ) + { + } + + public boolean isWarnEnabled() + { + return false; + } + + public void warn( String msg ) + { + } + + public void warn( String format, Object arg ) + { + } + + public void warn( String format, Object... arguments ) + { + } + + public void warn( String format, Object arg1, Object arg2 ) + { + } + + public void warn( String msg, Throwable t ) + { + } + + public boolean isWarnEnabled( Marker marker ) + { + return false; + } + + public void warn( Marker marker, String msg ) + { + } + + public void warn( Marker marker, String format, Object arg ) + { + } + + public void warn( Marker marker, String format, Object arg1, Object arg2 ) + { + } + + public void warn( Marker marker, String format, Object... arguments ) + { + } + + public void warn( Marker marker, String msg, Throwable t ) + { + } + + public boolean isErrorEnabled() + { + return false; + } + + public void error( String format, Object arg ) + { + } + + public void error( String format, Object arg1, Object arg2 ) + { + } + + public void error( String format, Object... arguments ) + { + } + + public boolean isErrorEnabled( Marker marker ) + { + return false; + } + + public void error( Marker marker, String msg ) + { + } + + public void error( Marker marker, String format, Object arg ) + { + } + + public void error( Marker marker, String format, Object arg1, Object arg2 ) + { + } + + public void error( Marker marker, String format, Object... arguments ) + { + } + + public void error( Marker marker, String msg, Throwable t ) + { + } + +} diff --git a/maven-embedder/src/main/java/org/apache/maven/cli/logging/impl/Log4j2Configuration.java b/maven-embedder/src/main/java/org/apache/maven/cli/logging/impl/Log4j2Configuration.java new file mode 100644 index 0000000000..9cec3ccb80 --- /dev/null +++ b/maven-embedder/src/main/java/org/apache/maven/cli/logging/impl/Log4j2Configuration.java @@ -0,0 +1,58 @@ +package org.apache.maven.cli.logging.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.apache.maven.cli.logging.BaseSlf4jConfiguration; + +/** + * Configuration for slf4j-log4j2. + * + * @author Hervé Boutemy + */ +public class Log4j2Configuration + extends BaseSlf4jConfiguration +{ + @Override + public void setRootLoggerLevel( Level level ) + { + String value = "info"; + switch ( level ) + { + case DEBUG: + value = "debug"; + break; + + case INFO: + value = "info"; + break; + + case ERROR: + value = "error"; + break; + } + System.setProperty( "maven.logging.root.level", value ); + } + + @Override + public void activate() + { + // no op + } +} diff --git a/maven-embedder/src/main/java/org/apache/maven/cli/logging/impl/LogbackConfiguration.java b/maven-embedder/src/main/java/org/apache/maven/cli/logging/impl/LogbackConfiguration.java new file mode 100644 index 0000000000..b72940a3a7 --- /dev/null +++ b/maven-embedder/src/main/java/org/apache/maven/cli/logging/impl/LogbackConfiguration.java @@ -0,0 +1,60 @@ +package org.apache.maven.cli.logging.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.apache.maven.cli.logging.BaseSlf4jConfiguration; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * Configuration for slf4j-logback. + * + * @author Hervé Boutemy + */ +public class LogbackConfiguration + extends BaseSlf4jConfiguration +{ + @Override + public void setRootLoggerLevel( Level level ) + { + ch.qos.logback.classic.Level value = ch.qos.logback.classic.Level.INFO; + switch ( level ) + { + case DEBUG: + value = ch.qos.logback.classic.Level.DEBUG; + break; + + case INFO: + value = ch.qos.logback.classic.Level.INFO; + break; + + case ERROR: + value = ch.qos.logback.classic.Level.ERROR; + break; + } + ( (ch.qos.logback.classic.Logger) LoggerFactory.getLogger( Logger.ROOT_LOGGER_NAME ) ).setLevel( value ); + } + + @Override + public void activate() + { + // no op + } +} diff --git a/maven-embedder/src/main/java/org/apache/maven/cli/logging/impl/Slf4jSimpleConfiguration.java b/maven-embedder/src/main/java/org/apache/maven/cli/logging/impl/Slf4jSimpleConfiguration.java new file mode 100644 index 0000000000..6a7f38518e --- /dev/null +++ b/maven-embedder/src/main/java/org/apache/maven/cli/logging/impl/Slf4jSimpleConfiguration.java @@ -0,0 +1,62 @@ +package org.apache.maven.cli.logging.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.apache.maven.cli.logging.BaseSlf4jConfiguration; +import org.slf4j.MavenSlf4jFriend; +import org.slf4j.impl.MavenSlf4jSimpleFriend; + +/** + * Configuration for slf4j-simple. + * + * @author Hervé Boutemy + */ +public class Slf4jSimpleConfiguration + extends BaseSlf4jConfiguration +{ + @Override + public void setRootLoggerLevel( Level level ) + { + String value = "info"; + switch ( level ) + { + case DEBUG: + value = "debug"; + break; + + case INFO: + value = "info"; + break; + + case ERROR: + value = "error"; + break; + } + System.setProperty( "org.slf4j.simpleLogger.defaultLogLevel", value ); + } + + @Override + public void activate() + { + // property for root logger level or System.out redirection need to be taken into account + MavenSlf4jFriend.reset(); + MavenSlf4jSimpleFriend.init(); + } +} diff --git a/maven-embedder/src/main/java/org/apache/maven/cli/transfer/Slf4jMavenTransferListener.java b/maven-embedder/src/main/java/org/apache/maven/cli/transfer/Slf4jMavenTransferListener.java index a2b21a3007..6560fe5231 100644 --- a/maven-embedder/src/main/java/org/apache/maven/cli/transfer/Slf4jMavenTransferListener.java +++ b/maven-embedder/src/main/java/org/apache/maven/cli/transfer/Slf4jMavenTransferListener.java @@ -28,13 +28,20 @@ import org.eclipse.aether.transfer.TransferCancelledException; import org.eclipse.aether.transfer.TransferEvent; import org.eclipse.aether.transfer.TransferResource; import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class Slf4jMavenTransferListener extends AbstractTransferListener { - protected Logger out; + protected final Logger out; + public Slf4jMavenTransferListener() + { + this.out = LoggerFactory.getLogger( Slf4jMavenTransferListener.class ); + } + + // TODO should we deprecate? public Slf4jMavenTransferListener( Logger out ) { this.out = out; diff --git a/maven-embedder/src/main/java/org/slf4j/MavenSlf4jFriend.java b/maven-embedder/src/main/java/org/slf4j/MavenSlf4jFriend.java new file mode 100644 index 0000000000..8a43053708 --- /dev/null +++ b/maven-embedder/src/main/java/org/slf4j/MavenSlf4jFriend.java @@ -0,0 +1,35 @@ +package org.slf4j; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +/** + * Utility for Maven to access Slf4j internals through package access. + * Use with precaution, since this is not normally intended for production use. + */ +public class MavenSlf4jFriend +{ + /** + * Reset Slf4j internal state. + */ + public static void reset() + { + LoggerFactory.reset(); + } +} diff --git a/maven-embedder/src/main/java/org/slf4j/impl/MavenSlf4jSimpleFriend.java b/maven-embedder/src/main/java/org/slf4j/impl/MavenSlf4jSimpleFriend.java new file mode 100644 index 0000000000..097ad68879 --- /dev/null +++ b/maven-embedder/src/main/java/org/slf4j/impl/MavenSlf4jSimpleFriend.java @@ -0,0 +1,32 @@ +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. + */ + +/** + * Utility for Maven to access Slf4j-Simple internals through package access. + * Use with precaution, since this is not normally intended for production use. + */ +public class MavenSlf4jSimpleFriend +{ + public static void init() + { + SimpleLogger.init(); + } +} 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 new file mode 100644 index 0000000000..5a6a12f765 --- /dev/null +++ b/maven-embedder/src/main/resources/META-INF/maven/slf4j-configuration.properties @@ -0,0 +1,5 @@ +# 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.helpers.Log4JLoggerFactory org.apache.maven.cli.logging.impl.Log4j2Configuration +ch.qos.logback.classic.LoggerContext org.apache.maven.cli.logging.impl.LogbackConfiguration diff --git a/maven-embedder/src/site/apt/logging.apt b/maven-embedder/src/site/apt/logging.apt index 22fa1ac25a..bdab9b2d57 100644 --- a/maven-embedder/src/site/apt/logging.apt +++ b/maven-embedder/src/site/apt/logging.apt @@ -22,7 +22,7 @@ Maven Logging * Getting Logger Instance - Plexus Logger can be injected in Plexus component using Plexus annotations + Plexus Logger and LoggerManager can be injected in Plexus component using Plexus annotations <<<<<<< HEAD +------ @@ -39,6 +39,9 @@ public class DefaultMyComponent { @Requirement private Logger logger; + + @Requirement + private LoggerManager loggerManager; } <<<<<<< HEAD +------ 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 e075f7b0e6..25d9eab957 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 @@ -278,6 +278,8 @@ public class DefaultModelBuilder modelNormalizer.mergeDuplicates( tmpModel, request, problems ); + profileActivationContext.setProjectProperties( tmpModel.getProperties() ); + List activePomProfiles = profileSelector.getActiveProfiles( rawModel.getProfiles(), profileActivationContext, problems ); currentData.setActiveProfiles( activePomProfiles ); @@ -317,7 +319,7 @@ public class DefaultModelBuilder } message += currentData.getId(); - problems.add( new ModelProblemCollectorRequest(ModelProblem.Severity.FATAL, ModelProblem.Version.BASE).setMessage(message)); + problems.add( new ModelProblemCollectorRequest( ModelProblem.Severity.FATAL, ModelProblem.Version.BASE ).setMessage( message ) ); throw problems.newModelBuildingException(); } } @@ -409,7 +411,7 @@ public class DefaultModelBuilder modelValidator.validateEffectiveModel( resultModel, request, problems ); - if ( hasModelErrors(problems) ) + if ( hasModelErrors( problems ) ) { throw problems.newModelBuildingException(); } @@ -471,15 +473,15 @@ public class DefaultModelBuilder if ( pomFile != null ) { - problems.add( new ModelProblemCollectorRequest(Severity.ERROR, Version.V20) - .setMessage("Malformed POM " + modelSource.getLocation() + ": " + e.getMessage()) - .setException(e )); + problems.add( new ModelProblemCollectorRequest( Severity.ERROR, Version.V20 ) + .setMessage( "Malformed POM " + modelSource.getLocation() + ": " + e.getMessage() ) + .setException( e ) ); } else { - problems.add( new ModelProblemCollectorRequest(Severity.WARNING, Version.V20) - .setMessage("Malformed POM " + modelSource.getLocation() + ": " + e.getMessage()) - .setException(e)); + problems.add( new ModelProblemCollectorRequest( Severity.WARNING, Version.V20 ) + .setMessage( "Malformed POM " + modelSource.getLocation() + ": " + e.getMessage() ) + .setException( e ) ); } } @@ -491,9 +493,9 @@ public class DefaultModelBuilder } catch ( ModelParseException e ) { - problems.add( new ModelProblemCollectorRequest(Severity.FATAL, Version.BASE) - .setMessage("Non-parseable POM " + modelSource.getLocation() + ": " + e.getMessage()) - .setException(e)); + problems.add( new ModelProblemCollectorRequest( Severity.FATAL, Version.BASE ) + .setMessage( "Non-parseable POM " + modelSource.getLocation() + ": " + e.getMessage() ) + .setException( e ) ); throw problems.newModelBuildingException(); } catch ( IOException e ) @@ -511,9 +513,9 @@ public class DefaultModelBuilder msg = e.getClass().getSimpleName(); } } - problems.add( new ModelProblemCollectorRequest(Severity.FATAL, Version.BASE) - .setMessage("Non-readable POM " + modelSource.getLocation() + ": " + msg) - .setException(e )); + problems.add( new ModelProblemCollectorRequest( Severity.FATAL, Version.BASE ) + .setMessage( "Non-readable POM " + modelSource.getLocation() + ": " + msg ) + .setException( e ) ); throw problems.newModelBuildingException(); } @@ -522,7 +524,7 @@ public class DefaultModelBuilder problems.setSource( model ); modelValidator.validateRawModel( model, request, problems ); - if ( hasFatalErrors(problems) ) + if ( hasFatalErrors( problems ) ) { throw problems.newModelBuildingException(); } @@ -562,10 +564,10 @@ public class DefaultModelBuilder } catch ( InvalidRepositoryException e ) { - problems.add( new ModelProblemCollectorRequest(Severity.ERROR, Version.BASE) - .setMessage( "Invalid repository " + repository.getId() + ": " + e.getMessage()) - .setLocation(repository.getLocation( "" )) - .setException(e) ); + problems.add( new ModelProblemCollectorRequest( Severity.ERROR, Version.BASE ) + .setMessage( "Invalid repository " + repository.getId() + ": " + e.getMessage() ) + .setLocation( repository.getLocation( "" ) ) + .setException( e ) ); } } } @@ -617,9 +619,9 @@ public class DefaultModelBuilder if ( versions.get( key ) == null && managedVersions.get( key ) == null ) { InputLocation location = plugins.get( key ).getLocation( "" ); - problems.add( new ModelProblemCollectorRequest(Severity.WARNING, Version.V20) - .setMessage( "'build.plugins.plugin.version' for " + key + " is missing.") - .setLocation(location)); + problems.add( new ModelProblemCollectorRequest( Severity.WARNING, Version.V20 ) + .setMessage( "'build.plugins.plugin.version' for " + key + " is missing." ) + .setLocation( location ) ); } } } @@ -694,10 +696,10 @@ public class DefaultModelBuilder if ( !"pom".equals( parentModel.getPackaging() ) ) { - problems.add( new ModelProblemCollectorRequest(Severity.ERROR, Version.BASE) - .setMessage( "Invalid packaging for parent POM " + ModelProblemUtils.toSourceHint( parentModel ) + ", must be \"pom\" but is \"" - + parentModel.getPackaging() + "\"") - .setLocation(parentModel.getLocation( "packaging" ))); + problems.add( new ModelProblemCollectorRequest( Severity.ERROR, Version.BASE ) + .setMessage( "Invalid packaging for parent POM " + ModelProblemUtils.toSourceHint( parentModel ) + + ", must be \"pom\" but is \"" + parentModel.getPackaging() + "\"" ) + .setLocation( parentModel.getLocation( "packaging" ) ) ); } } else @@ -749,9 +751,9 @@ public class DefaultModelBuilder buffer.append( ", please verify your project structure" ); problems.setSource( childModel ); - problems.add( new ModelProblemCollectorRequest( Severity.WARNING, Version.BASE) - .setMessage( buffer.toString()) - .setLocation( parent.getLocation( "" ))); + problems.add( new ModelProblemCollectorRequest( Severity.WARNING, Version.BASE ) + .setMessage( buffer.toString() ) + .setLocation( parent.getLocation( "" ) ) ); return null; } if ( version == null || !version.equals( parent.getVersion() ) ) @@ -843,10 +845,10 @@ public class DefaultModelBuilder } } - problems.add( new ModelProblemCollectorRequest(Severity.FATAL, Version.BASE) - .setMessage( buffer.toString()) - .setLocation(parent.getLocation( "" )) - .setException(e)); + problems.add( new ModelProblemCollectorRequest( Severity.FATAL, Version.BASE ) + .setMessage( buffer.toString() ) + .setLocation( parent.getLocation( "" ) ) + .setException( e ) ); throw problems.newModelBuildingException(); } @@ -912,23 +914,26 @@ public class DefaultModelBuilder if ( groupId == null || groupId.length() <= 0 ) { - problems.add( new ModelProblemCollectorRequest(Severity.ERROR, Version.BASE) - .setMessage( "'dependencyManagement.dependencies.dependency.groupId' for " + dependency.getManagementKey() + " is missing.") - .setLocation( dependency.getLocation( "" ))); + problems.add( new ModelProblemCollectorRequest( Severity.ERROR, Version.BASE ) + .setMessage( "'dependencyManagement.dependencies.dependency.groupId' for " + + dependency.getManagementKey() + " is missing." ) + .setLocation( dependency.getLocation( "" ) ) ); continue; } if ( artifactId == null || artifactId.length() <= 0 ) { - problems.add( new ModelProblemCollectorRequest( Severity.ERROR, Version.BASE) - .setMessage( "'dependencyManagement.dependencies.dependency.artifactId' for " + dependency.getManagementKey() + " is missing.") - .setLocation( dependency.getLocation( "" ))); + problems.add( new ModelProblemCollectorRequest( Severity.ERROR, Version.BASE ) + .setMessage( "'dependencyManagement.dependencies.dependency.artifactId' for " + + dependency.getManagementKey() + " is missing." ) + .setLocation( dependency.getLocation( "" ) ) ); continue; } if ( version == null || version.length() <= 0 ) { - problems.add( new ModelProblemCollectorRequest( Severity.ERROR, Version.BASE) - .setMessage( "'dependencyManagement.dependencies.dependency.version' for " + dependency.getManagementKey() + " is missing.") - .setLocation( dependency.getLocation( "" ))); + problems.add( new ModelProblemCollectorRequest( Severity.ERROR, Version.BASE ) + .setMessage( "'dependencyManagement.dependencies.dependency.version' for " + + dependency.getManagementKey() + " is missing." ) + .setLocation( dependency.getLocation( "" ) ) ); continue; } @@ -942,7 +947,7 @@ public class DefaultModelBuilder message += modelId + " -> "; } message += imported; - problems.add( new ModelProblemCollectorRequest( Severity.ERROR, Version.BASE ).setMessage( message )); + problems.add( new ModelProblemCollectorRequest( Severity.ERROR, Version.BASE ).setMessage( message ) ); continue; } @@ -976,8 +981,8 @@ public class DefaultModelBuilder problems.add( new ModelProblemCollectorRequest( Severity.ERROR, Version.BASE ) .setMessage( buffer.toString() ) - .setLocation( dependency.getLocation( "" )) - .setException( e )); + .setLocation( dependency.getLocation( "" ) ) + .setException( e ) ); continue; } @@ -1076,24 +1081,31 @@ public class DefaultModelBuilder && ( version == null || message.contains( version ) ); } - protected boolean hasModelErrors(ModelProblemCollectorExt problems) { - if (problems instanceof DefaultModelProblemCollector) { - return ((DefaultModelProblemCollector)problems).hasErrors(); - } else { - //the default execution path only knows the DefaultModelProblemCollector, - // only reason it's not in signature is because it's package private - throw new IllegalStateException(); + protected boolean hasModelErrors( ModelProblemCollectorExt problems ) + { + if ( problems instanceof DefaultModelProblemCollector ) + { + return ( (DefaultModelProblemCollector) problems ).hasErrors(); + } + else + { + // the default execution path only knows the DefaultModelProblemCollector, + // only reason it's not in signature is because it's package private + throw new IllegalStateException(); } - } - protected boolean hasFatalErrors(ModelProblemCollectorExt problems) { - if (problems instanceof DefaultModelProblemCollector) { - return ((DefaultModelProblemCollector)problems).hasFatalErrors(); - } else { - //the default execution path only knows the DefaultModelProblemCollector, + protected boolean hasFatalErrors( ModelProblemCollectorExt problems ) + { + if ( problems instanceof DefaultModelProblemCollector ) + { + return ( (DefaultModelProblemCollector) problems ).hasFatalErrors(); + } + else + { + // the default execution path only knows the DefaultModelProblemCollector, // only reason it's not in signature is because it's package private - throw new IllegalStateException(); + throw new IllegalStateException(); } } diff --git a/maven-model-builder/src/main/java/org/apache/maven/model/building/DefaultModelProblem.java b/maven-model-builder/src/main/java/org/apache/maven/model/building/DefaultModelProblem.java index e0effac17f..0d68aaeb5d 100644 --- a/maven-model-builder/src/main/java/org/apache/maven/model/building/DefaultModelProblem.java +++ b/maven-model-builder/src/main/java/org/apache/maven/model/building/DefaultModelProblem.java @@ -146,7 +146,8 @@ public class DefaultModelProblem return severity; } - public Version getVersion() { + public Version getVersion() + { return version; } diff --git a/maven-model-builder/src/main/java/org/apache/maven/model/building/DefaultModelProblemCollector.java b/maven-model-builder/src/main/java/org/apache/maven/model/building/DefaultModelProblemCollector.java index e2573eb69d..114afeb2de 100644 --- a/maven-model-builder/src/main/java/org/apache/maven/model/building/DefaultModelProblemCollector.java +++ b/maven-model-builder/src/main/java/org/apache/maven/model/building/DefaultModelProblemCollector.java @@ -23,10 +23,7 @@ import java.util.EnumSet; import java.util.List; import java.util.Set; -import org.apache.maven.model.InputLocation; import org.apache.maven.model.Model; -import org.apache.maven.model.building.ModelProblem.Severity; -import org.apache.maven.model.building.ModelProblem.Version; import org.apache.maven.model.io.ModelParseException; /** @@ -174,7 +171,9 @@ class DefaultModelProblemCollector column = e.getColumnNumber(); } - ModelProblem problem = new DefaultModelProblem( req.getMessage(), req.getSeverity(), req.getVersion(), source, line, column, modelId, req.getException() ); + ModelProblem problem = + new DefaultModelProblem( req.getMessage(), req.getSeverity(), req.getVersion(), source, line, column, + modelId, req.getException() ); add( problem ); } diff --git a/maven-model-builder/src/main/java/org/apache/maven/model/building/ModelProblem.java b/maven-model-builder/src/main/java/org/apache/maven/model/building/ModelProblem.java index 811f2e0a16..555f033c92 100644 --- a/maven-model-builder/src/main/java/org/apache/maven/model/building/ModelProblem.java +++ b/maven-model-builder/src/main/java/org/apache/maven/model/building/ModelProblem.java @@ -41,7 +41,8 @@ public interface ModelProblem } - enum Version { + enum Version + { //based on ModeBuildingResult.validationLevel BASE, V20, diff --git a/maven-model-builder/src/main/java/org/apache/maven/model/building/ModelProblemCollector.java b/maven-model-builder/src/main/java/org/apache/maven/model/building/ModelProblemCollector.java index b2321037fc..961d40abdf 100644 --- a/maven-model-builder/src/main/java/org/apache/maven/model/building/ModelProblemCollector.java +++ b/maven-model-builder/src/main/java/org/apache/maven/model/building/ModelProblemCollector.java @@ -19,9 +19,6 @@ package org.apache.maven.model.building; * under the License. */ -import java.util.List; -import org.apache.maven.model.InputLocation; - /** * Collects problems that are encountered during model building. The primary purpose of this component is to account for * the fact that the problem reporter has/should not have information about the calling context and hence cannot provide diff --git a/maven-model-builder/src/main/java/org/apache/maven/model/building/ModelProblemCollectorRequest.java b/maven-model-builder/src/main/java/org/apache/maven/model/building/ModelProblemCollectorRequest.java index d91c5c2ed5..60bfdde207 100644 --- a/maven-model-builder/src/main/java/org/apache/maven/model/building/ModelProblemCollectorRequest.java +++ b/maven-model-builder/src/main/java/org/apache/maven/model/building/ModelProblemCollectorRequest.java @@ -1,20 +1,24 @@ -/* - * Copyright 2012 The Apache Software Foundation. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ package org.apache.maven.model.building; +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + import org.apache.maven.model.InputLocation; import org.apache.maven.model.building.ModelProblem.Severity; import org.apache.maven.model.building.ModelProblem.Version; @@ -38,17 +42,17 @@ public final class ModelProblemCollectorRequest * @param severity * @param version */ - public ModelProblemCollectorRequest(Severity severity, Version version) + public ModelProblemCollectorRequest( Severity severity, Version version ) { this.severity = severity; this.version = version; - if (severity == null) + if ( severity == null ) { - throw new IllegalStateException("No severity declared"); + throw new IllegalStateException( "No severity declared" ); } - if (version == null) + if ( version == null ) { - throw new IllegalStateException("No version declared."); + throw new IllegalStateException( "No version declared." ); } } @@ -67,7 +71,7 @@ public final class ModelProblemCollectorRequest return exception; } - public ModelProblemCollectorRequest setException(Exception exception) + public ModelProblemCollectorRequest setException( Exception exception ) { this.exception = exception; return this; @@ -78,7 +82,7 @@ public final class ModelProblemCollectorRequest return message; } - public ModelProblemCollectorRequest setMessage(String message) + public ModelProblemCollectorRequest setMessage( String message ) { this.message = message; return this; @@ -89,7 +93,7 @@ public final class ModelProblemCollectorRequest return location; } - public ModelProblemCollectorRequest setLocation(InputLocation location) + public ModelProblemCollectorRequest setLocation( InputLocation location ) { this.location = location; return this; diff --git a/maven-model-builder/src/main/java/org/apache/maven/model/inheritance/DefaultInheritanceAssembler.java b/maven-model-builder/src/main/java/org/apache/maven/model/inheritance/DefaultInheritanceAssembler.java index a66be04dea..01ff9d71a6 100644 --- a/maven-model-builder/src/main/java/org/apache/maven/model/inheritance/DefaultInheritanceAssembler.java +++ b/maven-model-builder/src/main/java/org/apache/maven/model/inheritance/DefaultInheritanceAssembler.java @@ -58,12 +58,17 @@ public class DefaultInheritanceAssembler /** * Calculates the relative path from the base directory of the parent to the parent directory of the base directory - * of the child. The general idea is to adjust inherited URLs to match the project layout (in SCM). This calculation - * is only a heuristic based on our conventions. In detail, the algo relies on the following assumptions. The parent - * uses aggregation and refers to the child via the modules section. The module path to the child is considered to - * point at the POM rather than its base directory if the path ends with ".xml" (ignoring case). The name of the - * child's base directory matches the artifact id of the child. Note that for the sake of independence from the user - * environment, the filesystem is intentionally not used for the calculation. + * of the child. The general idea is to adjust inherited URLs to match the project layout (in SCM). + * + *

This calculation is only a heuristic based on our conventions. + * In detail, the algo relies on the following assumptions:

    + *
  • The parent uses aggregation and refers to the child via the modules section
  • + *
  • The module path to the child is considered to + * point at the POM rather than its base directory if the path ends with ".xml" (ignoring case)
  • + *
  • The name of the child's base directory matches the artifact id of the child.
  • + *
+ * Note that for the sake of independence from the user + * environment, the filesystem is intentionally not used for the calculation.

* * @param child The child model, must not be null. * @param parent The parent model, may be null. @@ -119,7 +124,7 @@ public class DefaultInheritanceAssembler return adjustment; } - private static class InheritanceModelMerger + protected static class InheritanceModelMerger extends MavenModelMerger { diff --git a/maven-model-builder/src/main/java/org/apache/maven/model/interpolation/AbstractStringBasedModelInterpolator.java b/maven-model-builder/src/main/java/org/apache/maven/model/interpolation/AbstractStringBasedModelInterpolator.java index dc8b41b6ad..57e11c3c21 100644 --- a/maven-model-builder/src/main/java/org/apache/maven/model/interpolation/AbstractStringBasedModelInterpolator.java +++ b/maven-model-builder/src/main/java/org/apache/maven/model/interpolation/AbstractStringBasedModelInterpolator.java @@ -45,7 +45,6 @@ import java.util.Collection; import java.util.HashSet; import java.util.List; import java.util.Properties; -import org.apache.maven.model.building.ModelProblem; import org.apache.maven.model.building.ModelProblem.Version; import org.apache.maven.model.building.ModelProblemCollectorRequest; @@ -244,7 +243,8 @@ public abstract class AbstractStringBasedModelInterpolator } catch ( InterpolationException e ) { - problems.add( new ModelProblemCollectorRequest( Severity.ERROR, Version.BASE ).setMessage( e.getMessage() ).setException( e )); + problems.add( new ModelProblemCollectorRequest( Severity.ERROR, Version.BASE ) + .setMessage( e.getMessage() ).setException( e ) ); } interpolator.clearFeedback(); diff --git a/maven-model-builder/src/main/java/org/apache/maven/model/interpolation/ProblemDetectingValueSource.java b/maven-model-builder/src/main/java/org/apache/maven/model/interpolation/ProblemDetectingValueSource.java index 106414eaf5..8167baf7ec 100644 --- a/maven-model-builder/src/main/java/org/apache/maven/model/interpolation/ProblemDetectingValueSource.java +++ b/maven-model-builder/src/main/java/org/apache/maven/model/interpolation/ProblemDetectingValueSource.java @@ -20,7 +20,6 @@ package org.apache.maven.model.interpolation; */ import java.util.List; -import org.apache.maven.model.building.ModelProblem; import org.apache.maven.model.building.ModelProblemCollector; import org.apache.maven.model.building.ModelProblem.Severity; @@ -65,7 +64,7 @@ class ProblemDetectingValueSource { msg += " Please use ${" + newPrefix + expression.substring( bannedPrefix.length() ) + "} instead."; } - problems.add( new ModelProblemCollectorRequest( Severity.WARNING, Version.V20 ).setMessage( msg )); + problems.add( new ModelProblemCollectorRequest( Severity.WARNING, Version.V20 ).setMessage( msg ) ); } return value; diff --git a/maven-model-builder/src/main/java/org/apache/maven/model/interpolation/StringSearchModelInterpolator.java b/maven-model-builder/src/main/java/org/apache/maven/model/interpolation/StringSearchModelInterpolator.java index d4bc534618..2ef7eb1333 100644 --- a/maven-model-builder/src/main/java/org/apache/maven/model/interpolation/StringSearchModelInterpolator.java +++ b/maven-model-builder/src/main/java/org/apache/maven/model/interpolation/StringSearchModelInterpolator.java @@ -49,7 +49,7 @@ public class StringSearchModelInterpolator extends AbstractStringBasedModelInterpolator { - private static final Map, InterpolateObjectAction.CacheItem> cachedEntries = + private static final Map, InterpolateObjectAction.CacheItem> CACHED_ENTRIES = new ConcurrentHashMap, InterpolateObjectAction.CacheItem>( 80, 0.75f, 2 ); // Empirical data from 3.x, actual =40 @@ -161,11 +161,11 @@ public class StringSearchModelInterpolator private CacheItem getCacheEntry( Class cls ) { - CacheItem cacheItem = cachedEntries.get( cls ); + CacheItem cacheItem = CACHED_ENTRIES.get( cls ); if ( cacheItem == null ) { cacheItem = new CacheItem( cls ); - cachedEntries.put( cls, cacheItem ); + CACHED_ENTRIES.put( cls, cacheItem ); } return cacheItem; } @@ -247,7 +247,7 @@ public class StringSearchModelInterpolator } else if ( Collection.class.isAssignableFrom( type ) ) { - throw new RuntimeException("We dont interpolate into collections, use a list instead"); + throw new RuntimeException( "We dont interpolate into collections, use a list instead" ); } else if ( Map.class.isAssignableFrom( type ) ) { @@ -278,7 +278,7 @@ public class StringSearchModelInterpolator } } - static abstract class CacheField + abstract static class CacheField { protected final Field field; diff --git a/maven-model-builder/src/main/java/org/apache/maven/model/management/DefaultDependencyManagementInjector.java b/maven-model-builder/src/main/java/org/apache/maven/model/management/DefaultDependencyManagementInjector.java index fbfd4b8132..a13dcca6c5 100644 --- a/maven-model-builder/src/main/java/org/apache/maven/model/management/DefaultDependencyManagementInjector.java +++ b/maven-model-builder/src/main/java/org/apache/maven/model/management/DefaultDependencyManagementInjector.java @@ -50,7 +50,7 @@ public class DefaultDependencyManagementInjector merger.mergeManagedDependencies( model ); } - private static class ManagementModelMerger + protected static class ManagementModelMerger extends MavenModelMerger { diff --git a/maven-model-builder/src/main/java/org/apache/maven/model/management/DefaultPluginManagementInjector.java b/maven-model-builder/src/main/java/org/apache/maven/model/management/DefaultPluginManagementInjector.java index 1d5809d9a7..ba9f060aeb 100644 --- a/maven-model-builder/src/main/java/org/apache/maven/model/management/DefaultPluginManagementInjector.java +++ b/maven-model-builder/src/main/java/org/apache/maven/model/management/DefaultPluginManagementInjector.java @@ -53,7 +53,7 @@ public class DefaultPluginManagementInjector merger.mergeManagedBuildPlugins( model ); } - private static class ManagementModelMerger + protected static class ManagementModelMerger extends MavenModelMerger { diff --git a/maven-model-builder/src/main/java/org/apache/maven/model/merge/MavenModelMerger.java b/maven-model-builder/src/main/java/org/apache/maven/model/merge/MavenModelMerger.java index 92c0ee6a94..568bbcb2a0 100644 --- a/maven-model-builder/src/main/java/org/apache/maven/model/merge/MavenModelMerger.java +++ b/maven-model-builder/src/main/java/org/apache/maven/model/merge/MavenModelMerger.java @@ -52,7 +52,8 @@ import org.apache.maven.model.Scm; import org.apache.maven.model.Site; /** - * The domain-specific model merger for the Maven POM. + * The domain-specific model merger for the Maven POM, overriding generic code from parent class when necessary with + * more adapted algorithms. * * @author Benjamin Bentmann */ @@ -631,45 +632,45 @@ public class MavenModelMerger } @Override - protected Object getPluginKey( Plugin object ) + protected Object getPluginKey( Plugin plugin ) { - return object.getKey(); + return plugin.getKey(); } @Override - protected Object getPluginExecutionKey( PluginExecution object ) + protected Object getPluginExecutionKey( PluginExecution pluginExecution ) { - return object.getId(); + return pluginExecution.getId(); } @Override - protected Object getReportPluginKey( ReportPlugin object ) + protected Object getReportPluginKey( ReportPlugin reportPlugin ) { - return object.getKey(); + return reportPlugin.getKey(); } @Override - protected Object getReportSetKey( ReportSet object ) + protected Object getReportSetKey( ReportSet reportSet ) { - return object.getId(); + return reportSet.getId(); } @Override - protected Object getRepositoryBaseKey( RepositoryBase object ) + protected Object getRepositoryBaseKey( RepositoryBase repositoryBase ) { - return object.getId(); + return repositoryBase.getId(); } @Override - protected Object getExtensionKey( Extension object ) + protected Object getExtensionKey( Extension extension ) { - return object.getGroupId() + ':' + object.getArtifactId(); + return extension.getGroupId() + ':' + extension.getArtifactId(); } @Override - protected Object getExclusionKey( Exclusion object ) + protected Object getExclusionKey( Exclusion exclusion ) { - return object.getGroupId() + ':' + object.getArtifactId(); + return exclusion.getGroupId() + ':' + exclusion.getArtifactId(); } private String appendPath( String parentPath, Map context ) diff --git a/maven-model-builder/src/main/java/org/apache/maven/model/normalization/DefaultModelNormalizer.java b/maven-model-builder/src/main/java/org/apache/maven/model/normalization/DefaultModelNormalizer.java index df7ae5b2ca..9163286a85 100644 --- a/maven-model-builder/src/main/java/org/apache/maven/model/normalization/DefaultModelNormalizer.java +++ b/maven-model-builder/src/main/java/org/apache/maven/model/normalization/DefaultModelNormalizer.java @@ -93,7 +93,7 @@ public class DefaultModelNormalizer } } - private static class DuplicateMerger + protected static class DuplicateMerger extends MavenModelMerger { diff --git a/maven-model-builder/src/main/java/org/apache/maven/model/plugin/DefaultReportingConverter.java b/maven-model-builder/src/main/java/org/apache/maven/model/plugin/DefaultReportingConverter.java index 6a95b97cf3..f8a2a93ba9 100644 --- a/maven-model-builder/src/main/java/org/apache/maven/model/plugin/DefaultReportingConverter.java +++ b/maven-model-builder/src/main/java/org/apache/maven/model/plugin/DefaultReportingConverter.java @@ -108,9 +108,9 @@ public class DefaultReportingConverter && request.getValidationLevel() >= ModelBuildingRequest.VALIDATION_LEVEL_MAVEN_3_1 ) { - problems.add( new ModelProblemCollectorRequest( Severity.WARNING, Version.V31) - .setMessage( "The section is deprecated, please move the reports to the section of the new Maven Site Plugin.") - .setLocation( reporting.getLocation( "" ) )); + problems.add( new ModelProblemCollectorRequest( Severity.WARNING, Version.V31 ) + .setMessage( "The section is deprecated, please move the reports to the section of the new Maven Site Plugin." ) + .setLocation( reporting.getLocation( "" ) ) ); } for ( ReportPlugin plugin : reporting.getPlugins() ) diff --git a/maven-model-builder/src/main/java/org/apache/maven/model/profile/DefaultProfileActivationContext.java b/maven-model-builder/src/main/java/org/apache/maven/model/profile/DefaultProfileActivationContext.java index 7258b8ba2f..5bd1c58383 100644 --- a/maven-model-builder/src/main/java/org/apache/maven/model/profile/DefaultProfileActivationContext.java +++ b/maven-model-builder/src/main/java/org/apache/maven/model/profile/DefaultProfileActivationContext.java @@ -21,13 +21,15 @@ package org.apache.maven.model.profile; import java.io.File; import java.util.Collections; +import java.util.Enumeration; +import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Properties; /** * Describes the environmental context used to determine the activation status of profiles. - * + * * @author Benjamin Bentmann */ public class DefaultProfileActivationContext @@ -42,6 +44,8 @@ public class DefaultProfileActivationContext private Map userProperties = Collections.emptyMap(); + private Map projectProperties = Collections.emptyMap(); + private File projectDirectory; public List getActiveProfileIds() @@ -51,7 +55,7 @@ public class DefaultProfileActivationContext /** * Sets the identifiers of those profiles that should be activated by explicit demand. - * + * * @param activeProfileIds The identifiers of those profiles to activate, may be {@code null}. * @return This context, never {@code null}. */ @@ -76,7 +80,7 @@ public class DefaultProfileActivationContext /** * Sets the identifiers of those profiles that should be deactivated by explicit demand. - * + * * @param inactiveProfileIds The identifiers of those profiles to deactivate, may be {@code null}. * @return This context, never {@code null}. */ @@ -102,11 +106,11 @@ public class DefaultProfileActivationContext /** * Sets the system properties to use for interpolation and profile activation. The system properties are collected * from the runtime environment like {@link System#getProperties()} and environment variables. - * + * * @param systemProperties The system properties, may be {@code null}. * @return This context, never {@code null}. */ - @SuppressWarnings( "unchecked" ) + @SuppressWarnings("unchecked") public DefaultProfileActivationContext setSystemProperties( Properties systemProperties ) { if ( systemProperties != null ) @@ -124,7 +128,7 @@ public class DefaultProfileActivationContext /** * Sets the system properties to use for interpolation and profile activation. The system properties are collected * from the runtime environment like {@link System#getProperties()} and environment variables. - * + * * @param systemProperties The system properties, may be {@code null}. * @return This context, never {@code null}. */ @@ -151,11 +155,11 @@ public class DefaultProfileActivationContext * Sets the user properties to use for interpolation and profile activation. The user properties have been * configured directly by the user on his discretion, e.g. via the {@code -Dkey=value} parameter on the command * line. - * + * * @param userProperties The user properties, may be {@code null}. * @return This context, never {@code null}. */ - @SuppressWarnings( "unchecked" ) + @SuppressWarnings("unchecked") public DefaultProfileActivationContext setUserProperties( Properties userProperties ) { if ( userProperties != null ) @@ -174,7 +178,7 @@ public class DefaultProfileActivationContext * Sets the user properties to use for interpolation and profile activation. The user properties have been * configured directly by the user on his discretion, e.g. via the {@code -Dkey=value} parameter on the command * line. - * + * * @param userProperties The user properties, may be {@code null}. * @return This context, never {@code null}. */ @@ -199,9 +203,9 @@ public class DefaultProfileActivationContext /** * Sets the base directory of the current project. - * + * * @param projectDirectory The base directory of the current project, may be {@code null} if profile activation - * happens in the context of metadata retrieval rather than project building. + * happens in the context of metadata retrieval rather than project building. * @return This context, never {@code null}. */ public DefaultProfileActivationContext setProjectDirectory( File projectDirectory ) @@ -211,4 +215,39 @@ public class DefaultProfileActivationContext return this; } + public Map getProjectProperties() + { + return projectProperties; + } + + public DefaultProfileActivationContext setProjectProperties( Properties projectProperties ) + { + if ( projectProperties != null ) + { + + this.projectProperties = Collections.unmodifiableMap( toMap( projectProperties ) ); + } + else + { + this.projectProperties = Collections.emptyMap(); + } + + return this; + } + + private Map toMap( Properties properties ) + { + if ( properties == null ) + { + return Collections.emptyMap(); + } + Map map = new HashMap(); + Enumeration keys = properties.keys(); + while ( keys.hasMoreElements() ) + { + String key = (String) keys.nextElement(); + map.put( key, properties.getProperty( key ) ); + } + return map; + } } diff --git a/maven-model-builder/src/main/java/org/apache/maven/model/profile/DefaultProfileInjector.java b/maven-model-builder/src/main/java/org/apache/maven/model/profile/DefaultProfileInjector.java index b7c8b1985f..38421bc4e9 100644 --- a/maven-model-builder/src/main/java/org/apache/maven/model/profile/DefaultProfileInjector.java +++ b/maven-model-builder/src/main/java/org/apache/maven/model/profile/DefaultProfileInjector.java @@ -71,7 +71,7 @@ public class DefaultProfileInjector } } - private static class ProfileModelMerger + protected static class ProfileModelMerger extends MavenModelMerger { diff --git a/maven-model-builder/src/main/java/org/apache/maven/model/profile/DefaultProfileSelector.java b/maven-model-builder/src/main/java/org/apache/maven/model/profile/DefaultProfileSelector.java index dc004105fb..c376c999e3 100644 --- a/maven-model-builder/src/main/java/org/apache/maven/model/profile/DefaultProfileSelector.java +++ b/maven-model-builder/src/main/java/org/apache/maven/model/profile/DefaultProfileSelector.java @@ -115,10 +115,10 @@ public class DefaultProfileSelector } catch ( RuntimeException e ) { - problems.add( new ModelProblemCollectorRequest( Severity.ERROR, Version.BASE) - .setMessage( "Failed to determine activation for profile " + profile.getId()) - .setLocation( profile.getLocation( "" )) - .setException( e )); + problems.add( new ModelProblemCollectorRequest( Severity.ERROR, Version.BASE ) + .setMessage( "Failed to determine activation for profile " + profile.getId() ) + .setLocation( profile.getLocation( "" ) ) + .setException( e ) ); return false; } } diff --git a/maven-model-builder/src/main/java/org/apache/maven/model/profile/ProfileActivationContext.java b/maven-model-builder/src/main/java/org/apache/maven/model/profile/ProfileActivationContext.java index 63540f23e7..fb9ea0cd89 100644 --- a/maven-model-builder/src/main/java/org/apache/maven/model/profile/ProfileActivationContext.java +++ b/maven-model-builder/src/main/java/org/apache/maven/model/profile/ProfileActivationContext.java @@ -69,4 +69,11 @@ public interface ProfileActivationContext */ File getProjectDirectory(); + /** + * Gets current calculated project properties + * + * @return The project properties, never {@code null}. + */ + Map getProjectProperties(); + } diff --git a/maven-model-builder/src/main/java/org/apache/maven/model/profile/activation/FileProfileActivator.java b/maven-model-builder/src/main/java/org/apache/maven/model/profile/activation/FileProfileActivator.java index aa35bcc120..b4ecf26177 100644 --- a/maven-model-builder/src/main/java/org/apache/maven/model/profile/activation/FileProfileActivator.java +++ b/maven-model-builder/src/main/java/org/apache/maven/model/profile/activation/FileProfileActivator.java @@ -118,6 +118,8 @@ public class FileProfileActivator return false; } + interpolator.addValueSource( new MapBasedValueSource( context.getProjectProperties() ) ); + interpolator.addValueSource( new MapBasedValueSource( context.getUserProperties() ) ); interpolator.addValueSource( new MapBasedValueSource( context.getSystemProperties() ) ); diff --git a/maven-model-builder/src/main/java/org/apache/maven/model/profile/activation/JdkVersionProfileActivator.java b/maven-model-builder/src/main/java/org/apache/maven/model/profile/activation/JdkVersionProfileActivator.java index 7fa55378a2..62b6cfb7b5 100644 --- a/maven-model-builder/src/main/java/org/apache/maven/model/profile/activation/JdkVersionProfileActivator.java +++ b/maven-model-builder/src/main/java/org/apache/maven/model/profile/activation/JdkVersionProfileActivator.java @@ -65,7 +65,7 @@ public class JdkVersionProfileActivator { problems.add( new ModelProblemCollectorRequest( Severity.ERROR, Version.BASE ) .setMessage( "Failed to determine Java version for profile " + profile.getId() ) - .setLocation(activation.getLocation( "jdk" ) ) ); + .setLocation( activation.getLocation( "jdk" ) ) ); return false; } 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 ff084f7201..77219a7b04 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 @@ -62,7 +62,7 @@ public class DefaultModelValidator implements ModelValidator { - private static final Pattern ID_REGEX = Pattern.compile("[A-Za-z0-9_\\-.]+"); + private static final Pattern ID_REGEX = Pattern.compile( "[A-Za-z0-9_\\-.]+" ); private static final String ILLEGAL_FS_CHARS = "\\/:\"<>|?*"; @@ -230,8 +230,9 @@ public class DefaultModelValidator { if ( !"pom".equals( model.getPackaging() ) ) { - addViolation( problems, Severity.ERROR, Version.BASE,"packaging", null, "with value '" + model.getPackaging() - + "' is invalid. Aggregator projects " + "require 'pom' as packaging.", model ); + addViolation( problems, Severity.ERROR, Version.BASE, "packaging", null, + "with value '" + model.getPackaging() + "' is invalid. Aggregator projects " + + "require 'pom' as packaging.", model ); } for ( int i = 0, n = model.getModules().size(); i < n; i++ ) @@ -850,7 +851,8 @@ public class DefaultModelValidator buffer.append( ' ' ).append( message ); - problems.add( new ModelProblemCollectorRequest( severity, version ).setMessage( buffer.toString() ).setLocation( getLocation( fieldName, tracker ))); + problems.add( new ModelProblemCollectorRequest( severity, version ) + .setMessage( buffer.toString() ).setLocation( getLocation( fieldName, tracker ) ) ); } private static InputLocation getLocation( String fieldName, InputLocationTracker tracker ) 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 1e70e8a016..3501f39063 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 @@ -56,7 +56,7 @@ under the License. ${project.artifactId}-${project.version} ${project.build.directory}/test-classes ${project.basedir}/src/main/java - src/main/scripts + ${project.basedir}/src/main/scripts ${project.basedir}/src/test/java @@ -82,11 +82,11 @@ under the License. maven-dependency-plugin - 2.1 + 2.5 maven-release-plugin - 2.0 + 2.3.2 diff --git a/maven-model-builder/src/site/apt/index.apt b/maven-model-builder/src/site/apt/index.apt index ed3930c4d4..1943d7bded 100644 --- a/maven-model-builder/src/site/apt/index.apt +++ b/maven-model-builder/src/site/apt/index.apt @@ -24,23 +24,31 @@ Maven Model Builder ** profile activation (see {{{./apidocs/org/apache/maven/model/profile/activation/package-summary.html}available activators}}) - ** model normalization + ** model normalization: <<>> ({{{./apidocs/org/apache/maven/model/normalization/ModelNormalizer.html}javadoc}}), + with its <<>> implementation + ({{{./xref/org/apache/maven/model/normalization/DefaultModelNormalizer.html}source}}) ** profile injection ** parent resolution until {{{./super-pom.html}super-pom}} - ** inheritance assembly + ** inheritance assembly: <<>> ({{{./apidocs/org/apache/maven/model/inheritance/InheritanceAssembler.html}javadoc}}), + with its <<>> implementation + ({{{./xref/org/apache/maven/model/inheritance/DefaultInheritanceAssembler.html}source}}) ** model interpolation (see below) - ** url normalization + ** url normalization: <<>> ({{{./apidocs/org/apache/maven/model/path/UrlNormalizer.html}javadoc}}), + with its <<>> implementation + ({{{./xref/org/apache/maven/model/path/DefaultUrlNormalizer.html}source}}) [] * phase 2 - ** model path translation + ** model path translation: <<>> ({{{./apidocs/org/apache/maven/model/path/ModelPathTranslator.html}javadoc}}), + with its <<>> implementation + ({{{./xref/org/apache/maven/model/path/DefaultModelPathTranslator.html}source}}) ** plugin management injection @@ -56,7 +64,9 @@ Maven Model Builder ** <(optional)> plugins configuration - ** effective model validation + ** effective model validation: <<>> ({{{./apidocs/org/apache/maven/model/validation/ModelValidator.html}javadoc}}), + with its <<>> implementation + ({{{./xref/org/apache/maven/model/validation/DefaultModelValidator.html}source}}) [] @@ -78,12 +88,12 @@ Maven Model Builder <<>> ()\ <<<*>>> () | POM content (see {{{../maven-model/maven.html}POM reference}}) | <<<$\{project.version\}>>>\ | | <<<$\{project.build.finalName\}>>>\ - | | <<<$\{project.build.artifactId\}>>>\ + | | <<<$\{project.artifactId\}>>>\ | | <<<$\{project.build.directory\}>>> | *----+------+------+ -| <<>>\ -<<>>\ -<<>> () | the directory containing the <<>> file | <<<$\{project.basedir\}>>> | +| <<>>\ +<<>> ()\ +<<>> () | the directory containing the <<>> file | <<<$\{project.basedir\}>>> | *----+------+------+ | <<>>\ <<>> () | the directory containing the <<>> file as URI | <<<$\{project.baseUri\}>>> | diff --git a/maven-model/src/main/java/org/apache/maven/model/merge/ModelMerger.java b/maven-model/src/main/java/org/apache/maven/model/merge/ModelMerger.java index 3c9e749e90..88e866b0b2 100644 --- a/maven-model/src/main/java/org/apache/maven/model/merge/ModelMerger.java +++ b/maven-model/src/main/java/org/apache/maven/model/merge/ModelMerger.java @@ -71,7 +71,16 @@ import org.codehaus.plexus.util.xml.Xpp3Dom; /** * This is a hand-crafted prototype of the default model merger that should eventually be generated by Modello by a new - * Java plugin. + * Java plugin. Code structure to merge source (read-only) object into the target object is:
    + *
  • mergeClassname( Classname target, Classname source, boolean sourceDominant, + * Map context ) for each model class
  • + *
  • mergeClassname_FieldName( Classname target, Classname source, boolean + * sourceDominant, Map context ) for each field of each model class
  • + *
  • Object getClassnameKey( Classname classname ) for each class that is used in a list
  • + *
+ * Code is written like it could be generated, with default behaviour to be overridden when necessary. + * This is particularly the case for Object getClassnameKey( Classname classname ) method, + * which by default return the object itself and is expected to be overridden to calculate better suited key value. * * @author Benjamin Bentmann */ @@ -2834,79 +2843,79 @@ public class ModelMerger return dependency; } - protected Object getPluginKey( Plugin object ) + protected Object getPluginKey( Plugin plugin ) { - return object; + return plugin; } - protected Object getPluginExecutionKey( PluginExecution object ) + protected Object getPluginExecutionKey( PluginExecution pluginExecution ) { - return object; + return pluginExecution; } - protected Object getReportPluginKey( ReportPlugin object ) + protected Object getReportPluginKey( ReportPlugin reportPlugin ) { - return object; + return reportPlugin; } - protected Object getReportSetKey( ReportSet object ) + protected Object getReportSetKey( ReportSet reportSet ) { - return object; + return reportSet; } - protected Object getLicenseKey( License object ) + protected Object getLicenseKey( License license ) { - return object; + return license; } - protected Object getMailingListKey( MailingList object ) + protected Object getMailingListKey( MailingList mailingList ) { - return object; + return mailingList; } - protected Object getDeveloperKey( Developer object ) + protected Object getDeveloperKey( Developer developer ) { - return object; + return developer; } - protected Object getContributorKey( Contributor object ) + protected Object getContributorKey( Contributor contributor ) { - return object; + return contributor; } - protected Object getProfileKey( Profile object ) + protected Object getProfileKey( Profile profile ) { - return object; + return profile; } - protected Object getRepositoryKey( Repository object ) + protected Object getRepositoryKey( Repository repository ) { - return getRepositoryBaseKey( object ); + return getRepositoryBaseKey( repository ); } - protected Object getRepositoryBaseKey( RepositoryBase object ) + protected Object getRepositoryBaseKey( RepositoryBase repositoryBase ) { - return object; + return repositoryBase; } - protected Object getNotifierKey( Notifier object ) + protected Object getNotifierKey( Notifier notifier ) { - return object; + return notifier; } - protected Object getResourceKey( Resource object ) + protected Object getResourceKey( Resource resource ) { - return object; + return resource; } - protected Object getExtensionKey( Extension object ) + protected Object getExtensionKey( Extension extension ) { - return object; + return extension; } - protected Object getExclusionKey( Exclusion object ) + protected Object getExclusionKey( Exclusion exclusion ) { - return object; + return exclusion; } } diff --git a/maven-plugin-api/src/main/java/org/apache/maven/plugin/descriptor/MojoDescriptor.java b/maven-plugin-api/src/main/java/org/apache/maven/plugin/descriptor/MojoDescriptor.java index d73f66d5f4..8c3d9da894 100644 --- a/maven-plugin-api/src/main/java/org/apache/maven/plugin/descriptor/MojoDescriptor.java +++ b/maven-plugin-api/src/main/java/org/apache/maven/plugin/descriptor/MojoDescriptor.java @@ -108,7 +108,10 @@ public class MojoDescriptor /** Specify the required dependencies in a specified scope */ private String dependencyResolutionRequired = null; - /** The scope of (transitive) dependencies that should be collected but not resolved. */ + /** + * The scope of (transitive) dependencies that should be collected but not resolved. + * @since 3.0-alpha-3 + */ private String dependencyCollectionRequired; /** By default, the Mojo needs a Maven project to be executed */ @@ -132,7 +135,10 @@ public class MojoDescriptor /** By default, the Mojo don't need reports to run */ private boolean requiresReports = false; - /** By default, mojos are not threadsafe */ + /** + * By default, mojos are not threadsafe + * @since 3.0-beta-2 + */ private boolean threadSafe = false; /** @@ -271,6 +277,9 @@ public class MojoDescriptor return dependencyResolutionRequired; } + /** + * @since 3.0-alpha-3 + */ public void setDependencyCollectionRequired( String requiresDependencyCollection ) { this.dependencyCollectionRequired = requiresDependencyCollection; @@ -284,6 +293,7 @@ public class MojoDescriptor * full dependency resolution might fail due to projects which haven't been built yet. * * @return The scope of (transitive) dependencies that should be collected or {@code null} if none. + * @since 3.0-alpha-3 */ public String getDependencyCollectionRequired() { @@ -664,6 +674,7 @@ public class MojoDescriptor /** * @return True if the Mojo is thread-safe and can be run safely in parallel + * @since 3.0-beta-2 */ public boolean isThreadSafe() { @@ -672,6 +683,7 @@ public class MojoDescriptor /** * @param threadSafe indicates that the mojo is thread-safe and can be run safely in parallel + * @since 3.0-beta-2 */ public void setThreadSafe( boolean threadSafe ) { diff --git a/pom.xml b/pom.xml index c631354cd8..22a0162e15 100644 --- a/pom.xml +++ b/pom.xml @@ -21,7 +21,7 @@ org.apache.maven maven-parent - 22 + 23 ../pom/maven/pom.xml @@ -30,7 +30,7 @@ pom Apache Maven - Maven is a project development management and + Maven is a software build management and comprehension tool. Based on the concept of a project object model: builds, dependency management, documentation creation, site publication, and distribution publication are all controlled from @@ -38,19 +38,19 @@ number of other development tools for reporting or the build process. - ${siteUrl} + http://maven.apache.org/ref/${project.version} 2001 - 2.4 + 2.4.2 1.2 1.2_Java1.3 3.8.2 1.5.5 - 1.14 - 3.0.9 + 1.16 + 3.0.10 2.3.0 - 2.3 + 2.4 1.3 1.7 1.6 @@ -64,6 +64,7 @@ Apache Maven scp://people.apache.org/www/maven.apache.org/ref/${project.version}/ http://maven.apache.org/ref/${project.version}/ + ref/3-LATEST @@ -82,9 +83,10 @@ - scm:svn:http://svn.apache.org/repos/asf/maven/maven-3/trunk - scm:svn:https://svn.apache.org/repos/asf/maven/maven-3/trunk - http://svn.apache.org/viewvc/maven/maven-3/trunk + scm:git:https://git-wip-us.apache.org/repos/asf/maven.git + scm:git:https://git-wip-us.apache.org/repos/asf/maven.git + https://git-wip-us.apache.org/repos/asf?p=maven.git + HEAD jira @@ -92,12 +94,12 @@ Jenkins - https://builds.apache.org/job/maven-3.0.x/ + https://builds.apache.org/job/maven-3.x/ apache.website - ${siteDeployUrl} + scm:svn:https://svn.apache.org/repos/infra/websites/production/maven/content/${maven.site.path} @@ -220,7 +222,13 @@ org.slf4j slf4j-simple ${slf4jVersion} - runtime + true +
+ + ch.qos.logback + logback-classic + 1.0.7 + true @@ -393,12 +401,12 @@ org.apache.maven.plugins maven-assembly-plugin - 2.2-beta-5 + 2.4 org.codehaus.mojo buildnumber-maven-plugin - 1.0 + 1.2 org.apache.maven.plugins @@ -412,6 +420,16 @@ + + org.apache.maven.plugins + maven-scm-publish-plugin + 1.0-beta-2 + + ${project.build.directory}/staging/${maven.site.path} + ${maven.site.cache}/${maven.site.path} + true + + @@ -439,16 +457,6 @@ - - - - org.apache.maven.plugins - maven-project-info-reports-plugin - 2.6 - - - - apache-release @@ -473,29 +481,18 @@ reporting - - org.apache.maven.plugins - maven-project-info-reports-plugin - 2.6 - org.apache.maven.plugins maven-javadoc-plugin true + true http://sonatype.github.com/sonatype-aether/apidocs/ http://plexus.codehaus.org/plexus-containers/plexus-container-default/apidocs/ - - non-aggregate - - javadoc - test-javadoc - - aggregate false @@ -510,13 +507,6 @@ maven-jxr-plugin 2.3 - - non-aggregate - - jxr - test-jxr - - aggregate false diff --git a/src/site/site.xml b/src/site/site.xml index cdaacd9826..291d8ced9f 100644 --- a/src/site/site.xml +++ b/src/site/site.xml @@ -35,11 +35,7 @@ under the License. org.apache.maven.skins maven-fluido-skin -<<<<<<< HEAD 1.3.0 -======= - 1.0 ->>>>>>> 4fdcdbd26244ff81e242054fd38cf415d92499be