Fixing artifact handling to only process the runtime artifacts, and select out the tld's from that. This is for the war mojo, BTW. :)

git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@191688 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
John Dennis Casey 2005-06-21 17:13:24 +00:00
parent ea5bbda3e0
commit fd3e9fe9e2
2 changed files with 71 additions and 17 deletions

View File

@ -33,7 +33,6 @@ import java.io.IOException;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
/**
* Build a war/webapp.
@ -143,6 +142,7 @@ public class WarMojo
}
/**
* @throws MojoExecutionException
*
*/
public void buildWebapp( MavenProject project )
@ -162,29 +162,22 @@ public class WarMojo
FileUtils.copyDirectoryStructure( classesDirectory, webappClassesDirectory );
}
Set artifacts = project.getArtifacts();
List runtimeArtifacts = project.getRuntimeArtifacts();
for ( Iterator iter = artifacts.iterator(); iter.hasNext(); )
for ( Iterator iter = runtimeArtifacts.iterator(); iter.hasNext(); )
{
Artifact artifact = (Artifact) iter.next();
// TODO: scope handler
// TODO: use classpath instead
// Include runtime and compile time libraries
// [jc, 21-June]: handle TLDs as a special-case.
if ( "tld".equals( artifact.getType() ) )
{
FileUtils.copyFileToDirectory( artifact.getFile(), tldDirectory );
}
// [jc, 21-June]: filter POMs out of the /lib copy process.
else if ( "pom".equals( artifact.getType() ) )
{
// don't mess with these...they'd only be here for inclusion of dependencies.
}
// [jc, 21-June]: I'm removing ( "jar".equals( artifact.getType() ) ) from consideration here
// we'll handle anything that's NOT a POM or a TLD as a binary library to go in /lib
else if ( !Artifact.SCOPE_TEST.equals( artifact.getScope() ) && !Artifact.SCOPE_PROVIDED.equals( artifact.getScope() ) )
// we'll handle anything that's in the runtime classpath and NOT a SCOPE_PROVIDED artifact.
else if ( !Artifact.SCOPE_PROVIDED.equals( artifact.getScope() ) )
{
FileUtils.copyFileToDirectory( artifact.getFile(), libDirectory );
}

View File

@ -302,6 +302,26 @@ public class MavenProject
return list;
}
public List getCompileArtifacts()
{
List list = new ArrayList( getArtifacts().size() );
for ( Iterator i = getArtifacts().iterator(); i.hasNext(); )
{
Artifact a = (Artifact) i.next();
if ( isAddedToClasspath( a ) )
{
// TODO: let the scope handler deal with this
if ( Artifact.SCOPE_COMPILE.equals( a.getScope() ) || Artifact.SCOPE_PROVIDED.equals( a.getScope() ) )
{
list.add( a );
}
}
}
return list;
}
public List getCompileDependencies()
{
Set artifacts = getArtifacts();
@ -348,8 +368,8 @@ public class MavenProject
if ( isAddedToClasspath( a ) )
{
// TODO: let the scope handler deal with this
if ( Artifact.SCOPE_TEST.equals( a.getScope() ) || Artifact.SCOPE_COMPILE.equals( a.getScope() ) ||
Artifact.SCOPE_RUNTIME.equals( a.getScope() ) )
if ( Artifact.SCOPE_TEST.equals( a.getScope() ) || Artifact.SCOPE_COMPILE.equals( a.getScope() )
|| Artifact.SCOPE_RUNTIME.equals( a.getScope() ) )
{
File file = a.getFile();
if ( file == null )
@ -363,6 +383,27 @@ public class MavenProject
return list;
}
public List getTestArtifacts()
{
List list = new ArrayList( getArtifacts().size() );
for ( Iterator i = getArtifacts().iterator(); i.hasNext(); )
{
Artifact a = (Artifact) i.next();
if ( isAddedToClasspath( a ) )
{
// TODO: let the scope handler deal with this
if ( Artifact.SCOPE_TEST.equals( a.getScope() ) || Artifact.SCOPE_COMPILE.equals( a.getScope() )
|| Artifact.SCOPE_RUNTIME.equals( a.getScope() ) )
{
list.add( a );
}
}
}
return list;
}
public List getTestDependencies()
{
Set artifacts = getArtifacts();
@ -379,8 +420,8 @@ public class MavenProject
Artifact a = (Artifact) i.next();
// TODO: let the scope handler deal with this
if ( Artifact.SCOPE_TEST.equals( a.getScope() ) || Artifact.SCOPE_COMPILE.equals( a.getScope() ) ||
Artifact.SCOPE_RUNTIME.equals( a.getScope() ) )
if ( Artifact.SCOPE_TEST.equals( a.getScope() ) || Artifact.SCOPE_COMPILE.equals( a.getScope() )
|| Artifact.SCOPE_RUNTIME.equals( a.getScope() ) )
{
Dependency dependency = new Dependency();
@ -424,6 +465,26 @@ public class MavenProject
return list;
}
public List getRuntimeArtifacts()
{
List list = new ArrayList( getArtifacts().size() );
for ( Iterator i = getArtifacts().iterator(); i.hasNext(); )
{
Artifact a = (Artifact) i.next();
if ( isAddedToClasspath( a ) )
{
// TODO: let the scope handler deal with this
if ( Artifact.SCOPE_COMPILE.equals( a.getScope() ) || Artifact.SCOPE_RUNTIME.equals( a.getScope() ) )
{
list.add( a );
}
}
}
return list;
}
public List getRuntimeDependencies()
{
Set artifacts = getArtifacts();
@ -866,7 +927,7 @@ public class MavenProject
}
public Xpp3Dom getGoalConfiguration( String pluginGroupId, String pluginArtifactId, String executionId,
String goalId )
String goalId )
{
Xpp3Dom dom = null;