You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by be...@apache.org on 2008/03/22 02:19:39 UTC
svn commit: r639932 - in /maven/plugins/trunk/maven-ant-plugin/src:
it/file-repo-it/ it/file-repo-it/repo1/ it/file-repo-it/repo2/
main/java/org/apache/maven/plugin/ant/
Author: bentmann
Date: Fri Mar 21 18:19:37 2008
New Revision: 639932
URL: http://svn.apache.org/viewvc?rev=639932&view=rev
Log:
[MANT-4] Generated ANT contains hardcoded "get" tasks that look at the "C:\" drive etc... when using a local repository
Added:
maven/plugins/trunk/maven-ant-plugin/src/it/file-repo-it/ (with props)
maven/plugins/trunk/maven-ant-plugin/src/it/file-repo-it/goals.txt (with props)
maven/plugins/trunk/maven-ant-plugin/src/it/file-repo-it/pom.xml (with props)
maven/plugins/trunk/maven-ant-plugin/src/it/file-repo-it/repo1/
maven/plugins/trunk/maven-ant-plugin/src/it/file-repo-it/repo2/
maven/plugins/trunk/maven-ant-plugin/src/it/file-repo-it/verify.bsh (with props)
Modified:
maven/plugins/trunk/maven-ant-plugin/src/main/java/org/apache/maven/plugin/ant/AntBuildWriter.java
Propchange: maven/plugins/trunk/maven-ant-plugin/src/it/file-repo-it/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Fri Mar 21 18:19:37 2008
@@ -0,0 +1,5 @@
+target
+build.xml
+maven-build.properties
+maven-build.xml
+build.log
Added: maven/plugins/trunk/maven-ant-plugin/src/it/file-repo-it/goals.txt
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-ant-plugin/src/it/file-repo-it/goals.txt?rev=639932&view=auto
==============================================================================
--- maven/plugins/trunk/maven-ant-plugin/src/it/file-repo-it/goals.txt (added)
+++ maven/plugins/trunk/maven-ant-plugin/src/it/file-repo-it/goals.txt Fri Mar 21 18:19:37 2008
@@ -0,0 +1,2 @@
+ant:ant
+initialize
Propchange: maven/plugins/trunk/maven-ant-plugin/src/it/file-repo-it/goals.txt
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/plugins/trunk/maven-ant-plugin/src/it/file-repo-it/goals.txt
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: maven/plugins/trunk/maven-ant-plugin/src/it/file-repo-it/pom.xml
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-ant-plugin/src/it/file-repo-it/pom.xml?rev=639932&view=auto
==============================================================================
--- maven/plugins/trunk/maven-ant-plugin/src/it/file-repo-it/pom.xml (added)
+++ maven/plugins/trunk/maven-ant-plugin/src/it/file-repo-it/pom.xml Fri Mar 21 18:19:37 2008
@@ -0,0 +1,62 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <groupId>org.apache.maven.plugins.maven-ant-plugin.it</groupId>
+ <artifactId>file-repo-it</artifactId>
+ <version>1.0-SNAPSHOT</version>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-ant-plugin</artifactId>
+ <version>@pom.version@</version>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-antrun-plugin</artifactId>
+ <version>1.1</version>
+ <executions>
+ <execution>
+ <phase>initialize</phase>
+ <configuration>
+ <tasks>
+ <ant dir="${basedir}" antfile="${basedir}/build.xml" target="help" />
+ </tasks>
+ </configuration>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+
+ <dependencies>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>3.8.2</version>
+ </dependency>
+ </dependencies>
+
+ <repositories>
+ <repository>
+ <id>repo0</id>
+ <url>file://localhost/${basedir}</url>
+ </repository>
+ <repository>
+ <id>repo1</id>
+ <url>file://${basedir}/repo1</url>
+ </repository>
+ <repository>
+ <id>repo2</id>
+ <url>file://${basedir}/repo2/</url>
+ </repository>
+ </repositories>
+
+</project>
Propchange: maven/plugins/trunk/maven-ant-plugin/src/it/file-repo-it/pom.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/plugins/trunk/maven-ant-plugin/src/it/file-repo-it/pom.xml
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: maven/plugins/trunk/maven-ant-plugin/src/it/file-repo-it/verify.bsh
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-ant-plugin/src/it/file-repo-it/verify.bsh?rev=639932&view=auto
==============================================================================
--- maven/plugins/trunk/maven-ant-plugin/src/it/file-repo-it/verify.bsh (added)
+++ maven/plugins/trunk/maven-ant-plugin/src/it/file-repo-it/verify.bsh Fri Mar 21 18:19:37 2008
@@ -0,0 +1,38 @@
+import java.io.*;
+import java.util.*;
+import java.util.regex.*;
+import org.codehaus.plexus.util.*;
+
+try
+{
+ File buildFile = new File( basedir, "maven-build.xml" );
+ String xml = FileUtils.fileRead( buildFile, "UTF-8" );
+
+ Matcher m0 = Pattern.compile( "<copy\\s+file\\s*=\\s*\\Q\"junit/junit/3.8.2/junit-3.8.2.jar\"\\E" ).matcher( xml );
+ if ( !m0.find() )
+ {
+ System.err.println( "Build script does not contain <copy> for local artifacts from repo0." );
+ return false;
+ }
+
+ Matcher m1 = Pattern.compile( "<copy\\s+file\\s*=\\s*\\Q\"repo1/junit/junit/3.8.2/junit-3.8.2.jar\"\\E" ).matcher( xml );
+ if ( !m1.find() )
+ {
+ System.err.println( "Build script does not contain <copy> for local artifacts from repo1." );
+ return false;
+ }
+
+ Matcher m2 = Pattern.compile( "<copy\\s+file\\s*=\\s*\\Q\"repo2/junit/junit/3.8.2/junit-3.8.2.jar\"\\E" ).matcher( xml );
+ if ( !m2.find() )
+ {
+ System.err.println( "Build script does not contain <copy> for local artifacts from repo2." );
+ return false;
+ }
+}
+catch( Throwable t )
+{
+ t.printStackTrace();
+ return false;
+}
+
+return true;
Propchange: maven/plugins/trunk/maven-ant-plugin/src/it/file-repo-it/verify.bsh
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/plugins/trunk/maven-ant-plugin/src/it/file-repo-it/verify.bsh
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Modified: maven/plugins/trunk/maven-ant-plugin/src/main/java/org/apache/maven/plugin/ant/AntBuildWriter.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-ant-plugin/src/main/java/org/apache/maven/plugin/ant/AntBuildWriter.java?rev=639932&r1=639931&r2=639932&view=diff
==============================================================================
--- maven/plugins/trunk/maven-ant-plugin/src/main/java/org/apache/maven/plugin/ant/AntBuildWriter.java (original)
+++ maven/plugins/trunk/maven-ant-plugin/src/main/java/org/apache/maven/plugin/ant/AntBuildWriter.java Fri Mar 21 18:19:37 2008
@@ -1144,6 +1144,8 @@
writer.addAttribute( "dir", "${maven.repo.local}" );
writer.endElement(); // mkdir
+ String basedir = project.getBasedir().getAbsolutePath();
+
// TODO: proxy - probably better to use wagon!
for ( Iterator i = project.getTestArtifacts().iterator(); i.hasNext(); )
{
@@ -1166,13 +1168,35 @@
for ( Iterator j = project.getRepositories().iterator(); j.hasNext(); )
{
Repository repository = (Repository) j.next();
+ String url = repository.getUrl();
+
+ if ( url.regionMatches( true, 0, "file:", 0, 5 ) && url.indexOf( basedir ) > 0 )
+ {
+ url = url.substring( url.indexOf( basedir ) + basedir.length() );
+ if ( url.startsWith( "/" ) )
+ {
+ url = url.substring( 1 );
+ }
+ if ( !url.endsWith( "/" ) && url.length() > 0 )
+ {
+ url += '/';
+ }
- writer.startElement( "get" );
- writer.addAttribute( "src", repository.getUrl() + "/" + path );
- AntBuildWriterUtil.addWrapAttribute( writer, "get", "dest", "${maven.repo.local}/" + path, 3 );
- AntBuildWriterUtil.addWrapAttribute( writer, "get", "usetimestamp", "false", 3 );
- AntBuildWriterUtil.addWrapAttribute( writer, "get", "ignoreerrors", "true", 3 );
- writer.endElement(); // get
+ writer.startElement( "copy" );
+ writer.addAttribute( "file", url + path );
+ AntBuildWriterUtil.addWrapAttribute( writer, "copy", "tofile", "${maven.repo.local}/" + path, 3 );
+ AntBuildWriterUtil.addWrapAttribute( writer, "copy", "failonerror", "false", 3 );
+ writer.endElement(); // copy
+ }
+ else
+ {
+ writer.startElement( "get" );
+ writer.addAttribute( "src", url + '/' + path );
+ AntBuildWriterUtil.addWrapAttribute( writer, "get", "dest", "${maven.repo.local}/" + path, 3 );
+ AntBuildWriterUtil.addWrapAttribute( writer, "get", "usetimestamp", "false", 3 );
+ AntBuildWriterUtil.addWrapAttribute( writer, "get", "ignoreerrors", "true", 3 );
+ writer.endElement(); // get
+ }
}
}
}