Skip to content
This repository has been archived by the owner on Aug 11, 2020. It is now read-only.

Commit

Permalink
Helping peter with nexus-qe
Browse files Browse the repository at this point in the history
git-svn-id: file:///opt/svn/repositories/sonatype.org/plugins/trunk/nexus-test-environment-maven-plugin@530 c2a14038-686d-4adc-8740-a14e5738cb64
  • Loading branch information
velo committed Sep 29, 2010
1 parent 9d42bf6 commit 011436f
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 2 deletions.
Expand Up @@ -49,6 +49,7 @@
import org.codehaus.plexus.util.FileUtils;
import org.codehaus.plexus.util.IOUtil;
import org.codehaus.plexus.util.io.RawInputStreamFacade;
import org.sonatype.plugin.nexus.testenvironment.filter.TestScopeFilter;
import org.sonatype.plugins.portallocator.Port;
import org.sonatype.plugins.portallocator.PortAllocatorMojo;

Expand Down Expand Up @@ -237,6 +238,13 @@ public class AbstractEnvironmentMojo
@SuppressWarnings( "rawtypes" )
private Map staticPorts;

/**
* If true plugin won't include nexus-plugin dependencies with scope test
*
* @parameter
*/
private boolean excludeTestDependencies;

public void execute()
throws MojoExecutionException, MojoFailureException
{
Expand Down Expand Up @@ -817,8 +825,9 @@ private void setupPlugins( File nexusBaseDir, Collection<MavenArtifact> nexusPlu
Collection<Artifact> nonTransitivePlugins = getNonTransitivePlugins( plugins );
for ( Artifact artifact : nonTransitivePlugins )
{
final MavenArtifact ma = new MavenArtifact( artifact.getGroupId(), artifact.getArtifactId(),
artifact.getClassifier(), artifact.getType() );
final MavenArtifact ma =
new MavenArtifact( artifact.getGroupId(), artifact.getArtifactId(), artifact.getClassifier(),
artifact.getType() );
ma.setVersion( artifact.getVersion() );
nexusPluginsArtifacts.add( ma );
}
Expand Down Expand Up @@ -1026,6 +1035,11 @@ private FilterArtifacts getFilters( String groupId, String artifactId, String ty
{
filter.addFilter( new ArtifactIdFilter( artifactId, null ) );
}

if ( excludeTestDependencies )
{
filter.addFilter( new TestScopeFilter() );
}
return filter;
}

Expand Down Expand Up @@ -1102,6 +1116,14 @@ private Collection<Artifact> getNonTransitivePlugins( Set<Artifact> projectArtif
plugins.addAll( filtterArtifacts( result, getFilters( null, null, "nexus-plugin", null ) ) );
plugins.addAll( filtterArtifacts( result, getFilters( null, null, "zip", "bundle" ) ) );
plugins.addAll( getNonTransitivePlugins( plugins ) );

if ( !plugins.isEmpty() )
{
getLog().debug(
"Adding non-transitive dependencies for: " + artifact + " -\n"
+ plugins.toString().replace( ',', '\n' ) );
}

deps.addAll( plugins );
}

Expand Down
@@ -0,0 +1,37 @@
package org.sonatype.plugin.nexus.testenvironment.filter;

import java.util.Iterator;
import java.util.Set;

import org.apache.maven.artifact.Artifact;
import org.apache.maven.shared.artifact.filter.collection.AbstractArtifactsFilter;
import org.apache.maven.shared.artifact.filter.collection.ArtifactFilterException;

public class TestScopeFilter
extends AbstractArtifactsFilter
{

@Override
public boolean isArtifactIncluded( Artifact artifact )
{
if ( Artifact.SCOPE_TEST.equals( artifact.getScope() ) )
{
return false;
}
return true;
}

public Set filter( Set artifacts )
throws ArtifactFilterException
{
for ( Iterator iterator = artifacts.iterator(); iterator.hasNext(); )
{
Artifact artifact = (Artifact) iterator.next();
if ( !isArtifactIncluded( artifact ) )
{
iterator.remove();
}
}
return artifacts;
}
}

0 comments on commit 011436f

Please sign in to comment.