PR: MNG-408

Add filesetId attribute to dependencies task

git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@170498 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Brett Leslie Porter 2005-05-17 01:04:43 +00:00
parent 92780b9511
commit 6eb9705933
2 changed files with 39 additions and 4 deletions

View File

@ -12,12 +12,16 @@
<artifact:pom file="pom.xml" id="maven.project"/>
<artifact:dependencies pathId="dependency.classpath">
<artifact:dependencies pathId="dependency.classpath" filesetId="dependency.fileset">
<dependency groupId="org.apache.maven.wagon" artifactId="wagon-provider-test" version="1.0-alpha-2"/>
<dependency groupId="org.codehaus.modello" artifactId="modello-core" version="1.0-alpha-2-SNAPSHOT"/>
<localRepository refid="local.repository"/>
</artifact:dependencies>
<copy todir="target/files">
<fileset refid="dependency.fileset" />
</copy>
<artifact:install file="target/maven-artifact-ant-2.0-SNAPSHOT.jar">
<localRepository refid="local.repository"/>
<pom refid="maven.project"/>

View File

@ -29,6 +29,7 @@ import org.apache.maven.project.artifact.MavenMetadataSource;
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.types.FileList;
import org.apache.tools.ant.types.Path;
import org.apache.tools.ant.types.FileSet;
import java.util.ArrayList;
import java.util.HashSet;
@ -53,6 +54,8 @@ public class DependenciesTask
private String pathId;
private String filesetId;
public void execute()
{
if ( localRepository == null )
@ -99,9 +102,17 @@ public class DependenciesTask
throw new BuildException( "Reference ID " + pathId + " already exists" );
}
if ( getProject().getReference( filesetId ) != null )
{
throw new BuildException( "Reference ID " + filesetId + " already exists" );
}
FileList fileList = new FileList();
fileList.setDir( localRepository.getLocation() );
FileSet fileSet = new FileSet();
fileSet.setDir( fileList.getDir( getProject() ) );
for ( Iterator i = result.getArtifacts().values().iterator(); i.hasNext(); )
{
Artifact artifact = (Artifact) i.next();
@ -119,11 +130,21 @@ public class DependenciesTask
file.setName( filename );
fileList.addConfiguredFile( file );
fileSet.createInclude().setName( filename );
}
Path path = new Path( getProject() );
path.addFilelist( fileList );
getProject().addReference( pathId, path );
if ( pathId != null )
{
Path path = new Path( getProject() );
path.addFilelist( fileList );
getProject().addReference( pathId, path );
}
if ( filesetId != null )
{
getProject().addReference( filesetId, fileSet );
}
}
private List createRemoteArtifactRepositories()
@ -181,4 +202,14 @@ public class DependenciesTask
{
this.pathId = pathId;
}
public String getFilesetId()
{
return filesetId;
}
public void setFilesetId( String filesetId )
{
this.filesetId = filesetId;
}
}