blob: 0fda7143d0ebf0cfe6ba4516aada041f51a92df2 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
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.IvyConfigure;
import org.apache.ivy.ant.IvyCacheFileset;
import org.apache.tools.ant.BuildException;
public class Ivy20Adapter
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.setOverride("true");
configure.setSettingsId("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();
}
}
|