diff --git a/.classpath.default b/.classpath.default
index 24d26f59..d60d9a68 100644
--- a/.classpath.default
+++ b/.classpath.default
@@ -1,45 +1,45 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/NOTICE b/NOTICE
index 14eef168..88d0339d 100644
--- a/NOTICE
+++ b/NOTICE
@@ -1,5 +1,5 @@
Apache Ivy (TM)
-Copyright 2007-2014 The Apache Software Foundation
+Copyright 2007-2017 The Apache Software Foundation
This product includes software developed at
The Apache Software Foundation (http://www.apache.org/).
diff --git a/build-release.xml b/build-release.xml
index 65c13c59..af396763 100644
--- a/build-release.xml
+++ b/build-release.xml
@@ -17,102 +17,102 @@
under the License.
-->
-
-
-
-
-
-
-
-
- Running @{antfile} @{target} > @{output}
-
+ xmlns:openpgp="antlib:org.apache.commons.openpgp.ant">
+
+
+
+
+
+
+
+
+ Running @{antfile} @{target} > @{output}
+
-
-
-
- [ivy@apache:${antfile.dir}]$ ant -f ${antfile.name} @{target}${line.separator}
-
-
-
-
-
-
-
-
-
+
+
+
+ [ivy@apache:${antfile.dir}]$ ant -f ${antfile.name} @{target}${line.separator}
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
-
-
+
+
-
+
-
+
-
+
-
-
+
+
@@ -128,26 +128,26 @@
${myrepository.content.deps}
-
+
- $ find ${tutorial.src.dir}/build-a-ivy-repository/myrepository/advanced -type f -print${line.separator}
+ $ find ${tutorial.src.dir}/build-a-ivy-repository/myrepository/advanced -type f -print${line.separator}${myrepository.content.namespace}
-
-
+
+
-
-
-
-
-
+
+
+
+
+
@@ -158,29 +158,22 @@
-
+
-
-
-
-
-
+
+
+
+
-
+
-
@@ -188,165 +181,165 @@
-
-
-
-
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
-
-
-
-
-
-
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Setting version to ${build.version}
-
-
-
-
-
-
-
- Setting status to ${status}
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Setting version to ${build.version}
+
+
+
+
+
+
+
+ Setting status to ${status}
+
+
+
@@ -368,54 +361,54 @@
module="bcprov-jdk16" revision="1.45" inline="true" pathid="bouncycastle.bcprov.classpath"/>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -443,8 +436,8 @@
-
-
+
+
@@ -455,7 +448,7 @@
-
+
@@ -481,11 +474,11 @@
-
-
-
+
+
+
diff --git a/build.xml b/build.xml
index a9b4c123..d6f50b50 100644
--- a/build.xml
+++ b/build.xml
@@ -14,27 +14,27 @@
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
- under the License.
+ under the License.
-->
-
+
-
+
-
+
-
+
@@ -45,18 +45,18 @@
-
+
-
-
+
+
+ description="build Ivy and install it in Ant home lib">
@@ -95,8 +95,8 @@
-
-
+
+
@@ -104,20 +104,20 @@
-
+
-
+
-
+
-
+
@@ -127,49 +127,49 @@
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
@@ -187,7 +187,7 @@
-
+
@@ -218,11 +218,11 @@
tofile="${core.classes.build.dir}/org/apache/ivy/core/settings/ivyconf.xml" />
-
+
-
-
+
+
-
+
-
-
+
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
@@ -325,24 +325,24 @@
-
-
+
+
-
-
@@ -365,23 +365,23 @@
-
+
-
+
-
+
-
-
+
+
@@ -403,14 +403,14 @@
-
-
+
-
+
-
+
-
+
@@ -441,10 +441,10 @@
-
+
-
-
-
-
-
-
-
+
+
+
+
+
-
+
-
+
+
+
+
+
+
+
+
+
+
+
-
+
@@ -496,7 +506,7 @@
-
+
@@ -511,19 +521,19 @@
-
-
-
-
+
+
+
+
-
+
-
+
@@ -533,21 +543,21 @@
-
-
+
+
-
-
-
-
-
@@ -556,20 +566,20 @@
-
+
+ inline="true" conf="default" pathid="checkstyle.classpath" transitive="true"
+ log="download-only"/>
-
-
-
-
+
+
+
+
@@ -578,11 +588,11 @@
-
-
+
+
-
+
@@ -596,37 +606,40 @@
-
+
-
-
-
-
-
+
-
-
-
-
@@ -635,15 +648,15 @@
-
+
-
-
+
+
-
+
-
+
+
-
+
-
-
+
diff --git a/doap_Ivy.rdf b/doap_Ivy.rdf
index 97e13ffb..1db78dce 100644
--- a/doap_Ivy.rdf
+++ b/doap_Ivy.rdf
@@ -34,13 +34,41 @@
Java
+
+
+ Apache Ivy 2.4.0
+ 2014-12-26
+ 2.4.0
+
+ Apache Ivy 2.3.0
- 2013-01-20
+ 2013-01-242.3.0
+
+
+ Apache Ivy 2.2.0
+ 2010-10-07
+ 2.2.0
+
+
+
+
+ Apache Ivy 2.1.0
+ 2009-10-13
+ 2.1.0
+
+
+
+
+ Apache Ivy 2.0.0
+ 2009-01-22
+ 2.0.0
+
+
diff --git a/doc/concept.html b/doc/concept.html
index 76029f28..74463c32 100644
--- a/doc/concept.html
+++ b/doc/concept.html
@@ -200,20 +200,27 @@ If you don't want to use xml namespaces, it's possible but you will need to disa
since 1.4
Ivy allows the use of checksums, also known as digests, to verify the correctness of a downloaded file.
-For the moment Ivy supports the md5 and sha1 algorithms.
-
-The configuration of using md5 and/or sha1 can be done globally or by dependency resolver.
-Globally, use the ivy.checksums variable to list the check to be done (only md5 and sha1 are supported).
+The configuration of using the algorithm can be done globally or by dependency resolver.
+Globally, use the ivy.checksums variable to list the check to be done.
On each resolver you can use the checksums attribute to override the global setting.
The setting is a comma separated list of checksum algorithms to use.
-During checking (at download time), the first checksum found is checked, and that's all. This means that if you have a "sha1, md5" setting, then if ivy finds a sha1 file, it will compare the downloaded file sha1 against this sha1, and if the comparison is ok, it will assume the file is ok. If no sha1 file is found, it will look for an md5 file. If none is found no checking is done.
+During checking (at download time), the first checksum found is checked, and that's all. This means that if you have a "SHA-256, sha1, md5" setting, then if ivy finds a SHA-256 file, it will compare the downloaded file SHA-256 against this SHA-256, and if the comparison is ok, it will assume the file is ok. If no SHA-256 file is found, it will look for an sha1 file. If that isn't found, then it checks for md5 and so on. If none is found no checking is done.
During publish, all listed checksum algorithms are computed and uploaded.
By default checksum algorithms are "sha1, md5".
If you want to change this default, you can set the variable ivy.checksums. Hence, to disable checksum validation you just have to set ivy.checksums to "".
+
Supported algorithms
+since 1.4
+
+
md5
+
sha1
+
+since 2.5
+Starting 2.5 version, in addition to md5 and sha1, Ivy supports SHA-256, SHA-512 and SHA-384 algorithms, if the Java runtime in which Ivy is running, supports those. For example, Java 6 runtime supports SHA-256 and SHA-512 as standard algorithms. If Ivy 2.5 and later versions are run under Java 6 or higher runtimes, these algorithms are supported by Ivy too.
+
since 1.4
When Ivy performs the dependency resolution and some other tasks, it fires events before and after the most important steps. You can listen to these events using Ivy API, or you can even register a trigger to perform a particular action when a particular event occur.
diff --git a/doc/ivyfile/dependencies.html b/doc/ivyfile/dependencies.html
index c7e519c0..6e284101 100644
--- a/doc/ivyfile/dependencies.html
+++ b/doc/ivyfile/dependencies.html
@@ -51,6 +51,9 @@ In Ivy 2.1.0 and earlier, if both defaultconf and defaultconfmapping are defined
Child elements
+
+Note: as specified by the ivy.xsd, the children elements are ordered; must come first the dependency elements, then the exclude elements, then the override elements, and then the conflict elements.
+
Element
Description
Cardinality
diff --git a/doc/printTemplate.html b/doc/printTemplate.html
index d9efe86d..fd29b367 100644
--- a/doc/printTemplate.html
+++ b/doc/printTemplate.html
@@ -47,7 +47,7 @@
diff --git a/doc/release-notes.html b/doc/release-notes.html
index 8009de9d..60936705 100644
--- a/doc/release-notes.html
+++ b/doc/release-notes.html
@@ -36,6 +36,7 @@ reporting) project dependencies, characterized by flexibility,
configurability, and tight integration with Apache Ant.
Key features of this 2.5.0 release are
+* Ivy nows uses BoucyCastle 1.52. Due to the non backward compatibility of that library, earlier versions are not supported.
* TODO
* TODO
* TODO
@@ -57,7 +58,27 @@ http://issues.apache.org/jira/browse/ivy
List of changes since Ivy 2.4.0:
+- FIX: Made the maven 'test' configuration public so we can use the test-jar as dependency (IVY-1444)
+- FIX: NullPointerException in dependencytree with no dependencies (IVY-1539)
+- FIX: checkIfChanged is not settable attribute for checkdepsupdate ant task (IVY-1549)
- FIX: ArrayIndexOutOfBoundsException when using a p2 repository for dependencies (IVY-1504)
+- FIX: fixdeps remove transitive 'kept' dependencies
+- FIX: PomModuleDescriptorParser should parse licenses from parent POM (IVY-1526) (Thanks to Jaikiran Pai)
+- FIX: dynamic revisions are not cached per resolver (IVY-1430) (Thanks to Stephen Haberman)
+- FIX: Dependencies failed using branch attribute (and extra attributes) (IVY-1141) (Thanks to Stephen Haberman)
+- FIX: useCacheOnly should allow lookup of changing dependencies in cache (IVY-1515) (Thanks to Ilya)
+- FIX: Translation of POM to Ivy XML with * exclusion is removing main artifact (IVY-1531) (Thanks to Jaikiran Pai)
+- FIX: Have makepom task take description from ivy-module > info > description element (IVY-1520)
+- FIX: Fix RetrieveEngine to take into account the correct extension while dealing with unpacked artifacts (IVY-1478) (Thanks to Jaikiran Pai)
+- FIX: ParseException "Unsupported repository, resources names are not uris" for ivy.xml with parent on Windows (IVY-1448) (Thanks to Riccardo Foschia and Jaikiran Pai)
+
+- IMPROVEMENT: Throw an IllegalStateException when retrieving the resolutionCacheRoot on the DefaultResolutionCacheManager if the basedir (or IvySettings) is not set (IVY-1482)
+- IMPROVEMENT: Optimization: limit the revision numbers scanned if revision prefix is specified (Thanks to Ernestas Vaiciukevičius)
+- IMPROVEMENT: Update bouncycastle to 1.52 (IVY-1521) (Thanks to Michal Srb)
+
+- NEW: Lets ssh-based resolvers use an ~/.ssh/config file to find username/hostname/keyfile options (Thanks to Colin Stanfill)
+- NEW: Add ivy.maven.lookup.sources and ivy.maven.lookup.javadoc variables to control the lookup of the additional artifacts. Defaults to true, for backward compatibility (IVY-1529)
+- NEW: Add (conditional) support for SHA-256 SHA-512 and SHA-384 checksum algorithms (IVY-1554) (Thanks to Jaikiran Pai)
-
-
-
-
+
+
+
+
+
-
-
-
-
-
+
+
+
+
+
-
-
-
+
+
+
diff --git a/src/java/org/apache/ivy/Ivy.java b/src/java/org/apache/ivy/Ivy.java
index c3799e92..fc190edb 100644
--- a/src/java/org/apache/ivy/Ivy.java
+++ b/src/java/org/apache/ivy/Ivy.java
@@ -24,7 +24,6 @@ import java.net.URL;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Collection;
-import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Properties;
@@ -38,6 +37,7 @@ import org.apache.ivy.core.deliver.DeliverOptions;
import org.apache.ivy.core.event.EventManager;
import org.apache.ivy.core.install.InstallEngine;
import org.apache.ivy.core.install.InstallOptions;
+import org.apache.ivy.core.module.descriptor.Artifact;
import org.apache.ivy.core.module.descriptor.ModuleDescriptor;
import org.apache.ivy.core.module.id.ModuleId;
import org.apache.ivy.core.module.id.ModuleRevisionId;
@@ -45,6 +45,7 @@ import org.apache.ivy.core.publish.PublishEngine;
import org.apache.ivy.core.publish.PublishOptions;
import org.apache.ivy.core.report.ResolveReport;
import org.apache.ivy.core.repository.RepositoryManagementEngine;
+import org.apache.ivy.core.resolve.IvyNode;
import org.apache.ivy.core.resolve.ResolveData;
import org.apache.ivy.core.resolve.ResolveEngine;
import org.apache.ivy.core.resolve.ResolveOptions;
@@ -614,8 +615,9 @@ public class Ivy {
// PUBLISH
// ///////////////////////////////////////////////////////////////////////
- public Collection publish(ModuleRevisionId mrid, Collection srcArtifactPattern,
- String resolverName, PublishOptions options) throws IOException {
+ public Collection publish(ModuleRevisionId mrid,
+ Collection srcArtifactPattern, String resolverName, PublishOptions options)
+ throws IOException {
pushContext();
try {
return publishEngine.publish(mrid, srcArtifactPattern, resolverName, options);
@@ -631,7 +633,7 @@ public class Ivy {
/**
* Sorts the collection of IvyNode from the less dependent to the more dependent
*/
- public List sortNodes(Collection nodes, SortOptions options) {
+ public List sortNodes(Collection nodes, SortOptions options) {
pushContext();
try {
return getSortEngine().sortNodes(nodes, options);
@@ -654,7 +656,8 @@ public class Ivy {
* if a circular dependency exists and circular dependency strategy decide to throw
* an exception
*/
- public List sortModuleDescriptors(Collection moduleDescriptors, SortOptions options) {
+ public List sortModuleDescriptors(
+ Collection moduleDescriptors, SortOptions options) {
pushContext();
try {
return getSortEngine().sortModuleDescriptors(moduleDescriptors, options);
@@ -750,7 +753,7 @@ public class Ivy {
}
}
- public String[] listTokenValues(String token, Map otherTokenValues) {
+ public String[] listTokenValues(String token, Map otherTokenValues) {
pushContext();
try {
return searchEngine.listTokenValues(token, otherTokenValues);
@@ -833,14 +836,12 @@ public class Ivy {
}
private void postConfigure() {
- Collection triggers = settings.getTriggers();
- for (Iterator iter = triggers.iterator(); iter.hasNext();) {
- Trigger trigger = (Trigger) iter.next();
+ List triggers = settings.getTriggers();
+ for (Trigger trigger : triggers) {
eventManager.addIvyListener(trigger, trigger.getEventFilter());
}
- for (Iterator iter = settings.getResolvers().iterator(); iter.hasNext();) {
- DependencyResolver resolver = (DependencyResolver) iter.next();
+ for (DependencyResolver resolver : settings.getResolvers()) {
if (resolver instanceof BasicResolver) {
((BasicResolver) resolver).setEventManager(eventManager);
}
diff --git a/src/java/org/apache/ivy/ant/AntWorkspaceResolver.java b/src/java/org/apache/ivy/ant/AntWorkspaceResolver.java
new file mode 100644
index 00000000..14fd0b14
--- /dev/null
+++ b/src/java/org/apache/ivy/ant/AntWorkspaceResolver.java
@@ -0,0 +1,236 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+package org.apache.ivy.ant;
+
+import java.io.File;
+import java.net.MalformedURLException;
+import java.net.URISyntaxException;
+import java.net.URL;
+import java.text.ParseException;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+
+import org.apache.ivy.core.module.descriptor.Artifact;
+import org.apache.ivy.core.module.descriptor.DefaultArtifact;
+import org.apache.ivy.core.module.descriptor.DependencyDescriptor;
+import org.apache.ivy.core.module.descriptor.ModuleDescriptor;
+import org.apache.ivy.core.report.ArtifactDownloadReport;
+import org.apache.ivy.core.report.DownloadReport;
+import org.apache.ivy.core.report.DownloadStatus;
+import org.apache.ivy.core.resolve.DownloadOptions;
+import org.apache.ivy.core.resolve.ResolveData;
+import org.apache.ivy.core.resolve.ResolvedModuleRevision;
+import org.apache.ivy.plugins.parser.ModuleDescriptorParserRegistry;
+import org.apache.ivy.plugins.resolver.AbstractWorkspaceResolver;
+import org.apache.ivy.util.Message;
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.types.DataType;
+import org.apache.tools.ant.types.ResourceCollection;
+import org.apache.tools.ant.types.resources.FileResource;
+
+public class AntWorkspaceResolver extends DataType {
+
+ public static final class WorkspaceArtifact {
+
+ private String name;
+
+ private String type;
+
+ private String ext;
+
+ private String path;
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public void setType(String type) {
+ this.type = type;
+ }
+
+ public void setExt(String ext) {
+ this.ext = ext;
+ }
+
+ public void setPath(String path) {
+ this.path = path;
+ }
+ }
+
+ private List allResources = new ArrayList();
+
+ private boolean haltOnError = true;
+
+ private Resolver resolver;
+
+ private String name;
+
+ private List artifacts = new ArrayList();
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public void setHaltonerror(boolean haltOnError) {
+ this.haltOnError = haltOnError;
+ }
+
+ public void addConfigured(ResourceCollection resources) {
+ if (!resources.isFilesystemOnly()) {
+ throw new BuildException("Only filesystem resource collection is supported");
+ }
+ allResources.add(resources);
+ }
+
+ public WorkspaceArtifact createArtifact() {
+ WorkspaceArtifact a = new WorkspaceArtifact();
+ artifacts.add(a);
+ return a;
+ }
+
+ public Resolver getResolver() {
+ if (resolver == null) {
+ if (name == null) {
+ throw new BuildException("A name is required");
+ }
+ resolver = new Resolver();
+ resolver.setName(name);
+ }
+ return resolver;
+ }
+
+ private String getProjectName(File ivyFile) {
+ return ivyFile.getParentFile().getName();
+ }
+
+ private class Resolver extends AbstractWorkspaceResolver {
+
+ private Map md2IvyFile;
+
+ private synchronized Map getModuleDescriptors() {
+ if (md2IvyFile == null) {
+ md2IvyFile = new HashMap();
+ for (ResourceCollection resources : allResources) {
+ for (Iterator it = resources.iterator(); it.hasNext();) {
+ File ivyFile = ((FileResource) it.next()).getFile();
+ try {
+ ModuleDescriptor md = ModuleDescriptorParserRegistry.getInstance()
+ .parseDescriptor(getParserSettings(), ivyFile.toURI().toURL(),
+ isValidate());
+ md2IvyFile.put(md, ivyFile);
+ Message.debug("Add " + md.getModuleRevisionId().getModuleId());
+ } catch (Exception ex) {
+ if (haltOnError) {
+ throw new BuildException("impossible to parse ivy file " + ivyFile
+ + " exception=" + ex, ex);
+ } else {
+ Message.warn("impossible to parse ivy file " + ivyFile
+ + " exception=" + ex.getMessage());
+ }
+ }
+ }
+ }
+ }
+ return md2IvyFile;
+ }
+
+ public ResolvedModuleRevision getDependency(DependencyDescriptor dd, ResolveData data)
+ throws ParseException {
+ Map mds = getModuleDescriptors();
+ for (Entry md : mds.entrySet()) {
+ ResolvedModuleRevision rmr = checkCandidate(dd, md.getKey(),
+ getProjectName(md.getValue()));
+ if (rmr != null) {
+ return rmr;
+ }
+ }
+ return null;
+ }
+
+ @Override
+ protected List createWorkspaceArtifacts(ModuleDescriptor md) {
+ List res = new ArrayList();
+
+ for (WorkspaceArtifact wa : artifacts) {
+ String name = wa.name;
+ String type = wa.type;
+ String ext = wa.ext;
+ String path = wa.path;
+ if (name == null) {
+ name = md.getModuleRevisionId().getName();
+ }
+ if (type == null) {
+ type = "jar";
+ }
+ if (ext == null) {
+ ext = "jar";
+ }
+ if (path == null) {
+ path = "target" + File.separator + "dist" + File.separator + type + "s"
+ + File.separator + name + "." + ext;
+ }
+
+ URL url;
+ File ivyFile = md2IvyFile.get(md);
+ File artifactFile = new File(ivyFile.getParentFile(), path);
+ try {
+ url = artifactFile.toURI().toURL();
+ } catch (MalformedURLException e) {
+ throw new RuntimeException("Unsupported file path : " + artifactFile, e);
+ }
+
+ res.add(new DefaultArtifact(md.getModuleRevisionId(), new Date(), name, type, ext,
+ url, null));
+ }
+
+ return res;
+ }
+
+ public DownloadReport download(Artifact[] artifacts, DownloadOptions options) {
+ // Not much to do here - downloads are not required for workspace projects.
+ DownloadReport dr = new DownloadReport();
+ for (int i = 0; i < artifacts.length; i++) {
+ ArtifactDownloadReport adr = new ArtifactDownloadReport(artifacts[i]);
+ dr.addArtifactReport(adr);
+ URL url = artifacts[i].getUrl();
+ if (url == null || !url.getProtocol().equals("file")) {
+ // this is not an artifact managed by this resolver
+ adr.setDownloadStatus(DownloadStatus.FAILED);
+ return dr;
+ }
+ File f;
+ try {
+ f = new File(url.toURI());
+ } catch (URISyntaxException e) {
+ f = new File(url.getPath());
+ }
+ adr.setLocalFile(f);
+ adr.setDownloadStatus(DownloadStatus.NO);
+ adr.setSize(0);
+ Message.verbose("\t[IN WORKSPACE] " + artifacts[i]);
+ }
+ return dr;
+ }
+ }
+
+}
diff --git a/src/java/org/apache/ivy/ant/FixDepsTask.java b/src/java/org/apache/ivy/ant/FixDepsTask.java
index 1be9222d..8695cb87 100644
--- a/src/java/org/apache/ivy/ant/FixDepsTask.java
+++ b/src/java/org/apache/ivy/ant/FixDepsTask.java
@@ -32,7 +32,7 @@ public class FixDepsTask extends IvyPostResolveTask {
private File dest;
- private List/* */keeps = new ArrayList();
+ private List keeps = new ArrayList();
public void setToFile(File dest) {
this.dest = dest;
@@ -59,6 +59,7 @@ public class FixDepsTask extends IvyPostResolveTask {
return k;
}
+ @Override
public void doExecute() throws BuildException {
prepareAndCheck();
@@ -72,10 +73,9 @@ public class FixDepsTask extends IvyPostResolveTask {
ResolveReport report = getResolvedReport();
- List/* */midToKeep = new ArrayList();
- for (int i = 0; i < keeps.size(); i++) {
- midToKeep.add(ModuleId.newInstance(((Keep) keeps.get(i)).org,
- ((Keep) keeps.get(i)).module));
+ List midToKeep = new ArrayList();
+ for (Keep keep : keeps) {
+ midToKeep.add(ModuleId.newInstance(keep.org, keep.module));
}
ModuleDescriptor md = report.toFixedModuleDescriptor(getSettings(), midToKeep);
diff --git a/src/java/org/apache/ivy/ant/IvyAntSettings.java b/src/java/org/apache/ivy/ant/IvyAntSettings.java
index 660ebbe9..bb67ba7a 100644
--- a/src/java/org/apache/ivy/ant/IvyAntSettings.java
+++ b/src/java/org/apache/ivy/ant/IvyAntSettings.java
@@ -102,6 +102,8 @@ public class IvyAntSettings extends DataType {
private boolean autoRegistered = false;
+ private AntWorkspaceResolver antWorkspaceResolver;
+
/**
* Returns the default ivy settings of this classloader. If it doesn't exist yet, a new one is
* created using the given project to back the VariableContainer.
@@ -275,6 +277,10 @@ public class IvyAntSettings extends DataType {
defineDefaultSettingFile(ivyAntVariableContainer, task);
}
+ if (antWorkspaceResolver != null) {
+ settings.addConfigured(antWorkspaceResolver.getResolver());
+ }
+
Ivy ivy = Ivy.newInstance(settings);
try {
ivy.pushContext();
@@ -388,4 +394,7 @@ public class IvyAntSettings extends DataType {
URLHandlerRegistry.setDefault(dispatcher);
}
+ public void addConfiguredWorkspaceResolver(AntWorkspaceResolver antWorkspaceResolver) {
+ this.antWorkspaceResolver = antWorkspaceResolver;
+ }
}
diff --git a/src/java/org/apache/ivy/ant/IvyBuildList.java b/src/java/org/apache/ivy/ant/IvyBuildList.java
index 0620b49e..ba4b1a37 100644
--- a/src/java/org/apache/ivy/ant/IvyBuildList.java
+++ b/src/java/org/apache/ivy/ant/IvyBuildList.java
@@ -23,7 +23,6 @@ import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
-import java.util.Iterator;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.ListIterator;
@@ -66,7 +65,7 @@ public class IvyBuildList extends IvyTask {
public static final String DESCRIPTOR_REQUIRED = "required";
- private List buildFileSets = new ArrayList(); // List (FileSet)
+ private List buildFileSets = new ArrayList();
private String reference;
@@ -152,6 +151,7 @@ public class IvyBuildList extends IvyTask {
this.onlydirectdep = onlydirectdep;
}
+ @Override
public void doExecute() throws BuildException {
if (reference == null) {
throw new BuildException("reference should be provided in ivy build list");
@@ -168,12 +168,12 @@ public class IvyBuildList extends IvyTask {
Path path = new Path(getProject());
- Map buildFiles = new HashMap(); // Map (ModuleDescriptor -> File buildFile)
- List independent = new ArrayList();
- List noDescriptor = new ArrayList();
- Collection mds = new ArrayList();
+ Map buildFiles = new HashMap();
+ List independent = new ArrayList();
+ List noDescriptor = new ArrayList();
+ Collection mds = new ArrayList();
- Set rootModuleNames = new LinkedHashSet();
+ Set rootModuleNames = new LinkedHashSet();
if (!"*".equals(root)) {
StringTokenizer st = new StringTokenizer(root, delimiter);
while (st.hasMoreTokens()) {
@@ -181,7 +181,7 @@ public class IvyBuildList extends IvyTask {
}
}
- Set leafModuleNames = new LinkedHashSet();
+ Set leafModuleNames = new LinkedHashSet();
if (!"*".equals(leaf)) {
StringTokenizer st = new StringTokenizer(leaf, delimiter);
while (st.hasMoreTokens()) {
@@ -189,15 +189,14 @@ public class IvyBuildList extends IvyTask {
}
}
- Set restartFromModuleNames = new LinkedHashSet();
+ Set restartFromModuleNames = new LinkedHashSet();
if (!"*".equals(restartFrom)) {
StringTokenizer st = new StringTokenizer(restartFrom, delimiter);
// Only accept one (first) module
restartFromModuleNames.add(st.nextToken());
}
- for (ListIterator iter = buildFileSets.listIterator(); iter.hasNext();) {
- FileSet fs = (FileSet) iter.next();
+ for (FileSet fs : buildFileSets) {
DirectoryScanner ds = fs.getDirectoryScanner(getProject());
String[] builds = ds.getIncludedFiles();
for (int i = 0; i < builds.length; i++) {
@@ -228,12 +227,12 @@ public class IvyBuildList extends IvyTask {
}
}
- List leafModuleDescriptors = convertModuleNamesToModuleDescriptors(mds, leafModuleNames,
- "leaf");
- List rootModuleDescriptors = convertModuleNamesToModuleDescriptors(mds, rootModuleNames,
- "root");
- List restartFromModuleDescriptors = convertModuleNamesToModuleDescriptors(mds,
- restartFromModuleNames, "restartFrom");
+ List leafModuleDescriptors = convertModuleNamesToModuleDescriptors(mds,
+ leafModuleNames, "leaf");
+ List rootModuleDescriptors = convertModuleNamesToModuleDescriptors(mds,
+ rootModuleNames, "root");
+ List restartFromModuleDescriptors = convertModuleNamesToModuleDescriptors(
+ mds, restartFromModuleNames, "restartFrom");
if (!rootModuleDescriptors.isEmpty()) {
Message.info("Filtering modules based on roots " + rootModuleNames);
@@ -244,16 +243,14 @@ public class IvyBuildList extends IvyTask {
mds = filterModulesFromLeaf(mds, leafModuleDescriptors);
}
- List sortedModules = ivy.sortModuleDescriptors(mds, SortOptions.DEFAULT);
+ List sortedModules = ivy.sortModuleDescriptors(mds, SortOptions.DEFAULT);
if (!OnMissingDescriptor.TAIL.equals(onMissingDescriptor)) {
- for (ListIterator iter = noDescriptor.listIterator(); iter.hasNext();) {
- File buildFile = (File) iter.next();
+ for (File buildFile : noDescriptor) {
addBuildFile(path, buildFile);
}
}
- for (ListIterator iter = independent.listIterator(); iter.hasNext();) {
- File buildFile = (File) iter.next();
+ for (File buildFile : independent) {
addBuildFile(path, buildFile);
}
if (isReverse()) {
@@ -264,11 +261,9 @@ public class IvyBuildList extends IvyTask {
// so they are not removed from build path.
if (!restartFromModuleDescriptors.isEmpty()) {
boolean foundRestartFrom = false;
- List keptModules = new ArrayList();
- ModuleDescriptor restartFromModuleDescriptor = (ModuleDescriptor) restartFromModuleDescriptors
- .get(0);
- for (ListIterator iter = sortedModules.listIterator(); iter.hasNext();) {
- ModuleDescriptor md = (ModuleDescriptor) iter.next();
+ List keptModules = new ArrayList();
+ ModuleDescriptor restartFromModuleDescriptor = restartFromModuleDescriptors.get(0);
+ for (ModuleDescriptor md : sortedModules) {
if (md.equals(restartFromModuleDescriptor)) {
foundRestartFrom = true;
}
@@ -279,18 +274,17 @@ public class IvyBuildList extends IvyTask {
sortedModules = keptModules;
}
StringBuffer order = new StringBuffer();
- for (ListIterator iter = sortedModules.listIterator(); iter.hasNext();) {
- ModuleDescriptor md = (ModuleDescriptor) iter.next();
+ for (ListIterator iter = sortedModules.listIterator(); iter.hasNext();) {
+ ModuleDescriptor md = iter.next();
order.append(md.getModuleRevisionId().getModuleId());
if (iter.hasNext()) {
order.append(", ");
}
- File buildFile = (File) buildFiles.get(md);
+ File buildFile = buildFiles.get(md);
addBuildFile(path, buildFile);
}
if (OnMissingDescriptor.TAIL.equals(onMissingDescriptor)) {
- for (ListIterator iter = noDescriptor.listIterator(); iter.hasNext();) {
- File buildFile = (File) iter.next();
+ for (File buildFile : noDescriptor) {
addBuildFile(path, buildFile);
}
}
@@ -299,7 +293,7 @@ public class IvyBuildList extends IvyTask {
getProject().setProperty("ivy.sorted.modules", order.toString());
}
- private void onMissingDescriptor(File buildFile, File ivyFile, List noDescriptor) {
+ private void onMissingDescriptor(File buildFile, File ivyFile, List noDescriptor) {
if (OnMissingDescriptor.SKIP.equals(onMissingDescriptor)) {
Message.debug("skipping " + buildFile + ": descriptor " + ivyFile + " doesn't exist");
} else if (OnMissingDescriptor.FAIL.equals(onMissingDescriptor)) {
@@ -323,12 +317,12 @@ public class IvyBuildList extends IvyTask {
}
}
- private List convertModuleNamesToModuleDescriptors(Collection mds, Set moduleNames, String kind) {
- List result = new ArrayList();
- Set foundModuleNames = new HashSet();
+ private List convertModuleNamesToModuleDescriptors(
+ Collection mds, Set moduleNames, String kind) {
+ List result = new ArrayList();
+ Set foundModuleNames = new HashSet();
- for (Iterator it = mds.iterator(); it.hasNext();) {
- ModuleDescriptor md = (ModuleDescriptor) it.next();
+ for (ModuleDescriptor md : mds) {
String name = md.getModuleRevisionId().getModuleId().getName();
if (moduleNames.contains(name)) {
foundModuleNames.add(name);
@@ -337,14 +331,14 @@ public class IvyBuildList extends IvyTask {
}
if (foundModuleNames.size() < moduleNames.size()) {
- Set missingModules = new HashSet(moduleNames);
+ Set missingModules = new HashSet(moduleNames);
missingModules.removeAll(foundModuleNames);
StringBuffer missingNames = new StringBuffer();
String sep = "";
- for (Iterator it = missingModules.iterator(); it.hasNext();) {
+ for (String name : missingModules) {
missingNames.append(sep);
- missingNames.append(it.next());
+ missingNames.append(name);
sep = ", ";
}
@@ -365,20 +359,17 @@ public class IvyBuildList extends IvyTask {
* root module
* @return filtered list of modules
*/
- private Collection filterModulesFromRoot(Collection mds, List rootmds) {
- // Make a map of ModuleId objects -> ModuleDescriptors
- Map moduleIdMap = new HashMap();
- for (Iterator iter = mds.iterator(); iter.hasNext();) {
- ModuleDescriptor md = ((ModuleDescriptor) iter.next());
+ private Collection filterModulesFromRoot(Collection mds,
+ List rootmds) {
+ Map moduleIdMap = new HashMap();
+ for (ModuleDescriptor md : mds) {
moduleIdMap.put(md.getModuleRevisionId().getModuleId(), md);
}
// recursively process the nodes
- Set toKeep = new LinkedHashSet();
+ Set toKeep = new LinkedHashSet();
- Iterator it = rootmds.iterator();
- while (it.hasNext()) {
- ModuleDescriptor rootmd = (ModuleDescriptor) it.next();
+ for (ModuleDescriptor rootmd : rootmds) {
processFilterNodeFromRoot(rootmd, toKeep, moduleIdMap);
// With the excluderoot attribute set to true, take the rootmd out of the toKeep set.
if (excludeRoot) {
@@ -391,8 +382,7 @@ public class IvyBuildList extends IvyTask {
}
// just for logging
- for (Iterator iter = toKeep.iterator(); iter.hasNext();) {
- ModuleDescriptor md = ((ModuleDescriptor) iter.next());
+ for (ModuleDescriptor md : toKeep) {
Message.verbose("Kept module " + md.getModuleRevisionId().getModuleId().getName());
}
@@ -411,13 +401,14 @@ public class IvyBuildList extends IvyTask {
* @param moduleIdMap
* reference mapping of moduleId to ModuleDescriptor that are part of the BuildList
*/
- private void processFilterNodeFromRoot(ModuleDescriptor node, Set toKeep, Map moduleIdMap) {
+ private void processFilterNodeFromRoot(ModuleDescriptor node, Set toKeep,
+ Map moduleIdMap) {
// toKeep.add(node);
DependencyDescriptor[] deps = node.getDependencies();
for (int i = 0; i < deps.length; i++) {
ModuleId id = deps[i].getDependencyId();
- ModuleDescriptor md = (ModuleDescriptor) moduleIdMap.get(id);
+ ModuleDescriptor md = moduleIdMap.get(id);
// we test if this module id has a module descriptor, and if it isn't already in the
// toKeep Set, in which there's probably a circular dependency
if (md != null && !toKeep.contains(md)) {
@@ -439,19 +430,16 @@ public class IvyBuildList extends IvyTask {
* leaf module
* @return filtered list of modules
*/
- private Collection filterModulesFromLeaf(Collection mds, List leafmds) {
- // Make a map of ModuleId objects -> ModuleDescriptors
- Map moduleIdMap = new HashMap();
- for (Iterator iter = mds.iterator(); iter.hasNext();) {
- ModuleDescriptor md = ((ModuleDescriptor) iter.next());
+ private Collection filterModulesFromLeaf(Collection mds,
+ List leafmds) {
+ Map moduleIdMap = new HashMap();
+ for (ModuleDescriptor md : mds) {
moduleIdMap.put(md.getModuleRevisionId().getModuleId(), md);
}
// recursively process the nodes
- Set toKeep = new LinkedHashSet();
- Iterator it = leafmds.iterator();
- while (it.hasNext()) {
- ModuleDescriptor leafmd = (ModuleDescriptor) it.next();
+ Set toKeep = new LinkedHashSet();
+ for (ModuleDescriptor leafmd : leafmds) {
// With the excludeleaf attribute set to true, take the rootmd out of the toKeep set.
if (excludeLeaf) {
Message.verbose("Excluded module "
@@ -463,8 +451,7 @@ public class IvyBuildList extends IvyTask {
}
// just for logging
- for (Iterator iter = toKeep.iterator(); iter.hasNext();) {
- ModuleDescriptor md = ((ModuleDescriptor) iter.next());
+ for (ModuleDescriptor md : toKeep) {
Message.verbose("Kept module " + md.getModuleRevisionId().getModuleId().getName());
}
@@ -482,9 +469,9 @@ public class IvyBuildList extends IvyTask {
* @param moduleIdMap
* reference mapping of moduleId to ModuleDescriptor that are part of the BuildList
*/
- private void processFilterNodeFromLeaf(ModuleDescriptor node, Set toKeep, Map moduleIdMap) {
- for (Iterator iter = moduleIdMap.values().iterator(); iter.hasNext();) {
- ModuleDescriptor md = (ModuleDescriptor) iter.next();
+ private void processFilterNodeFromLeaf(ModuleDescriptor node, Set toKeep,
+ Map moduleIdMap) {
+ for (ModuleDescriptor md : moduleIdMap.values()) {
DependencyDescriptor[] deps = md.getDependencies();
for (int i = 0; i < deps.length; i++) {
ModuleId id = deps[i].getDependencyId();
diff --git a/src/java/org/apache/ivy/ant/IvyBuildNumber.java b/src/java/org/apache/ivy/ant/IvyBuildNumber.java
index 7f7ce7d1..86344727 100644
--- a/src/java/org/apache/ivy/ant/IvyBuildNumber.java
+++ b/src/java/org/apache/ivy/ant/IvyBuildNumber.java
@@ -19,6 +19,7 @@ package org.apache.ivy.ant;
import java.util.List;
import java.util.ListIterator;
+import java.util.regex.Pattern;
import org.apache.ivy.Ivy;
import org.apache.ivy.core.module.id.ModuleId;
@@ -169,25 +170,32 @@ public class IvyBuildNumber extends IvyTask {
if (expression.equals(organisation) || expression.equals(module)
|| expression.equals(branch)) {
return exact.getMatcher(expression);
+ } else {
+ return regexp.getMatcher(expression);
}
- return regexp.getMatcher(expression);
}
public String getName() {
return "buildnumber-matcher";
}
};
+
+ String revisionPattern = ".*";
+ if (revision.endsWith("+")) {
+ revisionPattern = Pattern.quote(revision.substring(0, revision.length() - 1)) + ".*";
+ }
+
+ ModuleRevisionId mrid = ModuleRevisionId.newInstance(organisation, module, branch,
+ revisionPattern);
ModuleRevisionId[] revisions;
if (resolver == null) {
- revisions = searcher.listModules(
- ModuleRevisionId.newInstance(organisation, module, branch, ".*"), patternMatcher);
+ revisions = searcher.listModules(mrid, patternMatcher);
} else {
DependencyResolver depResolver = settings.getResolver(resolver);
if (depResolver == null) {
throw new BuildException("Unknown resolver: " + resolver);
}
- revisions = searcher.listModules(depResolver,
- ModuleRevisionId.newInstance(organisation, module, branch, ".*"), patternMatcher);
+ revisions = searcher.listModules(depResolver, mrid, patternMatcher);
}
ArtifactInfo[] infos = new ArtifactInfo[revisions.length];
diff --git a/src/java/org/apache/ivy/ant/IvyConfigure.java b/src/java/org/apache/ivy/ant/IvyConfigure.java
index 5e05adcb..6926d025 100644
--- a/src/java/org/apache/ivy/ant/IvyConfigure.java
+++ b/src/java/org/apache/ivy/ant/IvyConfigure.java
@@ -130,6 +130,11 @@ public class IvyConfigure extends Task {
settings.setPasswd(passwd);
}
+ public void addConfiguredWorkspaceResolver(AntWorkspaceResolver resolver) {
+ settings.addConfiguredWorkspaceResolver(resolver);
+ }
+
+ @Override
public void execute() throws BuildException {
String settingsId = settings.getId();
Object otherRef = getProject().getReference(settingsId);
diff --git a/src/java/org/apache/ivy/ant/IvyDependency.java b/src/java/org/apache/ivy/ant/IvyDependency.java
index dbc8f215..051a55ad 100644
--- a/src/java/org/apache/ivy/ant/IvyDependency.java
+++ b/src/java/org/apache/ivy/ant/IvyDependency.java
@@ -18,7 +18,6 @@
package org.apache.ivy.ant;
import java.util.ArrayList;
-import java.util.Iterator;
import java.util.List;
import org.apache.ivy.core.module.descriptor.DefaultDependencyDescriptor;
@@ -32,13 +31,13 @@ import org.apache.tools.ant.BuildException;
public class IvyDependency {
- private List/* */confs = new ArrayList();
+ private List confs = new ArrayList();
- private List/* */artifacts = new ArrayList();
+ private List artifacts = new ArrayList();
- private List/* */excludes = new ArrayList();
+ private List excludes = new ArrayList();
- private List/* */includes = new ArrayList();
+ private List includes = new ArrayList();
private String org;
@@ -161,28 +160,20 @@ public class IvyDependency {
dd.addDependencyConfiguration(masterConf, "*");
}
- Iterator itConfs = confs.iterator();
- while (itConfs.hasNext()) {
- IvyDependencyConf c = (IvyDependencyConf) itConfs.next();
+ for (IvyDependencyConf c : confs) {
c.addConf(dd, masterConf);
}
- Iterator itArtifacts = artifacts.iterator();
- while (itArtifacts.hasNext()) {
- IvyDependencyArtifact artifact = (IvyDependencyArtifact) itArtifacts.next();
+ for (IvyDependencyArtifact artifact : artifacts) {
artifact.addArtifact(dd, masterConf);
}
- Iterator itExcludes = excludes.iterator();
- while (itExcludes.hasNext()) {
- IvyDependencyExclude exclude = (IvyDependencyExclude) itExcludes.next();
+ for (IvyDependencyExclude exclude : excludes) {
DefaultExcludeRule rule = exclude.asRule(settings);
dd.addExcludeRule(masterConf, rule);
}
- Iterator itIncludes = includes.iterator();
- while (itIncludes.hasNext()) {
- IvyDependencyInclude include = (IvyDependencyInclude) itIncludes.next();
+ for (IvyDependencyInclude include : includes) {
DefaultIncludeRule rule = include.asRule(settings);
dd.addIncludeRule(masterConf, rule);
}
diff --git a/src/java/org/apache/ivy/ant/IvyDependencyTree.java b/src/java/org/apache/ivy/ant/IvyDependencyTree.java
index f7c9feed..bb7c2797 100644
--- a/src/java/org/apache/ivy/ant/IvyDependencyTree.java
+++ b/src/java/org/apache/ivy/ant/IvyDependencyTree.java
@@ -49,7 +49,10 @@ public class IvyDependencyTree extends IvyPostResolveTask {
IvyNode dependency = (IvyNode) iterator.next();
populateDependencyTree(dependency, mrid, report);
}
- printDependencies((List) dependencies.get(mrid), 0);
+ List dependencyList = (List) dependencies.get(mrid);
+ if (dependencyList != null) {
+ printDependencies(dependencyList, 0);
+ }
}
private void printDependencies(List/* */dependencyList, int indent) {
diff --git a/src/java/org/apache/ivy/ant/IvyDependencyUpdateChecker.java b/src/java/org/apache/ivy/ant/IvyDependencyUpdateChecker.java
index d416e570..4a71664e 100644
--- a/src/java/org/apache/ivy/ant/IvyDependencyUpdateChecker.java
+++ b/src/java/org/apache/ivy/ant/IvyDependencyUpdateChecker.java
@@ -211,4 +211,11 @@ public class IvyDependencyUpdateChecker extends IvyPostResolveTask {
this.showTransitive = showTransitive;
}
+ public boolean isCheckIfChanged() {
+ return checkIfChanged;
+ }
+
+ public void setCheckIfChanged(boolean checkIfChanged) {
+ this.checkIfChanged = checkIfChanged;
+ }
}
diff --git a/src/java/org/apache/ivy/ant/IvyMakePom.java b/src/java/org/apache/ivy/ant/IvyMakePom.java
index 406b1553..395a4ad6 100644
--- a/src/java/org/apache/ivy/ant/IvyMakePom.java
+++ b/src/java/org/apache/ivy/ant/IvyMakePom.java
@@ -22,15 +22,14 @@ import java.io.IOException;
import java.net.MalformedURLException;
import java.text.ParseException;
import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.Iterator;
+import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import org.apache.ivy.core.module.descriptor.ModuleDescriptor;
import org.apache.ivy.plugins.parser.m2.PomModuleDescriptorWriter;
import org.apache.ivy.plugins.parser.m2.PomWriterOptions;
+import org.apache.ivy.plugins.parser.m2.PomWriterOptions.ExtraDependency;
import org.apache.ivy.plugins.parser.xml.XmlModuleDescriptorParser;
import org.apache.ivy.util.FileUtil;
import org.apache.tools.ant.BuildException;
@@ -152,9 +151,9 @@ public class IvyMakePom extends IvyTask {
private String description;
- private Collection mappings = new ArrayList();
+ private List mappings = new ArrayList();
- private Collection dependencies = new ArrayList();
+ private List dependencies = new ArrayList();
public File getPomFile() {
return pomFile;
@@ -240,6 +239,7 @@ public class IvyMakePom extends IvyTask {
return dependency;
}
+ @Override
public void doExecute() throws BuildException {
try {
if (ivyFile == null) {
@@ -281,10 +281,9 @@ public class IvyMakePom extends IvyTask {
return options;
}
- private Map getMappingsMap() {
- Map mappingsMap = new HashMap();
- for (Iterator iter = mappings.iterator(); iter.hasNext();) {
- Mapping mapping = (Mapping) iter.next();
+ private Map getMappingsMap() {
+ Map mappingsMap = new LinkedHashMap();
+ for (Mapping mapping : mappings) {
String[] mappingConfs = splitConfs(mapping.getConf());
for (int i = 0; i < mappingConfs.length; i++) {
if (!mappingsMap.containsKey(mappingConfs[i])) {
@@ -295,13 +294,12 @@ public class IvyMakePom extends IvyTask {
return mappingsMap;
}
- private List getDependencies() {
- List result = new ArrayList();
- for (Iterator iter = dependencies.iterator(); iter.hasNext();) {
- Dependency dependency = (Dependency) iter.next();
- result.add(new PomWriterOptions.ExtraDependency(dependency.getGroup(), dependency
- .getArtifact(), dependency.getVersion(), dependency.getScope(), dependency
- .getType(), dependency.getClassifier(), dependency.getOptional()));
+ private List getDependencies() {
+ List result = new ArrayList();
+ for (Dependency dependency : dependencies) {
+ result.add(new ExtraDependency(dependency.getGroup(), dependency.getArtifact(),
+ dependency.getVersion(), dependency.getScope(), dependency.getType(),
+ dependency.getClassifier(), dependency.getOptional()));
}
return result;
}
diff --git a/src/java/org/apache/ivy/ant/IvyPublish.java b/src/java/org/apache/ivy/ant/IvyPublish.java
index d46b701f..04df76eb 100644
--- a/src/java/org/apache/ivy/ant/IvyPublish.java
+++ b/src/java/org/apache/ivy/ant/IvyPublish.java
@@ -61,7 +61,7 @@ public class IvyPublish extends IvyTask {
private String publishResolverName = null;
- private List artifactspattern = new ArrayList();
+ private List artifactspattern = new ArrayList();
private File deliveryList;
@@ -81,7 +81,7 @@ public class IvyPublish extends IvyTask {
private boolean forcedeliver;
- private Collection artifacts = new ArrayList();
+ private Collection artifacts = new ArrayList();
private String pubBranch;
@@ -190,7 +190,7 @@ public class IvyPublish extends IvyTask {
}
public String getArtifactspattern() {
- return (String) (artifactspattern.isEmpty() ? null : artifactspattern.get(0));
+ return artifactspattern.isEmpty() ? null : artifactspattern.get(0);
}
public void setArtifactspattern(String artifactsPattern) {
@@ -222,6 +222,7 @@ public class IvyPublish extends IvyTask {
this.merge = merge;
}
+ @Override
public void doExecute() throws BuildException {
Ivy ivy = getIvyInstance();
IvySettings settings = ivy.getSettings();
@@ -312,14 +313,10 @@ public class IvyPublish extends IvyTask {
mrid,
artifactspattern,
publishResolverName,
- new PublishOptions()
- .setPubrevision(getPubrevision())
- .setPubbranch(getPubbranch())
- .setSrcIvyPattern(publishivy ? srcivypattern : null)
- .setStatus(getStatus())
+ new PublishOptions().setPubrevision(getPubrevision()).setPubbranch(getPubbranch())
+ .setSrcIvyPattern(publishivy ? srcivypattern : null).setStatus(getStatus())
.setPubdate(pubdate)
- .setExtraArtifacts(
- (Artifact[]) artifacts.toArray(new Artifact[artifacts.size()]))
+ .setExtraArtifacts(artifacts.toArray(new Artifact[artifacts.size()]))
.setValidate(doValidate(settings)).setOverwrite(overwrite)
.setUpdate(update).setMerge(merge).setWarnOnMissing(warnonmissing)
.setHaltOnMissing(haltonmissing).setConfs(splitConfs(conf)));
@@ -392,7 +389,7 @@ public class IvyPublish extends IvyTask {
private String type;
- private Map extra = new HashMap();
+ private Map extra = new HashMap();
public String[] getConfigurations() {
return null;
@@ -439,22 +436,22 @@ public class IvyPublish extends IvyTask {
}
public String getAttribute(String attName) {
- return (String) extra.get(attName);
+ return extra.get(attName);
}
- public Map getAttributes() {
+ public Map getAttributes() {
return extra;
}
public String getExtraAttribute(String attName) {
- return (String) extra.get(attName);
+ return extra.get(attName);
}
- public Map getExtraAttributes() {
+ public Map getExtraAttributes() {
return extra;
}
- public Map getQualifiedExtraAttributes() {
+ public Map getQualifiedExtraAttributes() {
return extra;
}
diff --git a/src/java/org/apache/ivy/ant/IvyResolve.java b/src/java/org/apache/ivy/ant/IvyResolve.java
index 5dd77577..c700421b 100644
--- a/src/java/org/apache/ivy/ant/IvyResolve.java
+++ b/src/java/org/apache/ivy/ant/IvyResolve.java
@@ -23,7 +23,6 @@ import java.text.ParseException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
-import java.util.Iterator;
import java.util.List;
import org.apache.ivy.Ivy;
@@ -91,11 +90,11 @@ public class IvyResolve extends IvyTask {
private boolean checkIfChanged = true; // for backward compatibility
- private List/* */dependencies = new ArrayList();
+ private List dependencies = new ArrayList();
- private List/* */excludes = new ArrayList();
+ private List excludes = new ArrayList();
- private List/* */conflicts = new ArrayList();
+ private List conflicts = new ArrayList();
public boolean isUseOrigin() {
return useOrigin;
@@ -229,11 +228,13 @@ public class IvyResolve extends IvyTask {
return c;
}
+ @Override
protected void prepareTask() {
super.prepareTask();
Message.setShowProgress(showProgress);
}
+ @Override
public void doExecute() throws BuildException {
Ivy ivy = getIvyInstance();
IvySettings settings = ivy.getSettings();
@@ -267,24 +268,18 @@ public class IvyResolve extends IvyTask {
Ivy.getWorkingRevision());
DefaultModuleDescriptor md = DefaultModuleDescriptor.newBasicInstance(mrid, null);
- Iterator itDeps = dependencies.iterator();
- while (itDeps.hasNext()) {
- IvyDependency dep = (IvyDependency) itDeps.next();
+ for (IvyDependency dep : dependencies) {
DependencyDescriptor dd = dep.asDependencyDescriptor(md, "default", settings);
md.addDependency(dd);
}
- Iterator itExcludes = excludes.iterator();
- while (itExcludes.hasNext()) {
- IvyExclude exclude = (IvyExclude) itExcludes.next();
+ for (IvyExclude exclude : excludes) {
DefaultExcludeRule rule = exclude.asRule(settings);
rule.addConfiguration("default");
md.addExcludeRule(rule);
}
- Iterator itConflicts = conflicts.iterator();
- while (itConflicts.hasNext()) {
- IvyConflict conflict = (IvyConflict) itConflicts.next();
+ for (IvyConflict conflict : conflicts) {
conflict.addConflict(md, settings);
}
@@ -426,9 +421,9 @@ public class IvyResolve extends IvyTask {
}
}
- protected Collection/* */getAllowedLogOptions() {
- return Arrays.asList(new String[] {LogOptions.LOG_DEFAULT, LogOptions.LOG_DOWNLOAD_ONLY,
- LogOptions.LOG_QUIET});
+ protected Collection getAllowedLogOptions() {
+ return Arrays.asList(LogOptions.LOG_DEFAULT, LogOptions.LOG_DOWNLOAD_ONLY,
+ LogOptions.LOG_QUIET);
}
private ResolveOptions getResolveOptions(Ivy ivy, String[] confs, IvySettings settings) {
diff --git a/src/java/org/apache/ivy/ant/IvyTask.java b/src/java/org/apache/ivy/ant/IvyTask.java
index 3533480b..6d65c34a 100644
--- a/src/java/org/apache/ivy/ant/IvyTask.java
+++ b/src/java/org/apache/ivy/ant/IvyTask.java
@@ -265,6 +265,7 @@ public abstract class IvyTask extends Task {
/**
* Ant task execute. Calls prepareTask, doExecute, finalzeTask
*/
+ @Override
public final void execute() throws BuildException {
try {
prepareTask();
@@ -282,6 +283,7 @@ public abstract class IvyTask extends Task {
*/
public abstract void doExecute() throws BuildException;
+ @Override
public String toString() {
return getClass().getName() + ":" + getTaskName();
}
diff --git a/src/java/org/apache/ivy/ant/antlib.xml b/src/java/org/apache/ivy/ant/antlib.xml
index ac327408..0111f781 100644
--- a/src/java/org/apache/ivy/ant/antlib.xml
+++ b/src/java/org/apache/ivy/ant/antlib.xml
@@ -49,4 +49,5 @@
+
diff --git a/src/java/org/apache/ivy/core/cache/CacheMetadataOptions.java b/src/java/org/apache/ivy/core/cache/CacheMetadataOptions.java
index a1c77b48..8f827c49 100644
--- a/src/java/org/apache/ivy/core/cache/CacheMetadataOptions.java
+++ b/src/java/org/apache/ivy/core/cache/CacheMetadataOptions.java
@@ -32,6 +32,8 @@ public class CacheMetadataOptions extends CacheDownloadOptions {
private boolean checkTTL = true;
+ private boolean useCacheOnly = false;
+
public Namespace getNamespace() {
return namespace;
}
@@ -85,4 +87,13 @@ public class CacheMetadataOptions extends CacheDownloadOptions {
public boolean isCheckTTL() {
return checkTTL;
}
+
+ public CacheMetadataOptions setUseCacheOnly(boolean useCacheOnly) {
+ this.useCacheOnly = useCacheOnly;
+ return this;
+ }
+
+ public boolean isUseCacheOnly() {
+ return useCacheOnly;
+ }
}
diff --git a/src/java/org/apache/ivy/core/cache/DefaultRepositoryCacheManager.java b/src/java/org/apache/ivy/core/cache/DefaultRepositoryCacheManager.java
index 55f498d2..86b4a8b1 100644
--- a/src/java/org/apache/ivy/core/cache/DefaultRepositoryCacheManager.java
+++ b/src/java/org/apache/ivy/core/cache/DefaultRepositoryCacheManager.java
@@ -26,7 +26,6 @@ import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.text.ParseException;
import java.util.Date;
-import java.util.Iterator;
import java.util.Map;
import java.util.regex.Pattern;
@@ -114,7 +113,7 @@ public class DefaultRepositoryCacheManager implements RepositoryCacheManager, Iv
private Boolean useOrigin;
- private ModuleRules/* */ttlRules = new ModuleRules();
+ private ModuleRules ttlRules = new ModuleRules();
private Long defaultTTL = null;
@@ -188,17 +187,17 @@ public class DefaultRepositoryCacheManager implements RepositoryCacheManager, Iv
public long getDefaultTTL() {
if (defaultTTL == null) {
- defaultTTL = new Long(parseDuration(settings.getVariable("ivy.cache.ttl.default")));
+ defaultTTL = Long.valueOf(parseDuration(settings.getVariable("ivy.cache.ttl.default")));
}
return defaultTTL.longValue();
}
public void setDefaultTTL(long defaultTTL) {
- this.defaultTTL = new Long(defaultTTL);
+ this.defaultTTL = Long.valueOf(defaultTTL);
}
public void setDefaultTTL(String defaultTTL) {
- this.defaultTTL = new Long(parseDuration(defaultTTL));
+ this.defaultTTL = Long.valueOf(parseDuration(defaultTTL));
}
public String getDataFilePattern() {
@@ -239,16 +238,16 @@ public class DefaultRepositoryCacheManager implements RepositoryCacheManager, Iv
this.changingPattern = changingPattern;
}
- public void addTTL(Map attributes, PatternMatcher matcher, long duration) {
+ public void addTTL(Map attributes, PatternMatcher matcher, long duration) {
ttlRules.defineRule(new MapMatcher(attributes, matcher), new Long(duration));
}
- public void addConfiguredTtl(Map/* */attributes) {
- String duration = (String) attributes.remove("duration");
+ public void addConfiguredTtl(Map attributes) {
+ String duration = attributes.remove("duration");
if (duration == null) {
throw new IllegalArgumentException("'duration' attribute is mandatory for ttl");
}
- String matcher = (String) attributes.remove("matcher");
+ String matcher = attributes.remove("matcher");
addTTL(attributes,
matcher == null ? ExactPatternMatcher.INSTANCE : settings.getMatcher(matcher),
parseDuration(duration));
@@ -295,10 +294,9 @@ public class DefaultRepositoryCacheManager implements RepositoryCacheManager, Iv
return days * MILLIS_IN_DAY + hours * MILLIS_IN_HOUR + minutes * MILLIS_IN_MINUTES
+ seconds * MILLIS_IN_SECONDS + millis;
- } else {
- throw new IllegalArgumentException("invalid duration '" + duration
- + "': it must match " + DURATION_PATTERN.pattern() + " or 'eternal'");
}
+ throw new IllegalArgumentException("invalid duration '" + duration
+ + "': it must match " + DURATION_PATTERN.pattern() + " or 'eternal'");
}
private int getGroupIntValue(java.util.regex.Matcher m, int groupNumber) {
@@ -309,19 +307,14 @@ public class DefaultRepositoryCacheManager implements RepositoryCacheManager, Iv
/**
* True if this cache should check lastmodified date to know if ivy files are up to date.
*
- * @return
+ * @return boolean
*/
public boolean isCheckmodified() {
if (checkmodified == null) {
- if (getSettings() != null) {
- String check = getSettings().getVariable("ivy.resolver.default.check.modified");
- return check != null ? Boolean.valueOf(check).booleanValue() : false;
- } else {
- return false;
- }
- } else {
- return checkmodified.booleanValue();
+ return getSettings() != null && Boolean
+ .parseBoolean(getSettings().getVariable("ivy.resolver.default.check.modified"));
}
+ return checkmodified.booleanValue();
}
public void setCheckmodified(boolean check) {
@@ -334,14 +327,9 @@ public class DefaultRepositoryCacheManager implements RepositoryCacheManager, Iv
*/
public boolean isUseOrigin() {
if (useOrigin == null) {
- if (getSettings() != null) {
- return getSettings().isDefaultUseOrigin();
- } else {
- return false;
- }
- } else {
- return useOrigin.booleanValue();
+ return getSettings() != null && getSettings().isDefaultUseOrigin();
}
+ return useOrigin.booleanValue();
}
public void setUseOrigin(boolean b) {
@@ -384,9 +372,8 @@ public class DefaultRepositoryCacheManager implements RepositoryCacheManager, Iv
private File getArchiveFileInCache(Artifact artifact, ArtifactOrigin origin, boolean useOrigin) {
if (useOrigin && !ArtifactOrigin.isUnknown(origin) && origin.isLocal()) {
return Checks.checkAbsolute(origin.getLocation(), artifact + " origin location");
- } else {
- return new File(getRepositoryCacheRoot(), getArchivePathInCache(artifact, origin));
}
+ return new File(getRepositoryCacheRoot(), getArchivePathInCache(artifact, origin));
}
public String getArchivePathInCache(Artifact artifact) {
@@ -396,9 +383,8 @@ public class DefaultRepositoryCacheManager implements RepositoryCacheManager, Iv
public String getArchivePathInCache(Artifact artifact, ArtifactOrigin origin) {
if (isOriginalMetadataArtifact(artifact)) {
return IvyPatternHelper.substitute(getIvyPattern() + ".original", artifact, origin);
- } else {
- return IvyPatternHelper.substitute(getArtifactPattern(), artifact, origin);
}
+ return IvyPatternHelper.substitute(getArtifactPattern(), artifact, origin);
}
/**
@@ -423,7 +409,7 @@ public class DefaultRepositoryCacheManager implements RepositoryCacheManager, Iv
*
* @param md
* the module descriptor resolved
- * @param name
+ * @param artifactResolverName
* artifact resolver name
*/
public void saveResolvers(ModuleDescriptor md, String metadataResolverName,
@@ -531,10 +517,8 @@ public class DefaultRepositoryCacheManager implements RepositoryCacheManager, Iv
// try to find other cached artifact info with same location. This must be the
// origin. We must parse the key as we do not know for sure what the original
// artifact is named.
- Iterator it = cdf.entrySet().iterator();
String ownLocationKey = getLocationKey(artifact);
- while (it.hasNext()) {
- Map.Entry entry = (Map.Entry) it.next();
+ for (Map.Entry