2. rename <libraries> git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@277054 13f79535-47bb-0310-9956-ffa450edef68master
| @@ -13,8 +13,8 @@ | |||
| value="${commons.logging.project}/jars/${commons.logging.project}-1.0.1.jar"/> | |||
| <presetdef name="gl1"> | |||
| <getlibraries destDir="${lib.dir}"> | |||
| </getlibraries> | |||
| <libraries destDir="${lib.dir}"> | |||
| </libraries> | |||
| </presetdef> | |||
| <presetdef name="getlib"> | |||
| @@ -56,19 +56,19 @@ | |||
| <target name="teardown" depends="cleanup"/> | |||
| <target name="testEmpty" depends="init"> | |||
| <getlibraries/> | |||
| <libraries/> | |||
| </target> | |||
| <target name="testEmpty2" depends="init"> | |||
| <getlibraries destDir="${lib.dir}"> | |||
| <libraries destDir="${lib.dir}"> | |||
| </getlibraries> | |||
| </libraries> | |||
| </target> | |||
| <target name="testEmpty3" depends="init"> | |||
| <getlibraries destDir="${lib.dir}"> | |||
| <libraries destDir="${lib.dir}"> | |||
| <repository/> | |||
| </getlibraries> | |||
| </libraries> | |||
| </target> | |||
| <target name="testNoRepo" depends="init"> | |||
| @@ -80,6 +80,7 @@ defaultexcludes=org.apache.tools.ant.taskdefs.DefaultExcludes | |||
| presetdef=org.apache.tools.ant.taskdefs.PreSetDef | |||
| macrodef=org.apache.tools.ant.taskdefs.MacroDef | |||
| nice=org.apache.tools.ant.taskdefs.Nice | |||
| libraries=org.apache.tools.ant.taskdefs.repository.Libraries | |||
| # optional tasks | |||
| image=org.apache.tools.ant.taskdefs.optional.image.Image | |||
| @@ -203,7 +204,6 @@ rexec=org.apache.tools.ant.taskdefs.optional.net.RExecTask | |||
| scriptdef=org.apache.tools.ant.taskdefs.optional.script.ScriptDef | |||
| ildasm=org.apache.tools.ant.taskdefs.optional.dotnet.Ildasm | |||
| apt=org.apache.tools.ant.taskdefs.Apt | |||
| getlibraries=org.apache.tools.ant.taskdefs.optional.repository.GetLibraries | |||
| # deprecated ant tasks (kept for back compatibility) | |||
| starteam=org.apache.tools.ant.taskdefs.optional.scm.AntStarTeamCheckOut | |||
| @@ -16,8 +16,6 @@ | |||
| */ | |||
| package org.apache.tools.ant.taskdefs.repository; | |||
| import org.apache.tools.ant.taskdefs.optional.repository.GetLibraries; | |||
| import java.util.ListIterator; | |||
| /** | |||
| @@ -36,7 +34,7 @@ public class AbsentFilesPolicy extends BaseLibraryPolicy { | |||
| * @throws org.apache.tools.ant.BuildException | |||
| * if needed | |||
| */ | |||
| public boolean beforeConnect(GetLibraries owner, ListIterator libraries) { | |||
| public boolean beforeConnect(Libraries owner, ListIterator libraries) { | |||
| owner.markMissingLibrariesForFetch(); | |||
| return true; | |||
| } | |||
| @@ -17,7 +17,6 @@ | |||
| package org.apache.tools.ant.taskdefs.repository; | |||
| import org.apache.tools.ant.BuildException; | |||
| import org.apache.tools.ant.taskdefs.optional.repository.GetLibraries; | |||
| import java.util.ListIterator; | |||
| @@ -54,7 +53,7 @@ public class AssertDownloaded extends BaseLibraryPolicy { | |||
| * @throws org.apache.tools.ant.BuildException | |||
| * if needed | |||
| */ | |||
| public boolean beforeConnect(GetLibraries owner, ListIterator libraries) { | |||
| public boolean beforeConnect(Libraries owner, ListIterator libraries) { | |||
| if(count==null) { | |||
| throw new BuildException(ERROR_NO_COUNT); | |||
| } | |||
| @@ -70,7 +69,7 @@ public class AssertDownloaded extends BaseLibraryPolicy { | |||
| * @throws org.apache.tools.ant.BuildException | |||
| * | |||
| */ | |||
| public void afterFetched(GetLibraries owner, ListIterator libraries) { | |||
| public void afterFetched(Libraries owner, ListIterator libraries) { | |||
| int fetched=owner.calculateDownloadedCount(); | |||
| if(fetched!=count.intValue()) { | |||
| throw new BuildException(ERROR_DOWNLOAD_FAILURE | |||
| @@ -16,8 +16,6 @@ | |||
| */ | |||
| package org.apache.tools.ant.taskdefs.repository; | |||
| import org.apache.tools.ant.taskdefs.optional.repository.GetLibraries; | |||
| import java.util.ListIterator; | |||
| /** | |||
| @@ -57,7 +55,7 @@ public abstract class BaseLibraryPolicy implements LibraryPolicy { | |||
| * @throws org.apache.tools.ant.BuildException | |||
| * if needed | |||
| */ | |||
| public boolean beforeConnect(GetLibraries owner, ListIterator libraries) { | |||
| public boolean beforeConnect(Libraries owner, ListIterator libraries) { | |||
| return true; | |||
| } | |||
| @@ -70,7 +68,7 @@ public abstract class BaseLibraryPolicy implements LibraryPolicy { | |||
| * @throws org.apache.tools.ant.BuildException | |||
| * | |||
| */ | |||
| public void afterFetched(GetLibraries owner, ListIterator libraries) { | |||
| public void afterFetched(Libraries owner, ListIterator libraries) { | |||
| } | |||
| } | |||
| @@ -17,8 +17,6 @@ | |||
| package org.apache.tools.ant.taskdefs.repository; | |||
| import org.apache.tools.ant.BuildException; | |||
| import org.apache.tools.ant.taskdefs.optional.repository.GetLibraries; | |||
| import org.apache.tools.ant.taskdefs.optional.repository.Library; | |||
| import java.util.Iterator; | |||
| import java.util.ListIterator; | |||
| @@ -47,7 +45,7 @@ public class ForceUpdatePolicy extends BaseLibraryPolicy { | |||
| * @throws org.apache.tools.ant.BuildException | |||
| * if needed | |||
| */ | |||
| public boolean beforeConnect(GetLibraries owner, ListIterator libraries) { | |||
| public boolean beforeConnect(Libraries owner, ListIterator libraries) { | |||
| owner.markAllLibrariesForFetch(true); | |||
| owner._setUseTimestamp(false); | |||
| return true; | |||
| @@ -62,7 +60,7 @@ public class ForceUpdatePolicy extends BaseLibraryPolicy { | |||
| * @throws org.apache.tools.ant.BuildException | |||
| * | |||
| */ | |||
| public void afterFetched(GetLibraries owner, ListIterator libraries) { | |||
| public void afterFetched(Libraries owner, ListIterator libraries) { | |||
| //here verify that everything came in | |||
| Iterator downloaded = owner.enabledLibrariesIterator(); | |||
| while (downloaded.hasNext()) { | |||
| @@ -14,7 +14,7 @@ | |||
| * limitations under the License. | |||
| * | |||
| */ | |||
| package org.apache.tools.ant.taskdefs.optional.repository; | |||
| package org.apache.tools.ant.taskdefs.repository; | |||
| import org.apache.tools.ant.BuildException; | |||
| @@ -62,7 +62,7 @@ public abstract class HttpRepository extends Repository { | |||
| /** | |||
| * owner class | |||
| */ | |||
| private GetLibraries owner; | |||
| private Libraries owner; | |||
| /** | |||
| * retry logic | |||
| @@ -133,7 +133,7 @@ public abstract class HttpRepository extends Repository { | |||
| } | |||
| }*/ | |||
| public GetLibraries getOwner() { | |||
| public Libraries getOwner() { | |||
| return owner; | |||
| } | |||
| @@ -161,7 +161,7 @@ public abstract class HttpRepository extends Repository { | |||
| * @throws org.apache.tools.ant.BuildException | |||
| * | |||
| */ | |||
| public void connect(GetLibraries newOwner) { | |||
| public void connect(Libraries newOwner) { | |||
| this.owner = newOwner; | |||
| if (!url.endsWith("/")) { | |||
| url = url + '/'; | |||
| @@ -189,7 +189,7 @@ public abstract class HttpRepository extends Repository { | |||
| /** | |||
| * Test for a repository being reachable. This method is called after {@link | |||
| * #connect(org.apache.tools.ant.taskdefs.optional.repository.GetLibraries)} | |||
| * #connect(org.apache.tools.ant.taskdefs.repository.GetLibraries)} | |||
| * is called, before any files are to be retrieved. | |||
| * <p/> | |||
| * If it returns false the repository considers itself offline. Similarly, | |||
| @@ -14,19 +14,11 @@ | |||
| * limitations under the License. | |||
| * | |||
| */ | |||
| package org.apache.tools.ant.taskdefs.optional.repository; | |||
| package org.apache.tools.ant.taskdefs.repository; | |||
| import org.apache.tools.ant.BuildException; | |||
| import org.apache.tools.ant.Project; | |||
| import org.apache.tools.ant.Task; | |||
| import org.apache.tools.ant.taskdefs.repository.AbsentFilesPolicy; | |||
| import org.apache.tools.ant.taskdefs.repository.AssertDownloaded; | |||
| import org.apache.tools.ant.taskdefs.repository.EnabledLibraryElementList; | |||
| import org.apache.tools.ant.taskdefs.repository.ForceUpdatePolicy; | |||
| import org.apache.tools.ant.taskdefs.repository.LibraryPolicy; | |||
| import org.apache.tools.ant.taskdefs.repository.NoUpdatePolicy; | |||
| import org.apache.tools.ant.taskdefs.repository.ScheduledUpdatePolicy; | |||
| import org.apache.tools.ant.taskdefs.repository.TimestampPolicy; | |||
| import org.apache.tools.ant.types.Path; | |||
| import org.apache.tools.ant.types.Reference; | |||
| @@ -38,15 +30,17 @@ import java.util.List; | |||
| import java.util.ListIterator; | |||
| /** | |||
| * This task will retrieve one or more libraries from a repository. <ol> | |||
| * This task will retrieve one or more libraries from a repository. | |||
| * <ol> | |||
| * <li>Users must declare a repository, either inline or by reference</li> | |||
| * <li>Dependency checking is used (timestamps) unless forceDownload=true</li> | |||
| * <li>It is an error if, at the end of the task, a library is missing. | |||
| * </ol> | |||
| * | |||
| * @ant.task | |||
| * @since Ant 1.7 | |||
| */ | |||
| public final class GetLibraries extends Task { | |||
| public final class Libraries extends Task { | |||
| /** | |||
| * destination | |||
| @@ -15,10 +15,9 @@ | |||
| * | |||
| */ | |||
| package org.apache.tools.ant.taskdefs.optional.repository; | |||
| package org.apache.tools.ant.taskdefs.repository; | |||
| import org.apache.tools.ant.BuildException; | |||
| import org.apache.tools.ant.taskdefs.repository.EnabledLibraryElement; | |||
| import org.apache.tools.ant.types.Path; | |||
| import org.apache.tools.ant.util.FileUtils; | |||
| @@ -17,8 +17,6 @@ | |||
| package org.apache.tools.ant.taskdefs.repository; | |||
| import org.apache.tools.ant.taskdefs.optional.repository.GetLibraries; | |||
| import java.util.ListIterator; | |||
| /** | |||
| @@ -29,14 +27,14 @@ import java.util.ListIterator; | |||
| * Here is the use | |||
| * <ol> | |||
| * <li>Policies are executed in order of declaration. | |||
| * <li>The {@link #beforeConnect(org.apache.tools.ant.taskdefs.optional.repository.GetLibraries, java.util.ListIterator)} call, | |||
| * <li>The {@link #beforeConnect(org.apache.tools.ant.taskdefs.repository.Libraries, java.util.ListIterator)} call, | |||
| * is called before any connection has been initiated; policies can manipulate | |||
| * the library list, set/reset their toFetch list, rename destination files, etc. | |||
| * <li>If any policy returns false from the method, the connection does not proceed. | |||
| * This is not an error, provided the files are actually present. | |||
| * <li>After running through the fetch of all files marked for download, | |||
| * every policy implementation will again be called in order of declaration. | |||
| * <li>The {@link #afterFetched(org.apache.tools.ant.taskdefs.optional.repository.GetLibraries, java.util.ListIterator)} method | |||
| * <li>The {@link #afterFetched(org.apache.tools.ant.taskdefs.repository.Libraries, java.util.ListIterator)} method | |||
| * does not return anything. | |||
| * <li>Either method can throw a BuildException to indicate some kind of error. | |||
| * </ol> | |||
| @@ -57,7 +55,7 @@ public interface LibraryPolicy extends EnabledLibraryElement { | |||
| * @throws org.apache.tools.ant.BuildException | |||
| * if needed | |||
| */ | |||
| public boolean beforeConnect(GetLibraries owner, ListIterator libraries); | |||
| public boolean beforeConnect(Libraries owner, ListIterator libraries); | |||
| /** | |||
| * method called after a successful connection process. | |||
| @@ -65,7 +63,7 @@ public interface LibraryPolicy extends EnabledLibraryElement { | |||
| * @param libraries | |||
| * @throws org.apache.tools.ant.BuildException | |||
| */ | |||
| public void afterFetched(GetLibraries owner,ListIterator libraries); | |||
| public void afterFetched(Libraries owner,ListIterator libraries); | |||
| } | |||
| @@ -15,7 +15,7 @@ | |||
| * | |||
| */ | |||
| package org.apache.tools.ant.taskdefs.optional.repository; | |||
| package org.apache.tools.ant.taskdefs.repository; | |||
| import org.apache.tools.ant.util.FileUtils; | |||
| @@ -16,8 +16,6 @@ | |||
| */ | |||
| package org.apache.tools.ant.taskdefs.repository; | |||
| import org.apache.tools.ant.taskdefs.optional.repository.GetLibraries; | |||
| import java.util.ListIterator; | |||
| /** | |||
| @@ -36,7 +34,7 @@ public class NoUpdatePolicy extends BaseLibraryPolicy { | |||
| * @throws org.apache.tools.ant.BuildException | |||
| * if needed | |||
| */ | |||
| public boolean beforeConnect(GetLibraries owner, ListIterator libraries) { | |||
| public boolean beforeConnect(Libraries owner, ListIterator libraries) { | |||
| // mark all files as no Fetch | |||
| owner.markAllLibrariesForFetch(false); | |||
| return true; | |||
| @@ -15,7 +15,7 @@ | |||
| * | |||
| */ | |||
| package org.apache.tools.ant.taskdefs.optional.repository; | |||
| package org.apache.tools.ant.taskdefs.repository; | |||
| import org.apache.tools.ant.BuildException; | |||
| import org.apache.tools.ant.types.DataType; | |||
| @@ -28,7 +28,7 @@ import java.io.IOException; | |||
| * that ships with Ant, or one you implement and declare yourself. | |||
| * <p/> | |||
| * The <getlibraries> task lets you supply a repository by reference | |||
| * inline {@link GetLibraries#add(Repository)} or on the command line {@link | |||
| * inline {@link Libraries#add(Repository)} or on the command line {@link | |||
| * GetLibraries#setRepositoryRef(org.apache.tools.ant.types.Reference)} | |||
| * | |||
| * @since Ant1.7 | |||
| @@ -67,7 +67,7 @@ public abstract class Repository extends DataType { | |||
| * | |||
| * @throws BuildException | |||
| */ | |||
| public void connect(GetLibraries owner) { | |||
| public void connect(Libraries owner) { | |||
| } | |||
| @@ -14,7 +14,7 @@ | |||
| * limitations under the License. | |||
| * | |||
| */ | |||
| package org.apache.tools.ant.taskdefs.optional.repository; | |||
| package org.apache.tools.ant.taskdefs.repository; | |||
| import org.apache.tools.ant.BuildException; | |||
| import org.apache.tools.ant.Project; | |||
| @@ -18,9 +18,6 @@ package org.apache.tools.ant.taskdefs.repository; | |||
| import org.apache.tools.ant.BuildException; | |||
| import org.apache.tools.ant.Project; | |||
| import org.apache.tools.ant.taskdefs.optional.repository.GetLibraries; | |||
| import org.apache.tools.ant.taskdefs.optional.repository.Library; | |||
| import org.apache.tools.ant.taskdefs.optional.repository.Repository; | |||
| import org.apache.tools.ant.util.FileUtils; | |||
| import java.io.BufferedInputStream; | |||
| @@ -118,7 +115,7 @@ public class ScheduledUpdatePolicy extends BaseLibraryPolicy { | |||
| * @throws org.apache.tools.ant.BuildException | |||
| * if needed | |||
| */ | |||
| public boolean beforeConnect(GetLibraries owner, ListIterator libraries) { | |||
| public boolean beforeConnect(Libraries owner, ListIterator libraries) { | |||
| Repository repository=owner.getRepository(); | |||
| if(markerFile==null) { | |||
| @@ -161,7 +158,7 @@ public class ScheduledUpdatePolicy extends BaseLibraryPolicy { | |||
| * @param owner | |||
| * @param libraries | |||
| */ | |||
| public void afterFetched(GetLibraries owner, ListIterator libraries) { | |||
| public void afterFetched(Libraries owner, ListIterator libraries) { | |||
| if(markerFileToSave!=null) { | |||
| //if we get here, we need to save the file | |||
| @@ -16,8 +16,6 @@ | |||
| */ | |||
| package org.apache.tools.ant.taskdefs.repository; | |||
| import org.apache.tools.ant.taskdefs.optional.repository.GetLibraries; | |||
| import java.util.ListIterator; | |||
| /** | |||
| @@ -38,7 +36,7 @@ public class TimestampPolicy extends BaseLibraryPolicy { | |||
| * @throws org.apache.tools.ant.BuildException | |||
| * if needed | |||
| */ | |||
| public boolean beforeConnect(GetLibraries owner, ListIterator libraries) { | |||
| public boolean beforeConnect(Libraries owner, ListIterator libraries) { | |||
| owner.markAllLibrariesForFetch(true); | |||
| owner._setUseTimestamp(true); | |||
| return true; | |||
| @@ -34,4 +34,4 @@ propertyset=org.apache.tools.ant.types.PropertySet | |||
| assertions=org.apache.tools.ant.types.Assertions | |||
| concatfilter=org.apache.tools.ant.filters.ConcatFilter | |||
| ispingable=org.apache.tools.ant.taskdefs.optional.condition.IsPingable | |||
| mavenrepository=org.apache.tools.ant.taskdefs.optional.repository.MavenRepository | |||
| mavenrepository=org.apache.tools.ant.taskdefs.repository.MavenRepository | |||
| @@ -14,25 +14,26 @@ | |||
| * limitations under the License. | |||
| * | |||
| */ | |||
| package org.apache.tools.ant.taskdefs.optional.repository; | |||
| package org.apache.tools.ant.taskdefs; | |||
| import org.apache.tools.ant.BuildFileTest; | |||
| import org.apache.tools.ant.taskdefs.repository.AssertDownloaded; | |||
| import org.apache.tools.ant.taskdefs.repository.Libraries; | |||
| /** | |||
| * test the test libraries stuff. | |||
| * skip all the tests if we are offline | |||
| */ | |||
| public class GetLibrariesTest extends BuildFileTest { | |||
| private final static String TASKDEFS_DIR = "src/etc/testcases/taskdefs/optional/"; | |||
| public class LibrariesTest extends BuildFileTest { | |||
| private final static String TASKDEFS_DIR = "src/etc/testcases/taskdefs/"; | |||
| public GetLibrariesTest(String name) { | |||
| public LibrariesTest(String name) { | |||
| super(name); | |||
| } | |||
| public void setUp() { | |||
| configureProject(TASKDEFS_DIR + "getlibraries.xml"); | |||
| configureProject(TASKDEFS_DIR + "libraries.xml"); | |||
| } | |||
| @@ -45,19 +46,19 @@ public class GetLibrariesTest extends BuildFileTest { | |||
| } | |||
| public void testEmpty() { | |||
| expectBuildException("testEmpty",GetLibraries.ERROR_NO_DEST_DIR); | |||
| expectBuildException("testEmpty",Libraries.ERROR_NO_DEST_DIR); | |||
| } | |||
| public void testEmpty2() { | |||
| expectBuildException("testEmpty2", GetLibraries.ERROR_NO_REPOSITORY); | |||
| expectBuildException("testEmpty2", Libraries.ERROR_NO_REPOSITORY); | |||
| } | |||
| public void testEmpty3() { | |||
| expectBuildException("testEmpty3", GetLibraries.ERROR_NO_LIBRARIES); | |||
| expectBuildException("testEmpty3", Libraries.ERROR_NO_LIBRARIES); | |||
| } | |||
| public void testNoRepo() { | |||
| expectBuildException("testNoRepo", GetLibraries.ERROR_NO_REPOSITORY); | |||
| expectBuildException("testNoRepo", Libraries.ERROR_NO_REPOSITORY); | |||
| } | |||
| public void testUnknownReference() { | |||
| @@ -89,13 +90,13 @@ public class GetLibrariesTest extends BuildFileTest { | |||
| public void testTwoRepositories() { | |||
| expectBuildException("testTwoRepositories", | |||
| GetLibraries.ERROR_ONE_REPOSITORY_ONLY); | |||
| Libraries.ERROR_ONE_REPOSITORY_ONLY); | |||
| } | |||
| public void testMavenInlineBadURL() { | |||
| expectExceptionIfOnline("testMavenInlineBadURL", | |||
| "testMavenInlineBadURL", | |||
| GetLibraries.ERROR_INCOMPLETE_RETRIEVAL); | |||
| Libraries.ERROR_INCOMPLETE_RETRIEVAL); | |||
| } | |||
| /** | |||
| @@ -160,7 +161,7 @@ public class GetLibrariesTest extends BuildFileTest { | |||
| public void testNoUpdate() { | |||
| expectExceptionIfOnline("testNoUpdate", | |||
| "update disabled; dest file missing", | |||
| GetLibraries.ERROR_INCOMPLETE_RETRIEVAL); | |||
| Libraries.ERROR_INCOMPLETE_RETRIEVAL); | |||
| } | |||
| public void testTimestamp() { | |||