Author: lcorneliussen Date: Thu Jun 20 09:36:39 2013 New Revision: 1494899 URL: http://svn.apache.org/r1494899 Log: [NPANDAY-402]: Add support to automatically attach PDB-symbols and Code-Documentation (comment.xml)
o disable pdb resolving on compile:init, resolve:resolve and compile:compile o added an option to disable pdb resolving for test execution o cache resolver results in order to get better performance Added: incubator/npanday/trunk/components/dotnet-core/src/main/java/npanday/resolver/NPandayResolutionCache.java incubator/npanday/trunk/components/dotnet-core/src/main/java/npanday/resolver/filter/DotnetAssemblyArtifactFilter.java - copied, changed from r1491865, incubator/npanday/trunk/components/dotnet-core/src/main/java/npanday/resolver/filter/DebugSymbolsArtifactFilter.java incubator/npanday/trunk/components/dotnet-core/src/main/java/npanday/resolver/filter/DotnetSymbolsArtifactFilter.java - copied, changed from r1491865, incubator/npanday/trunk/components/dotnet-core/src/main/java/npanday/resolver/filter/DebugSymbolsArtifactFilter.java Removed: incubator/npanday/trunk/components/dotnet-core/src/main/java/npanday/resolver/filter/DebugSymbolsArtifactFilter.java Modified: incubator/npanday/trunk/components/dotnet-core/src/main/java/npanday/ArtifactTypeHelper.java incubator/npanday/trunk/components/dotnet-core/src/main/java/npanday/resolver/ArtifactResolvingContributor.java incubator/npanday/trunk/components/dotnet-core/src/main/java/npanday/resolver/DefaultNPandayArtifactResolver.java incubator/npanday/trunk/components/dotnet-core/src/main/java/npanday/resolver/NPandayArtifactResolver.java incubator/npanday/trunk/components/dotnet-core/src/main/java/npanday/resolver/NPandayDependencyResolution.java incubator/npanday/trunk/components/dotnet-core/src/main/java/npanday/resolver/NPandayResolutionListener.java incubator/npanday/trunk/components/dotnet-core/src/main/java/npanday/resolver/filter/DotnetExecutableArtifactFilter.java incubator/npanday/trunk/components/dotnet-core/src/main/java/npanday/resolver/filter/DotnetLibraryArtifactFilter.java incubator/npanday/trunk/components/dotnet-core/src/main/java/npanday/resolver/filter/OrArtifactFilter.java incubator/npanday/trunk/components/dotnet-core/src/main/java/npanday/resolver/resolvers/ComReferenceResolver.java incubator/npanday/trunk/components/dotnet-core/src/main/java/npanday/resolver/resolvers/GacResolver.java incubator/npanday/trunk/components/dotnet-core/src/main/java/npanday/resolver/resolvers/PdbAssemblyResolver.java incubator/npanday/trunk/components/dotnet-core/src/main/resources/META-INF/plexus/components.xml incubator/npanday/trunk/plugins/application-maven-plugin/src/main/java/npanday/plugin/application/PackagePreparedPackageFoldersMojo.java incubator/npanday/trunk/plugins/maven-compile-plugin/src/main/java/npanday/plugin/compile/AbstractCompilerMojo.java incubator/npanday/trunk/plugins/maven-compile-plugin/src/main/java/npanday/plugin/compile/ComponentInitializerMojo.java incubator/npanday/trunk/plugins/maven-resolver-plugin/src/main/java/npanday/plugin/resolver/CopyDependenciesMojo.java incubator/npanday/trunk/plugins/maven-resolver-plugin/src/main/java/npanday/plugin/resolver/ResolveMojo.java incubator/npanday/trunk/plugins/maven-test-plugin/src/main/java/npanday/plugin/test/TesterMojo.java Modified: incubator/npanday/trunk/components/dotnet-core/src/main/java/npanday/ArtifactTypeHelper.java URL: http://svn.apache.org/viewvc/incubator/npanday/trunk/components/dotnet-core/src/main/java/npanday/ArtifactTypeHelper.java?rev=1494899&r1=1494898&r2=1494899&view=diff ============================================================================== --- incubator/npanday/trunk/components/dotnet-core/src/main/java/npanday/ArtifactTypeHelper.java (original) +++ incubator/npanday/trunk/components/dotnet-core/src/main/java/npanday/ArtifactTypeHelper.java Thu Jun 20 09:36:39 2013 @@ -147,4 +147,14 @@ public class ArtifactTypeHelper { return isDotnetLibraryOrExecutable( ArtifactType.getArtifactTypeForPackagingName( packaging ) ); } + + public static boolean isDotnetAssembly(String packaging) { + return isDotnetAssembly( ArtifactType.getArtifactTypeForPackagingName( packaging ) ); + } + + public static boolean isDotnetAssembly(ArtifactType artifactType) { + return isDotnetLibrary(artifactType) + || isDotnetExecutable(artifactType) + || isDotnetAnyGac(artifactType); + } } Modified: incubator/npanday/trunk/components/dotnet-core/src/main/java/npanday/resolver/ArtifactResolvingContributor.java URL: http://svn.apache.org/viewvc/incubator/npanday/trunk/components/dotnet-core/src/main/java/npanday/resolver/ArtifactResolvingContributor.java?rev=1494899&r1=1494898&r2=1494899&view=diff ============================================================================== --- incubator/npanday/trunk/components/dotnet-core/src/main/java/npanday/resolver/ArtifactResolvingContributor.java (original) +++ incubator/npanday/trunk/components/dotnet-core/src/main/java/npanday/resolver/ArtifactResolvingContributor.java Thu Jun 20 09:36:39 2013 @@ -22,6 +22,7 @@ package npanday.resolver; import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.resolver.ArtifactNotFoundException; +import org.apache.maven.artifact.resolver.filter.ArtifactFilter; import java.util.List; import java.util.Set; @@ -40,19 +41,22 @@ public interface ArtifactResolvingContri * <b>Note:</b><i>run before maven artifact resolver.</i> * @param artifact the artifact to be resolved. * @param additionalDependenciesCollector additional dependencies of resolved artifact. + * @param filter */ - void tryResolve(Artifact artifact, Set<Artifact> additionalDependenciesCollector ) throws ArtifactNotFoundException; + void tryResolve(Artifact artifact, Set<Artifact> additionalDependenciesCollector, ArtifactFilter filter) throws ArtifactNotFoundException; /** * Contribute with additional dependencies for resolved artifact.<br> * * <b>Note:</b><i>run after maven artifact resolver.</i> + * * @param artifact resolved artifact. * @param localRepository maven local repository. * @param remoteRepositories maven remote repositories. * @param additionalDependenciesCollector additional dependencies of resolved artifact. + * @param filter * @throws ArtifactNotFoundException */ void contribute(Artifact artifact, ArtifactRepository localRepository, - List remoteRepositories, Set<Artifact> additionalDependenciesCollector) throws ArtifactNotFoundException; + List remoteRepositories, Set<Artifact> additionalDependenciesCollector, ArtifactFilter filter) throws ArtifactNotFoundException; } Modified: incubator/npanday/trunk/components/dotnet-core/src/main/java/npanday/resolver/DefaultNPandayArtifactResolver.java URL: http://svn.apache.org/viewvc/incubator/npanday/trunk/components/dotnet-core/src/main/java/npanday/resolver/DefaultNPandayArtifactResolver.java?rev=1494899&r1=1494898&r2=1494899&view=diff ============================================================================== --- incubator/npanday/trunk/components/dotnet-core/src/main/java/npanday/resolver/DefaultNPandayArtifactResolver.java (original) +++ incubator/npanday/trunk/components/dotnet-core/src/main/java/npanday/resolver/DefaultNPandayArtifactResolver.java Thu Jun 20 09:36:39 2013 @@ -70,9 +70,10 @@ public class DefaultNPandayArtifactResol private PlexusContainer container; private Set<Artifact> customResolveCache = Sets.newHashSet(); - private Set<Artifact> customDependenciesCache = Sets.newHashSet(); + private ArtifactFilter filter; + public void resolve( Artifact artifact, List remoteRepositories, ArtifactRepository localRepository ) throws ArtifactResolutionException, ArtifactNotFoundException @@ -119,9 +120,11 @@ public class DefaultNPandayArtifactResol private List intercept( List listeners, ArtifactFilter filter, ArtifactRepository localRepository, List remoteRepositories ) { + if (listeners == null) listeners = Lists.newArrayList(); + NPandayResolutionListener listener = new NPandayResolutionListener(this, filter, localRepository, remoteRepositories); listener.enableLogging( getLogger() ); @@ -139,10 +142,12 @@ public class DefaultNPandayArtifactResol public void runArtifactContributors(Artifact artifact, ArtifactRepository localRepository, List remoteRepositories) throws ArtifactNotFoundException { + if(!artifact.isResolved()) { + runCustomResolvers(artifact); + } + if(artifact.isResolved()) { runCustomDependencyContributors(artifact, localRepository, remoteRepositories); - } else { - runCustomResolvers(artifact); } } @@ -160,7 +165,7 @@ public class DefaultNPandayArtifactResol for ( ArtifactResolvingContributor contributor : contributors ) { Set<Artifact> additionalDependenciesCollector = Sets.newHashSet(); - contributor.tryResolve( artifact, additionalDependenciesCollector ); + contributor.tryResolve( artifact, additionalDependenciesCollector, filter ); if ( artifact.isResolved() ) { @@ -197,7 +202,7 @@ public class DefaultNPandayArtifactResol for ( ArtifactResolvingContributor contributor : contributors ) { Set<Artifact> additionalDependenciesCollector = Sets.newHashSet(); - contributor.contribute(artifact, localRepository, remoteRepositories, additionalDependenciesCollector); + contributor.contribute(artifact, localRepository, remoteRepositories, additionalDependenciesCollector, filter); if ( additionalDependenciesCollector.size() > 0 ) { @@ -304,6 +309,10 @@ public class DefaultNPandayArtifactResol remoteRepositories, source, null, listeners ); } + public void initializeWithFilter(ArtifactFilter filter) { + this.filter = filter; + } + public Set<Artifact> getCustomResolveCache() { return customResolveCache; Modified: incubator/npanday/trunk/components/dotnet-core/src/main/java/npanday/resolver/NPandayArtifactResolver.java URL: http://svn.apache.org/viewvc/incubator/npanday/trunk/components/dotnet-core/src/main/java/npanday/resolver/NPandayArtifactResolver.java?rev=1494899&r1=1494898&r2=1494899&view=diff ============================================================================== --- incubator/npanday/trunk/components/dotnet-core/src/main/java/npanday/resolver/NPandayArtifactResolver.java (original) +++ incubator/npanday/trunk/components/dotnet-core/src/main/java/npanday/resolver/NPandayArtifactResolver.java Thu Jun 20 09:36:39 2013 @@ -51,11 +51,19 @@ import java.util.Set; /** * NPanday-flavored implementation of the Artifact resolver. + * + * @author <a href="mailto:m...@lcorneliussen.de>Lars Corneliussen, Faktum Software</a> */ public interface NPandayArtifactResolver extends ArtifactResolver { /** + * Should never try to resolve things that would get excluded by this filter. + * @param filter + */ + public void initializeWithFilter(ArtifactFilter filter); + + /** * All artifacts that have been resolved outside of the maven * core, since they might need special treatment after resolving. * Modified: incubator/npanday/trunk/components/dotnet-core/src/main/java/npanday/resolver/NPandayDependencyResolution.java URL: http://svn.apache.org/viewvc/incubator/npanday/trunk/components/dotnet-core/src/main/java/npanday/resolver/NPandayDependencyResolution.java?rev=1494899&r1=1494898&r2=1494899&view=diff ============================================================================== --- incubator/npanday/trunk/components/dotnet-core/src/main/java/npanday/resolver/NPandayDependencyResolution.java (original) +++ incubator/npanday/trunk/components/dotnet-core/src/main/java/npanday/resolver/NPandayDependencyResolution.java Thu Jun 20 09:36:39 2013 @@ -70,6 +70,10 @@ public class NPandayDependencyResolution MavenProject project, ArtifactRepository localRepository, ArtifactFilter filter ) throws ArtifactResolutionException { + long startTime = System.currentTimeMillis(); + + artifactResolver.initializeWithFilter(filter); + if (getLogger().isDebugEnabled()) { getLogger().debug( "NPANDAY-148-007: Resolving dependencies for " + project.getArtifact() ); } @@ -99,7 +103,12 @@ public class NPandayDependencyResolution Set<Artifact> resultRequire = Sets.newLinkedHashSet(result.getArtifacts()); resultRequire.addAll(artifactResolver.getCustomDependenciesCache()); - + + if (getLogger().isInfoEnabled()) { + long endTime = System.currentTimeMillis(); + getLogger().info( "NPANDAY-148-009: Took " + (endTime - startTime) + "ms to resolve dependencies for " + project.getArtifact() + " with filter " + filter.toString() ); + } + return resultRequire; } catch ( ArtifactResolutionException e ) Added: incubator/npanday/trunk/components/dotnet-core/src/main/java/npanday/resolver/NPandayResolutionCache.java URL: http://svn.apache.org/viewvc/incubator/npanday/trunk/components/dotnet-core/src/main/java/npanday/resolver/NPandayResolutionCache.java?rev=1494899&view=auto ============================================================================== --- incubator/npanday/trunk/components/dotnet-core/src/main/java/npanday/resolver/NPandayResolutionCache.java (added) +++ incubator/npanday/trunk/components/dotnet-core/src/main/java/npanday/resolver/NPandayResolutionCache.java Thu Jun 20 09:36:39 2013 @@ -0,0 +1,57 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT 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 npanday.resolver; + +import com.google.common.collect.Sets; +import org.apache.maven.artifact.Artifact; +import org.codehaus.plexus.logging.AbstractLogEnabled; + +import java.io.File; +import java.util.HashSet; +import java.util.Hashtable; + +/** + * The instance of this cache should span the full maven reactor build. + * Resolving the artifact file once pr. artifact id is enough. + * + * @author <a href="mailto:m...@lcorneliussen.de>Lars Corneliussen, Faktum Software</a> + */ +public class NPandayResolutionCache + extends AbstractLogEnabled +{ + private Hashtable<String, File> cache = new Hashtable<String, File>(); + + public void put(Artifact artifact){ + cache.put(artifact.getId(), artifact.getFile()); + } + + public Boolean applyTo(Artifact artifact){ + String key = artifact.getArtifactId(); + if (cache.containsKey(key)){ + File resolvedFile = cache.get(key); + if (resolvedFile != null){ + artifact.setFile(resolvedFile); + artifact.setResolved(true); + } + return true; + } + return false; + } +} Modified: incubator/npanday/trunk/components/dotnet-core/src/main/java/npanday/resolver/NPandayResolutionListener.java URL: http://svn.apache.org/viewvc/incubator/npanday/trunk/components/dotnet-core/src/main/java/npanday/resolver/NPandayResolutionListener.java?rev=1494899&r1=1494898&r2=1494899&view=diff ============================================================================== --- incubator/npanday/trunk/components/dotnet-core/src/main/java/npanday/resolver/NPandayResolutionListener.java (original) +++ incubator/npanday/trunk/components/dotnet-core/src/main/java/npanday/resolver/NPandayResolutionListener.java Thu Jun 20 09:36:39 2013 @@ -55,19 +55,7 @@ public class NPandayResolutionListener public void testArtifact( Artifact node ) { - if ( filter != null && !filter.include( node ) ) - { - return; - } - try - { - resolver.runArtifactContributors( node, localRepository, remoteRepositories ); - } - catch ( ArtifactNotFoundException e ) - { - throw new RuntimeException( "NPANDAY-159-000: Error finding artifact " + node, e ); - } } public void startProcessChildren( Artifact artifact ) @@ -80,6 +68,19 @@ public class NPandayResolutionListener public void includeArtifact( Artifact artifact ) { + if ( filter != null && !filter.include( artifact ) ) + { + return; + } + + try + { + resolver.runArtifactContributors( artifact, localRepository, remoteRepositories ); + } + catch ( ArtifactNotFoundException e ) + { + throw new RuntimeException( "NPANDAY-159-000: Error finding artifact " + artifact, e ); + } } public void omitForNearer( Artifact omitted, Artifact kept ) Copied: incubator/npanday/trunk/components/dotnet-core/src/main/java/npanday/resolver/filter/DotnetAssemblyArtifactFilter.java (from r1491865, incubator/npanday/trunk/components/dotnet-core/src/main/java/npanday/resolver/filter/DebugSymbolsArtifactFilter.java) URL: http://svn.apache.org/viewvc/incubator/npanday/trunk/components/dotnet-core/src/main/java/npanday/resolver/filter/DotnetAssemblyArtifactFilter.java?p2=incubator/npanday/trunk/components/dotnet-core/src/main/java/npanday/resolver/filter/DotnetAssemblyArtifactFilter.java&p1=incubator/npanday/trunk/components/dotnet-core/src/main/java/npanday/resolver/filter/DebugSymbolsArtifactFilter.java&r1=1491865&r2=1494899&rev=1494899&view=diff ============================================================================== --- incubator/npanday/trunk/components/dotnet-core/src/main/java/npanday/resolver/filter/DebugSymbolsArtifactFilter.java (original) +++ incubator/npanday/trunk/components/dotnet-core/src/main/java/npanday/resolver/filter/DotnetAssemblyArtifactFilter.java Thu Jun 20 09:36:39 2013 @@ -27,11 +27,16 @@ import org.apache.maven.artifact.resolve /** * @author <a href="m...@lcorneliussen.de">Lars Corneliussen, Faktum Software</a> */ -public class DebugSymbolsArtifactFilter +public class DotnetAssemblyArtifactFilter implements ArtifactFilter { public boolean include( Artifact artifact ) { - return artifact.getType() == ArtifactType.DOTNET_SYMBOLS.getPackagingType(); + return ArtifactTypeHelper.isDotnetAssembly(artifact.getType()); + } + + @Override + public String toString() { + return "DotnetAssembly"; } } Modified: incubator/npanday/trunk/components/dotnet-core/src/main/java/npanday/resolver/filter/DotnetExecutableArtifactFilter.java URL: http://svn.apache.org/viewvc/incubator/npanday/trunk/components/dotnet-core/src/main/java/npanday/resolver/filter/DotnetExecutableArtifactFilter.java?rev=1494899&r1=1494898&r2=1494899&view=diff ============================================================================== --- incubator/npanday/trunk/components/dotnet-core/src/main/java/npanday/resolver/filter/DotnetExecutableArtifactFilter.java (original) +++ incubator/npanday/trunk/components/dotnet-core/src/main/java/npanday/resolver/filter/DotnetExecutableArtifactFilter.java Thu Jun 20 09:36:39 2013 @@ -33,4 +33,9 @@ public class DotnetExecutableArtifactFil { return ArtifactTypeHelper.isDotnetExecutable( artifact.getType() ); } + + @Override + public String toString() { + return "DotnetExecutable"; + } } Modified: incubator/npanday/trunk/components/dotnet-core/src/main/java/npanday/resolver/filter/DotnetLibraryArtifactFilter.java URL: http://svn.apache.org/viewvc/incubator/npanday/trunk/components/dotnet-core/src/main/java/npanday/resolver/filter/DotnetLibraryArtifactFilter.java?rev=1494899&r1=1494898&r2=1494899&view=diff ============================================================================== --- incubator/npanday/trunk/components/dotnet-core/src/main/java/npanday/resolver/filter/DotnetLibraryArtifactFilter.java (original) +++ incubator/npanday/trunk/components/dotnet-core/src/main/java/npanday/resolver/filter/DotnetLibraryArtifactFilter.java Thu Jun 20 09:36:39 2013 @@ -33,4 +33,9 @@ public class DotnetLibraryArtifactFilter { return ArtifactTypeHelper.isDotnetLibrary( artifact.getType() ); } + + @Override + public String toString() { + return "DotnetLibrary"; + } } Copied: incubator/npanday/trunk/components/dotnet-core/src/main/java/npanday/resolver/filter/DotnetSymbolsArtifactFilter.java (from r1491865, incubator/npanday/trunk/components/dotnet-core/src/main/java/npanday/resolver/filter/DebugSymbolsArtifactFilter.java) URL: http://svn.apache.org/viewvc/incubator/npanday/trunk/components/dotnet-core/src/main/java/npanday/resolver/filter/DotnetSymbolsArtifactFilter.java?p2=incubator/npanday/trunk/components/dotnet-core/src/main/java/npanday/resolver/filter/DotnetSymbolsArtifactFilter.java&p1=incubator/npanday/trunk/components/dotnet-core/src/main/java/npanday/resolver/filter/DebugSymbolsArtifactFilter.java&r1=1491865&r2=1494899&rev=1494899&view=diff ============================================================================== --- incubator/npanday/trunk/components/dotnet-core/src/main/java/npanday/resolver/filter/DebugSymbolsArtifactFilter.java (original) +++ incubator/npanday/trunk/components/dotnet-core/src/main/java/npanday/resolver/filter/DotnetSymbolsArtifactFilter.java Thu Jun 20 09:36:39 2013 @@ -27,11 +27,16 @@ import org.apache.maven.artifact.resolve /** * @author <a href="m...@lcorneliussen.de">Lars Corneliussen, Faktum Software</a> */ -public class DebugSymbolsArtifactFilter +public class DotnetSymbolsArtifactFilter implements ArtifactFilter { public boolean include( Artifact artifact ) { return artifact.getType() == ArtifactType.DOTNET_SYMBOLS.getPackagingType(); } + + @Override + public String toString() { + return "DotnetSymbols"; + } } Modified: incubator/npanday/trunk/components/dotnet-core/src/main/java/npanday/resolver/filter/OrArtifactFilter.java URL: http://svn.apache.org/viewvc/incubator/npanday/trunk/components/dotnet-core/src/main/java/npanday/resolver/filter/OrArtifactFilter.java?rev=1494899&r1=1494898&r2=1494899&view=diff ============================================================================== --- incubator/npanday/trunk/components/dotnet-core/src/main/java/npanday/resolver/filter/OrArtifactFilter.java (original) +++ incubator/npanday/trunk/components/dotnet-core/src/main/java/npanday/resolver/filter/OrArtifactFilter.java Thu Jun 20 09:36:39 2013 @@ -53,5 +53,10 @@ public class OrArtifactFilter { filters.add( artifactFilter ); } + + @Override + public String toString() { + return "Or{" + filters + '}'; + } } Modified: incubator/npanday/trunk/components/dotnet-core/src/main/java/npanday/resolver/resolvers/ComReferenceResolver.java URL: http://svn.apache.org/viewvc/incubator/npanday/trunk/components/dotnet-core/src/main/java/npanday/resolver/resolvers/ComReferenceResolver.java?rev=1494899&r1=1494898&r2=1494899&view=diff ============================================================================== --- incubator/npanday/trunk/components/dotnet-core/src/main/java/npanday/resolver/resolvers/ComReferenceResolver.java (original) +++ incubator/npanday/trunk/components/dotnet-core/src/main/java/npanday/resolver/resolvers/ComReferenceResolver.java Thu Jun 20 09:36:39 2013 @@ -21,8 +21,10 @@ package npanday.resolver.resolvers; import npanday.ArtifactTypeHelper; import npanday.resolver.ArtifactResolvingContributor; +import npanday.resolver.NPandayResolutionCache; import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.repository.ArtifactRepository; +import org.apache.maven.artifact.resolver.filter.ArtifactFilter; import org.codehaus.plexus.logging.AbstractLogEnabled; import org.codehaus.plexus.util.Os; import org.codehaus.plexus.util.cli.CommandLineException; @@ -49,13 +51,15 @@ public class ComReferenceResolver extends AbstractLogEnabled implements ArtifactResolvingContributor { - public void contribute(Artifact artifact, ArtifactRepository localRepository, List remoteRepositories, - Set<Artifact> additionalDependenciesCollector) + NPandayResolutionCache cache; + + public void contribute(Artifact artifact, ArtifactRepository localRepository, List remoteRepositories, + Set<Artifact> additionalDependenciesCollector, ArtifactFilter filter) { // NO-OP } - public void tryResolve( Artifact artifact, Set<Artifact> additionalDependenciesCollector ) + public void tryResolve(Artifact artifact, Set<Artifact> additionalDependenciesCollector, ArtifactFilter filter) { // resolve com reference // flow: @@ -64,6 +68,10 @@ public class ComReferenceResolver // MavenProject (CompilerContext.java) if ( ArtifactTypeHelper.isComReference(artifact.getType()) ) { + if (cache.applyTo(artifact)){ + return; + } + String tokenId = artifact.getClassifier(); String interopPath = null; try @@ -89,6 +97,7 @@ public class ComReferenceResolver artifact.setFile( f ); artifact.setResolved( true ); + cache.put(artifact); } } Modified: incubator/npanday/trunk/components/dotnet-core/src/main/java/npanday/resolver/resolvers/GacResolver.java URL: http://svn.apache.org/viewvc/incubator/npanday/trunk/components/dotnet-core/src/main/java/npanday/resolver/resolvers/GacResolver.java?rev=1494899&r1=1494898&r2=1494899&view=diff ============================================================================== --- incubator/npanday/trunk/components/dotnet-core/src/main/java/npanday/resolver/resolvers/GacResolver.java (original) +++ incubator/npanday/trunk/components/dotnet-core/src/main/java/npanday/resolver/resolvers/GacResolver.java Thu Jun 20 09:36:39 2013 @@ -22,9 +22,11 @@ package npanday.resolver.resolvers; import npanday.ArtifactTypeHelper; import npanday.PathUtil; import npanday.resolver.ArtifactResolvingContributor; +import npanday.resolver.NPandayResolutionCache; import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.resolver.ArtifactNotFoundException; +import org.apache.maven.artifact.resolver.filter.ArtifactFilter; import java.io.File; import java.util.List; @@ -36,7 +38,9 @@ import java.util.Set; public class GacResolver implements ArtifactResolvingContributor { - public void tryResolve( Artifact artifact, Set<Artifact> additionalDependenciesCollector ) throws + NPandayResolutionCache cache; + + public void tryResolve(Artifact artifact, Set<Artifact> additionalDependenciesCollector, ArtifactFilter filter) throws ArtifactNotFoundException { @@ -45,6 +49,10 @@ public class GacResolver if ( ArtifactTypeHelper.isDotnetAnyGac( artifactType ) ) { + if (cache.applyTo(artifact)){ + return; + } + if ( !ArtifactTypeHelper.isDotnet4Gac( artifactType ) ) { artifactFile = PathUtil.getGlobalAssemblyCacheFileFor( @@ -60,6 +68,7 @@ public class GacResolver { artifact.setFile( artifactFile ); artifact.setResolved( true ); + cache.put(artifact); } else { @@ -73,7 +82,7 @@ public class GacResolver } public void contribute(Artifact artifact, ArtifactRepository localRepository, List remoteRepositories, - Set<Artifact> additionalDependenciesCollector) throws ArtifactNotFoundException + Set<Artifact> additionalDependenciesCollector, ArtifactFilter filter) throws ArtifactNotFoundException { // NO-OP } Modified: incubator/npanday/trunk/components/dotnet-core/src/main/java/npanday/resolver/resolvers/PdbAssemblyResolver.java URL: http://svn.apache.org/viewvc/incubator/npanday/trunk/components/dotnet-core/src/main/java/npanday/resolver/resolvers/PdbAssemblyResolver.java?rev=1494899&r1=1494898&r2=1494899&view=diff ============================================================================== --- incubator/npanday/trunk/components/dotnet-core/src/main/java/npanday/resolver/resolvers/PdbAssemblyResolver.java (original) +++ incubator/npanday/trunk/components/dotnet-core/src/main/java/npanday/resolver/resolvers/PdbAssemblyResolver.java Thu Jun 20 09:36:39 2013 @@ -3,12 +3,14 @@ package npanday.resolver.resolvers; import java.util.List; import java.util.Set; +import npanday.resolver.NPandayResolutionCache; import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.factory.ArtifactFactory; import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.resolver.ArtifactNotFoundException; import org.apache.maven.artifact.resolver.ArtifactResolutionException; import org.apache.maven.artifact.resolver.ArtifactResolver; +import org.apache.maven.artifact.resolver.filter.ArtifactFilter; import org.codehaus.plexus.logging.AbstractLogEnabled; import npanday.ArtifactType; @@ -20,15 +22,15 @@ import npanday.resolver.ArtifactResolvin */ public class PdbAssemblyResolver extends AbstractLogEnabled implements ArtifactResolvingContributor { - ArtifactResolver mavenResolver; ArtifactFactory artifactFactory; - + + NPandayResolutionCache cache; /** * {@inheritDoc} */ - public void tryResolve(Artifact artifact, Set<Artifact> additionalDependenciesCollector) + public void tryResolve(Artifact artifact, Set<Artifact> additionalDependenciesCollector, ArtifactFilter filter) throws ArtifactNotFoundException { // NO-OP @@ -38,9 +40,9 @@ public class PdbAssemblyResolver extends /** * {@inheritDoc} */ - public void contribute(Artifact artifact, ArtifactRepository localRepository, - @SuppressWarnings("rawtypes") List remoteRepositories, - Set<Artifact> additionalDependenciesCollector) throws ArtifactNotFoundException + public void contribute(Artifact artifact, ArtifactRepository localRepository, + @SuppressWarnings("rawtypes") List remoteRepositories, + Set<Artifact> additionalDependenciesCollector, ArtifactFilter filter) throws ArtifactNotFoundException { final ArtifactType artifactType = ArtifactType.getArtifactTypeForPackagingName(artifact.getType()); if ( !ArtifactTypeHelper.isDotnetAnyGac(artifactType) && @@ -48,36 +50,51 @@ public class PdbAssemblyResolver extends ArtifactTypeHelper.isDotnetLibraryOrExecutable(artifactType)) { tryResolveArtifactPdbAssembly(artifact, localRepository, remoteRepositories, - additionalDependenciesCollector); + additionalDependenciesCollector, filter); } } - /** * Try to resolve PDB artifact for given artifact. + * * @param artifact * @param localRepository * @param remoteRepositories * @param additionalDependenciesCollector + * @param filter * @throws ArtifactNotFoundException */ - private void tryResolveArtifactPdbAssembly(Artifact artifact, ArtifactRepository localRepository, - List remoteRepositories, Set<Artifact> additionalDependenciesCollector) throws ArtifactNotFoundException + private void tryResolveArtifactPdbAssembly(Artifact artifact, ArtifactRepository localRepository, + List remoteRepositories, Set<Artifact> additionalDependenciesCollector, ArtifactFilter filter) throws ArtifactNotFoundException { Artifact pdbArtifact = artifactFactory.createArtifactWithClassifier(artifact.getGroupId(), artifact.getArtifactId(), artifact.getVersion(), ArtifactType.DOTNET_SYMBOLS.getPackagingType(), artifact.getClassifier()); - try { - mavenResolver.resolve(pdbArtifact, remoteRepositories, localRepository); + pdbArtifact.setScope(artifact.getScope()); + pdbArtifact.setRelease(artifact.isRelease()); + pdbArtifact.setDependencyTrail(artifact.getDependencyTrail()); + + if(filter != null && !filter.include(pdbArtifact)){ + getLogger().debug("NPANDAY-157-003: resolving pdb for " + artifact.getId() + " was excluded by a filter"); + return; + } - // the complimentary artifact should have the same scope as the leading one - pdbArtifact.setScope(artifact.getScope()); + Boolean wasCached = cache.applyTo(pdbArtifact); + if (!wasCached) { + try { + mavenResolver.resolve(pdbArtifact, remoteRepositories, localRepository); + // the complimentary artifact should have the same scope as the leading one + getLogger().debug("NPANDAY-157-001: found a pdb for " + artifact.getId()); + + } catch (ArtifactNotFoundException e) { + getLogger().debug("NPANDAY-157-002: no pdb found for " + artifact.getId()); + } catch (ArtifactResolutionException e) { + throw new ArtifactNotFoundException(e.getMessage(), artifact); + } - getLogger().debug("NPANDAY-157-001: found a pdb for " + artifact.getId()); + cache.put(artifact); + } + if (pdbArtifact.isResolved()){ additionalDependenciesCollector.add(pdbArtifact); - } catch (ArtifactNotFoundException e) { - getLogger().debug("NPANDAY-157-002: no pdb found for " + artifact.getId()); - } catch (ArtifactResolutionException e) { - throw new ArtifactNotFoundException(e.getMessage(), artifact); } } } Modified: incubator/npanday/trunk/components/dotnet-core/src/main/resources/META-INF/plexus/components.xml URL: http://svn.apache.org/viewvc/incubator/npanday/trunk/components/dotnet-core/src/main/resources/META-INF/plexus/components.xml?rev=1494899&r1=1494898&r2=1494899&view=diff ============================================================================== --- incubator/npanday/trunk/components/dotnet-core/src/main/resources/META-INF/plexus/components.xml (original) +++ incubator/npanday/trunk/components/dotnet-core/src/main/resources/META-INF/plexus/components.xml Thu Jun 20 09:36:39 2013 @@ -51,12 +51,22 @@ <role>npanday.resolver.ArtifactResolvingContributor</role> <role-hint>gac</role-hint> <implementation>npanday.resolver.resolvers.GacResolver</implementation> + <requirements> + <requirement> + <role>npanday.resolver.NPandayResolutionCache</role> + </requirement> + </requirements> </component> <component> <role>npanday.resolver.ArtifactResolvingContributor</role> <role-hint>com</role-hint> <implementation>npanday.resolver.resolvers.ComReferenceResolver</implementation> + <requirements> + <requirement> + <role>npanday.resolver.NPandayResolutionCache</role> + </requirement> + </requirements> </component> <component> @@ -70,7 +80,16 @@ <requirement> <role>org.apache.maven.artifact.factory.ArtifactFactory</role> </requirement> + <requirement> + <role>npanday.resolver.NPandayResolutionCache</role> + </requirement> </requirements> </component> + + <component> + <role>npanday.resolver.NPandayResolutionCache</role> + <implementation>npanday.resolver.NPandayResolutionCache</implementation> + </component> + </components> </component-set> Modified: incubator/npanday/trunk/plugins/application-maven-plugin/src/main/java/npanday/plugin/application/PackagePreparedPackageFoldersMojo.java URL: http://svn.apache.org/viewvc/incubator/npanday/trunk/plugins/application-maven-plugin/src/main/java/npanday/plugin/application/PackagePreparedPackageFoldersMojo.java?rev=1494899&r1=1494898&r2=1494899&view=diff ============================================================================== --- incubator/npanday/trunk/plugins/application-maven-plugin/src/main/java/npanday/plugin/application/PackagePreparedPackageFoldersMojo.java (original) +++ incubator/npanday/trunk/plugins/application-maven-plugin/src/main/java/npanday/plugin/application/PackagePreparedPackageFoldersMojo.java Thu Jun 20 09:36:39 2013 @@ -23,7 +23,9 @@ import com.google.common.collect.Lists; import npanday.ArtifactType; import npanday.LocalRepositoryUtil; import npanday.resolver.NPandayDependencyResolution; +import npanday.resolver.filter.OrArtifactFilter; import org.apache.maven.artifact.resolver.ArtifactResolutionException; +import org.apache.maven.artifact.resolver.filter.AndArtifactFilter; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoFailureException; import org.apache.maven.project.MavenProject; Modified: incubator/npanday/trunk/plugins/maven-compile-plugin/src/main/java/npanday/plugin/compile/AbstractCompilerMojo.java URL: http://svn.apache.org/viewvc/incubator/npanday/trunk/plugins/maven-compile-plugin/src/main/java/npanday/plugin/compile/AbstractCompilerMojo.java?rev=1494899&r1=1494898&r2=1494899&view=diff ============================================================================== --- incubator/npanday/trunk/plugins/maven-compile-plugin/src/main/java/npanday/plugin/compile/AbstractCompilerMojo.java (original) +++ incubator/npanday/trunk/plugins/maven-compile-plugin/src/main/java/npanday/plugin/compile/AbstractCompilerMojo.java Thu Jun 20 09:36:39 2013 @@ -35,9 +35,13 @@ import npanday.executable.compiler.Compi import npanday.executable.compiler.CompilerRequirement; import npanday.registry.RepositoryRegistry; import npanday.resolver.NPandayDependencyResolution; +import npanday.resolver.filter.DotnetAssemblyArtifactFilter; +import npanday.resolver.filter.OrArtifactFilter; import npanday.vendor.SettingsUtil; import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.resolver.ArtifactResolutionException; +import org.apache.maven.artifact.resolver.filter.AndArtifactFilter; +import org.apache.maven.artifact.resolver.filter.ScopeArtifactFilter; import org.apache.maven.plugin.AbstractMojo; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.project.MavenProject; @@ -1150,7 +1154,11 @@ public abstract class AbstractCompilerMo String scope = test ? "test" : "compile"; try { - dependencyResolution.require( project, LocalRepositoryUtil.create( localRepository ), scope ); + AndArtifactFilter filter = new AndArtifactFilter(); + filter.add(new ScopeArtifactFilter(scope)); + filter.add(new DotnetAssemblyArtifactFilter()); + + dependencyResolution.require( project, LocalRepositoryUtil.create( localRepository ), filter ); } catch ( ArtifactResolutionException e ) { Modified: incubator/npanday/trunk/plugins/maven-compile-plugin/src/main/java/npanday/plugin/compile/ComponentInitializerMojo.java URL: http://svn.apache.org/viewvc/incubator/npanday/trunk/plugins/maven-compile-plugin/src/main/java/npanday/plugin/compile/ComponentInitializerMojo.java?rev=1494899&r1=1494898&r2=1494899&view=diff ============================================================================== --- incubator/npanday/trunk/plugins/maven-compile-plugin/src/main/java/npanday/plugin/compile/ComponentInitializerMojo.java (original) +++ incubator/npanday/trunk/plugins/maven-compile-plugin/src/main/java/npanday/plugin/compile/ComponentInitializerMojo.java Thu Jun 20 09:36:39 2013 @@ -23,7 +23,11 @@ import npanday.InitializationException; import npanday.LocalRepositoryUtil; import npanday.assembler.AssemblerContext; import npanday.resolver.NPandayDependencyResolution; +import npanday.resolver.filter.DotnetAssemblyArtifactFilter; +import npanday.resolver.filter.OrArtifactFilter; import org.apache.maven.artifact.resolver.ArtifactResolutionException; +import org.apache.maven.artifact.resolver.filter.AndArtifactFilter; +import org.apache.maven.artifact.resolver.filter.ScopeArtifactFilter; import org.apache.maven.plugin.AbstractMojo; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.project.MavenProject; @@ -75,7 +79,11 @@ public class ComponentInitializerMojo // TODO: sadly we must resolve dependencies here because of 'org.apache.maven.plugins:maven-remote-resources-plugin:1.2.1:process' running later try { - dependencyResolution.require( project, LocalRepositoryUtil.create( localRepository ), "test" ); + AndArtifactFilter filter = new AndArtifactFilter(); + filter.add(new ScopeArtifactFilter("test")); + filter.add(new DotnetAssemblyArtifactFilter()); + + dependencyResolution.require( project, LocalRepositoryUtil.create( localRepository ), filter ); } catch ( ArtifactResolutionException e ) { Modified: incubator/npanday/trunk/plugins/maven-resolver-plugin/src/main/java/npanday/plugin/resolver/CopyDependenciesMojo.java URL: http://svn.apache.org/viewvc/incubator/npanday/trunk/plugins/maven-resolver-plugin/src/main/java/npanday/plugin/resolver/CopyDependenciesMojo.java?rev=1494899&r1=1494898&r2=1494899&view=diff ============================================================================== --- incubator/npanday/trunk/plugins/maven-resolver-plugin/src/main/java/npanday/plugin/resolver/CopyDependenciesMojo.java (original) +++ incubator/npanday/trunk/plugins/maven-resolver-plugin/src/main/java/npanday/plugin/resolver/CopyDependenciesMojo.java Thu Jun 20 09:36:39 2013 @@ -25,13 +25,12 @@ import npanday.LocalRepositoryUtil; import npanday.PathUtil; import npanday.registry.RepositoryRegistry; import npanday.resolver.NPandayDependencyResolution; -import npanday.resolver.filter.DebugSymbolsArtifactFilter; +import npanday.resolver.filter.DotnetSymbolsArtifactFilter; import npanday.resolver.filter.DotnetExecutableArtifactFilter; import npanday.resolver.filter.DotnetLibraryArtifactFilter; import npanday.resolver.filter.OrArtifactFilter; import npanday.vendor.SettingsUtil; import org.apache.maven.artifact.Artifact; -import org.apache.maven.artifact.metadata.ArtifactMetadata; import org.apache.maven.artifact.resolver.ArtifactResolutionException; import org.apache.maven.artifact.resolver.filter.AndArtifactFilter; import org.apache.maven.artifact.resolver.filter.ArtifactFilter; @@ -161,7 +160,7 @@ public class CopyDependenciesMojo typeIncludes.add( new DotnetLibraryArtifactFilter() ); if (includePdbs){ - typeIncludes.add( new DebugSymbolsArtifactFilter() ); + typeIncludes.add( new DotnetSymbolsArtifactFilter() ); } includeFilter.add( typeIncludes ); Modified: incubator/npanday/trunk/plugins/maven-resolver-plugin/src/main/java/npanday/plugin/resolver/ResolveMojo.java URL: http://svn.apache.org/viewvc/incubator/npanday/trunk/plugins/maven-resolver-plugin/src/main/java/npanday/plugin/resolver/ResolveMojo.java?rev=1494899&r1=1494898&r2=1494899&view=diff ============================================================================== --- incubator/npanday/trunk/plugins/maven-resolver-plugin/src/main/java/npanday/plugin/resolver/ResolveMojo.java (original) +++ incubator/npanday/trunk/plugins/maven-resolver-plugin/src/main/java/npanday/plugin/resolver/ResolveMojo.java Thu Jun 20 09:36:39 2013 @@ -23,6 +23,9 @@ import npanday.LocalRepositoryUtil; import npanday.registry.RepositoryRegistry; import npanday.resolver.NPandayArtifactResolver; import npanday.resolver.NPandayDependencyResolution; +import npanday.resolver.filter.DotnetAssemblyArtifactFilter; +import npanday.resolver.filter.DotnetSymbolsArtifactFilter; +import npanday.resolver.filter.OrArtifactFilter; import npanday.vendor.SettingsUtil; import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.factory.ArtifactFactory; @@ -30,6 +33,8 @@ import org.apache.maven.artifact.metadat import org.apache.maven.artifact.resolver.ArtifactNotFoundException; import org.apache.maven.artifact.resolver.ArtifactResolutionException; import org.apache.maven.artifact.resolver.ArtifactResolutionResult; +import org.apache.maven.artifact.resolver.filter.AndArtifactFilter; +import org.apache.maven.artifact.resolver.filter.ScopeArtifactFilter; import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException; import org.apache.maven.artifact.versioning.VersionRange; import org.apache.maven.model.Dependency; @@ -81,17 +86,22 @@ public class ResolveMojo private File localRepository; /** - * @parameter default-value="test" + * @parameter expression="${resolve.requiredScope}" default-value="test" */ private String requiredScope; /** + * @parameter expression="${resolve.pdbs}" default-value="false" + */ + private Boolean resolvePdbs; + + /** * @component */ private NPandayDependencyResolution dependencyResolution; /** - * @parameter default-value="false" + * @parameter expression="${resolve.skip}" default-value="false" */ private boolean skip; @@ -112,6 +122,15 @@ public class ResolveMojo try { + AndArtifactFilter filter = new AndArtifactFilter(); + filter.add(new ScopeArtifactFilter(requiredScope)); + + OrArtifactFilter types = new OrArtifactFilter(); + types.add(new DotnetAssemblyArtifactFilter()); + if (resolvePdbs){ + types.add(new DotnetSymbolsArtifactFilter()); + } + dependencyResolution.require( project, LocalRepositoryUtil.create( localRepository ), requiredScope ); } catch ( ArtifactResolutionException e ) Modified: incubator/npanday/trunk/plugins/maven-test-plugin/src/main/java/npanday/plugin/test/TesterMojo.java URL: http://svn.apache.org/viewvc/incubator/npanday/trunk/plugins/maven-test-plugin/src/main/java/npanday/plugin/test/TesterMojo.java?rev=1494899&r1=1494898&r2=1494899&view=diff ============================================================================== --- incubator/npanday/trunk/plugins/maven-test-plugin/src/main/java/npanday/plugin/test/TesterMojo.java (original) +++ incubator/npanday/trunk/plugins/maven-test-plugin/src/main/java/npanday/plugin/test/TesterMojo.java Thu Jun 20 09:36:39 2013 @@ -30,10 +30,15 @@ import npanday.executable.NetExecutable; import npanday.executable.NetExecutableFactory; import npanday.registry.RepositoryRegistry; import npanday.resolver.NPandayDependencyResolution; +import npanday.resolver.filter.DotnetAssemblyArtifactFilter; +import npanday.resolver.filter.DotnetSymbolsArtifactFilter; +import npanday.resolver.filter.OrArtifactFilter; import npanday.vendor.SettingsUtil; import npanday.vendor.StateMachineProcessor; import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.resolver.ArtifactResolutionException; +import org.apache.maven.artifact.resolver.filter.AndArtifactFilter; +import org.apache.maven.artifact.resolver.filter.InversionArtifactFilter; import org.apache.maven.artifact.resolver.filter.ScopeArtifactFilter; import org.apache.maven.plugin.AbstractMojo; import org.apache.maven.plugin.MojoExecutionException; @@ -147,7 +152,15 @@ public class TesterMojo * @component */ private NPandayDependencyResolution dependencyResolution; - + + /** + * Specifies if debug symbols for all dependencies should be resolved and copied to the test directory. + * + * @parameter expression = "${test.resolvePdbs}" default-value="true" + */ + private Boolean resolvePdbs; + + private File getExecutableHome() { return (nunitHome != null) ? new File(nunitHome, "bin") : null; @@ -163,9 +176,6 @@ public class TesterMojo testAssemblyPath = "/" + testAssemblyPath; } - - - commands.add( testAssemblyPath + File.separator + getTestFileName() ); String switchChar = "-"; @@ -224,12 +234,19 @@ public class TesterMojo return; } - List<Artifact> nunitLibs = new ArrayList<Artifact>(); Set<Artifact> artifacts; try { + AndArtifactFilter filter = new AndArtifactFilter(); + filter.add(new ScopeArtifactFilter("test")); + filter.add(new DotnetAssemblyArtifactFilter()); + + if (!resolvePdbs){ + filter.add(new InversionArtifactFilter(new DotnetSymbolsArtifactFilter())); + } + artifacts = dependencyResolution.require( - project, LocalRepositoryUtil.create( localRepository ), new ScopeArtifactFilter( "test" ) + project, LocalRepositoryUtil.create( localRepository ), filter ); } catch ( ArtifactResolutionException e )