clean code

git-svn-id: https://svn.apache.org/repos/asf/incubator/ivy/core/trunk@550916 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Xavier Hanin 2007-06-26 19:34:08 +00:00
parent 39380eaaa0
commit ac706640c8
17 changed files with 826 additions and 781 deletions

View File

@ -29,96 +29,96 @@ import org.apache.tools.ant.BuildException;
* properties according to what was found.
*/
public class IvyBuildNumber extends IvyTask {
private String _organisation;
private String organisation;
private String _module;
private String module;
private String _branch;
private String branch;
private String _revision;
private String revision;
private String _revSep = ".";
private String revSep = ".";
private String _prefix = "ivy.";
private String prefix = "ivy.";
private String _default = "0";
private String defaultValue = "0";
private String _defaultBuildNumber = "0";
private String defaultBuildNumber = "0";
public String getModule() {
return _module;
return module;
}
public void setModule(String module) {
_module = module;
this.module = module;
}
public String getOrganisation() {
return _organisation;
return organisation;
}
public void setOrganisation(String organisation) {
_organisation = organisation;
this.organisation = organisation;
}
public String getRevision() {
return _revision;
return revision;
}
public void setRevision(String revision) {
_revision = revision;
this.revision = revision;
}
public String getBranch() {
return _branch;
return branch;
}
public void setBranch(String branch) {
_branch = branch;
this.branch = branch;
}
public String getDefault() {
return _default;
return defaultValue;
}
public void setDefault(String default1) {
_default = default1;
defaultValue = default1;
}
public String getPrefix() {
return _prefix;
return prefix;
}
public void setPrefix(String prefix) {
_prefix = prefix;
this.prefix = prefix;
}
public void doExecute() throws BuildException {
if (_organisation == null) {
if (organisation == null) {
throw new BuildException("no organisation provided for ivy findmodules");
}
if (_module == null) {
if (module == null) {
throw new BuildException("no module name provided for ivy findmodules");
}
if (_prefix == null) {
if (prefix == null) {
throw new BuildException("null prefix not allowed");
}
Ivy ivy = getIvyInstance();
IvySettings settings = ivy.getSettings();
if (_branch == null) {
settings.getDefaultBranch(new ModuleId(_organisation, _module));
if (branch == null) {
settings.getDefaultBranch(new ModuleId(organisation, module));
}
if (_revision == null || _revision.length() == 0) {
_revision = "latest.integration";
} else if (!_revision.endsWith("+")) {
_revision = _revision + "+";
if (revision == null || revision.length() == 0) {
revision = "latest.integration";
} else if (!revision.endsWith("+")) {
revision = revision + "+";
}
if (!_prefix.endsWith(".") && _prefix.length() > 0) {
_prefix = _prefix + ".";
if (!prefix.endsWith(".") && prefix.length() > 0) {
prefix = prefix + ".";
}
ResolvedModuleRevision rmr = ivy.findModule(ModuleRevisionId.newInstance(_organisation,
_module, _branch, _revision));
ResolvedModuleRevision rmr = ivy.findModule(ModuleRevisionId.newInstance(organisation,
module, branch, revision));
String revision = rmr == null ? null : rmr.getId().getRevision();
NewRevision newRevision = computeNewRevision(revision);
setProperty("revision", newRevision.revision);
@ -129,13 +129,13 @@ public class IvyBuildNumber extends IvyTask {
private void setProperty(String propertyName, String value) {
if (value != null) {
getProject().setProperty(_prefix + propertyName, value);
getProject().setProperty(prefix + propertyName, value);
}
}
private NewRevision computeNewRevision(String revision) {
String revPrefix = "latest.integration".equals(_revision) ? "" : _revision.substring(0,
_revision.length() - 1);
String revPrefix = "latest.integration".equals(revision) ? "" : revision.substring(0,
revision.length() - 1);
if (revision != null && !revision.startsWith(revPrefix)) {
throw new BuildException("invalid exception found in repository: '" + revision
+ "' for '" + revPrefix + "'");
@ -143,15 +143,15 @@ public class IvyBuildNumber extends IvyTask {
if (revision == null) {
if (revPrefix.length() > 0) {
return new NewRevision(revision, revPrefix
+ (revPrefix.endsWith(_revSep) ? _defaultBuildNumber : _revSep
+ _defaultBuildNumber), null, _defaultBuildNumber);
+ (revPrefix.endsWith(revSep) ? defaultBuildNumber : revSep
+ defaultBuildNumber), null, defaultBuildNumber);
} else {
Range r = findLastNumber(_default);
Range r = findLastNumber(defaultValue);
if (r == null) { // no number found
return new NewRevision(revision, _default, null, null);
return new NewRevision(revision, defaultValue, null, null);
} else {
long n = Long.parseLong(_default.substring(r.startIndex, r.endIndex));
return new NewRevision(revision, _default, null, String.valueOf(n));
long n = Long.parseLong(defaultValue.substring(r.startIndex, r.endIndex));
return new NewRevision(revision, defaultValue, null, String.valueOf(n));
}
}
}
@ -160,13 +160,13 @@ public class IvyBuildNumber extends IvyTask {
r = findLastNumber(revision);
if (r == null) {
return new NewRevision(revision, revision
+ (revision.endsWith(_revSep) ? "1" : _revSep + "1"), null, "1");
+ (revision.endsWith(revSep) ? "1" : revSep + "1"), null, "1");
}
} else {
r = findFirstNumber(revision, revPrefix.length());
if (r == null) {
return new NewRevision(revision, revPrefix
+ (revPrefix.endsWith(_revSep) ? "1" : _revSep + "1"), null, "1");
+ (revPrefix.endsWith(revSep) ? "1" : revSep + "1"), null, "1");
}
}
long n = Long.parseLong(revision.substring(r.startIndex, r.endIndex)) + 1;
@ -177,7 +177,8 @@ public class IvyBuildNumber extends IvyTask {
private Range findFirstNumber(String str, int startIndex) {
// let's find the first digit in the string
int startNumberIndex = startIndex;
while (startNumberIndex < str.length() && !Character.isDigit(str.charAt(startNumberIndex))) {
while (startNumberIndex < str.length()
&& !Character.isDigit(str.charAt(startNumberIndex))) {
startNumberIndex++;
}
if (startNumberIndex == str.length()) {
@ -239,18 +240,18 @@ public class IvyBuildNumber extends IvyTask {
}
public String getRevSep() {
return _revSep;
return revSep;
}
public void setRevSep(String revSep) {
_revSep = revSep;
this.revSep = revSep;
}
public String getDefaultBuildNumber() {
return _defaultBuildNumber;
return defaultBuildNumber;
}
public void setDefaultBuildNumber(String defaultBuildNumber) {
_defaultBuildNumber = defaultBuildNumber;
this.defaultBuildNumber = defaultBuildNumber;
}
}

View File

@ -31,32 +31,34 @@ import org.apache.tools.ant.types.PatternSet.NameEntry;
* not compatible with the useOrigin mode.
*/
public class IvyCacheFileset extends IvyCacheTask {
private String _setid;
private String setid;
public String getSetid() {
return _setid;
return setid;
}
public void setSetid(String id) {
_setid = id;
setid = id;
}
public void setUseOrigin(boolean useOrigin) {
if (useOrigin) {
throw new UnsupportedOperationException(
"the cachefileset task does not support the useOrigin mode, since filesets require to have only one root directory. Please use the the cachepath task instead");
"the cachefileset task does not support the useOrigin mode, since filesets "
+ "require to have only one root directory. Please use the the cachepath "
+ "task instead");
}
}
public void doExecute() throws BuildException {
prepareAndCheck();
if (_setid == null) {
if (setid == null) {
throw new BuildException("setid is required in ivy cachefileset");
}
try {
FileSet fileset = new FileSet();
fileset.setProject(getProject());
getProject().addReference(_setid, fileset);
getProject().addReference(setid, fileset);
fileset.setDir(getCache());
List paths = getArtifacts();

View File

@ -29,16 +29,16 @@ import org.apache.tools.ant.types.Path;
* Creates an ant path consisting in all artifacts found during a resolve.
*/
public class IvyCachePath extends IvyCacheTask {
private String _pathid;
private String pathid;
private String _id;
private String id;
public String getPathid() {
return _pathid;
return pathid;
}
public void setPathid(String id) {
_pathid = id;
pathid = id;
}
/**
@ -46,14 +46,14 @@ public class IvyCachePath extends IvyCacheTask {
* @param id
*/
public void setId(String id) {
_id = id;
this.id = id;
}
public void doExecute() throws BuildException {
prepareAndCheck();
if (_pathid == null) {
if (_id != null) {
_pathid = _id;
if (pathid == null) {
if (id != null) {
pathid = id;
log("ID IS DEPRECATED, PLEASE USE PATHID INSTEAD", Project.MSG_WARN);
} else {
throw new BuildException("pathid is required in ivy classpath");
@ -61,7 +61,7 @@ public class IvyCachePath extends IvyCacheTask {
}
try {
Path path = new Path(getProject());
getProject().addReference(_pathid, path);
getProject().addReference(pathid, path);
CacheManager cache = getCacheManager();
for (Iterator iter = getArtifacts().iterator(); iter.hasNext();) {
Artifact a = (Artifact) iter.next();

View File

@ -36,18 +36,18 @@ import org.apache.tools.ant.types.FileSet;
* discover it.
*/
public class IvyCheck extends IvyTask {
private File _file = null;
private File file = null;
private List _filesets = new ArrayList();
private List filesets = new ArrayList();
private String _resolvername;
private String resolvername;
public File getFile() {
return _file;
return file;
}
public void setFile(File file) {
_file = file;
this.file = file;
}
/**
@ -57,27 +57,27 @@ public class IvyCheck extends IvyTask {
* a set of files to check
*/
public void addFileset(FileSet set) {
_filesets.add(set);
filesets.add(set);
}
public String getResolvername() {
return _resolvername;
return resolvername;
}
public void setResolvername(String resolverName) {
_resolvername = resolverName;
resolvername = resolverName;
}
public void doExecute() throws BuildException {
try {
Ivy ivy = getIvyInstance();
if (_file != null) {
if (ivy.check(_file.toURL(), _resolvername)) {
Message.verbose("checked " + _file + ": OK");
if (file != null) {
if (ivy.check(file.toURL(), resolvername)) {
Message.verbose("checked " + file + ": OK");
}
}
for (int i = 0; i < _filesets.size(); i++) {
FileSet fs = (FileSet) _filesets.get(i);
for (int i = 0; i < filesets.size(); i++) {
FileSet fs = (FileSet) filesets.get(i);
DirectoryScanner ds = fs.getDirectoryScanner(getProject());
File fromDir = fs.getDir(getProject());
@ -85,7 +85,7 @@ public class IvyCheck extends IvyTask {
String[] srcFiles = ds.getIncludedFiles();
for (int j = 0; j < srcFiles.length; j++) {
File file = new File(fromDir, srcFiles[j]);
if (ivy.check(file.toURL(), _resolvername)) {
if (ivy.check(file.toURL(), resolvername)) {
Message.verbose("checked " + file + ": OK");
}
}

View File

@ -32,47 +32,47 @@ import org.apache.tools.ant.Project;
* Convert a pom to an ivy file
*/
public class IvyConvertPom extends IvyTask {
private File _pomFile = null;
private File pomFile = null;
private File _ivyFile = null;
private File ivyFile = null;
public File getPomFile() {
return _pomFile;
return pomFile;
}
public void setPomFile(File file) {
_pomFile = file;
pomFile = file;
}
public File getIvyFile() {
return _ivyFile;
return ivyFile;
}
public void setIvyFile(File ivyFile) {
_ivyFile = ivyFile;
this.ivyFile = ivyFile;
}
public void doExecute() throws BuildException {
try {
if (_pomFile == null) {
if (pomFile == null) {
throw new BuildException("source pom file is required for convertpom task");
}
if (_ivyFile == null) {
if (ivyFile == null) {
throw new BuildException("destination ivy file is required for convertpom task");
}
ModuleDescriptor md = PomModuleDescriptorParser.getInstance().parseDescriptor(
new IvySettings(), _pomFile.toURL(), false);
PomModuleDescriptorParser.getInstance().toIvyFile(_pomFile.toURL().openStream(),
new URLResource(_pomFile.toURL()), getIvyFile(), md);
new IvySettings(), pomFile.toURL(), false);
PomModuleDescriptorParser.getInstance().toIvyFile(pomFile.toURL().openStream(),
new URLResource(pomFile.toURL()), getIvyFile(), md);
} catch (MalformedURLException e) {
throw new BuildException("unable to convert given pom file to url: " + _pomFile + ": "
throw new BuildException("unable to convert given pom file to url: " + pomFile + ": "
+ e, e);
} catch (ParseException e) {
log(e.getMessage(), Project.MSG_ERR);
throw new BuildException("syntax errors in pom file " + _pomFile + ": " + e, e);
throw new BuildException("syntax errors in pom file " + pomFile + ": " + e, e);
} catch (Exception e) {
throw new BuildException("impossible convert given pom file to ivy file: " + e
+ " from=" + _pomFile + " to=" + _ivyFile, e);
+ " from=" + pomFile + " to=" + ivyFile, e);
}
}
}

View File

@ -144,12 +144,12 @@ public class IvyDeliver extends IvyTask {
public void deliverDependency(ModuleRevisionId depMrid, String version, String status,
String depStatus) {
// call deliver target if any
if (_deliverTarget != null && _deliverTarget.trim().length() > 0) {
if (deliverTarget != null && deliverTarget.trim().length() > 0) {
CallTarget ct = (CallTarget) getProject().createTask("antcall");
ct.setOwningTarget(getOwningTarget());
ct.init();
ct.setTarget(_deliverTarget);
ct.setTarget(deliverTarget);
ct.setInheritAll(true);
ct.setInheritRefs(true);
Property param = ct.createParam();
@ -188,214 +188,220 @@ public class IvyDeliver extends IvyTask {
}
private String _organisation;
private String organisation;
private String _module;
private String module;
private String _revision;
private String revision;
private String _pubRevision;
private String pubRevision;
private File _cache;
private File cache;
private String _deliverpattern;
private String deliverpattern;
private String _status;
private String status;
private String _pubdate;
private String pubdate;
private String _deliverTarget;
private String deliverTarget;
private File _deliveryList;
private File deliveryList;
private boolean _replacedynamicrev = true;
private boolean replacedynamicrev = true;
private String _resolveId;
private String resolveId;
private String _conf;
private String conf;
public File getCache() {
return _cache;
return cache;
}
public void setCache(File cache) {
_cache = cache;
this.cache = cache;
}
public String getDeliverpattern() {
return _deliverpattern;
return deliverpattern;
}
public void setDeliverpattern(String destivypattern) {
_deliverpattern = destivypattern;
this.deliverpattern = destivypattern;
}
public String getModule() {
return _module;
return module;
}
public void setModule(String module) {
_module = module;
this.module = module;
}
public String getOrganisation() {
return _organisation;
return organisation;
}
public void setOrganisation(String organisation) {
_organisation = organisation;
this.organisation = organisation;
}
public String getPubdate() {
return _pubdate;
return pubdate;
}
public void setPubdate(String pubdate) {
_pubdate = pubdate;
this.pubdate = pubdate;
}
public String getPubrevision() {
return _pubRevision;
return pubRevision;
}
public void setPubrevision(String pubRevision) {
_pubRevision = pubRevision;
this.pubRevision = pubRevision;
}
public String getRevision() {
return _revision;
return revision;
}
public void setRevision(String revision) {
_revision = revision;
this.revision = revision;
}
public String getStatus() {
return _status;
return status;
}
public void setStatus(String status) {
_status = status;
this.status = status;
}
public void setDelivertarget(String deliverTarget) {
_deliverTarget = deliverTarget;
this.deliverTarget = deliverTarget;
}
public void setDeliveryList(File deliveryList) {
_deliveryList = deliveryList;
this.deliveryList = deliveryList;
}
public boolean isReplacedynamicrev() {
return _replacedynamicrev;
return replacedynamicrev;
}
public void setReplacedynamicrev(boolean replacedynamicrev) {
_replacedynamicrev = replacedynamicrev;
this.replacedynamicrev = replacedynamicrev;
}
public String getResolveId() {
return _resolveId;
return resolveId;
}
public void setResolveId(String resolveId) {
_resolveId = resolveId;
this.resolveId = resolveId;
}
public String getConf() {
return _conf;
return conf;
}
public void setConf(String confs) {
_conf = confs;
conf = confs;
}
public void doExecute() throws BuildException {
Ivy ivy = getIvyInstance();
IvySettings settings = ivy.getSettings();
_organisation = getProperty(_organisation, settings, "ivy.organisation", _resolveId);
_module = getProperty(_module, settings, "ivy.module", _resolveId);
_revision = getProperty(_revision, settings, "ivy.revision", _resolveId);
_pubRevision = getProperty(_pubRevision, settings, "ivy.deliver.revision");
if (_cache == null) {
_cache = settings.getDefaultCache();
organisation = getProperty(organisation, settings, "ivy.organisation", resolveId);
module = getProperty(module, settings, "ivy.module", resolveId);
revision = getProperty(revision, settings, "ivy.revision", resolveId);
pubRevision = getProperty(pubRevision, settings, "ivy.deliver.revision");
if (cache == null) {
cache = settings.getDefaultCache();
}
_deliverpattern = getProperty(_deliverpattern, settings, "ivy.deliver.ivy.pattern");
_status = getProperty(_status, settings, "ivy.status");
if (_deliveryList == null) {
deliverpattern = getProperty(deliverpattern, settings, "ivy.deliver.ivy.pattern");
status = getProperty(status, settings, "ivy.status");
if (deliveryList == null) {
String deliveryListPath = getProperty(settings, "ivy.delivery.list.file");
if (deliveryListPath == null) {
_deliveryList = new File(System.getProperty("java.io.tmpdir")
deliveryList = new File(System.getProperty("java.io.tmpdir")
+ "/delivery.properties");
} else {
_deliveryList = getProject().resolveFile(settings.substitute(deliveryListPath));
deliveryList = getProject().resolveFile(settings.substitute(deliveryListPath));
}
}
if (_resolveId == null) {
if (_organisation == null) {
if (resolveId == null) {
if (organisation == null) {
throw new BuildException(
"no organisation provided for ivy deliver task: It can either be set explicitely via the attribute 'organisation' or via 'ivy.organisation' property or a prior call to <resolve/>");
"no organisation provided for ivy deliver task: "
+ "It can either be set explicitely via the attribute 'organisation' "
+ "or via 'ivy.organisation' property or a prior call to <resolve/>");
}
if (_module == null) {
if (module == null) {
throw new BuildException(
"no module name provided for ivy deliver task: It can either be set explicitely via the attribute 'module' or via 'ivy.module' property or a prior call to <resolve/>");
"no module name provided for ivy deliver task: "
+ "It can either be set explicitely via the attribute 'module' "
+ "or via 'ivy.module' property or a prior call to <resolve/>");
}
}
if (_revision == null) {
_revision = Ivy.getWorkingRevision();
if (revision == null) {
revision = Ivy.getWorkingRevision();
}
Date pubdate = getPubDate(_pubdate, new Date());
if (_pubRevision == null) {
if (_revision.startsWith("working@")) {
_pubRevision = Ivy.DATE_FORMAT.format(pubdate);
Date pubdate = getPubDate(this.pubdate, new Date());
if (pubRevision == null) {
if (revision.startsWith("working@")) {
pubRevision = Ivy.DATE_FORMAT.format(pubdate);
} else {
_pubRevision = _revision;
pubRevision = revision;
}
}
if (_deliverpattern == null) {
if (deliverpattern == null) {
throw new BuildException(
"deliver ivy pattern is missing: either provide it as parameters or through ivy.deliver.ivy.pattern properties");
"deliver ivy pattern is missing: either provide it as parameters "
+ "or through ivy.deliver.ivy.pattern properties");
}
if (_status == null) {
if (status == null) {
throw new BuildException(
"no status provided: either provide it as parameter or through the ivy.status.default property");
"no status provided: either provide it as parameter or through "
+ "the ivy.status.default property");
}
ModuleRevisionId mrid = null;
if (_resolveId == null) {
mrid = ModuleRevisionId.newInstance(_organisation, _module, _revision);
if (resolveId == null) {
mrid = ModuleRevisionId.newInstance(organisation, module, revision);
}
boolean isLeading = false;
try {
if (!_deliveryList.exists()) {
if (!deliveryList.exists()) {
isLeading = true;
}
loadDeliveryList();
PublishingDependencyRevisionResolver drResolver;
if (_deliverTarget != null && _deliverTarget.trim().length() > 0) {
if (deliverTarget != null && deliverTarget.trim().length() > 0) {
drResolver = new DeliverDRResolver();
} else {
drResolver = new DefaultPublishingDRResolver();
}
DeliverOptions options = new DeliverOptions(_status, pubdate, CacheManager.getInstance(
settings, _cache), drResolver, doValidate(settings), _replacedynamicrev,
splitConfs(_conf)).setResolveId(_resolveId);
DeliverOptions options = new DeliverOptions(status, pubdate, CacheManager.getInstance(
settings, cache), drResolver, doValidate(settings), replacedynamicrev,
splitConfs(conf)).setResolveId(resolveId);
if (mrid == null) {
ivy.deliver(_pubRevision, _deliverpattern, options);
ivy.deliver(pubRevision, deliverpattern, options);
} else {
ivy.deliver(mrid, _pubRevision, _deliverpattern, options);
ivy.deliver(mrid, pubRevision, deliverpattern, options);
}
} catch (Exception e) {
throw new BuildException("impossible to deliver " + mrid == null ? _resolveId : mrid
throw new BuildException("impossible to deliver " + mrid == null ? resolveId : mrid
+ ": " + e, e);
} finally {
if (isLeading) {
if (_deliveryList.exists()) {
_deliveryList.delete();
if (deliveryList.exists()) {
deliveryList.delete();
}
}
}
@ -405,7 +411,7 @@ public class IvyDeliver extends IvyTask {
Property property = (Property) getProject().createTask("property");
property.setOwningTarget(getOwningTarget());
property.init();
property.setFile(_deliveryList);
property.setFile(deliveryList);
property.perform();
}
@ -413,7 +419,7 @@ public class IvyDeliver extends IvyTask {
Echo echo = (Echo) getProject().createTask("echo");
echo.setOwningTarget(getOwningTarget());
echo.init();
echo.setFile(_deliveryList);
echo.setFile(deliveryList);
echo.setMessage(msg + "\n");
echo.setAppend(true);
echo.perform();

View File

@ -47,90 +47,90 @@ import org.apache.tools.ant.types.RegularExpression;
*/
public class IvyExtractFromSources extends IvyTask {
public static class Ignore {
String _package;
private String packageName;
public String getPackage() {
return _package;
return packageName;
}
public void setPackage(String package1) {
_package = package1;
packageName = package1;
}
}
private String _organisation;
private String organisation;
private String _module;
private String module;
private String _revision;
private String revision;
private String _status;
private String status;
private List _ignoredPackaged = new ArrayList(); // List (String package)
private List ignoredPackaged = new ArrayList(); // List (String package)
private Map _mapping = new HashMap(); // Map (String package -> ModuleRevisionId)
private Map mapping = new HashMap(); // Map (String package -> ModuleRevisionId)
private Concat _concat = new Concat();
private Concat concat = new Concat();
private File _to;
private File to;
public void addConfiguredIgnore(Ignore ignore) {
_ignoredPackaged.add(ignore.getPackage());
ignoredPackaged.add(ignore.getPackage());
}
public File getTo() {
return _to;
return to;
}
public void setTo(File to) {
_to = to;
this.to = to;
}
public String getModule() {
return _module;
return module;
}
public void setModule(String module) {
_module = module;
this.module = module;
}
public String getOrganisation() {
return _organisation;
return organisation;
}
public void setOrganisation(String organisation) {
_organisation = organisation;
this.organisation = organisation;
}
public String getRevision() {
return _revision;
return revision;
}
public void setRevision(String revision) {
_revision = revision;
this.revision = revision;
}
public String getStatus() {
return _status;
return status;
}
public void setStatus(String status) {
_status = status;
this.status = status;
}
public void addConfiguredMapping(PackageMapping mapping) {
_mapping.put(mapping.getPackage(), mapping.getModuleRevisionId());
this.mapping.put(mapping.getPackage(), mapping.getModuleRevisionId());
}
public void addFileSet(FileSet fileSet) {
_concat.addFileset(fileSet);
concat.addFileset(fileSet);
}
public void doExecute() throws BuildException {
configureConcat();
Writer out = new StringWriter();
_concat.setWriter(out);
_concat.execute();
concat.setWriter(out);
concat.execute();
Set importsSet = new HashSet(Arrays.asList(out.toString().split("\n")));
Set dependencies = new HashSet();
for (Iterator iter = importsSet.iterator(); iter.hasNext();) {
@ -141,15 +141,15 @@ public class IvyExtractFromSources extends IvyTask {
}
}
try {
PrintWriter writer = new PrintWriter(new FileOutputStream(_to));
PrintWriter writer = new PrintWriter(new FileOutputStream(to));
writer.println("<ivy-module version=\"1.0\">");
writer.println("\t<info organisation=\"" + _organisation + "\"");
writer.println("\t module=\"" + _module + "\"");
if (_revision != null) {
writer.println("\t revision=\"" + _revision + "\"");
writer.println("\t<info organisation=\"" + organisation + "\"");
writer.println("\t module=\"" + module + "\"");
if (revision != null) {
writer.println("\t revision=\"" + revision + "\"");
}
if (_status != null) {
writer.println("\t status=\"" + _status + "\"");
if (status != null) {
writer.println("\t status=\"" + status + "\"");
} else {
writer.println("\t status=\"integration\"");
}
@ -165,9 +165,9 @@ public class IvyExtractFromSources extends IvyTask {
}
writer.println("</ivy-module>");
writer.close();
log(dependencies.size() + " dependencies put in " + _to);
log(dependencies.size() + " dependencies put in " + to);
} catch (FileNotFoundException e) {
throw new BuildException("impossible to create file " + _to + ": " + e, e);
throw new BuildException("impossible to create file " + to + ": " + e, e);
}
}
@ -179,10 +179,10 @@ public class IvyExtractFromSources extends IvyTask {
String askedPack = pack;
ModuleRevisionId ret = null;
while (ret == null && pack.length() > 0) {
if (_ignoredPackaged.contains(pack)) {
if (ignoredPackaged.contains(pack)) {
return null;
}
ret = (ModuleRevisionId) _mapping.get(pack);
ret = (ModuleRevisionId) mapping.get(pack);
int lastDotIndex = pack.lastIndexOf('.');
if (lastDotIndex != -1) {
pack = pack.substring(0, lastDotIndex);
@ -197,8 +197,8 @@ public class IvyExtractFromSources extends IvyTask {
}
private void configureConcat() {
_concat.setProject(getProject());
_concat.setTaskName(getTaskName());
concat.setProject(getProject());
concat.setTaskName(getTaskName());
FilterChain filterChain = new FilterChain();
LineContainsRegExp lcre = new LineContainsRegExp();
RegularExpression regexp = new RegularExpression();
@ -211,6 +211,6 @@ public class IvyExtractFromSources extends IvyTask {
rre.setReplace("\\1");
tf.add(rre);
filterChain.add(tf);
_concat.addFilterChain(filterChain);
concat.addFilterChain(filterChain);
}
}

View File

@ -29,76 +29,76 @@ import org.apache.tools.ant.BuildException;
* properties according to what was found.
*/
public class IvyFindRevision extends IvyTask {
private String _organisation;
private String organisation;
private String _module;
private String module;
private String _branch;
private String branch;
private String _revision;
private String revision;
private String _property = "ivy.revision";
private String property = "ivy.revision";
public String getModule() {
return _module;
return module;
}
public void setModule(String module) {
_module = module;
this.module = module;
}
public String getOrganisation() {
return _organisation;
return organisation;
}
public void setOrganisation(String organisation) {
_organisation = organisation;
this.organisation = organisation;
}
public String getRevision() {
return _revision;
return revision;
}
public void setRevision(String revision) {
_revision = revision;
this.revision = revision;
}
public String getBranch() {
return _branch;
return branch;
}
public void setBranch(String branch) {
_branch = branch;
this.branch = branch;
}
public String getProperty() {
return _property;
return property;
}
public void setProperty(String prefix) {
_property = prefix;
this.property = prefix;
}
public void doExecute() throws BuildException {
if (_organisation == null) {
if (organisation == null) {
throw new BuildException("no organisation provided for ivy findmodules");
}
if (_module == null) {
if (module == null) {
throw new BuildException("no module name provided for ivy findmodules");
}
if (_revision == null) {
if (revision == null) {
throw new BuildException("no revision provided for ivy findmodules");
}
Ivy ivy = getIvyInstance();
IvySettings settings = ivy.getSettings();
if (_branch == null) {
settings.getDefaultBranch(new ModuleId(_organisation, _module));
if (branch == null) {
settings.getDefaultBranch(new ModuleId(organisation, module));
}
ResolvedModuleRevision rmr = ivy.findModule(ModuleRevisionId.newInstance(_organisation,
_module, _branch, _revision));
ResolvedModuleRevision rmr = ivy.findModule(ModuleRevisionId.newInstance(organisation,
module, branch, revision));
if (rmr != null) {
getProject().setProperty(_property, rmr.getId().getRevision());
getProject().setProperty(property, rmr.getId().getRevision());
}
}
}

View File

@ -36,26 +36,26 @@ import org.apache.tools.ant.Project;
* Parses information about an ivy file and make them available in ant.
*/
public class IvyInfo extends IvyTask {
private File _file = null;
private File file = null;
public File getFile() {
return _file;
return file;
}
public void setFile(File file) {
_file = file;
this.file = file;
}
public void doExecute() throws BuildException {
Ivy ivy = getIvyInstance();
IvySettings settings = ivy.getSettings();
if (_file == null) {
_file = getProject().resolveFile(getProperty(settings, "ivy.dep.file"));
if (file == null) {
file = getProject().resolveFile(getProperty(settings, "ivy.dep.file"));
}
try {
ModuleDescriptor md = ModuleDescriptorParserRegistry.getInstance().parseDescriptor(
settings, _file.toURL(), doValidate(settings));
settings, file.toURL(), doValidate(settings));
getProject()
.setProperty("ivy.organisation", md.getModuleRevisionId().getOrganisation());
getProject().setProperty("ivy.module", md.getModuleRevisionId().getName());
@ -75,7 +75,7 @@ public class IvyInfo extends IvyTask {
getProject().setProperty("ivy.public.configurations", mergeConfs(publicConfigs));
} catch (MalformedURLException e) {
throw new BuildException(
"unable to convert given ivy file to url: " + _file + ": " + e, e);
"unable to convert given ivy file to url: " + file + ": " + e, e);
} catch (ParseException e) {
log(e.getMessage(), Project.MSG_ERR);
throw new BuildException("syntax errors in ivy file: " + e, e);

View File

@ -31,63 +31,69 @@ import org.apache.tools.ant.BuildException;
* Allow to install a module or a set of module from repository to another one.
*/
public class IvyInstall extends IvyTask {
private String _organisation;
private String organisation;
private String _module;
private String module;
private String _revision;
private String revision;
private File _cache;
private File cache;
private boolean _overwrite = false;
private boolean overwrite = false;
private String _from;
private String from;
private String _to;
private String to;
private boolean _transitive;
private boolean transitive;
private String _type;
private String type;
private String _matcher = PatternMatcher.EXACT;
private String matcher = PatternMatcher.EXACT;
private boolean _haltOnFailure = true;
private boolean haltOnFailure = true;
public void doExecute() throws BuildException {
Ivy ivy = getIvyInstance();
IvySettings settings = ivy.getSettings();
if (_cache == null) {
_cache = settings.getDefaultCache();
if (cache == null) {
cache = settings.getDefaultCache();
}
if (_organisation == null) {
if (organisation == null) {
throw new BuildException(
"no organisation provided for ivy publish task: It can either be set explicitely via the attribute 'organisation' or via 'ivy.organisation' property or a prior call to <resolve/>");
"no organisation provided for ivy publish task: "
+ "It can either be set explicitely via the attribute 'organisation' "
+ "or via 'ivy.organisation' property or a prior call to <resolve/>");
}
if (_module == null && PatternMatcher.EXACT.equals(_matcher)) {
if (module == null && PatternMatcher.EXACT.equals(matcher)) {
throw new BuildException(
"no module name provided for ivy publish task: It can either be set explicitely via the attribute 'module' or via 'ivy.module' property or a prior call to <resolve/>");
} else if (_module == null && !PatternMatcher.EXACT.equals(_matcher)) {
_module = PatternMatcher.ANY_EXPRESSION;
"no module name provided for ivy publish task: "
+ "It can either be set explicitely via the attribute 'module' "
+ "or via 'ivy.module' property or a prior call to <resolve/>");
} else if (module == null && !PatternMatcher.EXACT.equals(matcher)) {
module = PatternMatcher.ANY_EXPRESSION;
}
if (_revision == null && PatternMatcher.EXACT.equals(_matcher)) {
if (revision == null && PatternMatcher.EXACT.equals(matcher)) {
throw new BuildException(
"no module revision provided for ivy publish task: It can either be set explicitely via the attribute 'revision' or via 'ivy.revision' property or a prior call to <resolve/>");
} else if (_revision == null && !PatternMatcher.EXACT.equals(_matcher)) {
_revision = PatternMatcher.ANY_EXPRESSION;
"no module revision provided for ivy publish task: "
+ "It can either be set explicitely via the attribute 'revision' "
+ "or via 'ivy.revision' property or a prior call to <resolve/>");
} else if (revision == null && !PatternMatcher.EXACT.equals(matcher)) {
revision = PatternMatcher.ANY_EXPRESSION;
}
if (_from == null) {
if (from == null) {
throw new BuildException(
"no from resolver name: please provide it through parameter 'from'");
}
if (_to == null) {
if (to == null) {
throw new BuildException(
"no to resolver name: please provide it through parameter 'to'");
}
ModuleRevisionId mrid = ModuleRevisionId.newInstance(_organisation, _module, _revision);
ModuleRevisionId mrid = ModuleRevisionId.newInstance(organisation, module, revision);
ResolveReport report;
try {
report = ivy.install(mrid, _from, _to, _transitive, doValidate(settings), _overwrite,
FilterHelper.getArtifactTypeFilter(_type), _cache, _matcher);
report = ivy.install(mrid, from, to, transitive, doValidate(settings), overwrite,
FilterHelper.getArtifactTypeFilter(type), cache, matcher);
} catch (Exception e) {
throw new BuildException("impossible to install " + mrid + ": " + e, e);
}
@ -99,90 +105,90 @@ public class IvyInstall extends IvyTask {
}
public boolean isHaltonfailure() {
return _haltOnFailure;
return haltOnFailure;
}
public void setHaltonfailure(boolean haltOnFailure) {
_haltOnFailure = haltOnFailure;
this.haltOnFailure = haltOnFailure;
}
public File getCache() {
return _cache;
return cache;
}
public void setCache(File cache) {
_cache = cache;
this.cache = cache;
}
public String getModule() {
return _module;
return module;
}
public void setModule(String module) {
_module = module;
this.module = module;
}
public String getOrganisation() {
return _organisation;
return organisation;
}
public void setOrganisation(String organisation) {
_organisation = organisation;
this.organisation = organisation;
}
public String getRevision() {
return _revision;
return revision;
}
public void setRevision(String revision) {
_revision = revision;
this.revision = revision;
}
public boolean isOverwrite() {
return _overwrite;
return overwrite;
}
public void setOverwrite(boolean overwrite) {
_overwrite = overwrite;
this.overwrite = overwrite;
}
public String getFrom() {
return _from;
return from;
}
public void setFrom(String from) {
_from = from;
this.from = from;
}
public String getTo() {
return _to;
return to;
}
public void setTo(String to) {
_to = to;
this.to = to;
}
public boolean isTransitive() {
return _transitive;
return transitive;
}
public void setTransitive(boolean transitive) {
_transitive = transitive;
this.transitive = transitive;
}
public String getType() {
return _type;
return type;
}
public void setType(String type) {
_type = type;
this.type = type;
}
public String getMatcher() {
return _matcher;
return matcher;
}
public void setMatcher(String matcher) {
_matcher = matcher;
this.matcher = matcher;
}
}

View File

@ -29,99 +29,99 @@ import org.apache.tools.ant.BuildException;
* according to what was found.
*/
public class IvyListModules extends IvyTask {
private String _organisation;
private String organisation;
private String _module;
private String module;
private String _branch = PatternMatcher.ANY_EXPRESSION;
private String branch = PatternMatcher.ANY_EXPRESSION;
private String _revision;
private String revision;
private String _matcher = PatternMatcher.EXACT_OR_REGEXP;
private String matcher = PatternMatcher.EXACT_OR_REGEXP;
private String _property;
private String property;
private String _value;
private String value;
public String getMatcher() {
return _matcher;
return matcher;
}
public void setMatcher(String matcher) {
_matcher = matcher;
this.matcher = matcher;
}
public String getModule() {
return _module;
return module;
}
public void setModule(String module) {
_module = module;
this.module = module;
}
public String getProperty() {
return _property;
return property;
}
public void setProperty(String name) {
_property = name;
this.property = name;
}
public String getOrganisation() {
return _organisation;
return organisation;
}
public void setOrganisation(String organisation) {
_organisation = organisation;
this.organisation = organisation;
}
public String getRevision() {
return _revision;
return revision;
}
public void setRevision(String revision) {
_revision = revision;
this.revision = revision;
}
public String getValue() {
return _value;
return value;
}
public void setValue(String value) {
_value = value;
this.value = value;
}
public String getBranch() {
return _branch;
return branch;
}
public void setBranch(String branch) {
_branch = branch;
this.branch = branch;
}
public void doExecute() throws BuildException {
if (_organisation == null) {
if (organisation == null) {
throw new BuildException("no organisation provided for ivy findmodules");
}
if (_module == null) {
if (module == null) {
throw new BuildException("no module name provided for ivy findmodules");
}
if (_revision == null) {
if (revision == null) {
throw new BuildException("no revision provided for ivy findmodules");
}
if (_property == null) {
if (property == null) {
throw new BuildException("no property provided for ivy findmodules");
}
if (_value == null) {
if (value == null) {
throw new BuildException("no value provided for ivy findmodules");
}
Ivy ivy = getIvyInstance();
IvySettings settings = ivy.getSettings();
ModuleRevisionId[] mrids = ivy.listModules(ModuleRevisionId.newInstance(_organisation,
_module, _branch, _revision), settings.getMatcher(_matcher));
ModuleRevisionId[] mrids = ivy.listModules(ModuleRevisionId.newInstance(organisation,
module, branch, revision), settings.getMatcher(matcher));
for (int i = 0; i < mrids.length; i++) {
String name = IvyPatternHelper.substitute(settings.substitute(_property), mrids[i]);
String value = IvyPatternHelper.substitute(settings.substitute(_value), mrids[i]);
String name = IvyPatternHelper.substitute(settings.substitute(property), mrids[i]);
String value = IvyPatternHelper.substitute(settings.substitute(this.value), mrids[i]);
getProject().setProperty(name, value);
}
}

View File

@ -37,29 +37,29 @@ import org.apache.tools.ant.BuildException;
* Base class for tasks needing to be performed after a resolve.
*/
public abstract class IvyPostResolveTask extends IvyTask {
private String _conf;
private String conf;
private boolean _haltOnFailure = true;
private boolean haltOnFailure = true;
private boolean _transitive = true;
private boolean transitive = true;
private boolean _inline = false;
private boolean inline = false;
private File _cache;
private File cache;
private String _organisation;
private String organisation;
private String _module;
private String module;
private String _revision = "latest.integration";
private String revision = "latest.integration";
private String _resolveId;
private String resolveId;
private String _type;
private String type;
private File _file;
private File file;
private Filter _artifactFilter = null;
private Filter artifactFilter = null;
private boolean useOrigin = false;
@ -77,34 +77,38 @@ public abstract class IvyPostResolveTask extends IvyTask {
Ivy ivy = getIvyInstance();
IvySettings settings = ivy.getSettings();
boolean orgAndModSetManually = (_organisation != null) && (_module != null);
boolean orgAndModSetManually = (organisation != null) && (module != null);
_organisation = getProperty(_organisation, settings, "ivy.organisation");
_module = getProperty(_module, settings, "ivy.module");
organisation = getProperty(organisation, settings, "ivy.organisation");
module = getProperty(module, settings, "ivy.module");
if (_cache == null) {
_cache = settings.getDefaultCache();
if (cache == null) {
cache = settings.getDefaultCache();
}
if (_file == null) {
String fileName = getProperty(settings, "ivy.resolved.file", _resolveId);
if (file == null) {
String fileName = getProperty(settings, "ivy.resolved.file", resolveId);
if (fileName != null) {
_file = new File(fileName);
file = new File(fileName);
}
}
if (isInline()) {
_conf = _conf == null ? "*" : _conf;
if (_organisation == null) {
conf = conf == null ? "*" : conf;
if (organisation == null) {
throw new BuildException(
"no organisation provided for ivy cache task in inline mode: It can either be set explicitely via the attribute 'organisation' or via 'ivy.organisation' property");
"no organisation provided for ivy cache task in inline mode: "
+ "It can either be set explicitely via the attribute 'organisation' "
+ "or via 'ivy.organisation' property");
}
if (_module == null) {
if (module == null) {
throw new BuildException(
"no module name provided for ivy cache task in inline mode: It can either be set explicitely via the attribute 'module' or via 'ivy.module' property");
"no module name provided for ivy cache task in inline mode: "
+ "It can either be set explicitely via the attribute 'module' "
+ "or via 'ivy.module' property");
}
String[] toResolve = getConfsToResolve(getOrganisation(), getModule() + "-caller",
_conf, true);
conf, true);
if (toResolve.length > 0) {
Message.verbose("using inline mode to resolve " + getOrganisation() + " "
+ getModule() + " " + getRevision() + " ("
@ -114,16 +118,16 @@ public abstract class IvyPostResolveTask extends IvyTask {
resolve.setModule(getModule());
resolve.setRevision(getRevision());
resolve.setInline(true);
resolve.setConf(_conf);
resolve.setCache(_cache);
resolve.setResolveId(_resolveId);
resolve.setConf(conf);
resolve.setCache(cache);
resolve.setResolveId(resolveId);
resolve.execute();
} else {
Message.verbose("inline resolve already done for " + getOrganisation() + " "
+ getModule() + " " + getRevision() + " (" + _conf + ")");
+ getModule() + " " + getRevision() + " (" + conf + ")");
}
if ("*".equals(_conf)) {
_conf = StringUtils.join(getResolvedConfigurations(getOrganisation(), getModule()
if ("*".equals(conf)) {
conf = StringUtils.join(getResolvedConfigurations(getOrganisation(), getModule()
+ "-caller", true), ", ");
}
} else {
@ -135,35 +139,42 @@ public abstract class IvyPostResolveTask extends IvyTask {
// from these report names?)
if (!orgAndModSetManually) {
ensureResolved(isHaltonfailure(), isUseOrigin(), isTransitive(), getOrganisation(),
getModule(), getProperty(_conf, settings, "ivy.resolved.configurations"),
_resolveId, _cache);
getModule(), getProperty(conf, settings, "ivy.resolved.configurations"),
resolveId, cache);
}
_conf = getProperty(_conf, settings, "ivy.resolved.configurations");
if ("*".equals(_conf)) {
_conf = getProperty(settings, "ivy.resolved.configurations");
if (_conf == null) {
conf = getProperty(conf, settings, "ivy.resolved.configurations");
if ("*".equals(conf)) {
conf = getProperty(settings, "ivy.resolved.configurations");
if (conf == null) {
throw new BuildException(
"bad conf provided for ivy cache task: * can only be used with a prior call to <resolve/>");
"bad conf provided for ivy cache task: "
+ "'*' can only be used with a prior call to <resolve/>");
}
}
}
_organisation = getProperty(_organisation, settings, "ivy.organisation");
_module = getProperty(_module, settings, "ivy.module");
if (_organisation == null) {
organisation = getProperty(organisation, settings, "ivy.organisation");
module = getProperty(module, settings, "ivy.module");
if (organisation == null) {
throw new BuildException(
"no organisation provided for ivy cache task: It can either be set explicitely via the attribute 'organisation' or via 'ivy.organisation' property or a prior call to <resolve/>");
"no organisation provided for ivy cache task: "
+ "It can either be set explicitely via the attribute 'organisation' "
+ "or via 'ivy.organisation' property or a prior call to <resolve/>");
}
if (_module == null) {
if (module == null) {
throw new BuildException(
"no module name provided for ivy cache task: It can either be set explicitely via the attribute 'module' or via 'ivy.module' property or a prior call to <resolve/>");
"no module name provided for ivy cache task: "
+ "It can either be set explicitely via the attribute 'module' "
+ "or via 'ivy.module' property or a prior call to <resolve/>");
}
if (_conf == null) {
if (conf == null) {
throw new BuildException(
"no conf provided for ivy cache task: It can either be set explicitely via the attribute 'conf' or via 'ivy.resolved.configurations' property or a prior call to <resolve/>");
"no conf provided for ivy cache task: "
+ "It can either be set explicitely via the attribute 'conf' or "
+ "via 'ivy.resolved.configurations' property or a prior call to <resolve/>");
}
_artifactFilter = FilterHelper.getArtifactTypeFilter(_type);
artifactFilter = FilterHelper.getArtifactTypeFilter(type);
}
protected void ensureResolved(boolean haltOnFailure, boolean useOrigin, boolean transitive,
@ -179,7 +190,7 @@ public abstract class IvyPostResolveTask extends IvyTask {
if (confs.length > 0) {
IvyResolve resolve = createResolve(haltOnFailure, useOrigin);
resolve.setFile(_file);
resolve.setFile(file);
resolve.setCache(cache);
resolve.setTransitive(transitive);
resolve.setConf(StringUtils.join(confs, ", "));
@ -265,99 +276,99 @@ public abstract class IvyPostResolveTask extends IvyTask {
protected ResolveReport getResolvedReport() {
return getResolvedReport(getOrganisation(), isInline() ? getModule() + "-caller"
: getModule(), _resolveId);
: getModule(), resolveId);
}
public String getType() {
return _type;
return type;
}
public void setType(String type) {
_type = type;
this.type = type;
}
public String getConf() {
return _conf;
return conf;
}
public void setConf(String conf) {
_conf = conf;
this.conf = conf;
}
public String getModule() {
return _module;
return module;
}
public void setModule(String module) {
_module = module;
this.module = module;
}
public String getOrganisation() {
return _organisation;
return organisation;
}
public void setOrganisation(String organisation) {
_organisation = organisation;
this.organisation = organisation;
}
public boolean isHaltonfailure() {
return _haltOnFailure;
return haltOnFailure;
}
public void setHaltonfailure(boolean haltOnFailure) {
_haltOnFailure = haltOnFailure;
this.haltOnFailure = haltOnFailure;
}
public File getCache() {
return _cache;
return cache;
}
public void setCache(File cache) {
_cache = cache;
this.cache = cache;
}
public String getRevision() {
return _revision;
return revision;
}
public void setRevision(String rev) {
_revision = rev;
revision = rev;
}
public Filter getArtifactFilter() {
return _artifactFilter;
return artifactFilter;
}
public boolean isTransitive() {
return _transitive;
return transitive;
}
public void setTransitive(boolean transitive) {
_transitive = transitive;
this.transitive = transitive;
}
public boolean isInline() {
return _inline;
return inline;
}
public void setInline(boolean inline) {
_inline = inline;
this.inline = inline;
}
public void setResolveId(String resolveId) {
_resolveId = resolveId;
this.resolveId = resolveId;
}
public String getResolveId() {
return _resolveId;
return resolveId;
}
public void setFile(File file) {
_file = file;
this.file = file;
}
public File getFile() {
return _file;
return file;
}
public void setKeep(boolean keep) {

View File

@ -42,62 +42,62 @@ import org.apache.tools.ant.BuildException;
* This task allow to publish a module revision to an Ivy repository.
*/
public class IvyPublish extends IvyTask {
private String _organisation;
private String organisation;
private String _module;
private String module;
private String _revision;
private String revision;
private String _pubRevision;
private String pubRevision;
private File _cache;
private File cache;
private String _srcivypattern;
private String srcivypattern;
private String _status;
private String status;
private String _conf = null;
private String conf = null;
private String _pubdate;
private String pubdate;
private String _deliverTarget;
private String deliverTarget;
private String _publishResolverName = null;
private String publishResolverName = null;
private List _artifactspattern = new ArrayList();
private List artifactspattern = new ArrayList();
private File _deliveryList;
private File deliveryList;
private boolean _publishivy = true;
private boolean publishivy = true;
private boolean _warnonmissing = true;
private boolean warnonmissing = true;
private boolean _haltonmissing = true;
private boolean haltonmissing = true;
private boolean _overwrite = false;
private boolean overwrite = false;
private boolean _update = false;
private boolean update = false;
private boolean _replacedynamicrev = true;
private boolean replacedynamicrev = true;
private boolean _forcedeliver;
private boolean forcedeliver;
private Collection _artifacts = new ArrayList();
private Collection artifacts = new ArrayList();
public File getCache() {
return _cache;
return cache;
}
public void setCache(File cache) {
_cache = cache;
this.cache = cache;
}
public String getSrcivypattern() {
return _srcivypattern;
return srcivypattern;
}
public void setSrcivypattern(String destivypattern) {
_srcivypattern = destivypattern;
srcivypattern = destivypattern;
}
/**
@ -105,7 +105,7 @@ public class IvyPublish extends IvyTask {
* @return
*/
public String getDeliverivypattern() {
return _srcivypattern;
return srcivypattern;
}
/**
@ -113,170 +113,178 @@ public class IvyPublish extends IvyTask {
* @return
*/
public void setDeliverivypattern(String destivypattern) {
_srcivypattern = destivypattern;
srcivypattern = destivypattern;
}
public String getModule() {
return _module;
return module;
}
public void setModule(String module) {
_module = module;
this.module = module;
}
public String getOrganisation() {
return _organisation;
return organisation;
}
public void setOrganisation(String organisation) {
_organisation = organisation;
this.organisation = organisation;
}
public String getPubdate() {
return _pubdate;
return pubdate;
}
public void setPubdate(String pubdate) {
_pubdate = pubdate;
this.pubdate = pubdate;
}
public String getPubrevision() {
return _pubRevision;
return pubRevision;
}
public void setPubrevision(String pubRevision) {
_pubRevision = pubRevision;
this.pubRevision = pubRevision;
}
public String getRevision() {
return _revision;
return revision;
}
public void setRevision(String revision) {
_revision = revision;
this.revision = revision;
}
public String getStatus() {
return _status;
return status;
}
public void setStatus(String status) {
_status = status;
this.status = status;
}
public void setConf(String conf) {
_conf = conf;
this.conf = conf;
}
public void setDelivertarget(String deliverTarget) {
_deliverTarget = deliverTarget;
this.deliverTarget = deliverTarget;
}
public void setDeliveryList(File deliveryList) {
_deliveryList = deliveryList;
this.deliveryList = deliveryList;
}
public String getResolver() {
return _publishResolverName;
return publishResolverName;
}
public void setResolver(String publishResolverName) {
_publishResolverName = publishResolverName;
this.publishResolverName = publishResolverName;
}
public String getArtifactspattern() {
return (String) (_artifactspattern.isEmpty() ? null : _artifactspattern.get(0));
return (String) (artifactspattern.isEmpty() ? null : artifactspattern.get(0));
}
public void setArtifactspattern(String artifactsPattern) {
_artifactspattern.clear();
_artifactspattern.add(artifactsPattern);
artifactspattern.clear();
artifactspattern.add(artifactsPattern);
}
public void addArtifactspattern(String artifactsPattern) {
_artifactspattern.add(artifactsPattern);
artifactspattern.add(artifactsPattern);
}
public void addConfiguredArtifacts(ArtifactsPattern p) {
_artifactspattern.add(p.getPattern());
artifactspattern.add(p.getPattern());
}
public boolean isReplacedynamicrev() {
return _replacedynamicrev;
return replacedynamicrev;
}
public void setReplacedynamicrev(boolean replacedynamicrev) {
_replacedynamicrev = replacedynamicrev;
this.replacedynamicrev = replacedynamicrev;
}
public void doExecute() throws BuildException {
Ivy ivy = getIvyInstance();
IvySettings settings = ivy.getSettings();
_organisation = getProperty(_organisation, settings, "ivy.organisation");
_module = getProperty(_module, settings, "ivy.module");
_revision = getProperty(_revision, settings, "ivy.revision");
_pubRevision = getProperty(_pubRevision, settings, "ivy.deliver.revision");
if (_cache == null) {
_cache = settings.getDefaultCache();
organisation = getProperty(organisation, settings, "ivy.organisation");
module = getProperty(module, settings, "ivy.module");
revision = getProperty(revision, settings, "ivy.revision");
pubRevision = getProperty(pubRevision, settings, "ivy.deliver.revision");
if (cache == null) {
cache = settings.getDefaultCache();
}
if (_artifactspattern.isEmpty()) {
if (artifactspattern.isEmpty()) {
String p = getProperty(null, settings, "ivy.publish.src.artifacts.pattern");
if (p != null) {
_artifactspattern.add(p);
artifactspattern.add(p);
}
}
if (_srcivypattern == null) {
_srcivypattern = getArtifactspattern();
if (srcivypattern == null) {
srcivypattern = getArtifactspattern();
}
_status = getProperty(_status, settings, "ivy.status");
if (_organisation == null) {
status = getProperty(status, settings, "ivy.status");
if (organisation == null) {
throw new BuildException(
"no organisation provided for ivy publish task: It can either be set explicitely via the attribute 'organisation' or via 'ivy.organisation' property or a prior call to <resolve/>");
"no organisation provided for ivy publish task: "
+ "It can either be set explicitely via the attribute 'organisation' "
+ "or via 'ivy.organisation' property or a prior call to <resolve/>");
}
if (_module == null) {
if (module == null) {
throw new BuildException(
"no module name provided for ivy publish task: It can either be set explicitely via the attribute 'module' or via 'ivy.module' property or a prior call to <resolve/>");
"no module name provided for ivy publish task: "
+ "It can either be set explicitely via the attribute 'module' "
+ "or via 'ivy.module' property or a prior call to <resolve/>");
}
if (_revision == null) {
if (revision == null) {
throw new BuildException(
"no module revision provided for ivy publish task: It can either be set explicitely via the attribute 'revision' or via 'ivy.revision' property or a prior call to <resolve/>");
"no module revision provided for ivy publish task: "
+ "It can either be set explicitely via the attribute 'revision' "
+ "or via 'ivy.revision' property or a prior call to <resolve/>");
}
if (_artifactspattern.isEmpty()) {
if (artifactspattern.isEmpty()) {
throw new BuildException(
"no artifacts pattern: either provide it through parameter or through ivy.publish.src.artifacts.pattern property");
"no artifacts pattern: either provide it through parameter or "
+ "through ivy.publish.src.artifacts.pattern property");
}
if (_publishResolverName == null) {
if (publishResolverName == null) {
throw new BuildException(
"no publish deliver name: please provide it through parameter 'resolver'");
}
if ("working".equals(_revision)) {
_revision = Ivy.getWorkingRevision();
if ("working".equals(revision)) {
revision = Ivy.getWorkingRevision();
}
Date pubdate = getPubDate(_pubdate, new Date());
if (_pubRevision == null) {
if (_revision.startsWith("working@")) {
_pubRevision = Ivy.DATE_FORMAT.format(pubdate);
Date pubdate = getPubDate(this.pubdate, new Date());
if (pubRevision == null) {
if (revision.startsWith("working@")) {
pubRevision = Ivy.DATE_FORMAT.format(pubdate);
} else {
_pubRevision = _revision;
pubRevision = revision;
}
}
if (_status == null) {
if (status == null) {
throw new BuildException(
"no status provided: either provide it as parameter or through the ivy.status.default property");
"no status provided: either provide it as parameter "
+ "or through the ivy.status.default property");
}
ModuleRevisionId mrid = ModuleRevisionId.newInstance(_organisation, _module, _revision);
ModuleRevisionId mrid = ModuleRevisionId.newInstance(organisation, module, revision);
try {
File ivyFile = new File(IvyPatternHelper.substitute(_srcivypattern, _organisation,
_module, _pubRevision, "ivy", "ivy", "xml"));
if (_publishivy && (!ivyFile.exists() || _forcedeliver)) {
File ivyFile = new File(IvyPatternHelper.substitute(srcivypattern, organisation,
module, pubRevision, "ivy", "ivy", "xml"));
if (publishivy && (!ivyFile.exists() || forcedeliver)) {
IvyDeliver deliver = new IvyDeliver();
deliver.setSettingsRef(getSettingsRef());
deliver.setProject(getProject());
deliver.setCache(getCache());
deliver.setDeliverpattern(getSrcivypattern());
deliver.setDelivertarget(_deliverTarget);
deliver.setDeliveryList(_deliveryList);
deliver.setDelivertarget(deliverTarget);
deliver.setDeliveryList(deliveryList);
deliver.setModule(getModule());
deliver.setOrganisation(getOrganisation());
deliver.setPubdate(Ivy.DATE_FORMAT.format(pubdate));
@ -285,27 +293,28 @@ public class IvyPublish extends IvyTask {
deliver.setStatus(getStatus());
deliver.setValidate(doValidate(settings));
deliver.setReplacedynamicrev(isReplacedynamicrev());
deliver.setConf(_conf);
deliver.setConf(conf);
deliver.execute();
}
Collection missing = ivy.publish(mrid, _artifactspattern, _publishResolverName,
Collection missing = ivy.publish(mrid, artifactspattern, publishResolverName,
new PublishOptions().setPubrevision(getPubrevision()).setCache(
CacheManager.getInstance(settings, _cache)).setSrcIvyPattern(
_publishivy ? _srcivypattern : null).setStatus(getStatus()).setPubdate(pubdate)
CacheManager.getInstance(settings, cache)).setSrcIvyPattern(
publishivy ? srcivypattern : null).setStatus(getStatus()).setPubdate(pubdate)
.setExtraArtifacts(
(Artifact[]) _artifacts.toArray(new Artifact[_artifacts.size()]))
.setValidate(doValidate(settings)).setOverwrite(_overwrite).setUpdate(
_update).setConfs(splitConfs(_conf)));
if (_warnonmissing) {
(Artifact[]) artifacts.toArray(new Artifact[artifacts.size()]))
.setValidate(doValidate(settings)).setOverwrite(overwrite).setUpdate(
update).setConfs(splitConfs(conf)));
if (warnonmissing) {
for (Iterator iter = missing.iterator(); iter.hasNext();) {
Artifact artifact = (Artifact) iter.next();
Message.warn("missing artifact: " + artifact);
}
}
if (_haltonmissing && !missing.isEmpty()) {
throw new BuildException("missing published artifacts for " + mrid + ": " + missing);
if (haltonmissing && !missing.isEmpty()) {
throw new BuildException(
"missing published artifacts for " + mrid + ": " + missing);
}
} catch (Exception e) {
@ -315,71 +324,71 @@ public class IvyPublish extends IvyTask {
public PublishArtifact createArtifact() {
PublishArtifact art = new PublishArtifact();
_artifacts.add(art);
artifacts.add(art);
return art;
}
public boolean isPublishivy() {
return _publishivy;
return publishivy;
}
public void setPublishivy(boolean publishivy) {
_publishivy = publishivy;
this.publishivy = publishivy;
}
public boolean isWarnonmissing() {
return _warnonmissing;
return warnonmissing;
}
public void setWarnonmissing(boolean warnonmissing) {
_warnonmissing = warnonmissing;
this.warnonmissing = warnonmissing;
}
public boolean isHaltonmissing() {
return _haltonmissing;
return haltonmissing;
}
public void setHaltonmissing(boolean haltonmissing) {
_haltonmissing = haltonmissing;
this.haltonmissing = haltonmissing;
}
public boolean isOverwrite() {
return _overwrite;
return overwrite;
}
public void setOverwrite(boolean overwrite) {
_overwrite = overwrite;
this.overwrite = overwrite;
}
public void setForcedeliver(boolean b) {
_forcedeliver = b;
forcedeliver = b;
}
public boolean isForcedeliver() {
return _forcedeliver;
return forcedeliver;
}
public boolean isUpdate() {
return _update;
return update;
}
public void setUpdate(boolean update) {
_update = update;
this.update = update;
}
public class PublishArtifact implements Artifact {
private String _ext;
private String ext;
private String _name;
private String name;
private String _type;
private String type;
public String[] getConfigurations() {
return null;
}
public String getExt() {
return _ext == null ? _type : _ext;
return ext == null ? type : ext;
}
public ArtifactRevisionId getId() {
@ -391,7 +400,7 @@ public class IvyPublish extends IvyTask {
}
public String getName() {
return _name;
return name;
}
public Date getPublicationDate() {
@ -399,7 +408,7 @@ public class IvyPublish extends IvyTask {
}
public String getType() {
return _type;
return type;
}
public URL getUrl() {
@ -407,15 +416,15 @@ public class IvyPublish extends IvyTask {
}
public void setExt(String ext) {
_ext = ext;
this.ext = ext;
}
public void setName(String name) {
_name = name;
this.name = name;
}
public void setType(String type) {
_type = type;
this.type = type;
}
public String getAttribute(String attName) {
@ -444,14 +453,14 @@ public class IvyPublish extends IvyTask {
}
public static class ArtifactsPattern {
private String _pattern;
private String pattern;
public String getPattern() {
return _pattern;
return pattern;
}
public void setPattern(String pattern) {
_pattern = pattern;
this.pattern = pattern;
}
}
}

View File

@ -42,166 +42,172 @@ import org.apache.tools.ant.util.GlobPatternMapper;
* This ant task let users generates reports (html, xml, graphml, ...) from the last resolve done.
*/
public class IvyReport extends IvyTask {
private File _todir;
private File todir;
private String _organisation;
private String organisation;
private String _module;
private String module;
private String _conf;
private String conf;
private File _cache;
private File cache;
private boolean _graph = true;
private boolean graph = true;
private boolean _dot = false;
private boolean dot = false;
private boolean _xml = false;
private boolean xml = false;
private boolean _xsl = true;
private boolean xsl = true;
private String _xslFile;
private String xslFile;
private String _outputpattern;
private String outputpattern;
private String _xslext = "html";
private String xslext = "html";
private List _params = new ArrayList();
private List params = new ArrayList();
private String _resolveId;
private String resolveId;
public File getTodir() {
return _todir;
return todir;
}
public void setTodir(File todir) {
_todir = todir;
this.todir = todir;
}
public File getCache() {
return _cache;
return cache;
}
public void setCache(File cache) {
_cache = cache;
this.cache = cache;
}
public String getConf() {
return _conf;
return conf;
}
public void setConf(String conf) {
_conf = conf;
this.conf = conf;
}
public String getModule() {
return _module;
return module;
}
public void setModule(String module) {
_module = module;
this.module = module;
}
public String getOrganisation() {
return _organisation;
return organisation;
}
public void setOrganisation(String organisation) {
_organisation = organisation;
this.organisation = organisation;
}
public boolean isGraph() {
return _graph;
return graph;
}
public void setGraph(boolean graph) {
_graph = graph;
this.graph = graph;
}
public String getXslfile() {
return _xslFile;
return xslFile;
}
public void setXslfile(String xslFile) {
_xslFile = xslFile;
this.xslFile = xslFile;
}
public String getOutputpattern() {
return _outputpattern;
return outputpattern;
}
public void setOutputpattern(String outputpattern) {
_outputpattern = outputpattern;
this.outputpattern = outputpattern;
}
public String getResolveId() {
return _resolveId;
return resolveId;
}
public void setResolveId(String resolveId) {
_resolveId = resolveId;
this.resolveId = resolveId;
}
public void doExecute() throws BuildException {
Ivy ivy = getIvyInstance();
IvySettings settings = ivy.getSettings();
_organisation = getProperty(_organisation, settings, "ivy.organisation", _resolveId);
_module = getProperty(_module, settings, "ivy.module", _resolveId);
if (_cache == null) {
_cache = settings.getDefaultCache();
organisation = getProperty(organisation, settings, "ivy.organisation", resolveId);
module = getProperty(module, settings, "ivy.module", resolveId);
if (cache == null) {
cache = settings.getDefaultCache();
}
_conf = getProperty(_conf, settings, "ivy.resolved.configurations", _resolveId);
if ("*".equals(_conf)) {
_conf = getProperty(settings, "ivy.resolved.configurations", _resolveId);
conf = getProperty(conf, settings, "ivy.resolved.configurations", resolveId);
if ("*".equals(conf)) {
conf = getProperty(settings, "ivy.resolved.configurations", resolveId);
}
if (_conf == null) {
if (conf == null) {
throw new BuildException(
"no conf provided for ivy report task: It can either be set explicitely via the attribute 'conf' or via 'ivy.resolved.configurations' property or a prior call to <resolve/>");
"no conf provided for ivy report task: "
+ "It can either be set explicitely via the attribute 'conf' or"
+ "via 'ivy.resolved.configurations' property or a prior call to <resolve/>");
}
if (_todir == null) {
if (todir == null) {
String t = getProperty(settings, "ivy.report.todir");
if (t != null) {
_todir = new File(t);
todir = new File(t);
}
}
_outputpattern = getProperty(_outputpattern, settings, "ivy.report.output.pattern");
if (_todir != null && _todir.exists()) {
_todir.mkdirs();
outputpattern = getProperty(outputpattern, settings, "ivy.report.output.pattern");
if (todir != null && todir.exists()) {
todir.mkdirs();
}
if (_outputpattern == null) {
_outputpattern = "[organisation]-[module]-[conf].[ext]";
if (outputpattern == null) {
outputpattern = "[organisation]-[module]-[conf].[ext]";
}
if (_todir != null && _todir.exists() && !_todir.isDirectory()) {
if (todir != null && todir.exists() && !todir.isDirectory()) {
throw new BuildException("destination directory should be a directory !");
}
if (_organisation == null) {
if (organisation == null) {
throw new BuildException(
"no organisation provided for ivy report task: It can either be set explicitely via the attribute 'organisation' or via 'ivy.organisation' property or a prior call to <resolve/>");
"no organisation provided for ivy report task: "
+ "It can either be set explicitely via the attribute 'organisation' or "
+ "via 'ivy.organisation' property or a prior call to <resolve/>");
}
if (_module == null) {
if (module == null) {
throw new BuildException(
"no module name provided for ivy report task: It can either be set explicitely via the attribute 'module' or via 'ivy.module' property or a prior call to <resolve/>");
"no module name provided for ivy report task: "
+ "It can either be set explicitely via the attribute 'module' or "
+ "via 'ivy.module' property or a prior call to <resolve/>");
}
if (_resolveId == null) {
_resolveId = ResolveOptions.getDefaultResolveId(new ModuleId(_organisation, _module));
if (resolveId == null) {
resolveId = ResolveOptions.getDefaultResolveId(new ModuleId(organisation, module));
}
try {
String[] confs = splitConfs(_conf);
if (_xsl) {
genreport(_cache, _organisation, _module, confs);
String[] confs = splitConfs(conf);
if (xsl) {
genreport(cache, organisation, module, confs);
}
if (_xml) {
genxml(_cache, _organisation, _module, confs);
if (xml) {
genxml(cache, organisation, module, confs);
}
if (_graph) {
genStyled(_cache, _organisation, _module, confs, getStylePath(_cache,
if (graph) {
genStyled(cache, organisation, module, confs, getStylePath(cache,
"ivy-report-graph.xsl"), "graphml");
}
if (_dot) {
genStyled(_cache, _organisation, _module, confs, getStylePath(_cache,
if (dot) {
genStyled(cache, organisation, module, confs, getStylePath(cache,
"ivy-report-dot.xsl"), "dot");
}
} catch (IOException e) {
@ -211,16 +217,16 @@ public class IvyReport extends IvyTask {
private void genxml(File cache, String organisation, String module, String[] confs)
throws IOException {
CacheManager cacheMgr = getIvyInstance().getCacheManager(_cache);
CacheManager cacheMgr = getIvyInstance().getCacheManager(cache);
for (int i = 0; i < confs.length; i++) {
File xml = cacheMgr.getConfigurationResolveReportInCache(_resolveId, confs[i]);
File xml = cacheMgr.getConfigurationResolveReportInCache(resolveId, confs[i]);
File out;
if (_todir != null) {
out = new File(_todir, IvyPatternHelper.substitute(_outputpattern, organisation,
if (todir != null) {
out = new File(todir, IvyPatternHelper.substitute(outputpattern, organisation,
module, "", "", "", "xml", confs[i]));
} else {
out = new File(IvyPatternHelper.substitute(_outputpattern, organisation, module,
out = new File(IvyPatternHelper.substitute(outputpattern, organisation, module,
"", "", "", "xml", confs[i]));
}
@ -230,13 +236,13 @@ public class IvyReport extends IvyTask {
private void genreport(File cache, String organisation, String module, String[] confs)
throws IOException {
genStyled(cache, organisation, module, confs, getReportStylePath(cache), _xslext);
genStyled(cache, organisation, module, confs, getReportStylePath(cache), xslext);
// copy the css if required
if (_todir != null && _xslFile == null) {
File css = new File(_todir, "ivy-report.css");
if (todir != null && xslFile == null) {
File css = new File(todir, "ivy-report.css");
if (!css.exists()) {
Message.debug("copying report css to " + _todir);
Message.debug("copying report css to " + todir);
FileUtil.copy(XmlReportOutputter.class.getResourceAsStream("ivy-report.css"), css,
null);
}
@ -246,8 +252,8 @@ public class IvyReport extends IvyTask {
}
private String getReportStylePath(File cache) throws IOException {
if (_xslFile != null) {
return _xslFile;
if (xslFile != null) {
return xslFile;
}
// style should be a file (and not an url)
// so we have to copy it from classpath to cache
@ -260,8 +266,8 @@ public class IvyReport extends IvyTask {
String style, String ext) throws IOException {
// process the report with xslt to generate dot file
File out;
if (_todir != null) {
out = _todir;
if (todir != null) {
out = todir;
} else {
out = new File(".");
}
@ -279,12 +285,12 @@ public class IvyReport extends IvyTask {
CacheManager cacheMgr = getIvyInstance().getCacheManager(cache);
for (int i = 0; i < confs.length; i++) {
File reportFile = cacheMgr.getConfigurationResolveReportInCache(_resolveId, confs[i]);
File reportFile = cacheMgr.getConfigurationResolveReportInCache(resolveId, confs[i]);
xslt.setIncludes(reportFile.getName());
FileNameMapper reportMapper = new GlobPatternMapper();
reportMapper.setFrom(reportFile.getName());
reportMapper.setTo(IvyPatternHelper.substitute(_outputpattern, organisation, module,
reportMapper.setTo(IvyPatternHelper.substitute(outputpattern, organisation, module,
"", "", "", ext, confs[i]));
mapper.add(reportMapper);
}
@ -292,13 +298,13 @@ public class IvyReport extends IvyTask {
XSLTProcess.Param param = xslt.createParam();
param.setName("confs");
param.setExpression(_conf);
param.setExpression(conf);
param = xslt.createParam();
param.setName("extension");
param.setExpression(_xslext);
param.setExpression(xslext);
// add the provided XSLT parameters
for (Iterator it = _params.iterator(); it.hasNext();) {
for (Iterator it = params.iterator(); it.hasNext();) {
param = (XSLTProcess.Param) it.next();
XSLTProcess.Param realParam = xslt.createParam();
realParam.setName(param.getName());
@ -317,41 +323,41 @@ public class IvyReport extends IvyTask {
}
public boolean isXml() {
return _xml;
return xml;
}
public void setXml(boolean xml) {
_xml = xml;
this.xml = xml;
}
public boolean isXsl() {
return _xsl;
return xsl;
}
public void setXsl(boolean xsl) {
_xsl = xsl;
this.xsl = xsl;
}
public String getXslext() {
return _xslext;
return xslext;
}
public void setXslext(String xslext) {
_xslext = xslext;
this.xslext = xslext;
}
public XSLTProcess.Param createParam() {
XSLTProcess.Param result = new XSLTProcess.Param();
_params.add(result);
params.add(result);
return result;
}
public boolean isDot() {
return _dot;
return dot;
}
public void setDot(boolean dot) {
_dot = dot;
this.dot = dot;
}
}

View File

@ -42,87 +42,89 @@ import org.apache.tools.ant.taskdefs.XSLTProcess;
* specified using organisation/module and matcher.
*/
public class IvyRepositoryReport extends IvyTask {
private String _organisation = "*";
private String organisation = "*";
private String _module;
private String module;
private String _branch;
private String branch;
private String _revision = "latest.integration";
private String revision = "latest.integration";
private File _cache;
private File cache;
private String _matcher = PatternMatcher.EXACT_OR_REGEXP;
private String matcher = PatternMatcher.EXACT_OR_REGEXP;
private File _todir = new File(".");
private File todir = new File(".");
private boolean _graph = false;
private boolean graph = false;
private boolean _dot = false;
private boolean dot = false;
private boolean _xml = true;
private boolean xml = true;
private boolean _xsl = false;
private boolean xsl = false;
private String _xslFile;
private String xslFile;
private String _outputname = "ivy-repository-report";
private String outputname = "ivy-repository-report";
private String _xslext = "html";
private String xslext = "html";
private List _params = new ArrayList();
private List params = new ArrayList();
public void doExecute() throws BuildException {
Ivy ivy = getIvyInstance();
IvySettings settings = ivy.getSettings();
if (_cache == null) {
_cache = settings.getDefaultCache();
if (cache == null) {
cache = settings.getDefaultCache();
}
if (_xsl && _xslFile == null) {
if (xsl && xslFile == null) {
throw new BuildException("xsl file is mandatory when using xsl generation");
}
if (_module == null && PatternMatcher.EXACT.equals(_matcher)) {
if (module == null && PatternMatcher.EXACT.equals(matcher)) {
throw new BuildException(
"no module name provided for ivy repository graph task: It can either be set explicitely via the attribute 'module' or via 'ivy.module' property or a prior call to <resolve/>");
} else if (_module == null && !PatternMatcher.EXACT.equals(_matcher)) {
_module = PatternMatcher.ANY_EXPRESSION;
"no module name provided for ivy repository graph task: "
+ "It can either be set explicitely via the attribute 'module' or "
+ "via 'ivy.module' property or a prior call to <resolve/>");
} else if (module == null && !PatternMatcher.EXACT.equals(matcher)) {
module = PatternMatcher.ANY_EXPRESSION;
}
ModuleRevisionId mrid = ModuleRevisionId.newInstance(_organisation, _module, _revision);
ModuleRevisionId mrid = ModuleRevisionId.newInstance(organisation, module, revision);
try {
ModuleId[] mids = ivy.listModules(new ModuleId(_organisation, _module), settings
.getMatcher(_matcher));
ModuleId[] mids = ivy.listModules(new ModuleId(organisation, module), settings
.getMatcher(matcher));
ModuleRevisionId[] mrids = new ModuleRevisionId[mids.length];
for (int i = 0; i < mrids.length; i++) {
if (_branch != null) {
mrids[i] = new ModuleRevisionId(mids[i], _branch, _revision);
if (branch != null) {
mrids[i] = new ModuleRevisionId(mids[i], branch, revision);
} else {
mrids[i] = new ModuleRevisionId(mids[i], _revision);
mrids[i] = new ModuleRevisionId(mids[i], revision);
}
}
DefaultModuleDescriptor md = DefaultModuleDescriptor.newCallerInstance(mrids, true,
false);
String resolveId = ResolveOptions.getDefaultResolveId(md);
ResolveReport report = ivy.resolve(md, new ResolveOptions().setResolveId(resolveId)
.setCache(CacheManager.getInstance(settings, _cache)).setValidate(
.setCache(CacheManager.getInstance(settings, cache)).setValidate(
doValidate(settings)));
CacheManager cacheMgr = getIvyInstance().getCacheManager(_cache);
new XmlReportOutputter().output(report, _cache);
if (_graph) {
CacheManager cacheMgr = getIvyInstance().getCacheManager(cache);
new XmlReportOutputter().output(report, cache);
if (graph) {
gengraph(cacheMgr, md.getModuleRevisionId().getOrganisation(), md
.getModuleRevisionId().getName());
}
if (_dot) {
if (dot) {
gendot(cacheMgr, md.getModuleRevisionId().getOrganisation(), md
.getModuleRevisionId().getName());
}
if (_xml) {
if (xml) {
FileUtil.copy(cacheMgr.getConfigurationResolveReportInCache(resolveId, "default"),
new File(_todir, _outputname + ".xml"), null);
new File(todir, outputname + ".xml"), null);
}
if (_xsl) {
if (xsl) {
genreport(cacheMgr, md.getModuleRevisionId().getOrganisation(), md
.getModuleRevisionId().getName());
}
@ -141,16 +143,16 @@ public class IvyRepositoryReport extends IvyTask {
String resolveId = ResolveOptions.getDefaultResolveId(new ModuleId(organisation, module));
xslt.setIn(cache.getConfigurationResolveReportInCache(resolveId, "default"));
xslt.setOut(new File(_todir, _outputname + "." + _xslext));
xslt.setOut(new File(todir, outputname + "." + xslext));
xslt.setStyle(_xslFile);
xslt.setStyle(xslFile);
XSLTProcess.Param param = xslt.createParam();
param.setName("extension");
param.setExpression(_xslext);
param.setExpression(xslext);
// add the provided XSLT parameters
for (Iterator it = _params.iterator(); it.hasNext();) {
for (Iterator it = params.iterator(); it.hasNext();) {
param = (XSLTProcess.Param) it.next();
XSLTProcess.Param realParam = xslt.createParam();
realParam.setName(param.getName());
@ -196,127 +198,127 @@ public class IvyRepositoryReport extends IvyTask {
String resolveId = ResolveOptions.getDefaultResolveId(new ModuleId(organisation, module));
xslt.setIn(cache.getConfigurationResolveReportInCache(resolveId, "default"));
xslt.setOut(new File(_todir, _outputname + "." + ext));
xslt.setOut(new File(todir, outputname + "." + ext));
xslt.setBasedir(cache.getCache());
xslt.setStyle(style);
xslt.execute();
}
public File getTodir() {
return _todir;
return todir;
}
public void setTodir(File todir) {
_todir = todir;
this.todir = todir;
}
public boolean isGraph() {
return _graph;
return graph;
}
public void setGraph(boolean graph) {
_graph = graph;
this.graph = graph;
}
public String getXslfile() {
return _xslFile;
return xslFile;
}
public void setXslfile(String xslFile) {
_xslFile = xslFile;
this.xslFile = xslFile;
}
public boolean isXml() {
return _xml;
return xml;
}
public void setXml(boolean xml) {
_xml = xml;
this.xml = xml;
}
public boolean isXsl() {
return _xsl;
return xsl;
}
public void setXsl(boolean xsl) {
_xsl = xsl;
this.xsl = xsl;
}
public String getXslext() {
return _xslext;
return xslext;
}
public void setXslext(String xslext) {
_xslext = xslext;
this.xslext = xslext;
}
public XSLTProcess.Param createParam() {
XSLTProcess.Param result = new XSLTProcess.Param();
_params.add(result);
params.add(result);
return result;
}
public String getOutputname() {
return _outputname;
return outputname;
}
public void setOutputname(String outputpattern) {
_outputname = outputpattern;
outputname = outputpattern;
}
public File getCache() {
return _cache;
return cache;
}
public void setCache(File cache) {
_cache = cache;
this.cache = cache;
}
public String getMatcher() {
return _matcher;
return matcher;
}
public void setMatcher(String matcher) {
_matcher = matcher;
this.matcher = matcher;
}
public String getModule() {
return _module;
return module;
}
public void setModule(String module) {
_module = module;
this.module = module;
}
public String getOrganisation() {
return _organisation;
return organisation;
}
public void setOrganisation(String organisation) {
_organisation = organisation;
this.organisation = organisation;
}
public String getRevision() {
return _revision;
return revision;
}
public void setRevision(String revision) {
_revision = revision;
this.revision = revision;
}
public String getBranch() {
return _branch;
return branch;
}
public void setBranch(String branch) {
_branch = branch;
this.branch = branch;
}
public boolean isDot() {
return _dot;
return dot;
}
public void setDot(boolean dot) {
_dot = dot;
this.dot = dot;
}
}

View File

@ -37,94 +37,94 @@ import org.apache.tools.ant.Project;
* This task allow to call the Ivy dependency resolution from ant.
*/
public class IvyResolve extends IvyTask {
private File _file = null;
private File file = null;
private String _conf = null;
private String conf = null;
private File _cache = null;
private File cache = null;
private String _organisation = null;
private String organisation = null;
private String _module = null;
private String module = null;
private String _revision = null;
private String revision = null;
private String _pubdate = null;
private String pubdate = null;
private boolean _inline = false;
private boolean inline = false;
private boolean _haltOnFailure = true;
private boolean haltOnFailure = true;
private boolean _useCacheOnly = false;
private boolean useCacheOnly = false;
private String _type = null;
private String type = null;
private boolean _transitive = true;
private boolean transitive = true;
private boolean _changing = false;
private boolean changing = false;
private Boolean _keep = null;
private Boolean keep = null;
private String _failureProperty = null;
private String failureProperty = null;
private boolean _useOrigin = false;
private boolean useOrigin = false;
private String _resolveId = null;
private String resolveId = null;
public boolean isUseOrigin() {
return _useOrigin;
return useOrigin;
}
public void setUseOrigin(boolean useOrigin) {
_useOrigin = useOrigin;
this.useOrigin = useOrigin;
}
public String getDate() {
return _pubdate;
return pubdate;
}
public void setDate(String pubdate) {
_pubdate = pubdate;
this.pubdate = pubdate;
}
public String getRevision() {
return _revision;
return revision;
}
public void setRevision(String revision) {
_revision = revision;
this.revision = revision;
}
public File getCache() {
return _cache;
return cache;
}
public void setCache(File cache) {
_cache = cache;
this.cache = cache;
}
public String getConf() {
return _conf;
return conf;
}
public void setConf(String conf) {
_conf = conf;
this.conf = conf;
}
public File getFile() {
return _file;
return file;
}
public void setFile(File file) {
_file = file;
this.file = file;
}
public boolean isHaltonfailure() {
return _haltOnFailure;
return haltOnFailure;
}
public void setHaltonfailure(boolean haltOnFailure) {
_haltOnFailure = haltOnFailure;
this.haltOnFailure = haltOnFailure;
}
public void setShowprogress(boolean show) {
@ -132,19 +132,19 @@ public class IvyResolve extends IvyTask {
}
public boolean isUseCacheOnly() {
return _useCacheOnly;
return useCacheOnly;
}
public void setUseCacheOnly(boolean useCacheOnly) {
_useCacheOnly = useCacheOnly;
this.useCacheOnly = useCacheOnly;
}
public String getType() {
return _type;
return type;
}
public void setType(String type) {
_type = type;
this.type = type;
}
/**
@ -157,64 +157,64 @@ public class IvyResolve extends IvyTask {
}
public void setFailureProperty(String failureProperty) {
_failureProperty = failureProperty;
this.failureProperty = failureProperty;
}
public String getFailureProperty() {
return _failureProperty;
return failureProperty;
}
public void doExecute() throws BuildException {
Ivy ivy = getIvyInstance();
IvySettings settings = ivy.getSettings();
try {
_conf = getProperty(_conf, settings, "ivy.configurations");
_type = getProperty(_type, settings, "ivy.resolve.default.type.filter");
if (_cache == null) {
_cache = settings.getDefaultCache();
conf = getProperty(conf, settings, "ivy.configurations");
type = getProperty(type, settings, "ivy.resolve.default.type.filter");
if (cache == null) {
cache = settings.getDefaultCache();
}
String[] confs = splitConfs(_conf);
String[] confs = splitConfs(conf);
ResolveReport report;
if (isInline()) {
if (_organisation == null) {
if (organisation == null) {
throw new BuildException("'organisation' is required when using inline mode");
}
if (_module == null) {
if (module == null) {
throw new BuildException("'module' is required when using inline mode");
}
if (_file != null) {
if (file != null) {
throw new BuildException("'file' not allowed when using inline mode");
}
if (_revision == null) {
_revision = "latest.integration";
if (revision == null) {
revision = "latest.integration";
}
report = ivy.resolve(ModuleRevisionId
.newInstance(_organisation, _module, _revision), getResolveOptions(confs,
settings), _changing);
.newInstance(organisation, module, revision), getResolveOptions(confs,
settings), changing);
} else {
if (_organisation != null) {
if (organisation != null) {
throw new BuildException(
"'organisation' not allowed when not using 'org' attribute");
}
if (_module != null) {
if (module != null) {
throw new BuildException("'module' not allowed when not using 'org' attribute");
}
if (_file == null) {
_file = getProject().resolveFile(getProperty(settings, "ivy.dep.file"));
if (file == null) {
file = getProject().resolveFile(getProperty(settings, "ivy.dep.file"));
}
report = ivy.resolve(_file.toURL(), getResolveOptions(confs, settings));
report = ivy.resolve(file.toURL(), getResolveOptions(confs, settings));
}
if (report.hasError()) {
if (_failureProperty != null) {
getProject().setProperty(_failureProperty, "true");
if (failureProperty != null) {
getProject().setProperty(failureProperty, "true");
}
if (isHaltonfailure()) {
throw new BuildException("resolve failed - see output for details");
}
}
setResolved(report, _resolveId, isKeep());
setResolved(report, resolveId, isKeep());
if (isKeep()) {
ModuleDescriptor md = report.getModuleDescriptor();
@ -223,66 +223,66 @@ public class IvyResolve extends IvyTask {
// call to the other
getProject().setProperty("ivy.organisation",
md.getModuleRevisionId().getOrganisation());
settings
.setVariable("ivy.organisation", md.getModuleRevisionId().getOrganisation());
settings.setVariable(
"ivy.organisation", md.getModuleRevisionId().getOrganisation());
getProject().setProperty("ivy.module", md.getModuleRevisionId().getName());
settings.setVariable("ivy.module", md.getModuleRevisionId().getName());
getProject().setProperty("ivy.revision",
md.getResolvedModuleRevisionId().getRevision());
settings
.setVariable("ivy.revision", md.getResolvedModuleRevisionId().getRevision());
settings.setVariable(
"ivy.revision", md.getResolvedModuleRevisionId().getRevision());
boolean hasChanged = report.hasChanged();
getProject().setProperty("ivy.deps.changed", String.valueOf(hasChanged));
settings.setVariable("ivy.deps.changed", String.valueOf(hasChanged));
if (_conf.trim().equals("*")) {
if (conf.trim().equals("*")) {
getProject().setProperty("ivy.resolved.configurations",
mergeConfs(md.getConfigurationsNames()));
settings.setVariable("ivy.resolved.configurations", mergeConfs(md
.getConfigurationsNames()));
} else {
getProject().setProperty("ivy.resolved.configurations", _conf);
settings.setVariable("ivy.resolved.configurations", _conf);
getProject().setProperty("ivy.resolved.configurations", conf);
settings.setVariable("ivy.resolved.configurations", conf);
}
if (_file != null) {
getProject().setProperty("ivy.resolved.file", _file.getAbsolutePath());
settings.setVariable("ivy.resolved.file", _file.getAbsolutePath());
if (file != null) {
getProject().setProperty("ivy.resolved.file", file.getAbsolutePath());
settings.setVariable("ivy.resolved.file", file.getAbsolutePath());
}
if (_resolveId != null) {
getProject().setProperty("ivy.organisation." + _resolveId,
if (resolveId != null) {
getProject().setProperty("ivy.organisation." + resolveId,
md.getModuleRevisionId().getOrganisation());
settings.setVariable("ivy.organisation." + _resolveId, md.getModuleRevisionId()
settings.setVariable("ivy.organisation." + resolveId, md.getModuleRevisionId()
.getOrganisation());
getProject().setProperty("ivy.module." + _resolveId,
getProject().setProperty("ivy.module." + resolveId,
md.getModuleRevisionId().getName());
settings.setVariable("ivy.module." + _resolveId, md.getModuleRevisionId()
settings.setVariable("ivy.module." + resolveId, md.getModuleRevisionId()
.getName());
getProject().setProperty("ivy.revision." + _resolveId,
getProject().setProperty("ivy.revision." + resolveId,
md.getResolvedModuleRevisionId().getRevision());
settings.setVariable("ivy.revision." + _resolveId, md
settings.setVariable("ivy.revision." + resolveId, md
.getResolvedModuleRevisionId().getRevision());
getProject().setProperty("ivy.deps.changed." + _resolveId,
getProject().setProperty("ivy.deps.changed." + resolveId,
String.valueOf(hasChanged));
settings.setVariable("ivy.deps.changed." + _resolveId, String
settings.setVariable("ivy.deps.changed." + resolveId, String
.valueOf(hasChanged));
if (_conf.trim().equals("*")) {
getProject().setProperty("ivy.resolved.configurations." + _resolveId,
if (conf.trim().equals("*")) {
getProject().setProperty("ivy.resolved.configurations." + resolveId,
mergeConfs(md.getConfigurationsNames()));
settings.setVariable("ivy.resolved.configurations." + _resolveId,
settings.setVariable("ivy.resolved.configurations." + resolveId,
mergeConfs(md.getConfigurationsNames()));
} else {
getProject()
.setProperty("ivy.resolved.configurations." + _resolveId, _conf);
settings.setVariable("ivy.resolved.configurations." + _resolveId, _conf);
.setProperty("ivy.resolved.configurations." + resolveId, conf);
settings.setVariable("ivy.resolved.configurations." + resolveId, conf);
}
getProject().setProperty("ivy.resolved.file." + _resolveId,
_file.getAbsolutePath());
getProject().setProperty("ivy.resolved.file." + resolveId,
file.getAbsolutePath());
settings
.setVariable("ivy.resolved.file." + _resolveId, _file.getAbsolutePath());
.setVariable("ivy.resolved.file." + resolveId, file.getAbsolutePath());
}
}
} catch (MalformedURLException e) {
throw new BuildException(
"unable to convert given ivy file to url: " + _file + ": " + e, e);
"unable to convert given ivy file to url: " + file + ": " + e, e);
} catch (ParseException e) {
log(e.getMessage(), Project.MSG_ERR);
throw new BuildException("syntax errors in ivy file: " + e, e);
@ -293,65 +293,65 @@ public class IvyResolve extends IvyTask {
private ResolveOptions getResolveOptions(String[] confs, IvySettings settings) {
return new ResolveOptions().setConfs(confs).setValidate(doValidate(settings))
.setArtifactFilter(FilterHelper.getArtifactTypeFilter(_type))
.setRevision(_revision).setCache(CacheManager.getInstance(settings, _cache))
.setDate(getPubDate(_pubdate, null)).setUseCacheOnly(_useCacheOnly).setUseOrigin(
_useOrigin).setTransitive(_transitive).setResolveId(_resolveId);
.setArtifactFilter(FilterHelper.getArtifactTypeFilter(type))
.setRevision(revision).setCache(CacheManager.getInstance(settings, cache))
.setDate(getPubDate(pubdate, null)).setUseCacheOnly(useCacheOnly).setUseOrigin(
useOrigin).setTransitive(transitive).setResolveId(resolveId);
}
public String getModule() {
return _module;
return module;
}
public void setModule(String module) {
_module = module;
this.module = module;
}
public String getOrganisation() {
return _organisation;
return organisation;
}
public void setOrganisation(String organisation) {
_organisation = organisation;
this.organisation = organisation;
}
public boolean isTransitive() {
return _transitive;
return transitive;
}
public void setTransitive(boolean transitive) {
_transitive = transitive;
this.transitive = transitive;
}
public boolean isChanging() {
return _changing;
return changing;
}
public void setChanging(boolean changing) {
_changing = changing;
this.changing = changing;
}
public boolean isKeep() {
return _keep == null ? _organisation == null : _keep.booleanValue();
return keep == null ? organisation == null : keep.booleanValue();
}
public void setKeep(boolean keep) {
_keep = Boolean.valueOf(keep);
this.keep = Boolean.valueOf(keep);
}
public boolean isInline() {
return _inline;
return inline;
}
public void setInline(boolean inline) {
_inline = inline;
this.inline = inline;
}
public String getResolveId() {
return _resolveId;
return resolveId;
}
public void setResolveId(String resolveId) {
_resolveId = resolveId;
this.resolveId = resolveId;
}
}

View File

@ -82,7 +82,9 @@ public abstract class IvyTask extends Task {
if (!(antIvyEngine instanceof IvyAntSettings)) {
throw new BuildException(
antIvyEngineRef.getRefId()
+ " has been defined in a different classloader. Please use the same loader when defining your task, or redeclare your ivy:settings in this classloader",
+ " has been defined in a different classloader. "
+ "Please use the same loader when defining your task, or "
+ "redeclare your ivy:settings in this classloader",
getLocation());
}
} else {