From fd615cbeea84d268448ec7dc78f3220ee727a307 Mon Sep 17 00:00:00 2001 From: Brett Leslie Porter Date: Fri, 22 Jul 2005 16:51:09 +0000 Subject: [PATCH] PR: MNG-579 correct inclusion of tlds git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@224365 13f79535-47bb-0310-9956-ffa450edef68 --- .../org/apache/maven/plugin/war/WarMojo.java | 31 ++++++++++++------- .../apache/maven/project/MavenProject.java | 10 +++--- 2 files changed, 24 insertions(+), 17 deletions(-) diff --git a/maven-plugins/maven-war-plugin/src/main/java/org/apache/maven/plugin/war/WarMojo.java b/maven-plugins/maven-war-plugin/src/main/java/org/apache/maven/plugin/war/WarMojo.java index 3f3b3b24a2..856dd8c49e 100644 --- a/maven-plugins/maven-war-plugin/src/main/java/org/apache/maven/plugin/war/WarMojo.java +++ b/maven-plugins/maven-war-plugin/src/main/java/org/apache/maven/plugin/war/WarMojo.java @@ -33,6 +33,7 @@ import java.io.IOException; import java.util.ArrayList; import java.util.Iterator; import java.util.List; +import java.util.Set; /** * Build a war/webapp. @@ -155,25 +156,33 @@ public class WarMojo FileUtils.copyDirectoryStructure( classesDirectory, webappClassesDirectory ); } - List runtimeArtifacts = project.getRuntimeArtifacts(); + Set artifacts = project.getArtifacts(); - for ( Iterator iter = runtimeArtifacts.iterator(); iter.hasNext(); ) + for ( Iterator iter = artifacts.iterator(); iter.hasNext(); ) { Artifact artifact = (Artifact) iter.next(); + // TODO: utilise appropriate methods from project builder // TODO: scope handler // Include runtime and compile time libraries - // [jc, 21-June]: handle TLDs as a special-case. - if ( "tld".equals( artifact.getType() ) ) + if ( !Artifact.SCOPE_PROVIDED.equals( artifact.getScope() ) && + !!Artifact.SCOPE_TEST.equals( artifact.getScope() ) ) { - FileUtils.copyFileToDirectory( artifact.getFile(), tldDirectory ); - } - // [jc, 21-June]: I'm removing ( "jar".equals( artifact.getType() ) ) from consideration here - // 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 ); + String type = artifact.getType(); + if ( "tld".equals( type ) ) + { + FileUtils.copyFileToDirectory( artifact.getFile(), tldDirectory ); + } + else if ( "jar".equals( type ) || "ejb".equals( type ) || "ejb-client".equals( type ) ) + { + FileUtils.copyFileToDirectory( artifact.getFile(), libDirectory ); + } + else + { + getLog().debug( "Skipping artifact of type " + type + " for WEB-INF/lib" ); + } } + } } diff --git a/maven-project/src/main/java/org/apache/maven/project/MavenProject.java b/maven-project/src/main/java/org/apache/maven/project/MavenProject.java index 4f75c777e1..16f8321b9d 100644 --- a/maven-project/src/main/java/org/apache/maven/project/MavenProject.java +++ b/maven-project/src/main/java/org/apache/maven/project/MavenProject.java @@ -331,6 +331,7 @@ public class MavenProject { Artifact a = (Artifact) i.next(); + // TODO: classpath check doesn't belong here - that's the other method if ( isAddedToClasspath( a ) ) { // TODO: let the scope handler deal with this @@ -412,6 +413,7 @@ public class MavenProject { Artifact a = (Artifact) i.next(); + // TODO: classpath check doesn't belong here - that's the other method if ( isAddedToClasspath( a ) ) { // TODO: let the scope handler deal with this @@ -494,6 +496,7 @@ public class MavenProject { Artifact a = (Artifact) i.next(); + // TODO: classpath check doesn't belong here - that's the other method if ( isAddedToClasspath( a ) ) { // TODO: let the scope handler deal with this @@ -543,12 +546,7 @@ public class MavenProject String type = artifact.getType(); // TODO: utilise type handler - if ( "jar".equals( type ) || "ejb".equals( type ) || "ejb-client".equals( type ) ) - { - return true; - } - - return false; + return "jar".equals( type ) || "ejb".equals( type ) || "ejb-client".equals( type ); } // ----------------------------------------------------------------------