stevel 2004/11/24 15:10:47 Modified: src/etc/testcases/taskdefs libraries.xml src/main/org/apache/tools/ant/taskdefs/repository Library.java src/testcases/org/apache/tools/ant/taskdefs LibrariesTest.java Log: Tuning 1-if you dont specify an archive name, use that of the project 2-its OK to specify suffix="" 3-you do need the "." in the suffix; this was not needed. (3) will break anything which set the suffix. I assumed the user base was small enough to avoid a compatibility hack. Revision Changes Path 1.2 +58 -7 ant/src/etc/testcases/taskdefs/libraries.xml Index: libraries.xml =================================================================== RCS file: /home/cvs/ant/src/etc/testcases/taskdefs/libraries.xml,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- libraries.xml 18 Nov 2004 16:25:04 -0000 1.1 +++ libraries.xml 24 Nov 2004 23:10:47 -0000 1.2 @@ -9,8 +9,9 @@ <property name="lib.dir" value="getlib"/> <property name="commons.logging.project" value="commons-logging"/> - <property name="commons.logging" - value="${commons.logging.project}/jars/${commons.logging.project}-1.0.1.jar"/> + <property name="version" value="1.0.4"/> + <property name="commons.logging" + value="${commons.logging.project}/jars/${commons.logging.project}-${version}.jar"/> <presetdef name="gl1"> <libraries destDir="${lib.dir}"> @@ -19,7 +20,8 @@ <presetdef name="getlib"> <gl1 destDir="${lib.dir}"> - <library archive="commons-logging" project="commons-logging" version="1.0.1"/> + <library archive="commons-logging" project="commons-logging" + version="${version}"/> </gl1> </presetdef> @@ -112,7 +114,7 @@ <target name="testRenaming" depends="init"> <getlib> <mavenrepository/> - <library archive="commons-logging" project="commons-logging" version="1.0.1" + <library archive="commons-logging" project="commons-logging" version="${version}" destinationName="renamed.jar" /> </getlib> @@ -135,8 +137,7 @@ <target name="testIf" depends="init"> <gl1> <mavenrepository/> - <library archive="commons-logging" project="commons-logging" version="1.0.1" - enabled="true"/> + <library archive="commons-logging" project="commons-logging" version="${version}" enabled="true"/> </gl1> <assert-downloaded/> </target> @@ -144,7 +145,7 @@ <target name="testUnless" depends="init"> <gl1> <mavenrepository/> - <library archive="commons-logging" project="commons-logging" version="1.0.1" + <library archive="commons-logging" project="commons-logging" version="${version}" enabled="false"/> </gl1> <assert-not-downloaded/> @@ -256,5 +257,55 @@ <assertdownloaded count="152" /> </getlib> </target> + + + <target name="testNoArchiveName" depends="init"> + <gl1 destDir="${lib.dir}" > + <library project="commons-logging" version="${version}"/> + <mavenrepository/> + <assertdownloaded count="1"/> + </gl1> + </target> + + <target name="testNoVersion" depends="init"> + <gl1 destDir="${lib.dir}" offline="true"> + <library project="commons-logging" /> + <mavenrepository/> + </gl1> + </target> + + <target name="testNoProject" depends="init"> + <gl1 destDir="${lib.dir}" offline="true"> + <library archive="commons-logging" version="${version}"/> + <mavenrepository/> + </gl1> + </target> + + <target name="testNewSuffix" depends="init"> + <gl1 destDir="${lib.dir}"> + <library project="commons-logging" version="${version}" + suffix=".jar.asc"/> + <mavenrepository checkMD5="false"/> + <assertdownloaded count="1"/> + </gl1> + </target> + + <target name="testNoSuffix" depends="init"> + <gl1 destDir="${lib.dir}"> + <library project="commons-logging" version="snapshot-version" suffix=""/> + <assertdownloaded count="1"/> + <mavenrepository checkMD5="false"/> + </gl1> + </target> + + <target name="testEmptyArchive" depends="init"> + <gl1 destDir="${lib.dir}"> + <library project="commons-logging" version="${version}" + archive=""/> + <assertdownloaded count="1"/> + <mavenrepository/> + </gl1> + </target> + </project> 1.3 +15 -7 ant/src/main/org/apache/tools/ant/taskdefs/repository/Library.java Index: Library.java =================================================================== RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/taskdefs/repository/Library.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- Library.java 22 Nov 2004 09:23:35 -0000 1.2 +++ Library.java 24 Nov 2004 23:10:47 -0000 1.3 @@ -80,18 +80,20 @@ */ private boolean toFetch = true; + /** + * flag set after fetching + */ private boolean fetched = false; public static final String ERROR_NO_ARCHIVE = "No archive defined"; public static final String ERROR_NO_PROJECT = "No project defined"; public static final String ERROR_NO_VERSION = "No version defined"; - public static final String ERROR_NO_SUFFIX = "No version defined"; + public static final String ERROR_FILE_IS_A_DIR = "Library file is a directory:"; /** * suffix */ - private String suffix = "jar"; - public static final String ERROR_FILE_IS_A_DIR = "Library file is a directory:"; + private String suffix = ".jar"; /** @@ -169,7 +171,7 @@ } /** - * set the suffix for this file; default is "jar" + * set the suffix for this file; default is ".jar" * @param suffix */ public void setSuffix(String suffix) { @@ -213,10 +215,16 @@ * @throws BuildException if invalid */ public void validate() { - faultIfEmpty(archive, ERROR_NO_ARCHIVE); faultIfEmpty(project, ERROR_NO_PROJECT); + if(archive==null) { + //adopt the name of the project if no archive is specced + archive=project; + } + faultIfEmpty(archive, ERROR_NO_ARCHIVE); faultIfEmpty(version, ERROR_NO_VERSION); - faultIfEmpty(version, ERROR_NO_SUFFIX); + if(suffix==null) { + suffix=""; + } } /** @@ -278,7 +286,7 @@ * source */ public String getNormalFilename() { - return archive + "-" + version + "." + suffix; + return archive + "-" + version + suffix; } /** 1.2 +25 -0 ant/src/testcases/org/apache/tools/ant/taskdefs/LibrariesTest.java Index: LibrariesTest.java =================================================================== RCS file: /home/cvs/ant/src/testcases/org/apache/tools/ant/taskdefs/LibrariesTest.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- LibrariesTest.java 18 Nov 2004 16:25:04 -0000 1.1 +++ LibrariesTest.java 24 Nov 2004 23:10:47 -0000 1.2 @@ -19,6 +19,7 @@ import org.apache.tools.ant.BuildFileTest; import org.apache.tools.ant.taskdefs.repository.AssertDownloaded; import org.apache.tools.ant.taskdefs.repository.Libraries; +import org.apache.tools.ant.taskdefs.repository.Library; /** * test the test libraries stuff. @@ -179,4 +180,28 @@ "Wrong count in assertdownloaded", AssertDownloaded.ERROR_DOWNLOAD_FAILURE); } + + public void testNoVersion() { + expectBuildException("testNoVersion", + Library.ERROR_NO_PROJECT); + } + + public void testNoProject() { + expectBuildException("testNoProject", + Library.ERROR_NO_PROJECT); + } + + public void testNoArchiveName() { + execIfOnline("testNoArchiveName"); + } + + public void testEmptyArchive() { + expectBuildException("testEmptyArchive", + Library.ERROR_NO_ARCHIVE); + } + + public void testNoSuffix() { + execIfOnline("testNoSuffix"); + } + }
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]