summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ivy-conf.xml2
-rw-r--r--ivy.xml6
-rw-r--r--lib/ivy/jars/ivy-2.0.0-rc1.jarbin0 -> 840894 bytes
-rw-r--r--src/main/java/net/sf/antcontrib/net/Ivy14Adapter.java130
-rw-r--r--src/main/java/net/sf/antcontrib/net/Ivy20Adapter.java133
-rw-r--r--src/main/java/net/sf/antcontrib/net/IvyAdapter.java6
-rwxr-xr-xsrc/main/java/net/sf/antcontrib/net/URLImportTask.java157
7 files changed, 334 insertions, 100 deletions
diff --git a/ivy-conf.xml b/ivy-conf.xml
index 4a778b1..dc022c8 100644
--- a/ivy-conf.xml
+++ b/ivy-conf.xml
@@ -1,5 +1,5 @@
<ivy-conf>
- <properties file="build.properties" />
+ <properties file="${ivy.conf.dir}/build.properties" />
<conf defaultResolver="default-resolver" checkUpToDate="true" />
diff --git a/ivy.xml b/ivy.xml
index c313e3e..881dc62 100644
--- a/ivy.xml
+++ b/ivy.xml
@@ -18,7 +18,7 @@
conf="default->default" />
<dependency org="apache"
name="ant"
- rev="1.6.5"
+ rev="1.7.0"
conf="provided->default" />
<dependency org="apache"
name="xercesImpl"
@@ -32,6 +32,10 @@
name="commons-logging"
rev="1.0.4"
conf="default->default" />
+ <dependency org="apache"
+ name="ivy"
+ rev="2.0.0-rc1"
+ conf="default->default" />
<dependency org="jayasoft"
name="ivy"
rev="1.4.1"
diff --git a/lib/ivy/jars/ivy-2.0.0-rc1.jar b/lib/ivy/jars/ivy-2.0.0-rc1.jar
new file mode 100644
index 0000000..badaa52
--- /dev/null
+++ b/lib/ivy/jars/ivy-2.0.0-rc1.jar
Binary files differ
diff --git a/src/main/java/net/sf/antcontrib/net/Ivy14Adapter.java b/src/main/java/net/sf/antcontrib/net/Ivy14Adapter.java
new file mode 100644
index 0000000..e1ef983
--- /dev/null
+++ b/src/main/java/net/sf/antcontrib/net/Ivy14Adapter.java
@@ -0,0 +1,130 @@
+package net.sf.antcontrib.net;
+
+import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.net.MalformedURLException;
+import java.net.URL;
+
+import org.apache.tools.ant.BuildException;
+
+import fr.jayasoft.ivy.ant.IvyCacheFileset;
+import fr.jayasoft.ivy.ant.IvyConfigure;
+
+public class Ivy14Adapter
+ implements IvyAdapter {
+
+ public void configure(URLImportTask task) {
+ IvyConfigure configure = new IvyConfigure();
+ configure.setProject(task.getProject());
+ configure.setLocation(task.getLocation());
+ configure.setOwningTarget(task.getOwningTarget());
+ configure.setTaskName(task.getTaskName());
+ configure.init();
+
+ URL ivyConfUrl = task.getIvyConfUrl();
+ File ivyConfFile = task.getIvyConfFile();
+ String repositoryUrl = task.getRepositoryUrl();
+ File repositoryDir = task.getRepositoryDir();
+ String ivyPattern = task.getIvyPattern();
+ String artifactPattern = task.getArtifactPattern();
+
+ if (ivyConfUrl != null) {
+ if (ivyConfUrl.getProtocol().equalsIgnoreCase("file")) {
+ String path = ivyConfUrl.getPath();
+ File f = new File(path);
+ if (! f.isAbsolute()) {
+ f = new File(task.getProject().getBaseDir(), path);
+ }
+ configure.setFile(f);
+ }
+ else {
+ try {
+ configure.setUrl(ivyConfUrl.toExternalForm());
+ }
+ catch (MalformedURLException e) {
+ throw new BuildException(e);
+ }
+ }
+ }
+ else if (ivyConfFile != null) {
+ configure.setFile(ivyConfFile);
+ }
+ else if (repositoryDir != null ||
+ repositoryUrl != null) {
+ File temp = null;
+ FileWriter fw = null;
+
+ try {
+ temp = File.createTempFile("ivyconf", ".xml");
+ temp.deleteOnExit();
+ fw = new FileWriter(temp);
+ fw.write("<ivyconf>");
+ fw.write("<conf defaultResolver=\"default\" />");
+ fw.write("<resolvers>");
+ if (repositoryDir != null) {
+ fw.write("<filesystem name=\"default\">");
+ fw.write("<ivy pattern=\"" + repositoryDir + "/" + ivyPattern + "\" />");
+ fw.write("<artifact pattern=\"" + repositoryDir + "/" + artifactPattern + "\" />");
+ fw.write("</filesystem>");
+ }
+ else {
+ fw.write("<url name=\"default\">");
+ fw.write("<ivy pattern=\"" + repositoryUrl + "/" + ivyPattern + "\" />");
+ fw.write("<artifact pattern=\"" + repositoryUrl + "/" + artifactPattern + "\" />");
+ fw.write("</url>");
+ }
+ fw.write("</resolvers>");
+
+ fw.write("<latest-strategies>");
+ fw.write("<latest-revision name=\"latest\"/>");
+ fw.write("</latest-strategies>");
+ fw.write("</ivyconf>");
+ fw.close();
+
+
+ fw = null;
+
+ configure.setFile(temp);
+ }
+ catch (IOException e) {
+ throw new BuildException(e);
+ }
+ finally {
+ try {
+ if (fw != null) {
+ fw.close();
+ fw = null;
+ }
+ }
+ catch (IOException e) {
+ ;
+ }
+ }
+ }
+
+ configure.execute();
+ }
+
+ public void fileset(URLImportTask task, String setId) {
+ String org = task.getOrg();
+ String module = task.getModule();
+ String rev = task.getRev();
+ String conf = task.getConf();
+
+ IvyCacheFileset cacheFileSet = new IvyCacheFileset();
+ cacheFileSet.setProject(task.getProject());
+ cacheFileSet.setLocation(task.getLocation());
+ cacheFileSet.setOwningTarget(task.getOwningTarget());
+ cacheFileSet.setTaskName(task.getTaskName());
+ cacheFileSet.setInline(true);
+ cacheFileSet.setOrganisation(org);
+ cacheFileSet.setModule(module);
+ cacheFileSet.setRevision(rev);
+ cacheFileSet.setConf(conf);
+ cacheFileSet.init();
+ cacheFileSet.setSetid(setId);
+ cacheFileSet.execute();
+ }
+
+}
diff --git a/src/main/java/net/sf/antcontrib/net/Ivy20Adapter.java b/src/main/java/net/sf/antcontrib/net/Ivy20Adapter.java
new file mode 100644
index 0000000..116b1f7
--- /dev/null
+++ b/src/main/java/net/sf/antcontrib/net/Ivy20Adapter.java
@@ -0,0 +1,133 @@
+package net.sf.antcontrib.net;
+
+import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.net.MalformedURLException;
+import java.net.URL;
+
+import org.apache.ivy.ant.IvyAntSettings;
+import org.apache.ivy.ant.IvyCacheFileset;
+import org.apache.tools.ant.BuildException;
+
+public class Ivy20Adapter
+ implements IvyAdapter {
+
+ public void configure(URLImportTask task) {
+ IvyAntSettings configure = new IvyAntSettings();
+ configure.setProject(task.getProject());
+ configure.setLocation(task.getLocation());
+ configure.setOwningTarget(task.getOwningTarget());
+ configure.setTaskName(task.getTaskName());
+ configure.setOverride("true");
+ configure.setId("urlimporttask");
+ configure.init();
+
+ URL ivyConfUrl = task.getIvyConfUrl();
+ File ivyConfFile = task.getIvyConfFile();
+ String repositoryUrl = task.getRepositoryUrl();
+ File repositoryDir = task.getRepositoryDir();
+ String ivyPattern = task.getIvyPattern();
+ String artifactPattern = task.getArtifactPattern();
+
+ if (ivyConfUrl != null) {
+ if (ivyConfUrl.getProtocol().equalsIgnoreCase("file")) {
+ String path = ivyConfUrl.getPath();
+ File f = new File(path);
+ if (! f.isAbsolute()) {
+ f = new File(task.getProject().getBaseDir(), path);
+ }
+ configure.setFile(f);
+ }
+ else {
+ try {
+ configure.setUrl(ivyConfUrl.toExternalForm());
+ }
+ catch (MalformedURLException e) {
+ throw new BuildException(e);
+ }
+ }
+ }
+ else if (ivyConfFile != null) {
+ configure.setFile(ivyConfFile);
+ }
+ else if (repositoryDir != null ||
+ repositoryUrl != null) {
+ File temp = null;
+ FileWriter fw = null;
+
+ try {
+ temp = File.createTempFile("ivyconf", ".xml");
+ temp.deleteOnExit();
+ fw = new FileWriter(temp);
+ fw.write("<ivysettings>");
+ fw.write("<settings defaultResolver=\"default\" />");
+ fw.write("<resolvers>");
+ if (repositoryDir != null) {
+ fw.write("<filesystem name=\"default\">");
+ fw.write("<ivy pattern=\"" + repositoryDir + "/" + ivyPattern + "\" />");
+ fw.write("<artifact pattern=\"" + repositoryDir + "/" + artifactPattern + "\" />");
+ fw.write("</filesystem>");
+ }
+ else {
+ fw.write("<url name=\"default\">");
+ fw.write("<ivy pattern=\"" + repositoryUrl + "/" + ivyPattern + "\" />");
+ fw.write("<artifact pattern=\"" + repositoryUrl + "/" + artifactPattern + "\" />");
+ fw.write("</url>");
+ }
+ fw.write("</resolvers>");
+
+ fw.write("<latest-strategies>");
+ fw.write("<latest-revision name=\"latest\"/>");
+ fw.write("</latest-strategies>");
+ fw.write("</ivysettings>");
+ fw.close();
+
+
+ fw = null;
+
+ configure.setFile(temp);
+ }
+ catch (IOException e) {
+ throw new BuildException(e);
+ }
+ finally {
+ try {
+ if (fw != null) {
+ fw.close();
+ fw = null;
+ }
+ }
+ catch (IOException e) {
+ ;
+ }
+ }
+ }
+
+ configure.execute();
+ }
+
+ public void fileset(URLImportTask task, String setId) {
+ String org = task.getOrg();
+ String module = task.getModule();
+ String rev = task.getRev();
+ String conf = task.getConf();
+
+ IvyCacheFileset cacheFileSet = new IvyCacheFileset();
+ cacheFileSet.setProject(task.getProject());
+ cacheFileSet.setLocation(task.getLocation());
+ cacheFileSet.setOwningTarget(task.getOwningTarget());
+ cacheFileSet.setTaskName(task.getTaskName());
+ cacheFileSet.setInline(true);
+ cacheFileSet.setOrganisation(org);
+ cacheFileSet.setModule(module);
+ cacheFileSet.setRevision(rev);
+ cacheFileSet.setConf(conf);
+ cacheFileSet.init();
+ cacheFileSet.setSetid(setId);
+ cacheFileSet.setSettingsRef(
+ new org.apache.tools.ant.types.Reference(task.getProject(), "urlimporttask"));
+ cacheFileSet.execute();
+ }
+
+}
diff --git a/src/main/java/net/sf/antcontrib/net/IvyAdapter.java b/src/main/java/net/sf/antcontrib/net/IvyAdapter.java
new file mode 100644
index 0000000..db4fd4f
--- /dev/null
+++ b/src/main/java/net/sf/antcontrib/net/IvyAdapter.java
@@ -0,0 +1,6 @@
+package net.sf.antcontrib.net;
+
+public interface IvyAdapter {
+ void configure(URLImportTask task);
+ void fileset(URLImportTask task, String setId);
+}
diff --git a/src/main/java/net/sf/antcontrib/net/URLImportTask.java b/src/main/java/net/sf/antcontrib/net/URLImportTask.java
index a155767..4792ef4 100755
--- a/src/main/java/net/sf/antcontrib/net/URLImportTask.java
+++ b/src/main/java/net/sf/antcontrib/net/URLImportTask.java
@@ -16,9 +16,6 @@
package net.sf.antcontrib.net;
import java.io.File;
-import java.io.FileWriter;
-import java.io.IOException;
-import java.net.MalformedURLException;
import java.net.URL;
import org.apache.tools.ant.BuildException;
@@ -28,9 +25,6 @@ import org.apache.tools.ant.taskdefs.Expand;
import org.apache.tools.ant.taskdefs.ImportTask;
import org.apache.tools.ant.types.FileSet;
-import fr.jayasoft.ivy.ant.IvyCacheFileset;
-import fr.jayasoft.ivy.ant.IvyConfigure;
-
/***
* Task to import a build file from a url. The build file can be a build.xml,
* or a .zip/.jar, in which case we download and extract the entire archive, and
@@ -106,105 +100,72 @@ public class URLImportTask
throw new BuildException("'file' property not accessed for ImportURL.");
}
+ public String getOrg() {
+ return org;
+ }
+
+ public String getModule() {
+ return module;
+ }
+
+ public String getRev() {
+ return rev;
+ }
+
+ public String getConf() {
+ return conf;
+ }
+
+ public String getType() {
+ return type;
+ }
+
+ public String getRepositoryUrl() {
+ return repositoryUrl;
+ }
+
+ public File getRepositoryDir() {
+ return repositoryDir;
+ }
+
+ public URL getIvyConfUrl() {
+ return ivyConfUrl;
+ }
+
+ public File getIvyConfFile() {
+ return ivyConfFile;
+ }
+
+ public String getResource() {
+ return resource;
+ }
+
+ public String getArtifactPattern() {
+ return artifactPattern;
+ }
+
+ public String getIvyPattern() {
+ return ivyPattern;
+ }
+
public void execute()
throws BuildException {
- IvyConfigure configure = new IvyConfigure();
- configure.setProject(getProject());
- configure.setLocation(getLocation());
- configure.setOwningTarget(getOwningTarget());
- configure.setTaskName(getTaskName());
- configure.init();
- if (ivyConfUrl != null) {
- if (ivyConfUrl.getProtocol().equalsIgnoreCase("file")) {
- String path = ivyConfUrl.getPath();
- File f = new File(path);
- if (! f.isAbsolute()) {
- f = new File(getProject().getBaseDir(), path);
- }
- configure.setFile(f);
- }
- else {
- try {
- configure.setUrl(ivyConfUrl.toExternalForm());
- }
- catch (MalformedURLException e) {
- throw new BuildException(e);
- }
- }
- }
- else if (ivyConfFile != null) {
- configure.setFile(ivyConfFile);
+ IvyAdapter adapter = null;
+
+ try {
+ Class.forName("org.apache.ivy.Ivy");
+ adapter = new Ivy20Adapter();
}
- else if (repositoryDir != null ||
- repositoryUrl != null) {
- File temp = null;
- FileWriter fw = null;
-
- try {
- temp = File.createTempFile("ivyconf", ".xml");
- temp.deleteOnExit();
- fw = new FileWriter(temp);
- fw.write("<ivyconf>");
- fw.write("<conf defaultResolver=\"default\" />");
- fw.write("<resolvers>");
- if (repositoryDir != null) {
- fw.write("<filesystem name=\"default\">");
- fw.write("<ivy pattern=\"" + repositoryDir + "/" + ivyPattern + "\" />");
- fw.write("<artifact pattern=\"" + repositoryDir + "/" + artifactPattern + "\" />");
- fw.write("</filesystem>");
- }
- else {
- fw.write("<url name=\"default\">");
- fw.write("<ivy pattern=\"" + repositoryUrl + "/" + ivyPattern + "\" />");
- fw.write("<artifact pattern=\"" + repositoryUrl + "/" + artifactPattern + "\" />");
- fw.write("</url>");
- }
- fw.write("</resolvers>");
-
- fw.write("<latest-strategies>");
- fw.write("<latest-revision name=\"latest\"/>");
- fw.write("</latest-strategies>");
- fw.write("</ivyconf>");
- fw.close();
- fw = null;
-
- configure.setFile(temp);
- }
- catch (IOException e) {
- throw new BuildException(e);
- }
- finally {
- try {
- if (fw != null) {
- fw.close();
- fw = null;
- }
- }
- catch (IOException e) {
- ;
- }
- }
+ catch (ClassNotFoundException e) {
+ adapter = new Ivy14Adapter();
}
- configure.execute();
-
- IvyCacheFileset cacheFileSet = new IvyCacheFileset();
- cacheFileSet.setProject(getProject());
- cacheFileSet.setLocation(getLocation());
- cacheFileSet.setOwningTarget(getOwningTarget());
- cacheFileSet.setTaskName(getTaskName());
- cacheFileSet.setInline(true);
- cacheFileSet.setOrganisation(org);
- cacheFileSet.setModule(module);
- cacheFileSet.setRevision(rev);
- cacheFileSet.setConf(conf);
- cacheFileSet.init();
- cacheFileSet.setSetid(org + module + rev + ".fileset");
- cacheFileSet.execute();
+ String setId = org + "." + module + "." + rev + ".fileset";
+ adapter.configure(this);
+ adapter.fileset(this, setId);
- FileSet fileset =
- (FileSet) getProject().getReference(org + module + rev + ".fileset");
+ FileSet fileset =(FileSet) getProject().getReference(setId);
DirectoryScanner scanner =
fileset.getDirectoryScanner(getProject());