diff --git a/apache-maven/src/bin/mvn b/apache-maven/src/bin/mvn index 6dd9d5ebd3..52451ad663 100755 --- a/apache-maven/src/bin/mvn +++ b/apache-maven/src/bin/mvn @@ -53,16 +53,31 @@ mingw=false case "`uname`" in CYGWIN*) cygwin=true ;; MINGW*) mingw=true;; +<<<<<<< HEAD Darwin*) darwin=true +======= + Darwin*) darwin=true +>>>>>>> fcffe3c9d5ceb65c229b07f60ad4d215f5cd05e2 # # Look for the Apple JDKs first to preserve the existing behaviour, and then look # for the new JDKs provided by Oracle. # +<<<<<<< HEAD +======= + if [[ -z "$JAVA_HOME" && -L /System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK ]] ; then + # + # Apple JDKs + # + export JAVA_HOME=/System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK/Home + fi + +>>>>>>> fcffe3c9d5ceb65c229b07f60ad4d215f5cd05e2 if [[ -z "$JAVA_HOME" && -L /System/Library/Java/JavaVirtualMachines/CurrentJDK ]] ; then # # Apple JDKs # +<<<<<<< HEAD JAVA_HOME=/System/Library/Java/JavaVirtualMachines/CurrentJDK/Contents/Home fi @@ -71,6 +86,16 @@ case "`uname`" in # Oracle JDKs # JAVA_HOME=/Library/Java/JavaVirtualMachines/CurrentJDK/Contents/Home +======= + export JAVA_HOME=/System/Library/Java/JavaVirtualMachines/CurrentJDK/Contents/Home + fi + + if [[ -z "$JAVA_HOME" && -L "/Library/Java/JavaVirtualMachines/CurrentJDK" ]] ; then + # + # Oracle JDKs + # + export JAVA_HOME=/Library/Java/JavaVirtualMachines/CurrentJDK/Contents/Home +>>>>>>> fcffe3c9d5ceb65c229b07f60ad4d215f5cd05e2 fi ;; esac diff --git a/apache-maven/src/bin/mvnDebug b/apache-maven/src/bin/mvnDebug index 04babaa036..43a09cc5bf 100755 --- a/apache-maven/src/bin/mvnDebug +++ b/apache-maven/src/bin/mvnDebug @@ -58,12 +58,30 @@ case "`uname`" in CYGWIN*) cygwin=true ;; MINGW*) mingw=true;; Darwin*) darwin=true - if [ -z "$JAVA_VERSION" ] ; then - JAVA_VERSION="CurrentJDK" + # + # Look for the Apple JDKs first to preserve the existing behaviour, and then look + # for the new JDKs provided by Oracle. + # + if [[ -z "$JAVA_HOME" && -L /System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK ]] ; then + # + # Apple JDKs + # + export JAVA_HOME=/System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK/Home fi - if [ -z "$JAVA_HOME" ] ; then - JAVA_HOME=/System/Library/Frameworks/JavaVM.framework/Versions/${JAVA_VERSION}/Home + + if [[ -z "$JAVA_HOME" && -L /System/Library/Java/JavaVirtualMachines/CurrentJDK ]] ; then + # + # Apple JDKs + # + export JAVA_HOME=/System/Library/Java/JavaVirtualMachines/CurrentJDK/Contents/Home fi + + if [[ -z "$JAVA_HOME" && -L "/Library/Java/JavaVirtualMachines/CurrentJDK" ]] ; then + # + # Oracle JDKs + # + export JAVA_HOME=/Library/Java/JavaVirtualMachines/CurrentJDK/Contents/Home + fi ;; esac diff --git a/apache-maven/src/bin/mvnyjp b/apache-maven/src/bin/mvnyjp index 4c22d51363..ec2f7e0736 100755 --- a/apache-maven/src/bin/mvnyjp +++ b/apache-maven/src/bin/mvnyjp @@ -61,17 +61,31 @@ mingw=false case "`uname`" in CYGWIN*) cygwin=true ;; MINGW*) mingw=true;; - Darwin*) darwin=true - if [ -z "$JAVA_VERSION" ] ; then - JAVA_VERSION="CurrentJDK" + Darwin*) darwin=true + # + # Look for the Apple JDKs first to preserve the existing behaviour, and then look + # for the new JDKs provided by Oracle. + # + if [[ -z "$JAVA_HOME" && -L /System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK ]] ; then + # + # Apple JDKs + # + export JAVA_HOME=/System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK/Home fi - if [ -z "$JAVA_HOME" ] ; then - JAVA_HOME=/System/Library/Frameworks/JavaVM.framework/Versions/${JAVA_VERSION}/Home + + if [[ -z "$JAVA_HOME" && -L /System/Library/Java/JavaVirtualMachines/CurrentJDK ]] ; then + # + # Apple JDKs + # + export JAVA_HOME=/System/Library/Java/JavaVirtualMachines/CurrentJDK/Contents/Home fi - if [ -z "$YJP_HOME" ]; then - YJP_HOME=/Applications/YourKit.app - fi - YJPLIB=$YJP_HOME/bin/mac/libyjpagent.jnilib + + if [[ -z "$JAVA_HOME" && -L "/Library/Java/JavaVirtualMachines/CurrentJDK" ]] ; then + # + # Oracle JDKs + # + export JAVA_HOME=/Library/Java/JavaVirtualMachines/CurrentJDK/Contents/Home + fi ;; esac diff --git a/apache-maven/src/main/assembly/src.xml b/apache-maven/src/main/assembly/src.xml index 634e92250e..8e6d6451ed 100644 --- a/apache-maven/src/main/assembly/src.xml +++ b/apache-maven/src/main/assembly/src.xml @@ -32,6 +32,7 @@ under the License. **/*.log **/.gitignore **/.gitattributes + init-git-svn.sh diff --git a/init-git-svn.sh b/init-git-svn.sh new file mode 100755 index 0000000000..28ea5be9be --- /dev/null +++ b/init-git-svn.sh @@ -0,0 +1,4 @@ +cd .git;wget http://git.apache.org/authors.txt; cd .. +git config svn.authorsfile ".git/authors.txt" +git svn init --prefix=origin/ --tags=tags --trunk=trunk --branches=branches https://svn.apache.org/repos/asf/maven/maven-3 +git svn rebase diff --git a/maven-core/src/main/java/org/apache/maven/DefaultArtifactFilterManager.java b/maven-core/src/main/java/org/apache/maven/DefaultArtifactFilterManager.java index 55a576075f..9d772f70b4 100644 --- a/maven-core/src/main/java/org/apache/maven/DefaultArtifactFilterManager.java +++ b/maven-core/src/main/java/org/apache/maven/DefaultArtifactFilterManager.java @@ -37,7 +37,7 @@ import org.codehaus.plexus.component.repository.exception.ComponentLookupExcepti * @author Jason van Zyl * @todo this should probably be a component with some dynamic control of filtering */ -@Component(role = ArtifactFilterManager.class) +@Component( role = ArtifactFilterManager.class ) public class DefaultArtifactFilterManager implements ArtifactFilterManager { @@ -90,7 +90,7 @@ public class DefaultArtifactFilterManager * wagon from their plugin realm. */ - DEFAULT_EXCLUSIONS = Collections.unmodifiableSet( artifacts); + DEFAULT_EXCLUSIONS = Collections.unmodifiableSet( artifacts ); } protected Set excludedArtifacts = new HashSet( DEFAULT_EXCLUSIONS ); 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 bdfacbf55c..e80185bbda 100644 --- a/maven-core/src/main/java/org/apache/maven/DefaultMaven.java +++ b/maven-core/src/main/java/org/apache/maven/DefaultMaven.java @@ -1,18 +1,22 @@ package org.apache.maven; /* - * Licensed to the Apache Software Foundation (ASF) under one or more contributor license - * agreements. See the NOTICE file distributed with this work for additional information regarding - * copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance with the License. You may obtain a - * copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License - * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express - * or implied. See the License for the specific language governing permissions and limitations under - * the License. + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR 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; @@ -79,26 +83,11 @@ import org.codehaus.plexus.util.xml.Xpp3Dom; import org.sonatype.aether.ConfigurationProperties; import org.sonatype.aether.RepositorySystem; import org.sonatype.aether.RepositorySystemSession; -import org.sonatype.aether.collection.DependencyGraphTransformer; -import org.sonatype.aether.collection.DependencyManager; -import org.sonatype.aether.collection.DependencySelector; -import org.sonatype.aether.collection.DependencyTraverser; import org.sonatype.aether.repository.Authentication; import org.sonatype.aether.repository.LocalRepository; import org.sonatype.aether.repository.RepositoryPolicy; import org.sonatype.aether.repository.WorkspaceReader; import org.sonatype.aether.util.DefaultRepositorySystemSession; -import org.sonatype.aether.util.graph.manager.ClassicDependencyManager; -import org.sonatype.aether.util.graph.selector.AndDependencySelector; -import org.sonatype.aether.util.graph.selector.ExclusionDependencySelector; -import org.sonatype.aether.util.graph.selector.OptionalDependencySelector; -import org.sonatype.aether.util.graph.selector.ScopeDependencySelector; -import org.sonatype.aether.util.graph.transformer.ChainedDependencyGraphTransformer; -import org.sonatype.aether.util.graph.transformer.NearestVersionConflictResolver; -import org.sonatype.aether.util.graph.transformer.ConflictMarker; -import org.sonatype.aether.util.graph.transformer.JavaDependencyContextRefiner; -import org.sonatype.aether.util.graph.transformer.JavaEffectiveScopeCalculator; -import org.sonatype.aether.util.graph.traverser.FatArtifactTraverser; import org.sonatype.aether.util.repository.ChainedWorkspaceReader; import org.sonatype.aether.util.repository.DefaultAuthenticationSelector; import org.sonatype.aether.util.repository.DefaultMirrorSelector; @@ -107,7 +96,7 @@ import org.sonatype.aether.util.repository.DefaultProxySelector; /** * @author Jason van Zyl */ -@Component(role = Maven.class) +@Component( role = Maven.class ) public class DefaultMaven implements Maven { diff --git a/maven-core/src/main/java/org/apache/maven/DefaultProjectDependenciesResolver.java b/maven-core/src/main/java/org/apache/maven/DefaultProjectDependenciesResolver.java index 4d6fa14bee..d511d1d04e 100644 --- a/maven-core/src/main/java/org/apache/maven/DefaultProjectDependenciesResolver.java +++ b/maven-core/src/main/java/org/apache/maven/DefaultProjectDependenciesResolver.java @@ -42,7 +42,7 @@ import org.apache.maven.repository.RepositorySystem; import org.codehaus.plexus.component.annotations.Component; import org.codehaus.plexus.component.annotations.Requirement; -@Component(role = ProjectDependenciesResolver.class) +@Component( role = ProjectDependenciesResolver.class ) public class DefaultProjectDependenciesResolver implements ProjectDependenciesResolver { @@ -97,8 +97,8 @@ public class DefaultProjectDependenciesResolver return resolved; } - if ( ( scopesToCollect == null || scopesToCollect.isEmpty() ) && - ( scopesToResolve == null || scopesToResolve.isEmpty() ) ) + if ( ( scopesToCollect == null || scopesToCollect.isEmpty() ) + && ( scopesToResolve == null || scopesToResolve.isEmpty() ) ) { return resolved; } diff --git a/maven-core/src/main/java/org/apache/maven/ProjectBuildFailureException.java b/maven-core/src/main/java/org/apache/maven/ProjectBuildFailureException.java index 1e9509842b..480f9c5a5a 100644 --- a/maven-core/src/main/java/org/apache/maven/ProjectBuildFailureException.java +++ b/maven-core/src/main/java/org/apache/maven/ProjectBuildFailureException.java @@ -1,5 +1,24 @@ package org.apache.maven; +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + import org.apache.maven.plugin.MojoFailureException; /** diff --git a/maven-core/src/main/java/org/apache/maven/ReactorReader.java b/maven-core/src/main/java/org/apache/maven/ReactorReader.java index 9afe864765..4e1a638f47 100644 --- a/maven-core/src/main/java/org/apache/maven/ReactorReader.java +++ b/maven-core/src/main/java/org/apache/maven/ReactorReader.java @@ -43,9 +43,9 @@ import java.util.Map; class ReactorReader implements WorkspaceReader { - private final static Collection JAR_LIKE_TYPES = Arrays.asList( "jar", "test-jar", "ejb-client" ); + private static final Collection JAR_LIKE_TYPES = Arrays.asList( "jar", "test-jar", "ejb-client" ); - private final static Collection COMPILE_PHASE_TYPES = Arrays.asList( "jar", "ejb-client" ); + private static final Collection COMPILE_PHASE_TYPES = Arrays.asList( "jar", "ejb-client" ); private Map projectsByGAV; @@ -103,7 +103,7 @@ class ReactorReader } else { - String type = artifact.getProperty( "type", ""); + String type = artifact.getProperty( "type", "" ); if ( project.hasLifecyclePhase( "compile" ) && COMPILE_PHASE_TYPES.contains( type ) ) { return new File( project.getBuild().getOutputDirectory() ); diff --git a/maven-core/src/main/java/org/apache/maven/artifact/repository/RepositoryCache.java b/maven-core/src/main/java/org/apache/maven/artifact/repository/RepositoryCache.java new file mode 100644 index 0000000000..3afe33d359 --- /dev/null +++ b/maven-core/src/main/java/org/apache/maven/artifact/repository/RepositoryCache.java @@ -0,0 +1,58 @@ +package org.apache.maven.artifact.repository; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +/** + * Caches auxiliary data used during repository access like already processed metadata. The data in the cache is meant + * for exclusive consumption by the repository system and is opaque to the cache implementation. + * + * @author Benjamin Bentmann + */ +@Deprecated +// +// Used by Tycho and will break users and force them to upgrade to Maven 3.1 so we should really leave +// this here, possibly indefinitely. +// +public interface RepositoryCache +{ + + /** + * Puts the specified data into the cache. Warning: The cache will directly save the provided + * reference. If the cached data is mutable, i.e. could be modified after being put into the cache, the caller is + * responsible for creating a copy of the original data and store the copy in the cache. + * + * @param request The repository request from which this cache was retrieved, must not be {@code null}. + * @param key The key to use associate the data with, must not be {@code null}. + * @param data The data to store in the cache, may be {@code null}. + */ + void put( RepositoryRequest request, Object key, Object data ); + + /** + * Gets the specified data from the cache. Warning: The cache will directly return the saved + * reference. If the cached data is to be modified after its retrieval, the caller is responsible to create a copy + * of the returned data and use this instead of the cache record. + * + * @param request The repository request from which this cache was retrieved, must not be {@code null}. + * @param key The key to use for lookup of the data, must not be {@code null}. + * @return The requested data or {@code null} if none was present in the cache. + */ + Object get( RepositoryRequest request, Object key ); + +} diff --git a/maven-core/src/main/java/org/apache/maven/artifact/repository/metadata/io/MetadataReader.java b/maven-core/src/main/java/org/apache/maven/artifact/repository/metadata/io/MetadataReader.java index 7f554e4346..232246fd1d 100644 --- a/maven-core/src/main/java/org/apache/maven/artifact/repository/metadata/io/MetadataReader.java +++ b/maven-core/src/main/java/org/apache/maven/artifact/repository/metadata/io/MetadataReader.java @@ -39,7 +39,7 @@ public interface MetadataReader * The key for the option to enable strict parsing. This option is of type {@link Boolean} and defaults to {@code * true}. If {@code false}, unknown elements will be ignored instead of causing a failure. */ - final String IS_STRICT = "org.apache.maven.artifact.repository.metadata.io.isStrict"; + String IS_STRICT = "org.apache.maven.artifact.repository.metadata.io.isStrict"; /** * Reads the metadata from the specified file. diff --git a/maven-core/src/main/java/org/apache/maven/artifact/resolver/ArtifactResolutionRequest.java b/maven-core/src/main/java/org/apache/maven/artifact/resolver/ArtifactResolutionRequest.java index fe8d1f2845..890b466211 100644 --- a/maven-core/src/main/java/org/apache/maven/artifact/resolver/ArtifactResolutionRequest.java +++ b/maven-core/src/main/java/org/apache/maven/artifact/resolver/ArtifactResolutionRequest.java @@ -26,6 +26,7 @@ import java.util.Set; import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.repository.ArtifactRepository; +import org.apache.maven.artifact.repository.RepositoryCache; import org.apache.maven.artifact.repository.RepositoryRequest; import org.apache.maven.artifact.resolver.filter.ArtifactFilter; import org.apache.maven.settings.Mirror; @@ -317,4 +318,12 @@ public class ArtifactResolutionRequest return proxies; } + // + // Used by Tycho and will break users and force them to upgrade to Maven 3.1 so we should really leave + // this here, possibly indefinitely. + // + public ArtifactResolutionRequest setCache( RepositoryCache cache ) + { + return this; + } } diff --git a/maven-core/src/main/java/org/apache/maven/classrealm/DefaultClassRealmManager.java b/maven-core/src/main/java/org/apache/maven/classrealm/DefaultClassRealmManager.java index b1c6d9e6ae..0db5b4b29f 100644 --- a/maven-core/src/main/java/org/apache/maven/classrealm/DefaultClassRealmManager.java +++ b/maven-core/src/main/java/org/apache/maven/classrealm/DefaultClassRealmManager.java @@ -183,6 +183,12 @@ public class DefaultClassRealmManager // classworlds (for legacy code) imports.put( "org.codehaus.classworlds", coreRealm ); + // plexus-utils (for DOM-type fields in maven-model) + imports.put( "org.codehaus.plexus.util.xml.Xpp3Dom", coreRealm ); + imports.put( "org.codehaus.plexus.util.xml.pull.XmlPullParser", coreRealm ); + imports.put( "org.codehaus.plexus.util.xml.pull.XmlPullParserException", coreRealm ); + imports.put( "org.codehaus.plexus.util.xml.pull.XmlSerializer", coreRealm ); + // plexus-container, plexus-component-annotations imports.put( "org.codehaus.plexus.*", coreRealm ); imports.put( "org.codehaus.plexus.component", coreRealm ); @@ -193,17 +199,10 @@ public class DefaultClassRealmManager imports.put( "org.codehaus.plexus.logging", coreRealm ); imports.put( "org.codehaus.plexus.personality", coreRealm ); - // plexus-utils (for maven-model) - imports.put( "org.codehaus.plexus.util.xml.Xpp3Dom", coreRealm ); - imports.put( "org.codehaus.plexus.util.xml.pull.XmlPullParser", coreRealm ); - imports.put( "org.codehaus.plexus.util.xml.pull.XmlPullParserException", coreRealm ); - imports.put( "org.codehaus.plexus.util.xml.pull.XmlSerializer", coreRealm ); - // javax.inject, sisu-inject (JSR-330) imports.put( "javax.inject.*", coreRealm ); imports.put( "javax.enterprise.inject.*", coreRealm ); imports.put( "org.sonatype.inject.*", coreRealm ); - imports.put( "org.slf4j.*", coreRealm ); // com.google // @@ -218,6 +217,9 @@ public class DefaultClassRealmManager // imports.put( "com.google.inject.name.*", coreRealm ); // imports.put( "com.google.inject.spi.*", coreRealm ); // imports.put( "com.google.inject.util.*", coreRealm ); + + // SLF4J + imports.put( "org.slf4j.*", coreRealm ); } /** diff --git a/maven-core/src/main/java/org/apache/maven/exception/DefaultExceptionHandler.java b/maven-core/src/main/java/org/apache/maven/exception/DefaultExceptionHandler.java index ddbe038fe1..6066593f7b 100644 --- a/maven-core/src/main/java/org/apache/maven/exception/DefaultExceptionHandler.java +++ b/maven-core/src/main/java/org/apache/maven/exception/DefaultExceptionHandler.java @@ -179,9 +179,11 @@ public class DefaultExceptionHandler reference = MojoExecutionException.class.getSimpleName(); Throwable cause = exception.getCause(); - if ( cause instanceof IOException ) { + if ( cause instanceof IOException ) + { cause = cause.getCause(); - if ( cause instanceof ConnectException ) { + if ( cause instanceof ConnectException ) + { reference = ConnectException.class.getSimpleName(); } } diff --git a/maven-core/src/main/java/org/apache/maven/execution/MavenSession.java b/maven-core/src/main/java/org/apache/maven/execution/MavenSession.java index 21ac3881bc..30ff3332d9 100644 --- a/maven-core/src/main/java/org/apache/maven/execution/MavenSession.java +++ b/maven-core/src/main/java/org/apache/maven/execution/MavenSession.java @@ -28,6 +28,7 @@ import java.util.Properties; import java.util.concurrent.ConcurrentHashMap; import org.apache.maven.artifact.repository.ArtifactRepository; +import org.apache.maven.artifact.repository.RepositoryCache; import org.apache.maven.monitor.event.EventDispatcher; import org.apache.maven.plugin.descriptor.PluginDescriptor; import org.apache.maven.project.MavenProject; @@ -381,4 +382,14 @@ public class MavenSession return repositorySession; } + @Deprecated + // + // Used by Tycho and will break users and force them to upgrade to Maven 3.1 so we should really leave + // this here, possibly indefinitely. + // + public RepositoryCache getRepositoryCache() + { + return null; + } + } diff --git a/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginRealmCache.java b/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginRealmCache.java index 896236741e..c821ae90ad 100644 --- a/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginRealmCache.java +++ b/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginRealmCache.java @@ -29,7 +29,9 @@ import org.apache.maven.artifact.Artifact; import org.apache.maven.model.Plugin; import org.apache.maven.project.MavenProject; import org.codehaus.plexus.classworlds.realm.ClassRealm; +import org.codehaus.plexus.classworlds.realm.NoSuchRealmException; import org.codehaus.plexus.component.annotations.Component; +import org.codehaus.plexus.personality.plexus.lifecycle.phase.Disposable; import org.sonatype.aether.RepositorySystemSession; import org.sonatype.aether.graph.DependencyFilter; import org.sonatype.aether.repository.LocalRepository; @@ -41,7 +43,7 @@ import org.sonatype.aether.repository.WorkspaceRepository; */ @Component( role = PluginRealmCache.class ) public class DefaultPluginRealmCache - implements PluginRealmCache + implements PluginRealmCache, Disposable { protected static class CacheKey @@ -179,6 +181,18 @@ public class DefaultPluginRealmCache public void flush() { + for ( CacheRecord record : cache.values() ) + { + ClassRealm realm = record.realm; + try + { + realm.getWorld().disposeRealm( realm.getId() ); + } + catch ( NoSuchRealmException e ) + { + // ignore + } + } cache.clear(); } @@ -197,4 +211,9 @@ public class DefaultPluginRealmCache // default cache does not track plugin usage } + public void dispose() + { + flush(); + } + } diff --git a/maven-core/src/main/java/org/apache/maven/project/DefaultMavenProjectHelper.java b/maven-core/src/main/java/org/apache/maven/project/DefaultMavenProjectHelper.java index 37061c86f9..2b9444f025 100644 --- a/maven-core/src/main/java/org/apache/maven/project/DefaultMavenProjectHelper.java +++ b/maven-core/src/main/java/org/apache/maven/project/DefaultMavenProjectHelper.java @@ -19,9 +19,6 @@ package org.apache.maven.project; * under the License. */ -import java.io.File; -import java.util.List; - import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.handler.ArtifactHandler; import org.apache.maven.artifact.handler.manager.ArtifactHandlerManager; @@ -31,6 +28,9 @@ import org.codehaus.plexus.component.annotations.Component; import org.codehaus.plexus.component.annotations.Requirement; import org.codehaus.plexus.logging.AbstractLogEnabled; +import java.io.File; +import java.util.List; + @SuppressWarnings( "deprecation" ) @Component( role = MavenProjectHelper.class ) public class DefaultMavenProjectHelper @@ -90,20 +90,15 @@ public class DefaultMavenProjectHelper attachArtifact( project, artifact ); } + /** + * Add an attached artifact or replace the file for an existing artifact. + * @see MavenProject#addAttachedArtifact(org.apache.maven.artifact.Artifact) + * @param project project reference. + * @param artifact artifact to add or replace. + */ public void attachArtifact( MavenProject project, Artifact artifact ) { - try - { - project.addAttachedArtifact( artifact ); - } - catch ( DuplicateArtifactAttachmentException dae ) - { - getLogger().warn( dae.getMessage() ); - - // We can throw this because it's unchecked, and won't change the MavenProjectHelper API, which would break - // backward compat if it did. - throw dae; - } + project.addAttachedArtifact( artifact ); } public void addResource( MavenProject project, String resourceDirectory, List includes, List excludes ) 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 db31299054..5090c3e4f7 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 @@ -15,22 +15,6 @@ package org.apache.maven.project; * the License. */ -import java.io.File; -import java.io.IOException; -import java.io.Writer; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Iterator; -import java.util.LinkedHashMap; -import java.util.LinkedHashSet; -import java.util.List; -import java.util.Map; -import java.util.Properties; -import java.util.Set; - import org.apache.maven.RepositoryUtils; import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.ArtifactUtils; @@ -75,6 +59,22 @@ import org.codehaus.plexus.util.xml.Xpp3Dom; import org.sonatype.aether.graph.DependencyFilter; import org.sonatype.aether.repository.RemoteRepository; +import java.io.File; +import java.io.IOException; +import java.io.Writer; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Iterator; +import java.util.LinkedHashMap; +import java.util.LinkedHashSet; +import java.util.List; +import java.util.Map; +import java.util.Properties; +import java.util.Set; + /** * The concern of the project is provide runtime values based on the model. *

