summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormattinger <[email protected]>2007-03-01 23:19:57 +0000
committermattinger <[email protected]>2007-03-01 23:19:57 +0000
commit0fefe647cbfe0e616044f58c241d733f8d56c92a (patch)
tree65801411fab3d61c02e3d9d75f44b61fa3bc7a66
parentb1083f0784b10ea62ad76a0ed1ecf3b0c717e687 (diff)
Finishing correction of how import task calls Ivy API
git-svn-id: file:///home/sven/projects/JOGL/temp/ant-contrib/svn/ant-contrib-code/trunk/ant-contrib@87 32d7a393-a5a9-423c-abd3-5d954feb1f2f
-rwxr-xr-xsrc/java/net/sf/antcontrib/net/URLImportTask.java61
1 files changed, 46 insertions, 15 deletions
diff --git a/src/java/net/sf/antcontrib/net/URLImportTask.java b/src/java/net/sf/antcontrib/net/URLImportTask.java
index c245e61..e513a8a 100755
--- a/src/java/net/sf/antcontrib/net/URLImportTask.java
+++ b/src/java/net/sf/antcontrib/net/URLImportTask.java
@@ -17,9 +17,11 @@ package net.sf.antcontrib.net;
import java.io.File;
import java.io.IOException;
+import java.net.MalformedURLException;
import java.net.URL;
import java.text.ParseException;
import java.util.Date;
+import java.util.List;
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.Project;
@@ -28,7 +30,9 @@ import org.apache.tools.ant.taskdefs.Expand;
import org.apache.tools.ant.taskdefs.ImportTask;
import fr.jayasoft.ivy.Artifact;
+import fr.jayasoft.ivy.DefaultDependencyDescriptor;
import fr.jayasoft.ivy.DefaultModuleDescriptor;
+import fr.jayasoft.ivy.DependencyDescriptor;
import fr.jayasoft.ivy.DependencyResolver;
import fr.jayasoft.ivy.Ivy;
import fr.jayasoft.ivy.IvyContext;
@@ -36,13 +40,21 @@ import fr.jayasoft.ivy.MDArtifact;
import fr.jayasoft.ivy.ModuleDescriptor;
import fr.jayasoft.ivy.ModuleId;
import fr.jayasoft.ivy.ModuleRevisionId;
+import fr.jayasoft.ivy.ResolveData;
+import fr.jayasoft.ivy.ResolvedModuleRevision;
+import fr.jayasoft.ivy.ant.IvyConfigure;
+import fr.jayasoft.ivy.filter.FilterHelper;
+import fr.jayasoft.ivy.latest.LatestRevisionStrategy;
import fr.jayasoft.ivy.report.ArtifactDownloadReport;
+import fr.jayasoft.ivy.report.ConfigurationResolveReport;
import fr.jayasoft.ivy.report.DownloadStatus;
+import fr.jayasoft.ivy.report.ResolveReport;
import fr.jayasoft.ivy.repository.Repository;
import fr.jayasoft.ivy.resolver.FileSystemResolver;
import fr.jayasoft.ivy.resolver.IvyRepResolver;
import fr.jayasoft.ivy.resolver.URLResolver;
import fr.jayasoft.ivy.util.MessageImpl;
+import fr.jayasoft.ivy.version.LatestVersionMatcher;
/***
* Task to import a build file from a url. The build file can be a build.xml,
@@ -108,7 +120,7 @@ public class URLImportTask
public void execute()
throws BuildException {
-
+
if (! verbose) {
IvyContext.getContext().setMessageImpl(
new MessageImpl() {
@@ -137,6 +149,7 @@ public class URLImportTask
DependencyResolver resolver = null;
Repository rep = null;
+
if (repositoryUrl != null) {
resolver = new URLResolver();
((URLResolver)resolver).addArtifactPattern(
@@ -186,27 +199,38 @@ public class URLImportTask
ivy.addResolver(resolver);
ivy.setDefaultResolver(resolver.getName());
+
+ try {
ModuleId moduleId =
new ModuleId(org, module);
ModuleRevisionId revId =
new ModuleRevisionId(moduleId, rev);
- ModuleDescriptor md =
- new DefaultModuleDescriptor(revId, "integration", new Date());
- Artifact artifact =
- new MDArtifact(md, module, type, type);
- ArtifactDownloadReport report =
- ivy.download(artifact, null);
+ ResolveReport resolveReport = ivy.resolve(
+ ModuleRevisionId.newInstance(org, module, rev),
+ new String[] { "*" },
+ false,
+ true,
+ ivy.getDefaultCache(),
+ new Date(),
+ ivy.doValidate(),
+ false,
+ false,
+ FilterHelper.getArtifactTypeFilter(type));
- DownloadStatus status = report.getDownloadStatus();
- if (status == DownloadStatus.FAILED) {
- throw new BuildException("Could not resolve resource.");
+ if (resolveReport.hasError()) {
+ throw new BuildException("Could not resolve resource for: " +
+ "org=" + org +
+ ";module=" + module +
+ ";rev=" + rev);
}
-
- String path = ivy.getArchivePathInCache(artifact);
-
- File file = new File(ivy.getDefaultCache(), path);
-
+
+ ModuleDescriptor desc = resolveReport.getModuleDescriptor();
+ List artifacts = resolveReport.getArtifacts();
+ Artifact artifact = (Artifact) artifacts.get(0);
+ log("Fetched revision " + artifact.getModuleRevisionId().getRevision());
+ File file = ivy.getArchiveFileInCache(ivy.getDefaultCache(), artifact);
+
File importFile = null;
if ("xml".equalsIgnoreCase(type)) {
@@ -237,5 +261,12 @@ public class URLImportTask
importTask.setFile(importFile.getAbsolutePath());
importTask.perform();
log("Import complete.", Project.MSG_INFO);
+ }
+ catch (ParseException e) {
+ throw new BuildException(e);
+ }
+ catch (IOException e) {
+ throw new BuildException(e);
+ }
}
}