You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by br...@apache.org on 2007/01/03 02:28:55 UTC
svn commit: r492001 - in /maven/plugins/trunk/maven-dependency-plugin: ./
src/main/java/org/apache/maven/plugin/dependency/utils/filters/
src/test/java/org/apache/maven/plugin/dependency/
src/test/java/org/apache/maven/plugin/dependency/utils/filters/
Author: brianf
Date: Tue Jan 2 17:28:54 2007
New Revision: 492001
URL: http://svn.apache.org/viewvc?view=rev&rev=492001
Log:
MDEP-52: error in excluding provided or runtime scope.
Modified:
maven/plugins/trunk/maven-dependency-plugin/pom.xml
maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/utils/filters/ScopeFilter.java
maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugin/dependency/TestCopyDependenciesMojo.java
maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugin/dependency/TestUnpackDependenciesMojo.java
maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugin/dependency/utils/filters/TestScopeFilter.java
Modified: maven/plugins/trunk/maven-dependency-plugin/pom.xml
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-dependency-plugin/pom.xml?view=diff&rev=492001&r1=492000&r2=492001
==============================================================================
--- maven/plugins/trunk/maven-dependency-plugin/pom.xml (original)
+++ maven/plugins/trunk/maven-dependency-plugin/pom.xml Tue Jan 2 17:28:54 2007
@@ -148,7 +148,7 @@
<!-- Include the apache process LICENSE and NOTICE
files.
- -->
+ --><!--
<resource>
<targetPath>META-INF</targetPath>
<filtering>false</filtering>
@@ -157,7 +157,7 @@
<include>LICENSE</include>
<include>NOTICE</include>
</includes>
- </resource>
+ </resource>-->
<!-- Include super-pom defined main/resources
Removing this section will break the build.
Since we have defined a new build/resources
Modified: maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/utils/filters/ScopeFilter.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/utils/filters/ScopeFilter.java?view=diff&rev=492001&r1=492000&r2=492001
==============================================================================
--- maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/utils/filters/ScopeFilter.java (original)
+++ maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/utils/filters/ScopeFilter.java Tue Jan 2 17:28:54 2007
@@ -120,7 +120,7 @@
}
else
{
- excludeSingleScope( artifacts, excludeScope );
+ results = excludeSingleScope( artifacts, excludeScope );
}
}
Modified: maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugin/dependency/TestCopyDependenciesMojo.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugin/dependency/TestCopyDependenciesMojo.java?view=diff&rev=492001&r1=492000&r2=492001
==============================================================================
--- maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugin/dependency/TestCopyDependenciesMojo.java (original)
+++ maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugin/dependency/TestCopyDependenciesMojo.java Tue Jan 2 17:28:54 2007
@@ -1,4 +1,5 @@
package org.apache.maven.plugin.dependency;
+
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -655,7 +656,111 @@
public void testGetDependencies()
throws MojoExecutionException
{
- assertEquals( mojo.getResolvedDependencies( true ).toString(), mojo.getDependencySets( true ).getResolvedDependencies()
- .toString() );
+ assertEquals( mojo.getResolvedDependencies( true ).toString(), mojo.getDependencySets( true )
+ .getResolvedDependencies().toString() );
+ }
+
+ public void testCopyDependenciesMojoExcludeProvidedScope()
+ throws Exception
+ {
+ mojo.project.setArtifacts( stubFactory.getScopedArtifacts() );
+ mojo.project.setDependencyArtifacts( new HashSet() );
+ mojo.excludeScope = "provided";
+ // mojo.silent = false;
+
+ mojo.execute();
+
+ Iterator iter = mojo.project.getArtifacts().iterator();
+ while ( iter.hasNext() )
+ {
+ Artifact artifact = (Artifact) iter.next();
+ String fileName = DependencyUtil.getFormattedFileName( artifact, false );
+ File file = new File( mojo.outputDirectory, fileName );
+ assertEquals( artifact.getScope().equals( "provided" ), !file.exists() );
+ file.delete();
+ assertFalse( file.exists() );
+ }
+
+ }
+
+ public void testCopyDependenciesMojoExcludeSystemScope()
+ throws Exception
+ {
+ mojo.project.setArtifacts( stubFactory.getScopedArtifacts() );
+ mojo.project.setDependencyArtifacts( new HashSet() );
+ mojo.excludeScope = "system";
+ // mojo.silent = false;
+
+ mojo.execute();
+
+ Iterator iter = mojo.project.getArtifacts().iterator();
+ while ( iter.hasNext() )
+ {
+ Artifact artifact = (Artifact) iter.next();
+ String fileName = DependencyUtil.getFormattedFileName( artifact, false );
+ File file = new File( mojo.outputDirectory, fileName );
+ assertEquals( artifact.getScope().equals( "system" ), !file.exists() );
+ file.delete();
+ assertFalse( file.exists() );
+ }
+
+ }
+
+ public void testCopyDependenciesMojoExcludeCompileScope()
+ throws Exception
+{
+ mojo.project.setArtifacts( stubFactory.getScopedArtifacts() );
+ mojo.project.setDependencyArtifacts( new HashSet() );
+ mojo.excludeScope = "compile";
+ mojo.execute();
+ ScopeArtifactFilter saf = new ScopeArtifactFilter( mojo.excludeScope );
+
+ Iterator iter = mojo.project.getArtifacts().iterator();
+ while ( iter.hasNext() )
+ {
+ Artifact artifact = (Artifact) iter.next();
+ String fileName = DependencyUtil.getFormattedFileName( artifact, false );
+ File file = new File( mojo.outputDirectory, fileName );
+
+ assertEquals( !saf.include( artifact ), file.exists() );
+ }
+}
+
+public void testCopyDependenciesMojoExcludeTestScope() throws IOException
+{
+ mojo.project.setArtifacts( stubFactory.getScopedArtifacts() );
+ mojo.project.setDependencyArtifacts( new HashSet() );
+ mojo.excludeScope = "test";
+
+ try
+ {
+ mojo.execute();
+ fail("expected an exception");
+ }
+ catch ( MojoExecutionException e )
+ {
+
+ }
+
+}
+
+public void testCopyDependenciesMojoExcludeRuntimeScope()
+ throws Exception
+{
+ mojo.project.setArtifacts( stubFactory.getScopedArtifacts() );
+ mojo.project.setDependencyArtifacts( new HashSet() );
+ mojo.excludeScope = "runtime";
+ mojo.execute();
+ ScopeArtifactFilter saf = new ScopeArtifactFilter( mojo.excludeScope );
+
+ Iterator iter = mojo.project.getArtifacts().iterator();
+ while ( iter.hasNext() )
+ {
+ Artifact artifact = (Artifact) iter.next();
+ String fileName = DependencyUtil.getFormattedFileName( artifact, false );
+ File file = new File( mojo.outputDirectory, fileName );
+
+ assertEquals( !saf.include( artifact ), file.exists() );
}
+}
}
Modified: maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugin/dependency/TestUnpackDependenciesMojo.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugin/dependency/TestUnpackDependenciesMojo.java?view=diff&rev=492001&r1=492000&r2=492001
==============================================================================
--- maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugin/dependency/TestUnpackDependenciesMojo.java (original)
+++ maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugin/dependency/TestUnpackDependenciesMojo.java Tue Jan 2 17:28:54 2007
@@ -150,6 +150,96 @@
}
}
+ public void testUnpackDependenciesMojoExcludeProvidedScope()
+ throws Exception
+ {
+ mojo.project.setArtifacts( stubFactory.getScopedArtifacts() );
+ mojo.project.setDependencyArtifacts( new HashSet() );
+ mojo.excludeScope = "provided";
+ // mojo.silent = false;
+
+ mojo.execute();
+
+ Iterator iter = mojo.project.getArtifacts().iterator();
+ while ( iter.hasNext() )
+ {
+ Artifact artifact = (Artifact) iter.next();
+ assertUnpacked( !artifact.getScope().equals( "provided" ), artifact );
+ }
+
+ }
+
+ public void testUnpackDependenciesMojoExcludeSystemScope()
+ throws Exception
+ {
+ mojo.project.setArtifacts( stubFactory.getScopedArtifacts() );
+ mojo.project.setDependencyArtifacts( new HashSet() );
+ mojo.excludeScope = "system";
+ // mojo.silent = false;
+
+ mojo.execute();
+
+ Iterator iter = mojo.project.getArtifacts().iterator();
+ while ( iter.hasNext() )
+ {
+ Artifact artifact = (Artifact) iter.next();
+ assertUnpacked( !artifact.getScope().equals( "system" ), artifact );
+ }
+
+ }
+
+ public void testUnpackDependenciesMojoExcludeCompileScope()
+ throws Exception
+ {
+ mojo.project.setArtifacts( stubFactory.getScopedArtifacts() );
+ mojo.project.setDependencyArtifacts( new HashSet() );
+ mojo.excludeScope = "compile";
+ mojo.execute();
+ ScopeArtifactFilter saf = new ScopeArtifactFilter( mojo.excludeScope );
+
+ Iterator iter = mojo.project.getArtifacts().iterator();
+ while ( iter.hasNext() )
+ {
+ Artifact artifact = (Artifact) iter.next();
+ assertUnpacked( !saf.include( artifact ), artifact );
+ }
+ }
+
+ public void testUnpackDependenciesMojoExcludeTestScope() throws IOException
+ {
+ mojo.project.setArtifacts( stubFactory.getScopedArtifacts() );
+ mojo.project.setDependencyArtifacts( new HashSet() );
+ mojo.excludeScope = "test";
+
+ try
+ {
+ mojo.execute();
+ fail("expected an exception");
+ }
+ catch ( MojoExecutionException e )
+ {
+
+ }
+
+ }
+
+ public void testUnpackDependenciesMojoExcludeRuntimeScope()
+ throws Exception
+ {
+ mojo.project.setArtifacts( stubFactory.getScopedArtifacts() );
+ mojo.project.setDependencyArtifacts( new HashSet() );
+ mojo.excludeScope = "runtime";
+ mojo.execute();
+ ScopeArtifactFilter saf = new ScopeArtifactFilter( mojo.excludeScope );
+
+ Iterator iter = mojo.project.getArtifacts().iterator();
+ while ( iter.hasNext() )
+ {
+ Artifact artifact = (Artifact) iter.next();
+ assertUnpacked( !saf.include( artifact ), artifact );
+ }
+ }
+
public void testUnpackDependenciesMojoIncludeType()
throws Exception
{
Modified: maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugin/dependency/utils/filters/TestScopeFilter.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugin/dependency/utils/filters/TestScopeFilter.java?view=diff&rev=492001&r1=492000&r2=492001
==============================================================================
--- maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugin/dependency/utils/filters/TestScopeFilter.java (original)
+++ maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugin/dependency/utils/filters/TestScopeFilter.java Tue Jan 2 17:28:54 2007
@@ -133,7 +133,11 @@
{
ScopeFilter filter = new ScopeFilter( "", Artifact.SCOPE_PROVIDED );
Set result = filter.filter( artifacts, log );
+ assertNotNull(result);
+ assertTrue( result.size() > 0 );
Iterator iter = result.iterator();
+ assertNotNull(result);
+ assertTrue( result.size() > 0 );
while ( iter.hasNext() )
{
Artifact artifact = (Artifact) iter.next();
@@ -147,6 +151,8 @@
ScopeFilter filter = new ScopeFilter( "", Artifact.SCOPE_SYSTEM );
Set result = filter.filter( artifacts, log );
Iterator iter = result.iterator();
+ assertNotNull(result);
+ assertTrue( result.size() > 0 );
while ( iter.hasNext() )
{
Artifact artifact = (Artifact) iter.next();