@@ -1449,19 +1449,46 @@ public class MavenProject return this.injectedProfileIds; } + private String logStringForArtifactFile( Artifact a ) + { + if ( a.getFile() != null ) + { + return a.getFile().getAbsolutePath(); + } + else + { + return "(no path)"; + } + } + + /** + * Add or replace an artifact. + * In spite of the 'throws' declaration on this API, this method has never thrown an exception since Maven 3.0.x. + * Historically, it logged and ignored a second addition of the same g/a/v/c/t. Now it replaces the file for + * the artifact, so that plugins (e.g. shade) can change the pathname of the file for a particular set of + * coordinates. + * @param artifact the artifact to add or replace. + * @throws DuplicateArtifactAttachmentException + */ public void addAttachedArtifact( Artifact artifact ) throws DuplicateArtifactAttachmentException { List attachedArtifacts = getAttachedArtifacts(); - - if ( attachedArtifacts.contains( artifact ) ) + for ( int ax = 0; ax < attachedArtifacts.size(); ax++ ) { - if ( logger != null ) + Artifact a = attachedArtifacts.get( ax ); + if ( a.equals( artifact )) { - logger.warn( "Artifact " + artifact + " already attached to project, ignoring duplicate" ); + if ( logger != null ) + { + logger.debug( String.format( "Replacing attached artifact %s. Old path %s, new path %s. ", + a, + logStringForArtifactFile( a ), + logStringForArtifactFile( artifact ) ) ); + } + attachedArtifacts.set( ax, artifact ); + return; } - return; - //throw new DuplicateArtifactAttachmentException( this, artifact ); } getAttachedArtifacts().add( artifact ); diff --git a/maven-core/src/main/java/org/apache/maven/project/MavenProjectHelper.java b/maven-core/src/main/java/org/apache/maven/project/MavenProjectHelper.java index 58b4b2248e..406bbf25b8 100644 --- a/maven-core/src/main/java/org/apache/maven/project/MavenProjectHelper.java +++ b/maven-core/src/main/java/org/apache/maven/project/MavenProjectHelper.java @@ -22,18 +22,54 @@ package org.apache.maven.project; import java.io.File; import java.util.List; +/** + * Convenience interface for plugins to add or replace artifacts and resources on projects. + */ public interface MavenProjectHelper { String ROLE = MavenProjectHelper.class.getName(); + /** + * See {@link #attachArtifact(MavenProject, String, String, java.io.File)}, but with type set to null. + * @param project project reference. + * @param artifactFile artifact file. + * @param artifactClassifier artifact classifier. + */ void attachArtifact( MavenProject project, File artifactFile, String artifactClassifier ); + /** + * * See {@link #attachArtifact(MavenProject, String, String, java.io.File)}, but with classifier set to null. + * @param project project reference. + * @param artifactType artifact type. + * @param artifactFile arrifact file. + */ void attachArtifact( MavenProject project, String artifactType, File artifactFile ); + /** + * Add or replace an artifact to the current project. + * @param project the project reference. + * @param artifactType the type (e.g. jar) or null. + * @param artifactClassifier the classifier or null. + * @param artifactFile the file for the artifact. + */ void attachArtifact( MavenProject project, String artifactType, String artifactClassifier, File artifactFile ); + /** + * Add a resource directory to the project. + * @param project project reference. + * @param resourceDirectory directory. + * @param includes include patterns. + * @param excludes exclude patterns. + */ void addResource( MavenProject project, String resourceDirectory, List includes, List excludes ); + /** + * Add a test resource directory to the project. + * @param project project reference. + * @param resourceDirectory directory. + * @param includes include patterns. + * @param excludes exclude patterns. + */ void addTestResource( MavenProject project, String resourceDirectory, List includes, List excludes ); } 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 a88a0abaa8..0f8262b102 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 @@ -21,8 +21,6 @@ package org.apache.maven.cli; import java.io.IOException; import java.io.InputStream; -import java.io.OutputStream; -import java.io.PrintStream; import java.text.SimpleDateFormat; import java.util.Date; import java.util.Locale; @@ -51,7 +49,7 @@ public final class CLIReportingUtils public static String showVersion() { - String LS = System.getProperty("line.separator"); + final String LS = System.getProperty( "line.separator" ); Properties properties = getBuildProperties(); StringBuffer version = new StringBuffer(); version.append( createMavenVersionString( properties ) ).append( LS ); 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 10d21a2b84..772f984494 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 @@ -55,6 +55,7 @@ import org.apache.maven.execution.MavenExecutionResult; import org.apache.maven.lifecycle.LifecycleExecutionException; import org.apache.maven.lifecycle.internal.LifecycleWeaveBuilder; import org.apache.maven.model.building.ModelProcessor; +import org.apache.maven.plugin.PluginRealmCache; import org.apache.maven.project.MavenProject; import org.apache.maven.properties.internal.EnvironmentUtils; import org.apache.maven.settings.building.DefaultSettingsBuildingRequest; @@ -112,9 +113,6 @@ public class MavenCli private ClassWorld classWorld; - // Per-instance container supports fast embedded execution of core ITs - private DefaultPlexusContainer container; - private LoggerManager plexusLoggerManager; private ILoggerFactory slf4jLoggerFactory; @@ -197,7 +195,7 @@ public class MavenCli // TODO: need to externalize CliRequest public int doMain( CliRequest cliRequest ) { - PlexusContainer localContainer = this.container; + PlexusContainer localContainer = null; try { initialize( cliRequest ); @@ -235,7 +233,7 @@ public class MavenCli } finally { - if ( localContainer != this.container ) + if (localContainer != null) { localContainer.dispose(); } @@ -285,7 +283,7 @@ public class MavenCli if ( cliRequest.commandLine.hasOption( CLIManager.VERSION ) ) { - System.out.println(CLIReportingUtils.showVersion()); + System.out.println( CLIReportingUtils.showVersion() ); throw new ExitException( 0 ); } } @@ -377,10 +375,8 @@ public class MavenCli cliRequest.classWorld = new ClassWorld( "plexus.core", Thread.currentThread().getContextClassLoader() ); } - DefaultPlexusContainer container = this.container; + DefaultPlexusContainer container = null; - if ( container == null ) - { ContainerConfiguration cc = new DefaultContainerConfiguration() .setClassWorld( cliRequest.classWorld ) .setRealm( setupContainerRealm( cliRequest ) ) @@ -405,12 +401,6 @@ public class MavenCli customizeContainer( container ); - if ( cliRequest.classWorld == classWorld ) - { - this.container = container; - } - } - container.getLoggerManager().setThresholds( cliRequest.request.getLoggingLevel() ); Thread.currentThread().setContextClassLoader( container.getContainerRealm() ); @@ -427,7 +417,7 @@ public class MavenCli eventSpyDispatcher.init( eventSpyContext ); // refresh logger in case container got customized by spy - slf4jLogger = slf4jLoggerFactory.getLogger(this.getClass().getName()); + slf4jLogger = slf4jLoggerFactory.getLogger( this.getClass().getName() ); maven = container.lookup( Maven.class ); @@ -885,7 +875,7 @@ public class MavenCli { transferListener = new QuietMavenTransferListener(); } - else if ( request.isInteractiveMode() && !cliRequest.commandLine.hasOption( CLIManager.LOG_FILE )) + else if ( request.isInteractiveMode() && !cliRequest.commandLine.hasOption( CLIManager.LOG_FILE ) ) { // // If we're logging to a file then we don't want the console transfer listener as it will spew diff --git a/maven-embedder/src/main/java/org/apache/maven/cli/transfer/BatchModeMavenTransferListener.java b/maven-embedder/src/main/java/org/apache/maven/cli/transfer/BatchModeMavenTransferListener.java index ca65d943a7..0e20f17f8d 100644 --- a/maven-embedder/src/main/java/org/apache/maven/cli/transfer/BatchModeMavenTransferListener.java +++ b/maven-embedder/src/main/java/org/apache/maven/cli/transfer/BatchModeMavenTransferListener.java @@ -1,7 +1,5 @@ package org.apache.maven.cli.transfer; -import java.io.PrintStream; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -21,6 +19,8 @@ import java.io.PrintStream; * under the License. */ +import java.io.PrintStream; + public class BatchModeMavenTransferListener extends AbstractMavenTransferListener { diff --git a/maven-embedder/src/site/apt/logging.apt b/maven-embedder/src/site/apt/logging.apt index cca01bf974..22fa1ac25a 100644 --- a/maven-embedder/src/site/apt/logging.apt +++ b/maven-embedder/src/site/apt/logging.apt @@ -24,7 +24,11 @@ Maven Logging Plexus Logger can be injected in Plexus component using Plexus annotations +<<<<<<< HEAD +------ +======= ++------+ +>>>>>>> fcffe3c9d5ceb65c229b07f60ad4d215f5cd05e2 import org.codehaus.plexus.logging.Logger; import org.codehaus.plexus.component.annotations.Component; import org.codehaus.plexus.component.annotations.Requirement; @@ -36,11 +40,16 @@ public class DefaultMyComponent @Requirement private Logger logger; } +<<<<<<< HEAD +------ +======= ++------+ +>>>>>>> fcffe3c9d5ceb65c229b07f60ad4d215f5cd05e2 Starting with Maven 3.1.0, SLF4J Logger can be used directly too, without Plexus. Of course, this will only work when run under Maven 3.1.0, then this technique can be used safely only in Maven core components. +<<<<<<< HEAD +----- import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -50,6 +59,17 @@ public class Wombat final Logger logger = LoggerFactory.getLogger(Wombat.class); } +----- +======= ++-----+ +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class MyClass +{ + final Logger logger = LoggerFactory.getLogger( MyClass.class ); +} ++-----+ +>>>>>>> fcffe3c9d5ceb65c229b07f60ad4d215f5cd05e2 * Logger Name