You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by hb...@apache.org on 2017/12/20 09:28:31 UTC
[maven-ant-plugin] 33/42: [MANT-44] Generated ant copy commands in
package target point to hard-coded local repository instead of
${maven.repo.local}
This is an automated email from the ASF dual-hosted git repository.
hboutemy pushed a commit to annotated tag maven-ant-plugin-2.1.1
in repository https://gitbox.apache.org/repos/asf/maven-ant-plugin.git
commit 2cd5a082a43e79cf3767ab6864b51b31c24090df
Author: Benjamin Bentmann <be...@apache.org>
AuthorDate: Wed Sep 3 14:43:28 2008 +0000
[MANT-44] Generated ant copy commands in package target point to hard-coded local repository instead of ${maven.repo.local}
git-svn-id: https://svn.apache.org/repos/asf/maven/plugins/trunk/maven-ant-plugin@691629 13f79535-47bb-0310-9956-ffa450edef68
---
src/it/webapp-it/pom.xml | 6 ++++++
src/it/webapp-it/verify.bsh | 16 +++++++++++++++-
.../org/apache/maven/plugin/ant/AntBuildWriter.java | 2 +-
.../apache/maven/plugin/ant/AntBuildWriterUtil.java | 19 ++++++++++++++-----
4 files changed, 36 insertions(+), 7 deletions(-)
diff --git a/src/it/webapp-it/pom.xml b/src/it/webapp-it/pom.xml
index 2d432c0..954b253 100644
--- a/src/it/webapp-it/pom.xml
+++ b/src/it/webapp-it/pom.xml
@@ -29,8 +29,14 @@ under the License.
<version>1.0-SNAPSHOT</version>
<name>Webapp project</name>
<url>http://maven.apache.org</url>
+
<dependencies>
<dependency>
+ <groupId>log4j</groupId>
+ <artifactId>log4j</artifactId>
+ <version>1.2.14</version>
+ </dependency>
+ <dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.2</version>
diff --git a/src/it/webapp-it/verify.bsh b/src/it/webapp-it/verify.bsh
index 8f2ba8b..b9dc041 100644
--- a/src/it/webapp-it/verify.bsh
+++ b/src/it/webapp-it/verify.bsh
@@ -2,8 +2,9 @@ import java.io.BufferedReader;
import java.io.File;
import java.io.IOException;
import java.util.jar.*;
+import java.util.regex.*;
-import org.codehaus.plexus.util.IOUtil;
+import org.codehaus.plexus.util.*;
try
{
@@ -19,12 +20,24 @@ try
System.err.println( "The file '" + build.getAbsolutePath() + "' is a directory or doesn't exist." );
return false;
}
+
mavenBuild = new File( basedir, "maven-build.xml" );
if ( mavenBuild.isDirectory() || !mavenBuild.exists() )
{
System.err.println( "The file '" + mavenBuild.getAbsolutePath() + "' is a directory or doesn't exist." );
return false;
}
+
+ String xml = FileUtils.fileRead( mavenBuild, "UTF-8" );
+ Matcher m0 = Pattern.compile( "<copy\\s+file\\s*=\\s*\\Q\"${maven.repo.local}/log4j/log4j/1.2.14/log4j-1.2.14.jar\"\\E"
+ + "\\s*todir\\s*=\\s*\\Q\"${maven.build.dir}/${maven.build.finalName}/WEB-INF/lib\"\\E" ).matcher( xml );
+ System.out.println( "Checking for existence of <copy> from ${maven.repo.local} for WAR libs" );
+ if ( !m0.find() )
+ {
+ System.err.println( "FAILED!\n" + xml );
+ return false;
+ }
+
mavenBuildProperties = new File( basedir, "maven-build.properties" );
if ( mavenBuildProperties.isDirectory() || !mavenBuildProperties.exists() )
{
@@ -48,6 +61,7 @@ try
"WEB-INF/test.txt",
"WEB-INF/classes/test.properties",
"WEB-INF/classes/org/MyClass.class",
+ "WEB-INF/lib/log4j-1.2.14.jar",
};
for ( String entry : expected )
{
diff --git a/src/main/java/org/apache/maven/plugin/ant/AntBuildWriter.java b/src/main/java/org/apache/maven/plugin/ant/AntBuildWriter.java
index 61f22dd..915761a 100644
--- a/src/main/java/org/apache/maven/plugin/ant/AntBuildWriter.java
+++ b/src/main/java/org/apache/maven/plugin/ant/AntBuildWriter.java
@@ -1039,7 +1039,7 @@ public class AntBuildWriter
}
else if ( AntBuildWriterUtil.isEarPackaging( project ) )
{
- AntBuildWriterUtil.writeEarTask( writer, project );
+ AntBuildWriterUtil.writeEarTask( writer, project, localRepository );
synonym = "ear";
}
else if ( AntBuildWriterUtil.isWarPackaging( project ) )
diff --git a/src/main/java/org/apache/maven/plugin/ant/AntBuildWriterUtil.java b/src/main/java/org/apache/maven/plugin/ant/AntBuildWriterUtil.java
index c5b052f..d7f42f2 100644
--- a/src/main/java/org/apache/maven/plugin/ant/AntBuildWriterUtil.java
+++ b/src/main/java/org/apache/maven/plugin/ant/AntBuildWriterUtil.java
@@ -452,12 +452,13 @@ public class AntBuildWriterUtil
*
* @param writer not null
* @param project not null
+ * @param localRepository not null
* @throws IOException if any
*/
- public static void writeEarTask( XMLWriter writer, MavenProject project )
+ public static void writeEarTask( XMLWriter writer, MavenProject project, File localRepository )
throws IOException
{
- writeCopyLib( writer, project, "${maven.build.dir}/${maven.build.finalName}" );
+ writeCopyLib( writer, project, localRepository, "${maven.build.dir}/${maven.build.finalName}" );
writer.startElement( "ear" );
writer.addAttribute( "destfile", "${maven.build.dir}/${maven.build.finalName}.ear" );
@@ -502,7 +503,7 @@ public class AntBuildWriterUtil
webXml = webXml.substring( "${basedir}/".length() );
}
- writeCopyLib( writer, project, "${maven.build.dir}/${maven.build.finalName}/WEB-INF/lib" );
+ writeCopyLib( writer, project, localRepository, "${maven.build.dir}/${maven.build.finalName}/WEB-INF/lib" );
writer.startElement( "war" );
writer.addAttribute( "destfile", "${maven.build.dir}/${maven.build.finalName}.war" );
@@ -1108,9 +1109,10 @@ public class AntBuildWriterUtil
*
* @param writer not null
* @param project not null
+ * @param localRepository not null
* @param outputDir not null
*/
- private static void writeCopyLib( XMLWriter writer, MavenProject project, String outputDir )
+ private static void writeCopyLib( XMLWriter writer, MavenProject project, File localRepository, String outputDir )
{
writer.startElement( "mkdir" );
writer.addAttribute( "dir", outputDir );
@@ -1125,8 +1127,15 @@ public class AntBuildWriterUtil
if ( !artifact.getScope().equals( Artifact.SCOPE_PROVIDED )
&& !artifact.getScope().equals( Artifact.SCOPE_TEST ) )
{
+ String path = artifact.getFile().getPath();
+ path = toRelative( localRepository, path );
+ if ( !new File( path ).isAbsolute() )
+ {
+ path = "${maven.repo.local}/" + path;
+ }
+
writer.startElement( "copy" );
- writer.addAttribute( "file", artifact.getFile().getPath() );
+ writer.addAttribute( "file", path );
addWrapAttribute( writer, "copy", "todir", outputDir, 3 );
writer.endElement(); // copy
}
--
To stop receiving notification emails like this one, please contact
"commits@maven.apache.org" <co...@maven.apache.org>.