Author: pgier Date: Thu May 7 20:49:18 2009 New Revision: 772768 URL: http://svn.apache.org/viewvc?rev=772768&view=rev Log: [MANTTASKS-147] Preserve original behaviour of useScope and add new scope option.
Modified: maven/ant-tasks/branches/maven-ant-tasks-2.0.x/sample.build.xml maven/ant-tasks/branches/maven-ant-tasks-2.0.x/src/main/java/org/apache/maven/artifact/ant/DependenciesTask.java maven/ant-tasks/branches/maven-ant-tasks-2.0.x/src/site/apt/examples/dependencies.apt maven/ant-tasks/branches/maven-ant-tasks-2.0.x/src/site/apt/reference.apt Modified: maven/ant-tasks/branches/maven-ant-tasks-2.0.x/sample.build.xml URL: http://svn.apache.org/viewvc/maven/ant-tasks/branches/maven-ant-tasks-2.0.x/sample.build.xml?rev=772768&r1=772767&r2=772768&view=diff ============================================================================== --- maven/ant-tasks/branches/maven-ant-tasks-2.0.x/sample.build.xml (original) +++ maven/ant-tasks/branches/maven-ant-tasks-2.0.x/sample.build.xml Thu May 7 20:49:18 2009 @@ -585,7 +585,7 @@ </target> <target name="test-deps-scopes" depends="initTaskDefs"> - <artifact:dependencies filesetId="dependency.scopes.fileset" useScope=" provided , test "> + <artifact:dependencies filesetId="dependency.scopes.fileset" scopes=" provided , test "> <pom file="src/test/pom-with-scopes.xml"/> </artifact:dependencies> Modified: maven/ant-tasks/branches/maven-ant-tasks-2.0.x/src/main/java/org/apache/maven/artifact/ant/DependenciesTask.java URL: http://svn.apache.org/viewvc/maven/ant-tasks/branches/maven-ant-tasks-2.0.x/src/main/java/org/apache/maven/artifact/ant/DependenciesTask.java?rev=772768&r1=772767&r2=772768&view=diff ============================================================================== --- maven/ant-tasks/branches/maven-ant-tasks-2.0.x/src/main/java/org/apache/maven/artifact/ant/DependenciesTask.java (original) +++ maven/ant-tasks/branches/maven-ant-tasks-2.0.x/src/main/java/org/apache/maven/artifact/ant/DependenciesTask.java Thu May 7 20:49:18 2009 @@ -77,6 +77,8 @@ private String useScope; + private String scopes; + private String type; private boolean verbose; @@ -85,6 +87,11 @@ { showVersion(); + if ( useScope != null && scopes != null ) + { + throw new BuildException( "You cannot specify both useScope and scopes in the dependencies task." ); + } + ArtifactRepository localRepo = createLocalArtifactRepository(); log( "Using local repository: " + localRepo.getBasedir(), Project.MSG_VERBOSE ); @@ -137,7 +144,11 @@ ArtifactFilter filter = null; if ( useScope != null ) { - filter = new SpecificScopesArtifactFilter( useScope ); + filter = new ScopeArtifactFilter( useScope ); + } + if ( scopes != null ) + { + filter = new SpecificScopesArtifactFilter( scopes ); } if ( type != null ) { @@ -363,6 +374,16 @@ this.type = type; } + public String getScopes() + { + return scopes; + } + + public void setScopes( String scopes ) + { + this.scopes = scopes; + } + private void showVersion() { InputStream resourceAsStream; Modified: maven/ant-tasks/branches/maven-ant-tasks-2.0.x/src/site/apt/examples/dependencies.apt URL: http://svn.apache.org/viewvc/maven/ant-tasks/branches/maven-ant-tasks-2.0.x/src/site/apt/examples/dependencies.apt?rev=772768&r1=772767&r2=772768&view=diff ============================================================================== --- maven/ant-tasks/branches/maven-ant-tasks-2.0.x/src/site/apt/examples/dependencies.apt (original) +++ maven/ant-tasks/branches/maven-ant-tasks-2.0.x/src/site/apt/examples/dependencies.apt Thu May 7 20:49:18 2009 @@ -133,19 +133,13 @@ Filtering Dependencies by Scope - Dependencies from a Pom file can be filtered by scope using the task attribute <<<useScope>>>. - <(since 2.0.10)> The <<<useScope>>> attribute accepts a comma separated list of scopes to - include in the filtering. If no value is specified, all scopes are included. The following - example includes only dependencies with a scope of either "provided" or "test". + There are two options available for filtering pom dependencies by scope, the <<<useScope>>> + attribute, and the <<<scopes>>> atribute. One or the other of these attributes should be used + but not both. ------ - <artifact:dependencies filesetId="deps.fileset" useScope="provided, test"> - <pom file="mypom.xml"/> - </artifact:dependencies> ------ - - Note: prior to version 2.0.10 of the ant tasks, only compile, runtime, and test scopes were supported - and they had the following behaviour. + The <<<useScopes>>> follows the maven conventions for scoping behaviour. This means attribute + can be set to one of three possible scopes: compile, runtime, or test. These scopes will + behave as follows. * compile - Includes scopes compile, system, and provided @@ -153,4 +147,25 @@ * test - Includes scopes system, provided, compile, runtime, and test + For example, using the scope <<<runtime>>>, any dependencies defined with compile, + runtime, or nothing (defaults to compile) in the scope field will be included in + the resulting fileset. + +----- + <artifact:dependencies filesetId="deps.fileset" useScope="runtime"> + <pom file="mypom.xml"/> + </artifact:dependencies> +----- + + <Since 2.0.10> The <<<scopes>>> attribute accepts a comma separated list of scopes to + include in the filtering. Only dependencies with these specific scopes will be + included in the resulting fileset. If no value is specified, all scopes are included. + The following example includes only dependencies with a scope of either "provided" or "test". + +----- + <artifact:dependencies filesetId="deps.fileset" scopes="provided, test"> + <pom file="mypom.xml"/> + </artifact:dependencies> +----- + Modified: maven/ant-tasks/branches/maven-ant-tasks-2.0.x/src/site/apt/reference.apt URL: http://svn.apache.org/viewvc/maven/ant-tasks/branches/maven-ant-tasks-2.0.x/src/site/apt/reference.apt?rev=772768&r1=772767&r2=772768&view=diff ============================================================================== --- maven/ant-tasks/branches/maven-ant-tasks-2.0.x/src/site/apt/reference.apt (original) +++ maven/ant-tasks/branches/maven-ant-tasks-2.0.x/src/site/apt/reference.apt Thu May 7 20:49:18 2009 @@ -56,7 +56,9 @@ *-------------------------+---------------------------------------------------------------------------+--------------+-------------+ | <<<type>>> | The type of artifacts to be retrieved. The default is <<<jar>>>. | No | | *-------------------------+---------------------------------------------------------------------------+--------------+-------------+ -| <<<useScope>>> | A comma separated list of scopes to be retrieved. If no value is provided, all scopes will be included. | No | | +| <<<useScope>>> | Follows the maven scope behaviour. Can be set to <<<compile>>>, <<<runtime>>>, or <<<test>>>. If no value is provided, all scopes will be included. | No | | +*-------------------------+---------------------------------------------------------------------------+--------------+-------------+ +| <<<scopes>>> | <since 2.0.10> A comma separated list of specific scopes to be retrieved. If no value is provided, all scopes will be included. | No | | *-------------------------+---------------------------------------------------------------------------+--------------+-------------+ | <<<verbose>>> | If <<<true>>> this displays the results of each dependency resolution and their relationships. Default is <false>. | No | | *-------------------------+---------------------------------------------------------------------------+--------------+-------------+