You are viewing a plain text version of this content. The canonical link for it is here.
Posted to ivy-commits@incubator.apache.org by xa...@apache.org on 2007/06/05 12:02:43 UTC
svn commit: r544459 [3/36] - in /incubator/ivy/core/trunk:
src/java/org/apache/ivy/ src/java/org/apache/ivy/ant/
src/java/org/apache/ivy/core/ src/java/org/apache/ivy/core/cache/
src/java/org/apache/ivy/core/check/ src/java/org/apache/ivy/core/deliver/...
Modified: incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/AntCallTrigger.java
URL: http://svn.apache.org/viewvc/incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/AntCallTrigger.java?view=diff&rev=544459&r1=544458&r2=544459
==============================================================================
--- incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/AntCallTrigger.java (original)
+++ incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/AntCallTrigger.java Tue Jun 5 05:02:27 2007
@@ -33,104 +33,96 @@
import org.apache.tools.ant.taskdefs.CallTarget;
import org.apache.tools.ant.taskdefs.Property;
-
/**
- * Triggers an call to an ant target on an event occurence.
- *
- * This trigger only works when ivy is called from an ant build file, otherwise the trigger
- * only log a failure.
- *
- * Example of use in an ivysettings file:
- * <ant-call-trigger event="post-download-artifact" filter="type=zip"
- * target="unzip"/>
- * Triggers a call to the target "unzip" for any downloaded artifact of type zip
+ * Triggers an call to an ant target on an event occurence. This trigger only works when ivy is
+ * called from an ant build file, otherwise the trigger only log a failure. Example of use in an
+ * ivysettings file: <ant-call-trigger event="post-download-artifact" filter="type=zip"
+ * target="unzip"/> Triggers a call to the target "unzip" for any downloaded artifact of type zip
*
* @see AntBuildTrigger
* @since 1.4
- *
*/
public class AntCallTrigger extends AbstractTrigger implements Trigger {
- private boolean _onlyonce = true;
- private String _target = null;
- private Collection _calls = new ArrayList();
- private String _prefix;
-
- public void progress(IvyEvent event) {
- Project project = (Project)IvyContext.getContext().peek(IvyTask.ANT_PROJECT_CONTEXT_KEY);
- if (project == null) {
- Message.info("ant call trigger can only be used from an ant build. Ignoring.");
- return;
- }
- if (_onlyonce && isTriggered(event)) {
- Message.verbose("call already triggered for this event, skipping: "+event);
- } else {
- CallTarget call = new CallTarget();
-
- call.setProject(project);
- call.setTaskName("antcall");
-
- Map attributes = event.getAttributes();
- String target = IvyPatternHelper.substituteTokens(getTarget(), attributes);
- call.setTarget(target);
-
- for (Iterator iter = attributes.keySet().iterator(); iter.hasNext();) {
- String key = (String) iter.next();
- String value = (String) attributes.get(key);
- Property p = call.createParam();
- p.setName(_prefix == null?key:_prefix+key);
- p.setValue(value == null?"":value);
- }
-
- Message.verbose("triggering ant call: target="+target+" for "+event);
- MessageImpl impl = IvyContext.getContext().getMessageImpl();
- try {
- IvyContext.getContext().setMessageImpl(null);
- call.execute();
- markTriggered(event);
- } finally {
- IvyContext.getContext().setMessageImpl(impl);
- }
-
- Message.debug("triggered ant call finished: target="+target+" for "+event);
- }
- }
-
-
+ private boolean _onlyonce = true;
- private void markTriggered(IvyEvent event) {
- _calls.add(event);
- }
+ private String _target = null;
- private boolean isTriggered(IvyEvent event) {
- return _calls.contains(event);
- }
+ private Collection _calls = new ArrayList();
+ private String _prefix;
+ public void progress(IvyEvent event) {
+ Project project = (Project) IvyContext.getContext().peek(IvyTask.ANT_PROJECT_CONTEXT_KEY);
+ if (project == null) {
+ Message.info("ant call trigger can only be used from an ant build. Ignoring.");
+ return;
+ }
+ if (_onlyonce && isTriggered(event)) {
+ Message.verbose("call already triggered for this event, skipping: " + event);
+ } else {
+ CallTarget call = new CallTarget();
+
+ call.setProject(project);
+ call.setTaskName("antcall");
+
+ Map attributes = event.getAttributes();
+ String target = IvyPatternHelper.substituteTokens(getTarget(), attributes);
+ call.setTarget(target);
+
+ for (Iterator iter = attributes.keySet().iterator(); iter.hasNext();) {
+ String key = (String) iter.next();
+ String value = (String) attributes.get(key);
+ Property p = call.createParam();
+ p.setName(_prefix == null ? key : _prefix + key);
+ p.setValue(value == null ? "" : value);
+ }
- public String getTarget() {
- return _target;
- }
-
- public void setTarget(String target) {
- _target = target;
- }
-
- public boolean isOnlyonce() {
- return _onlyonce;
- }
+ Message.verbose("triggering ant call: target=" + target + " for " + event);
+ MessageImpl impl = IvyContext.getContext().getMessageImpl();
+ try {
+ IvyContext.getContext().setMessageImpl(null);
+ call.execute();
+ markTriggered(event);
+ } finally {
+ IvyContext.getContext().setMessageImpl(impl);
+ }
- public void setOnlyonce(boolean onlyonce) {
- _onlyonce = onlyonce;
- }
+ Message.debug("triggered ant call finished: target=" + target + " for " + event);
+ }
+ }
- public String getPrefix() {
- return _prefix;
- }
+ private void markTriggered(IvyEvent event) {
+ _calls.add(event);
+ }
+
+ private boolean isTriggered(IvyEvent event) {
+ return _calls.contains(event);
+ }
+
+ public String getTarget() {
+ return _target;
+ }
+
+ public void setTarget(String target) {
+ _target = target;
+ }
+
+ public boolean isOnlyonce() {
+ return _onlyonce;
+ }
+
+ public void setOnlyonce(boolean onlyonce) {
+ _onlyonce = onlyonce;
+ }
+
+ public String getPrefix() {
+ return _prefix;
+ }
- public void setPrefix(String prefix) {
- _prefix = prefix;
+ public void setPrefix(String prefix) {
+ _prefix = prefix;
if (!prefix.endsWith(".")) {
_prefix += ".";
}
- }
+ }
}
Modified: incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/AntMessageImpl.java
URL: http://svn.apache.org/viewvc/incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/AntMessageImpl.java?view=diff&rev=544459&r1=544458&r2=544459
==============================================================================
--- incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/AntMessageImpl.java (original)
+++ incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/AntMessageImpl.java Tue Jun 5 05:02:27 2007
@@ -23,15 +23,14 @@
import org.apache.tools.ant.BuildListener;
import org.apache.tools.ant.Task;
-
/**
* Implementation of the simple message facility for ant.
- *
*/
public class AntMessageImpl implements MessageImpl {
private Task _task;
private static long _lastProgressFlush = 0;
+
private static StringBuffer _buf = new StringBuffer();
/**
@@ -41,40 +40,47 @@
_task = task;
task.getProject().addBuildListener(new BuildListener() {
private int stackDepth = 0;
- public void buildFinished(BuildEvent event) {
+
+ public void buildFinished(BuildEvent event) {
}
+
public void buildStarted(BuildEvent event) {
}
+
public void targetStarted(BuildEvent event) {
}
+
public void targetFinished(BuildEvent event) {
}
+
public void taskStarted(BuildEvent event) {
- stackDepth++;
+ stackDepth++;
}
+
public void taskFinished(BuildEvent event) {
- //NB: There is somtimes task created by an other task
- //in that case, we should not uninit Message. The log should stay associated
- //with the initial task, except if it was an antcall, ant or subant target
- //NB2 : Testing the identity of the task is not enought, event.getTask() return
- //an instance of UnknownElement is wrapping the concrete instance
- if (stackDepth==0) {
- Message.uninit();
- event.getProject().removeBuildListener(this);
- }
- stackDepth--;
+ // NB: There is somtimes task created by an other task
+ // in that case, we should not uninit Message. The log should stay associated
+ // with the initial task, except if it was an antcall, ant or subant target
+ // NB2 : Testing the identity of the task is not enought, event.getTask() return
+ // an instance of UnknownElement is wrapping the concrete instance
+ if (stackDepth == 0) {
+ Message.uninit();
+ event.getProject().removeBuildListener(this);
+ }
+ stackDepth--;
}
+
public void messageLogged(BuildEvent event) {
}
- });
+ });
}
public void log(String msg, int level) {
- _task.log(msg, level);
+ _task.log(msg, level);
}
-
+
public void rawlog(String msg, int level) {
- _task.getProject().log(msg, level);
+ _task.getProject().log(msg, level);
}
public void progress() {
@@ -91,7 +97,7 @@
}
}
}
-
+
public void endProgress(String msg) {
_task.log(_buf + msg);
_buf.setLength(0);
Modified: incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyAntSettings.java
URL: http://svn.apache.org/viewvc/incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyAntSettings.java?view=diff&rev=544459&r1=544458&r2=544459
==============================================================================
--- incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyAntSettings.java (original)
+++ incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyAntSettings.java Tue Jun 5 05:02:27 2007
@@ -37,210 +37,227 @@
import org.apache.tools.ant.Project;
import org.apache.tools.ant.types.DataType;
-
public class IvyAntSettings extends DataType {
-
+
public static class Credentials {
- private String _realm;
- private String _host;
- private String _username;
- private String _passwd;
-
+ private String _realm;
+
+ private String _host;
+
+ private String _username;
+
+ private String _passwd;
+
public String getPasswd() {
return _passwd;
}
+
public void setPasswd(String passwd) {
_passwd = passwd;
}
+
public String getRealm() {
return _realm;
}
+
public void setRealm(String realm) {
_realm = format(realm);
}
+
public String getHost() {
return _host;
}
+
public void setHost(String host) {
_host = format(host);
}
+
public String getUsername() {
return _username;
}
+
public void setUsername(String userName) {
_username = format(userName);
}
- }
+ }
-
private Ivy _ivyEngine = null;
-
- private File _file = null;
+
+ private File _file = null;
+
private URL _url = null;
+
private String _realm = null;
+
private String _host = null;
+
private String _userName = null;
+
private String _passwd = null;
+
private String id = null;
/**
- * Returns the default ivy settings of this classloader. If it doesn't exist yet, a new one is created using the given
- * project to back the VariableContainer.
+ * Returns the default ivy settings of this classloader. If it doesn't exist yet, a new one is
+ * created using the given project to back the VariableContainer.
+ *
* @param project
* @return
*/
public static IvyAntSettings getDefaultInstance(Project project) {
- Object defaultInstanceObj = project.getReference("ivy.instance");
- if (defaultInstanceObj!=null && defaultInstanceObj.getClass().getClassLoader()!=IvyAntSettings.class.getClassLoader()) {
- Message.warn("ivy.instance reference an ivy:settings defined in an other classloader. An new default one will be used in this project.");
- defaultInstanceObj=null;
- }
- if (defaultInstanceObj!=null && ! (defaultInstanceObj instanceof IvyAntSettings)) {
- throw new BuildException("ivy.instance reference a "
- + defaultInstanceObj.getClass().getName()
- + " an not an IvyAntSettings. Please don't use this reference id ()");
- }
- if (defaultInstanceObj==null) {
- Message.info("No ivy:settings found for the default reference 'ivy.instance'. A default instance will be used");
- IvyAntSettings defaultInstance = new IvyAntSettings();
- defaultInstance.setProject(project);
- defaultInstance.registerAsDefault();
- return defaultInstance;
- } else {
- return (IvyAntSettings) defaultInstanceObj;
- }
-
- }
-
-
+ Object defaultInstanceObj = project.getReference("ivy.instance");
+ if (defaultInstanceObj != null
+ && defaultInstanceObj.getClass().getClassLoader() != IvyAntSettings.class
+ .getClassLoader()) {
+ Message
+ .warn("ivy.instance reference an ivy:settings defined in an other classloader. An new default one will be used in this project.");
+ defaultInstanceObj = null;
+ }
+ if (defaultInstanceObj != null && !(defaultInstanceObj instanceof IvyAntSettings)) {
+ throw new BuildException("ivy.instance reference a "
+ + defaultInstanceObj.getClass().getName()
+ + " an not an IvyAntSettings. Please don't use this reference id ()");
+ }
+ if (defaultInstanceObj == null) {
+ Message
+ .info("No ivy:settings found for the default reference 'ivy.instance'. A default instance will be used");
+ IvyAntSettings defaultInstance = new IvyAntSettings();
+ defaultInstance.setProject(project);
+ defaultInstance.registerAsDefault();
+ return defaultInstance;
+ } else {
+ return (IvyAntSettings) defaultInstanceObj;
+ }
- protected void registerAsDefault() {
- getProject().addReference("ivy.instance", this);
- }
+ }
+ protected void registerAsDefault() {
+ getProject().addReference("ivy.instance", this);
+ }
-
public File getFile() {
return _file;
}
+
public URL getUrl() {
return _url;
- }
+ }
+
public String getPasswd() {
return _passwd;
}
+
public void setPasswd(String passwd) {
_passwd = passwd;
}
+
public String getRealm() {
return _realm;
}
+
public void setRealm(String realm) {
_realm = format(realm);
}
+
public String getHost() {
return _host;
}
+
public void setHost(String host) {
_host = format(host);
}
+
public String getUsername() {
return _userName;
}
+
public void setUsername(String userName) {
_userName = format(userName);
}
+
public String getId() {
- return id;
- }
- public void setId(String id) {
- this.id = id;
- }
- private static String format(String str) {
+ return id;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ private static String format(String str) {
return str == null ? str : (str.trim().length() == 0 ? null : str.trim());
}
-
- public void addConfiguredCredentials(Credentials c) {
- CredentialsStore.INSTANCE.addCredentials(c.getRealm(), c.getHost(), c.getUsername(), c.getPasswd());
- }
-
-
-
-
-
- public void setFile(File file) {
- this._file = file;
- }
-
-
- public void setUrl(String confUrl) throws MalformedURLException {
- this._url = new URL(confUrl);
- }
-
-
-
-
-
- /*public void execute() throws BuildException {
- ensureMessageInitialised();
- if (getId()==null) {
- log("No id specified for the ivy:settings, set the instance as the default one", Project.MSG_DEBUG);
- getProject().addReference("ivy.instance", this);
- } else {
- getProject().addReference(id, this);
- }
- }*/
-
-
- /**
- * @return
- */
- public Ivy getConfiguredIvyInstance() {
- if (_ivyEngine==null) {
- _ivyEngine = createIvyEngine();
- }
- return _ivyEngine;
- }
-
-
- private Ivy createIvyEngine() {
- IvyAntVariableContainer ivyAntVariableContainer = new IvyAntVariableContainer(getProject());
-
- IvySettings settings = new IvySettings(ivyAntVariableContainer);
- //NB: It is alrady done in the ivy.configure, but it is required for defineDefaultSettingFile (that should be done before the ivy.configure
- settings.addAllVariables(getDefaultProperties(), false);
- Ivy ivy = Ivy.newInstance(settings);
+ public void addConfiguredCredentials(Credentials c) {
+ CredentialsStore.INSTANCE.addCredentials(c.getRealm(), c.getHost(), c.getUsername(), c
+ .getPasswd());
+ }
+
+ public void setFile(File file) {
+ this._file = file;
+ }
+
+ public void setUrl(String confUrl) throws MalformedURLException {
+ this._url = new URL(confUrl);
+ }
+
+ /*
+ * public void execute() throws BuildException { ensureMessageInitialised(); if (getId()==null) {
+ * log("No id specified for the ivy:settings, set the instance as the default one",
+ * Project.MSG_DEBUG); getProject().addReference("ivy.instance", this); } else {
+ * getProject().addReference(id, this); } }
+ */
+
+ /**
+ * @return
+ */
+ public Ivy getConfiguredIvyInstance() {
+ if (_ivyEngine == null) {
+ _ivyEngine = createIvyEngine();
+ }
+ return _ivyEngine;
+ }
+
+ private Ivy createIvyEngine() {
+ IvyAntVariableContainer ivyAntVariableContainer = new IvyAntVariableContainer(getProject());
+
+ IvySettings settings = new IvySettings(ivyAntVariableContainer);
+ // NB: It is alrady done in the ivy.configure, but it is required for
+ // defineDefaultSettingFile (that should be done before the ivy.configure
+ settings.addAllVariables(getDefaultProperties(), false);
+
+ Ivy ivy = Ivy.newInstance(settings);
if (_file == null && _url == null) {
- defineDefaultSettingFile(ivyAntVariableContainer);
+ defineDefaultSettingFile(ivyAntVariableContainer);
}
-
+
try {
configureURLHandler();
if (_file != null) {
if (!_file.exists()) {
- throw new BuildException("settings file does not exist: "+_file);
- }
+ throw new BuildException("settings file does not exist: " + _file);
+ }
ivy.configure(_file);
} else {
- if (_url==null) {
- throw new AssertionError("ivy setting should have either a file, either an url, and if not defineDefaultSettingFile must set it.");
- }
+ if (_url == null) {
+ throw new AssertionError(
+ "ivy setting should have either a file, either an url, and if not defineDefaultSettingFile must set it.");
+ }
ivy.configure(_url);
}
} catch (ParseException e) {
- throw new BuildException("impossible to configure ivy:settings with given "+(_file != null ? "file: "+_file : "url :"+_url)+" :"+e, e);
- } catch (IOException e) {
- throw new BuildException("impossible to configure ivy:settings with given "+(_file != null ? "file: "+_file : "url :"+_url)+" :"+e, e);
- }
- return ivy;
- }
-
-
- protected Properties getDefaultProperties() {
- URL url = IvySettings.getDefaultPropertiesURL();
- // this is copy of loadURL code from ant Property task (not available in 1.5.1)
+ throw new BuildException("impossible to configure ivy:settings with given "
+ + (_file != null ? "file: " + _file : "url :" + _url) + " :" + e, e);
+ } catch (IOException e) {
+ throw new BuildException("impossible to configure ivy:settings with given "
+ + (_file != null ? "file: " + _file : "url :" + _url) + " :" + e, e);
+ }
+ return ivy;
+ }
+
+ protected Properties getDefaultProperties() {
+ URL url = IvySettings.getDefaultPropertiesURL();
+ // this is copy of loadURL code from ant Property task (not available in 1.5.1)
Properties props = new Properties();
Message.verbose("Loading " + url);
try {
@@ -255,63 +272,54 @@
} catch (IOException ex) {
throw new BuildException(ex);
}
- return props;
- }
+ return props;
+ }
-
- /** Set _file or _url to its default value
- * @param variableContainer */
- private void defineDefaultSettingFile(IvyVariableContainer variableContainer) {
- String settingsFileName = variableContainer.getVariable("ivy.conf.file");
- if (settingsFileName != null) {
- Message.deprecated("'ivy.conf.file' is deprecated, use 'ivy.settings.file' instead");
- } else {
- settingsFileName = variableContainer.getVariable("ivy.settings.file");
- }
- File[] settingsLocations = new File[] {
- new File(getProject().getBaseDir(), settingsFileName),
- new File(getProject().getBaseDir(), "ivyconf.xml"),
- new File(settingsFileName),
- new File("ivyconf.xml"),
- };
- for (int i = 0; i < settingsLocations.length; i++) {
- _file = settingsLocations[i];
- Message.verbose("searching settings file: trying "+_file);
- if (_file.exists()) {
- break;
- }
- }
+ /**
+ * Set _file or _url to its default value
+ *
+ * @param variableContainer
+ */
+ private void defineDefaultSettingFile(IvyVariableContainer variableContainer) {
+ String settingsFileName = variableContainer.getVariable("ivy.conf.file");
+ if (settingsFileName != null) {
+ Message.deprecated("'ivy.conf.file' is deprecated, use 'ivy.settings.file' instead");
+ } else {
+ settingsFileName = variableContainer.getVariable("ivy.settings.file");
+ }
+ File[] settingsLocations = new File[] {
+ new File(getProject().getBaseDir(), settingsFileName),
+ new File(getProject().getBaseDir(), "ivyconf.xml"), new File(settingsFileName),
+ new File("ivyconf.xml"),};
+ for (int i = 0; i < settingsLocations.length; i++) {
+ _file = settingsLocations[i];
+ Message.verbose("searching settings file: trying " + _file);
+ if (_file.exists()) {
+ break;
+ }
+ }
if (!_file.exists()) {
- if (Boolean.valueOf(getProject().getProperty("ivy.14.compatible")).booleanValue()) {
+ if (Boolean.valueOf(getProject().getProperty("ivy.14.compatible")).booleanValue()) {
Message.info("no settings file found, using Ivy 1.4 default...");
_file = null;
_url = IvySettings.getDefault14SettingsURL();
- } else {
+ } else {
Message.info("no settings file found, using default...");
_file = null;
_url = IvySettings.getDefaultSettingsURL();
- }
+ }
}
- }
+ }
-
-
-
-
private void configureURLHandler() {
- //TODO : the credentialStore should also be scoped
- CredentialsStore.INSTANCE.addCredentials(getRealm(), getHost(), getUsername(), getPasswd());
+ // TODO : the credentialStore should also be scoped
+ CredentialsStore.INSTANCE.addCredentials(getRealm(), getHost(), getUsername(), getPasswd());
- URLHandlerDispatcher dispatcher = new URLHandlerDispatcher();
+ URLHandlerDispatcher dispatcher = new URLHandlerDispatcher();
URLHandler httpHandler = URLHandlerRegistry.getHttp();
dispatcher.setDownloader("http", httpHandler);
dispatcher.setDownloader("https", httpHandler);
URLHandlerRegistry.setDefault(dispatcher);
}
-
-
-
-
-
}
Modified: incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyAntVariableContainer.java
URL: http://svn.apache.org/viewvc/incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyAntVariableContainer.java?view=diff&rev=544459&r1=544458&r2=544459
==============================================================================
--- incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyAntVariableContainer.java (original)
+++ incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyAntVariableContainer.java Tue Jun 5 05:02:27 2007
@@ -11,41 +11,40 @@
import org.apache.ivy.util.Message;
import org.apache.tools.ant.Project;
-class IvyAntVariableContainer extends IvyVariableContainerImpl implements IvyVariableContainer{
+class IvyAntVariableContainer extends IvyVariableContainerImpl implements IvyVariableContainer {
- protected Map _overwrittenProperties = new HashMap();
- protected Project _project;
+ protected Map _overwrittenProperties = new HashMap();
-
- public IvyAntVariableContainer(Project project) {
- this._project = project;
- }
-
-
- public String getVariable(String name) {
- String r = (String) _overwrittenProperties.get(name);
- if (r==null) {
- r=_project.getProperty(name);
- }
- if (r==null) {
- r = super.getVariable(name);
- }
- return r;
- }
-
- public Map getVariables() {
- Map r = new HashMap(super.getVariables());
- r.putAll(_project.getProperties());
- r.putAll(_overwrittenProperties);
- return r;
- }
-
- public void setVariable(String varName, String value, boolean overwrite) {
- if (overwrite) {
- Message.debug("setting '"+varName+"' to '"+value+"'");
- _overwrittenProperties.put(varName, value);
- } else {
- super.setVariable(varName, value, overwrite);
- }
- }
+ protected Project _project;
+
+ public IvyAntVariableContainer(Project project) {
+ this._project = project;
+ }
+
+ public String getVariable(String name) {
+ String r = (String) _overwrittenProperties.get(name);
+ if (r == null) {
+ r = _project.getProperty(name);
+ }
+ if (r == null) {
+ r = super.getVariable(name);
+ }
+ return r;
+ }
+
+ public Map getVariables() {
+ Map r = new HashMap(super.getVariables());
+ r.putAll(_project.getProperties());
+ r.putAll(_overwrittenProperties);
+ return r;
+ }
+
+ public void setVariable(String varName, String value, boolean overwrite) {
+ if (overwrite) {
+ Message.debug("setting '" + varName + "' to '" + value + "'");
+ _overwrittenProperties.put(varName, value);
+ } else {
+ super.setVariable(varName, value, overwrite);
+ }
+ }
}
Modified: incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyArtifactProperty.java
URL: http://svn.apache.org/viewvc/incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyArtifactProperty.java?view=diff&rev=544459&r1=544458&r2=544459
==============================================================================
--- incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyArtifactProperty.java (original)
+++ incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyArtifactProperty.java Tue Jun 5 05:02:27 2007
@@ -26,53 +26,57 @@
import org.apache.ivy.plugins.report.XmlReportParser;
import org.apache.tools.ant.BuildException;
-
/**
- * Set a set of ant properties according to the last artifact resolved
- *
+ * Set a set of ant properties according to the last artifact resolved
*/
public class IvyArtifactProperty extends IvyPostResolveTask {
private String _name;
+
private String _value;
public String getName() {
return _name;
}
+
public void setName(String name) {
_name = name;
}
+
public String getValue() {
return _value;
}
+
public void setValue(String value) {
_value = value;
}
public void doExecute() throws BuildException {
- prepareAndCheck();
+ prepareAndCheck();
try {
- CacheManager cacheMgr = getIvyInstance().getCacheManager(getCache());
+ CacheManager cacheMgr = getIvyInstance().getCacheManager(getCache());
String[] confs = splitConfs(getConf());
String resolveId = getResolveId();
if (resolveId == null) {
- resolveId = ResolveOptions.getDefaultResolveId(getResolvedModuleId());
+ resolveId = ResolveOptions.getDefaultResolveId(getResolvedModuleId());
}
XmlReportParser parser = new XmlReportParser();
for (int i = 0; i < confs.length; i++) {
- File report = cacheMgr.getConfigurationResolveReportInCache(resolveId, confs[i]);
- parser.parse(report);
-
+ File report = cacheMgr.getConfigurationResolveReportInCache(resolveId, confs[i]);
+ parser.parse(report);
+
Artifact[] artifacts = parser.getArtifacts();
for (int j = 0; j < artifacts.length; j++) {
Artifact artifact = artifacts[j];
- String name = IvyPatternHelper.substitute(getSettings().substitute(getName()), artifact, confs[i]);
- String value = IvyPatternHelper.substitute(getSettings().substitute(getValue()), artifact, confs[i]);
+ String name = IvyPatternHelper.substitute(getSettings().substitute(getName()),
+ artifact, confs[i]);
+ String value = IvyPatternHelper.substitute(
+ getSettings().substitute(getValue()), artifact, confs[i]);
getProject().setProperty(name, value);
}
}
} catch (Exception ex) {
- throw new BuildException("impossible to add artifact properties: "+ex, ex);
+ throw new BuildException("impossible to add artifact properties: " + ex, ex);
}
}
}
Modified: incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyArtifactReport.java
URL: http://svn.apache.org/viewvc/incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyArtifactReport.java?view=diff&rev=544459&r1=544458&r2=544459
==============================================================================
--- incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyArtifactReport.java (original)
+++ incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyArtifactReport.java Tue Jun 5 05:02:27 2007
@@ -47,31 +47,35 @@
import org.xml.sax.SAXException;
import org.xml.sax.helpers.AttributesImpl;
-
/**
- * Generates a report of all artifacts involved during the last resolve.
+ * Generates a report of all artifacts involved during the last resolve.
*/
public class IvyArtifactReport extends IvyPostResolveTask {
private File _tofile;
+
private String _pattern;
public File getTofile() {
return _tofile;
}
+
public void setTofile(File tofile) {
_tofile = tofile;
}
+
public String getPattern() {
return _pattern;
}
+
public void setPattern(String pattern) {
_pattern = pattern;
}
public void doExecute() throws BuildException {
- prepareAndCheck();
+ prepareAndCheck();
if (_tofile == null) {
- throw new BuildException("no destination file name: please provide it through parameter 'tofile'");
+ throw new BuildException(
+ "no destination file name: please provide it through parameter 'tofile'");
}
_pattern = getProperty(_pattern, getSettings(), "ivy.retrieve.pattern");
@@ -81,31 +85,26 @@
CacheManager cacheManager = CacheManager.getInstance(getSettings(), getCache());
ModuleDescriptor md = null;
if (getResolveId() != null) {
- md = (ModuleDescriptor) getResolvedDescriptor(getResolveId());
+ md = (ModuleDescriptor) getResolvedDescriptor(getResolveId());
} else {
- md = (ModuleDescriptor) getResolvedDescriptor(getOrganisation(), getModule(), false);
+ md = (ModuleDescriptor) getResolvedDescriptor(getOrganisation(), getModule(), false);
}
- IvyNode[] dependencies = getIvyInstance().getResolveEngine()
- .getDependencies(md,
- new ResolveOptions()
- .setConfs(confs)
- .setCache(cacheManager)
- .setResolveId(getResolveId())
- .setValidate(doValidate(getSettings())),
- null);
+ IvyNode[] dependencies = getIvyInstance().getResolveEngine().getDependencies(
+ md,
+ new ResolveOptions().setConfs(confs).setCache(cacheManager).setResolveId(
+ getResolveId()).setValidate(doValidate(getSettings())), null);
Map artifactsToCopy = getIvyInstance().getRetrieveEngine().determineArtifactsToCopy(
- ModuleRevisionId.newInstance(getOrganisation(), getModule(), getRevision()),
- _pattern,
- new RetrieveOptions()
- .setConfs(confs)
- .setResolveId(getResolveId())
- .setCache(cacheManager));
-
+ ModuleRevisionId.newInstance(getOrganisation(), getModule(), getRevision()),
+ _pattern,
+ new RetrieveOptions().setConfs(confs).setResolveId(getResolveId()).setCache(
+ cacheManager));
+
Map moduleRevToArtifactsMap = new HashMap();
for (Iterator iter = artifactsToCopy.keySet().iterator(); iter.hasNext();) {
Artifact artifact = (Artifact) iter.next();
- Set moduleRevArtifacts = (Set) moduleRevToArtifactsMap.get(artifact.getModuleRevisionId());
+ Set moduleRevArtifacts = (Set) moduleRevToArtifactsMap.get(artifact
+ .getModuleRevisionId());
if (moduleRevArtifacts == null) {
moduleRevArtifacts = new HashSet();
moduleRevToArtifactsMap.put(artifact.getModuleRevisionId(), moduleRevArtifacts);
@@ -116,29 +115,32 @@
generateXml(cacheManager, dependencies, moduleRevToArtifactsMap, artifactsToCopy);
} catch (ParseException e) {
log(e.getMessage(), Project.MSG_ERR);
- throw new BuildException("syntax errors in ivy file: "+e, e);
+ throw new BuildException("syntax errors in ivy file: " + e, e);
} catch (IOException e) {
- throw new BuildException("impossible to generate report: "+e, e);
+ throw new BuildException("impossible to generate report: " + e, e);
}
}
- private void generateXml(CacheManager cache, IvyNode[] dependencies, Map moduleRevToArtifactsMap, Map artifactsToCopy) {
+
+ private void generateXml(CacheManager cache, IvyNode[] dependencies,
+ Map moduleRevToArtifactsMap, Map artifactsToCopy) {
try {
FileOutputStream fileOuputStream = new FileOutputStream(_tofile);
try {
TransformerHandler saxHandler = createTransformerHandler(fileOuputStream);
-
+
saxHandler.startDocument();
saxHandler.startElement(null, "modules", "modules", new AttributesImpl());
for (int i = 0; i < dependencies.length; i++) {
IvyNode dependency = dependencies[i];
if (dependency.getModuleRevision() == null || dependency.isCompletelyEvicted()) {
- continue;
+ continue;
}
startModule(saxHandler, dependency);
- Set artifactsOfModuleRev = (Set) moduleRevToArtifactsMap.get(dependency.getModuleRevision().getId());
+ Set artifactsOfModuleRev = (Set) moduleRevToArtifactsMap.get(dependency
+ .getModuleRevision().getId());
if (artifactsOfModuleRev != null) {
for (Iterator iter = artifactsOfModuleRev.iterator(); iter.hasNext();) {
Artifact artifact = (Artifact) iter.next();
@@ -150,7 +152,8 @@
writeCacheLocation(cache, saxHandler, artifact);
Set artifactDestPaths = (Set) artifactsToCopy.get(artifact);
- for (Iterator iterator = artifactDestPaths.iterator(); iterator.hasNext();) {
+ for (Iterator iterator = artifactDestPaths.iterator(); iterator
+ .hasNext();) {
String artifactDestPath = (String) iterator.next();
writeRetrieveLocation(saxHandler, artifactDestPath);
}
@@ -173,8 +176,11 @@
}
}
- private TransformerHandler createTransformerHandler(FileOutputStream fileOuputStream) throws TransformerFactoryConfigurationError, TransformerConfigurationException, SAXException {
- SAXTransformerFactory transformerFact = (SAXTransformerFactory) SAXTransformerFactory.newInstance();
+ private TransformerHandler createTransformerHandler(FileOutputStream fileOuputStream)
+ throws TransformerFactoryConfigurationError, TransformerConfigurationException,
+ SAXException {
+ SAXTransformerFactory transformerFact = (SAXTransformerFactory) SAXTransformerFactory
+ .newInstance();
TransformerHandler saxHandler = transformerFact.newTransformerHandler();
saxHandler.getTransformer().setOutputProperty(OutputKeys.ENCODING, "UTF-8");
saxHandler.getTransformer().setOutputProperty(OutputKeys.INDENT, "yes");
@@ -184,14 +190,18 @@
private void startModule(TransformerHandler saxHandler, IvyNode dependency) throws SAXException {
AttributesImpl moduleAttrs = new AttributesImpl();
- moduleAttrs.addAttribute(null, "organisation", "organisation", "CDATA", dependency.getModuleId().getOrganisation());
+ moduleAttrs.addAttribute(null, "organisation", "organisation", "CDATA", dependency
+ .getModuleId().getOrganisation());
moduleAttrs.addAttribute(null, "name", "name", "CDATA", dependency.getModuleId().getName());
- moduleAttrs.addAttribute(null, "rev", "rev", "CDATA", dependency.getModuleRevision().getId().getRevision());
- moduleAttrs.addAttribute(null, "status", "status", "CDATA", dependency.getModuleRevision().getDescriptor().getStatus());
+ moduleAttrs.addAttribute(null, "rev", "rev", "CDATA", dependency.getModuleRevision()
+ .getId().getRevision());
+ moduleAttrs.addAttribute(null, "status", "status", "CDATA", dependency.getModuleRevision()
+ .getDescriptor().getStatus());
saxHandler.startElement(null, "module", "module", moduleAttrs);
}
- private void startArtifact(TransformerHandler saxHandler, Artifact artifact) throws SAXException {
+ private void startArtifact(TransformerHandler saxHandler, Artifact artifact)
+ throws SAXException {
AttributesImpl artifactAttrs = new AttributesImpl();
artifactAttrs.addAttribute(null, "name", "name", "CDATA", artifact.getName());
artifactAttrs.addAttribute(null, "ext", "ext", "CDATA", artifact.getExt());
@@ -199,13 +209,14 @@
saxHandler.startElement(null, "artifact", "artifact", artifactAttrs);
}
- private void writeOriginLocationIfPresent(CacheManager cache, TransformerHandler saxHandler, Artifact artifact) throws IOException, SAXException {
- ArtifactOrigin origin = cache.getSavedArtifactOrigin(artifact);
- if (origin != null) {
- String originName = origin.getLocation();
- boolean isOriginLocal = origin.isLocal();
+ private void writeOriginLocationIfPresent(CacheManager cache, TransformerHandler saxHandler,
+ Artifact artifact) throws IOException, SAXException {
+ ArtifactOrigin origin = cache.getSavedArtifactOrigin(artifact);
+ if (origin != null) {
+ String originName = origin.getLocation();
+ boolean isOriginLocal = origin.isLocal();
- String originLocation;
+ String originLocation;
AttributesImpl originLocationAttrs = new AttributesImpl();
if (isOriginLocal) {
originLocationAttrs.addAttribute(null, "is-local", "is-local", "CDATA", "true");
@@ -217,15 +228,17 @@
originLocationAttrs.addAttribute(null, "is-local", "is-local", "CDATA", "false");
originLocation = originName;
}
- saxHandler.startElement(null, "origin-location", "origin-location", originLocationAttrs);
+ saxHandler
+ .startElement(null, "origin-location", "origin-location", originLocationAttrs);
char[] originLocationAsChars = originLocation.toCharArray();
saxHandler.characters(originLocationAsChars, 0, originLocationAsChars.length);
saxHandler.endElement(null, "origin-location", "origin-location");
}
}
- private void writeCacheLocation(CacheManager cache, TransformerHandler saxHandler, Artifact artifact) throws SAXException {
- ArtifactOrigin origin = cache.getSavedArtifactOrigin(artifact);
+ private void writeCacheLocation(CacheManager cache, TransformerHandler saxHandler,
+ Artifact artifact) throws SAXException {
+ ArtifactOrigin origin = cache.getSavedArtifactOrigin(artifact);
File archiveInCacheFile = cache.getArchiveFileInCache(artifact, origin, false);
StringBuffer archiveInCachePathWithSlashes = new StringBuffer(1000);
replaceFileSeparatorWithSlash(archiveInCacheFile, archiveInCachePathWithSlashes);
@@ -236,17 +249,19 @@
saxHandler.endElement(null, "cache-location", "cache-location");
}
- private void writeRetrieveLocation(TransformerHandler saxHandler, String artifactDestPath) throws SAXException {
+ private void writeRetrieveLocation(TransformerHandler saxHandler, String artifactDestPath)
+ throws SAXException {
artifactDestPath = removeLeadingPath(getProject().getBaseDir(), new File(artifactDestPath));
StringBuffer artifactDestPathWithSlashes = new StringBuffer(1000);
replaceFileSeparatorWithSlash(new File(artifactDestPath), artifactDestPathWithSlashes);
- saxHandler.startElement(null, "retrieve-location", "retrieve-location", new AttributesImpl());
+ saxHandler.startElement(null, "retrieve-location", "retrieve-location",
+ new AttributesImpl());
char[] artifactDestPathAsChars = artifactDestPathWithSlashes.toString().toCharArray();
saxHandler.characters(artifactDestPathAsChars, 0, artifactDestPathAsChars.length);
saxHandler.endElement(null, "retrieve-location", "retrieve-location");
}
-
+
private void replaceFileSeparatorWithSlash(File file, StringBuffer resultPath) {
if (file.getParentFile() != null) {
replaceFileSeparatorWithSlash(file.getParentFile(), resultPath);
@@ -264,7 +279,7 @@
resultPath.append(file.getName());
}
}
-
+
// method largely inspired by ant 1.6.5 FileUtils method
public String removeLeadingPath(File leading, File path) {
String l = leading.getAbsolutePath();
Modified: incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyBuildList.java
URL: http://svn.apache.org/viewvc/incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyBuildList.java?view=diff&rev=544459&r1=544458&r2=544459
==============================================================================
--- incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyBuildList.java (original)
+++ incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyBuildList.java Tue Jun 5 05:02:27 2007
@@ -44,23 +44,32 @@
import org.apache.tools.ant.types.FileSet;
import org.apache.tools.ant.types.Path;
-
/**
- * Creates an ant filelist of files (usually build.xml) ordered according to the dependencies declared in ivy files.
+ * Creates an ant filelist of files (usually build.xml) ordered according to the dependencies
+ * declared in ivy files.
*/
public class IvyBuildList extends IvyTask {
private List buildFileSets = new ArrayList(); // List (FileSet)
+
private String reference;
+
private boolean haltOnError = true;
+
private boolean skipBuildWithoutIvy = false;
+
private boolean reverse = false;
+
private String ivyFilePath;
+
private String root = "*";
+
private boolean excludeRoot = false;
+
private String leaf = "*";
+
private String delimiter = ",";
- private boolean excludeLeaf = false;
+ private boolean excludeLeaf = false;
public void addFileset(FileSet buildFiles) {
buildFileSets.add(buildFiles);
@@ -90,42 +99,43 @@
excludeRoot = root;
}
- public String getLeaf() {
- return leaf;
- }
-
- public void setLeaf(String leaf) {
- this.leaf = leaf;
- }
-
- public boolean isExcludeLeaf() {
- return excludeLeaf;
- }
-
- public void setExcludeLeaf(boolean excludeLeaf) {
- this.excludeLeaf = excludeLeaf;
- }
-
- public String getDelimiter() {
- return delimiter;
- }
-
- public void setDelimiter(String delimiter) {
- this.delimiter = delimiter;
- }
-
+ public String getLeaf() {
+ return leaf;
+ }
+
+ public void setLeaf(String leaf) {
+ this.leaf = leaf;
+ }
+
+ public boolean isExcludeLeaf() {
+ return excludeLeaf;
+ }
+
+ public void setExcludeLeaf(boolean excludeLeaf) {
+ this.excludeLeaf = excludeLeaf;
+ }
+
+ public String getDelimiter() {
+ return delimiter;
+ }
+
+ public void setDelimiter(String delimiter) {
+ this.delimiter = delimiter;
+ }
+
public void doExecute() throws BuildException {
if (reference == null) {
throw new BuildException("reference should be provided in ivy build list");
}
if (buildFileSets.isEmpty()) {
- throw new BuildException("at least one nested fileset should be provided in ivy build list");
+ throw new BuildException(
+ "at least one nested fileset should be provided in ivy build list");
}
Ivy ivy = getIvyInstance();
IvySettings settings = ivy.getSettings();
-
- ivyFilePath = getProperty(ivyFilePath, settings, "ivy.buildlist.ivyfilepath");
+
+ ivyFilePath = getProperty(ivyFilePath, settings, "ivy.buildlist.ivyfilepath");
Path path = new Path(getProject());
@@ -135,22 +145,22 @@
Set rootModuleNames = new LinkedHashSet();
if (!"*".equals(root)) {
- StringTokenizer st = new StringTokenizer(root, delimiter);
- while (st.hasMoreTokens()) {
- rootModuleNames.add(st.nextToken());
- }
+ StringTokenizer st = new StringTokenizer(root, delimiter);
+ while (st.hasMoreTokens()) {
+ rootModuleNames.add(st.nextToken());
+ }
}
-
+
Set leafModuleNames = new LinkedHashSet();
- if (! "*".equals(leaf)) {
- StringTokenizer st = new StringTokenizer(leaf, delimiter);
- while (st.hasMoreTokens()) {
- leafModuleNames.add(st.nextToken());
- }
+ if (!"*".equals(leaf)) {
+ StringTokenizer st = new StringTokenizer(leaf, delimiter);
+ while (st.hasMoreTokens()) {
+ leafModuleNames.add(st.nextToken());
+ }
}
-
+
for (ListIterator iter = buildFileSets.listIterator(); iter.hasNext();) {
- FileSet fs = (FileSet)iter.next();
+ FileSet fs = (FileSet) iter.next();
DirectoryScanner ds = fs.getDirectoryScanner(getProject());
String[] builds = ds.getIncludedFiles();
for (int i = 0; i < builds.length; i++) {
@@ -158,23 +168,29 @@
File ivyFile = getIvyFileFor(buildFile);
if (!ivyFile.exists()) {
if (skipBuildWithoutIvy) {
- Message.debug("skipping "+buildFile+": ivy file "+ivyFile+" doesn't exist");
+ Message.debug("skipping " + buildFile + ": ivy file " + ivyFile
+ + " doesn't exist");
} else {
- Message.verbose("no ivy file for "+buildFile+": ivyfile="+ivyFile+": adding it at the beginning of the path");
- Message.verbose("\t(set skipbuildwithoutivy to true if you don't want this file to be added to the path)");
+ Message.verbose("no ivy file for " + buildFile + ": ivyfile=" + ivyFile
+ + ": adding it at the beginning of the path");
+ Message
+ .verbose("\t(set skipbuildwithoutivy to true if you don't want this file to be added to the path)");
independent.add(buildFile);
}
} else {
try {
- ModuleDescriptor md = ModuleDescriptorParserRegistry.getInstance().parseDescriptor(settings, ivyFile.toURL(), doValidate(settings));
+ ModuleDescriptor md = ModuleDescriptorParserRegistry.getInstance()
+ .parseDescriptor(settings, ivyFile.toURL(), doValidate(settings));
buildFiles.put(md, buildFile);
mdsMap.put(md.getModuleRevisionId().getModuleId().getName(), md);
Message.debug("Add " + md.getModuleRevisionId().getModuleId());
} catch (Exception ex) {
if (haltOnError) {
- throw new BuildException("impossible to parse ivy file for "+buildFile+": ivyfile="+ivyFile+" exception="+ex, ex);
+ throw new BuildException("impossible to parse ivy file for "
+ + buildFile + ": ivyfile=" + ivyFile + " exception=" + ex, ex);
} else {
- Message.warn("impossible to parse ivy file for "+buildFile+": ivyfile="+ivyFile+" exception="+ex.getMessage());
+ Message.warn("impossible to parse ivy file for " + buildFile
+ + ": ivyfile=" + ivyFile + " exception=" + ex.getMessage());
Message.info("\t=> adding it at the beginning of the path");
independent.add(buildFile);
}
@@ -182,24 +198,26 @@
}
}
}
-
- List leafModuleDescriptors = convertModuleNamesToModuleDescriptors(mdsMap, leafModuleNames, "leaf");
- List rootModuleDescriptors = convertModuleNamesToModuleDescriptors(mdsMap, rootModuleNames, "root");
-
+
+ List leafModuleDescriptors = convertModuleNamesToModuleDescriptors(mdsMap, leafModuleNames,
+ "leaf");
+ List rootModuleDescriptors = convertModuleNamesToModuleDescriptors(mdsMap, rootModuleNames,
+ "root");
+
Collection mds = new ArrayList(mdsMap.values());
- if (! rootModuleDescriptors.isEmpty()) {
+ if (!rootModuleDescriptors.isEmpty()) {
Message.info("Filtering modules based on roots " + rootModuleNames);
mds = filterModulesFromRoot(mds, rootModuleDescriptors);
}
- if (! leafModuleDescriptors.isEmpty()) {
+ if (!leafModuleDescriptors.isEmpty()) {
Message.info("Filtering modules based on leafs " + leafModuleNames);
mds = filterModulesFromLeaf(mds, leafModuleDescriptors);
}
- List sortedModules = ivy.sortModuleDescriptors(mds);
+ List sortedModules = ivy.sortModuleDescriptors(mds);
for (ListIterator iter = independent.listIterator(); iter.hasNext();) {
- File buildFile = (File)iter.next();
+ File buildFile = (File) iter.next();
addBuildFile(path, buildFile);
}
if (isReverse()) {
@@ -207,12 +225,12 @@
}
StringBuffer order = new StringBuffer();
for (ListIterator iter = sortedModules.listIterator(); iter.hasNext();) {
- ModuleDescriptor md = (ModuleDescriptor)iter.next();
+ ModuleDescriptor md = (ModuleDescriptor) iter.next();
order.append(md.getModuleRevisionId().getModuleId());
if (iter.hasNext()) {
- order.append(", ");
+ order.append(", ");
}
- File buildFile = (File)buildFiles.get(md);
+ File buildFile = (File) buildFiles.get(md);
addBuildFile(path, buildFile);
}
@@ -220,25 +238,28 @@
getProject().setProperty("ivy.sorted.modules", order.toString());
}
- private List convertModuleNamesToModuleDescriptors(Map mdsMap, Set moduleNames, String kind) {
- List mds = new ArrayList();
- for (Iterator iter = moduleNames.iterator(); iter.hasNext();) {
- String name = (String) iter.next();
+ private List convertModuleNamesToModuleDescriptors(Map mdsMap, Set moduleNames, String kind) {
+ List mds = new ArrayList();
+ for (Iterator iter = moduleNames.iterator(); iter.hasNext();) {
+ String name = (String) iter.next();
ModuleDescriptor md = (ModuleDescriptor) mdsMap.get(name);
if (md == null) {
- throw new BuildException("unable to find "+kind+" module " + name + " in build fileset");
+ throw new BuildException("unable to find " + kind + " module " + name
+ + " in build fileset");
}
- mds.add(md);
- }
- return mds;
- }
+ mds.add(md);
+ }
+ return mds;
+ }
/**
- * Returns a collection of ModuleDescriptors that are conatined in the input
- * collection of ModuleDescriptors and upon which the root module depends
- *
- * @param mds input collection of ModuleDescriptors
- * @param rootmd root module
+ * Returns a collection of ModuleDescriptors that are conatined in the input collection of
+ * ModuleDescriptors and upon which the root module depends
+ *
+ * @param mds
+ * input collection of ModuleDescriptors
+ * @param rootmd
+ * root module
* @return filtered list of modules
*/
private Collection filterModulesFromRoot(Collection mds, List rootmds) {
@@ -251,18 +272,18 @@
// recursively process the nodes
Set toKeep = new LinkedHashSet();
-
+
Iterator it = rootmds.iterator();
while (it.hasNext()) {
- ModuleDescriptor rootmd = (ModuleDescriptor) it.next();
+ ModuleDescriptor rootmd = (ModuleDescriptor) it.next();
processFilterNodeFromRoot(rootmd, toKeep, moduleIdMap);
// With the excluderoot attribute set to true, take the rootmd out of the toKeep set.
if (excludeRoot) {
- Message.verbose("Excluded module " + rootmd.getModuleRevisionId().getModuleId().getName());
+ Message.verbose("Excluded module "
+ + rootmd.getModuleRevisionId().getModuleId().getName());
toKeep.remove(rootmd);
}
}
-
// just for logging
for (Iterator iter = toKeep.iterator(); iter.hasNext();) {
@@ -274,31 +295,38 @@
}
/**
- * Adds the current node to the toKeep collection and then processes the each of the direct dependencies
- * of this node that appear in the moduleIdMap (indicating that the dependency is part of this BuildList)
- *
- * @param node the node to be processed
- * @param toKeep the set of ModuleDescriptors that should be kept
- * @param moduleIdMap reference mapping of moduleId to ModuleDescriptor that are part of the BuildList
+ * Adds the current node to the toKeep collection and then processes the each of the direct
+ * dependencies of this node that appear in the moduleIdMap (indicating that the dependency is
+ * part of this BuildList)
+ *
+ * @param node
+ * the node to be processed
+ * @param toKeep
+ * the set of ModuleDescriptors that should be kept
+ * @param moduleIdMap
+ * reference mapping of moduleId to ModuleDescriptor that are part of the BuildList
*/
private void processFilterNodeFromRoot(ModuleDescriptor node, Set toKeep, Map moduleIdMap) {
toKeep.add(node);
DependencyDescriptor[] deps = node.getDependencies();
- for (int i=0; i<deps.length; i++) {
+ for (int i = 0; i < deps.length; i++) {
ModuleId id = deps[i].getDependencyId();
if (moduleIdMap.get(id) != null) {
- processFilterNodeFromRoot((ModuleDescriptor) moduleIdMap.get(id), toKeep, moduleIdMap);
+ processFilterNodeFromRoot((ModuleDescriptor) moduleIdMap.get(id), toKeep,
+ moduleIdMap);
}
}
}
/**
- * Returns a collection of ModuleDescriptors that are conatined in the input
- * collection of ModuleDescriptors which depends on the leaf module
- *
- * @param mds input collection of ModuleDescriptors
- * @param leafmd leaf module
+ * Returns a collection of ModuleDescriptors that are conatined in the input collection of
+ * ModuleDescriptors which depends on the leaf module
+ *
+ * @param mds
+ * input collection of ModuleDescriptors
+ * @param leafmd
+ * leaf module
* @return filtered list of modules
*/
private Collection filterModulesFromLeaf(Collection mds, List leafmds) {
@@ -313,17 +341,17 @@
Set toKeep = new LinkedHashSet();
Iterator it = leafmds.iterator();
while (it.hasNext()) {
- ModuleDescriptor leafmd = (ModuleDescriptor) it.next();
+ ModuleDescriptor leafmd = (ModuleDescriptor) it.next();
// With the excludeleaf attribute set to true, take the rootmd out of the toKeep set.
if (excludeLeaf) {
- Message.verbose("Excluded module " + leafmd.getModuleRevisionId().getModuleId().getName());
+ Message.verbose("Excluded module "
+ + leafmd.getModuleRevisionId().getModuleId().getName());
} else {
- toKeep.add(leafmd);
+ toKeep.add(leafmd);
}
processFilterNodeFromLeaf(leafmd, toKeep, moduleIdMap);
}
-
// just for logging
for (Iterator iter = toKeep.iterator(); iter.hasNext();) {
ModuleDescriptor md = ((ModuleDescriptor) iter.next());
@@ -334,25 +362,28 @@
}
/**
- * Search in the moduleIdMap modules depending on node, add them to the toKeep set and process them
- * recursively.
- *
- * @param node the node to be processed
- * @param toKeep the set of ModuleDescriptors that should be kept
- * @param moduleIdMap reference mapping of moduleId to ModuleDescriptor that are part of the BuildList
+ * Search in the moduleIdMap modules depending on node, add them to the toKeep set and process
+ * them recursively.
+ *
+ * @param node
+ * the node to be processed
+ * @param toKeep
+ * the set of ModuleDescriptors that should be kept
+ * @param moduleIdMap
+ * reference mapping of moduleId to ModuleDescriptor that are part of the BuildList
*/
private void processFilterNodeFromLeaf(ModuleDescriptor node, Set toKeep, Map moduleIdMap) {
- for (Iterator iter = moduleIdMap.values().iterator(); iter.hasNext();) {
- ModuleDescriptor md = (ModuleDescriptor) iter.next();
- DependencyDescriptor[] deps = md.getDependencies();
- for (int i=0; i<deps.length; i++) {
- ModuleId id = deps[i].getDependencyId();
- if (node.getModuleRevisionId().getModuleId().equals(id) && !toKeep.contains(md)) {
- toKeep.add(md);
- processFilterNodeFromLeaf(md, toKeep, moduleIdMap);
- }
- }
- }
+ for (Iterator iter = moduleIdMap.values().iterator(); iter.hasNext();) {
+ ModuleDescriptor md = (ModuleDescriptor) iter.next();
+ DependencyDescriptor[] deps = md.getDependencies();
+ for (int i = 0; i < deps.length; i++) {
+ ModuleId id = deps[i].getDependencyId();
+ if (node.getModuleRevisionId().getModuleId().equals(id) && !toKeep.contains(md)) {
+ toKeep.add(md);
+ processFilterNodeFromLeaf(md, toKeep, moduleIdMap);
+ }
+ }
+ }
}
private void addBuildFile(Path path, File buildFile) {
@@ -395,7 +426,6 @@
public boolean isReverse() {
return reverse;
}
-
public void setReverse(boolean reverse) {
this.reverse = reverse;
Modified: incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyBuildNumber.java
URL: http://svn.apache.org/viewvc/incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyBuildNumber.java?view=diff&rev=544459&r1=544458&r2=544459
==============================================================================
--- incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyBuildNumber.java (original)
+++ incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyBuildNumber.java Tue Jun 5 05:02:27 2007
@@ -24,73 +24,76 @@
import org.apache.ivy.core.settings.IvySettings;
import org.apache.tools.ant.BuildException;
-
/**
- * Look for the latest module in the repository matching the given criteria,
- * and sets a set of properties according to what was found.
- *
+ * Look for the latest module in the repository matching the given criteria, and sets a set of
+ * properties according to what was found.
*/
public class IvyBuildNumber extends IvyTask {
- private String _organisation;
- private String _module;
- private String _branch;
- private String _revision;
-
- private String _revSep = ".";
- private String _prefix = "ivy.";
- private String _default = "0";
- private String _defaultBuildNumber = "0";
-
- public String getModule() {
- return _module;
- }
-
- public void setModule(String module) {
- _module = module;
- }
-
- public String getOrganisation() {
- return _organisation;
- }
-
- public void setOrganisation(String organisation) {
- _organisation = organisation;
- }
-
- public String getRevision() {
- return _revision;
- }
-
- public void setRevision(String revision) {
- _revision = revision;
- }
-
-
- public String getBranch() {
- return _branch;
- }
-
- public void setBranch(String branch) {
- _branch = branch;
- }
-
- public String getDefault() {
- return _default;
- }
-
- public void setDefault(String default1) {
- _default = default1;
- }
-
- public String getPrefix() {
- return _prefix;
- }
-
- public void setPrefix(String prefix) {
- _prefix = prefix;
- }
+ private String _organisation;
+
+ private String _module;
+
+ private String _branch;
+
+ private String _revision;
+
+ private String _revSep = ".";
+
+ private String _prefix = "ivy.";
+
+ private String _default = "0";
+
+ private String _defaultBuildNumber = "0";
+
+ public String getModule() {
+ return _module;
+ }
+
+ public void setModule(String module) {
+ _module = module;
+ }
+
+ public String getOrganisation() {
+ return _organisation;
+ }
- public void doExecute() throws BuildException {
+ public void setOrganisation(String organisation) {
+ _organisation = organisation;
+ }
+
+ public String getRevision() {
+ return _revision;
+ }
+
+ public void setRevision(String revision) {
+ _revision = revision;
+ }
+
+ public String getBranch() {
+ return _branch;
+ }
+
+ public void setBranch(String branch) {
+ _branch = branch;
+ }
+
+ public String getDefault() {
+ return _default;
+ }
+
+ public void setDefault(String default1) {
+ _default = default1;
+ }
+
+ public String getPrefix() {
+ return _prefix;
+ }
+
+ public void setPrefix(String prefix) {
+ _prefix = prefix;
+ }
+
+ public void doExecute() throws BuildException {
if (_organisation == null) {
throw new BuildException("no organisation provided for ivy findmodules");
}
@@ -98,9 +101,9 @@
throw new BuildException("no module name provided for ivy findmodules");
}
if (_prefix == null) {
- throw new BuildException("null prefix not allowed");
+ throw new BuildException("null prefix not allowed");
}
-
+
Ivy ivy = getIvyInstance();
IvySettings settings = ivy.getSettings();
if (_branch == null) {
@@ -109,134 +112,145 @@
if (_revision == null || _revision.length() == 0) {
_revision = "latest.integration";
} else if (!_revision.endsWith("+")) {
- _revision = _revision+"+";
+ _revision = _revision + "+";
}
if (!_prefix.endsWith(".") && _prefix.length() > 0) {
- _prefix = _prefix+".";
+ _prefix = _prefix + ".";
}
- 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);
- setProperty("new.revision", newRevision.newRevision);
- setProperty("build.number", newRevision.buildNumber);
- setProperty("new.build.number", newRevision.newBuildNumber);
- }
-
- private void setProperty(String propertyName, String value) {
- if (value != null) {
- getProject().setProperty(_prefix+propertyName, value);
- }
- }
-
- private NewRevision computeNewRevision(String revision) {
- 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+"'");
- }
- if (revision == null) {
- if (revPrefix.length() > 0) {
- return new NewRevision(revision, revPrefix+(revPrefix.endsWith(_revSep)?_defaultBuildNumber:_revSep+_defaultBuildNumber), null, _defaultBuildNumber);
- } else {
- Range r = findLastNumber(_default);
- if (r == null) { // no number found
- return new NewRevision(revision, _default, null, null);
- } else {
- long n = Long.parseLong(_default.substring(r.startIndex, r.endIndex));
- return new NewRevision(revision, _default, null, String.valueOf(n));
- }
- }
- }
- Range r;
- if (revPrefix.length() == 0) {
- r = findLastNumber(revision);
- if (r == null) {
- return new NewRevision(revision, revision+(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");
- }
- }
- long n = Long.parseLong(revision.substring(r.startIndex, r.endIndex)) + 1;
- return new NewRevision(
- revision,
- revision.substring(0, r.startIndex)+n,
- String.valueOf(n-1),
- String.valueOf(n));
- }
-
- 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))) {
- startNumberIndex++;
- }
- if (startNumberIndex == str.length()) {
- return null;
- }
- // let's find the end of the number
- int endNumberIndex = startNumberIndex+1;
- while (endNumberIndex<str.length() && Character.isDigit(str.charAt(endNumberIndex))) {
- endNumberIndex++;
- }
- return new Range(startNumberIndex, endNumberIndex);
- }
-
- private Range findLastNumber(String str) {
- int endNumberIndex = str.length() - 1;
- while (endNumberIndex >= 0 && !Character.isDigit(str.charAt(endNumberIndex))) {
- endNumberIndex--;
- }
- int startNumberIndex = endNumberIndex == -1?-1:endNumberIndex - 1;
- while (startNumberIndex >= 0 && Character.isDigit(str.charAt(startNumberIndex))) {
- startNumberIndex--;
- }
- endNumberIndex ++;
- startNumberIndex ++;
- if (startNumberIndex == endNumberIndex) { // no number found
- return null;
- } else {
- return new Range(startNumberIndex, endNumberIndex);
- }
- }
-
- private static class Range {
- private int startIndex;
- private int endIndex;
- public Range(int startIndex, int endIndex) {
- this.startIndex = startIndex;
- this.endIndex = endIndex;
- }
- }
-
- private static class NewRevision {
- private String revision;
- private String newRevision;
- private String buildNumber;
- private String newBuildNumber;
- public NewRevision(String revision, String newRevision, String buildNumber, String newBuildNumber) {
- this.revision = revision;
- this.newRevision = newRevision;
- this.buildNumber = buildNumber;
- this.newBuildNumber = newBuildNumber;
- }
- }
-
- public String getRevSep() {
- return _revSep;
- }
-
- public void setRevSep(String revSep) {
- _revSep = revSep;
- }
-
- public String getDefaultBuildNumber() {
- return _defaultBuildNumber;
- }
-
- public void setDefaultBuildNumber(String defaultBuildNumber) {
- _defaultBuildNumber = defaultBuildNumber;
- }
+ 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);
+ setProperty("new.revision", newRevision.newRevision);
+ setProperty("build.number", newRevision.buildNumber);
+ setProperty("new.build.number", newRevision.newBuildNumber);
+ }
+
+ private void setProperty(String propertyName, String value) {
+ if (value != null) {
+ getProject().setProperty(_prefix + propertyName, value);
+ }
+ }
+
+ private NewRevision computeNewRevision(String revision) {
+ 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 + "'");
+ }
+ if (revision == null) {
+ if (revPrefix.length() > 0) {
+ return new NewRevision(revision, revPrefix
+ + (revPrefix.endsWith(_revSep) ? _defaultBuildNumber : _revSep
+ + _defaultBuildNumber), null, _defaultBuildNumber);
+ } else {
+ Range r = findLastNumber(_default);
+ if (r == null) { // no number found
+ return new NewRevision(revision, _default, null, null);
+ } else {
+ long n = Long.parseLong(_default.substring(r.startIndex, r.endIndex));
+ return new NewRevision(revision, _default, null, String.valueOf(n));
+ }
+ }
+ }
+ Range r;
+ if (revPrefix.length() == 0) {
+ r = findLastNumber(revision);
+ if (r == null) {
+ return new NewRevision(revision, revision
+ + (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");
+ }
+ }
+ long n = Long.parseLong(revision.substring(r.startIndex, r.endIndex)) + 1;
+ return new NewRevision(revision, revision.substring(0, r.startIndex) + n, String
+ .valueOf(n - 1), String.valueOf(n));
+ }
+
+ 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))) {
+ startNumberIndex++;
+ }
+ if (startNumberIndex == str.length()) {
+ return null;
+ }
+ // let's find the end of the number
+ int endNumberIndex = startNumberIndex + 1;
+ while (endNumberIndex < str.length() && Character.isDigit(str.charAt(endNumberIndex))) {
+ endNumberIndex++;
+ }
+ return new Range(startNumberIndex, endNumberIndex);
+ }
+
+ private Range findLastNumber(String str) {
+ int endNumberIndex = str.length() - 1;
+ while (endNumberIndex >= 0 && !Character.isDigit(str.charAt(endNumberIndex))) {
+ endNumberIndex--;
+ }
+ int startNumberIndex = endNumberIndex == -1 ? -1 : endNumberIndex - 1;
+ while (startNumberIndex >= 0 && Character.isDigit(str.charAt(startNumberIndex))) {
+ startNumberIndex--;
+ }
+ endNumberIndex++;
+ startNumberIndex++;
+ if (startNumberIndex == endNumberIndex) { // no number found
+ return null;
+ } else {
+ return new Range(startNumberIndex, endNumberIndex);
+ }
+ }
+
+ private static class Range {
+ private int startIndex;
+
+ private int endIndex;
+
+ public Range(int startIndex, int endIndex) {
+ this.startIndex = startIndex;
+ this.endIndex = endIndex;
+ }
+ }
+
+ private static class NewRevision {
+ private String revision;
+
+ private String newRevision;
+
+ private String buildNumber;
+
+ private String newBuildNumber;
+
+ public NewRevision(String revision, String newRevision, String buildNumber,
+ String newBuildNumber) {
+ this.revision = revision;
+ this.newRevision = newRevision;
+ this.buildNumber = buildNumber;
+ this.newBuildNumber = newBuildNumber;
+ }
+ }
+
+ public String getRevSep() {
+ return _revSep;
+ }
+
+ public void setRevSep(String revSep) {
+ _revSep = revSep;
+ }
+
+ public String getDefaultBuildNumber() {
+ return _defaultBuildNumber;
+ }
+
+ public void setDefaultBuildNumber(String defaultBuildNumber) {
+ _defaultBuildNumber = defaultBuildNumber;
+ }
}
Modified: incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyCacheFileset.java
URL: http://svn.apache.org/viewvc/incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyCacheFileset.java?view=diff&rev=544459&r1=544458&r2=544459
==============================================================================
--- incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyCacheFileset.java (original)
+++ incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyCacheFileset.java Tue Jun 5 05:02:27 2007
@@ -26,12 +26,9 @@
import org.apache.tools.ant.types.FileSet;
import org.apache.tools.ant.types.PatternSet.NameEntry;
-
-
/**
- * Creates an ant fileset consisting in all artifacts found during a resolve.
- * Note that this task is not compatible with the useOrigin mode.
- *
+ * Creates an ant fileset consisting in all artifacts found during a resolve. Note that this task is
+ * not compatible with the useOrigin mode.
*/
public class IvyCacheFileset extends IvyCacheTask {
private String _setid;
@@ -39,13 +36,16 @@
public String getSetid() {
return _setid;
}
+
public void setSetid(String 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");
- }
+ 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");
+ }
}
public void doExecute() throws BuildException {
@@ -58,22 +58,22 @@
fileset.setProject(getProject());
getProject().addReference(_setid, fileset);
fileset.setDir(getCache());
-
+
List paths = getArtifacts();
if (paths.isEmpty()) {
NameEntry ne = fileset.createExclude();
ne.setName("**/*");
} else {
- CacheManager cache = getCacheManager();
+ CacheManager cache = getCacheManager();
for (Iterator iter = paths.iterator(); iter.hasNext();) {
- Artifact a = (Artifact)iter.next();
+ Artifact a = (Artifact) iter.next();
NameEntry ne = fileset.createInclude();
ne.setName(cache.getArchivePathInCache(a, cache.getSavedArtifactOrigin(a)));
}
}
} catch (Exception ex) {
- throw new BuildException("impossible to build ivy cache fileset: "+ex, ex);
- }
+ throw new BuildException("impossible to build ivy cache fileset: " + ex, ex);
+ }
}
}
Modified: incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyCachePath.java
URL: http://svn.apache.org/viewvc/incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyCachePath.java?view=diff&rev=544459&r1=544458&r2=544459
==============================================================================
--- incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyCachePath.java (original)
+++ incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyCachePath.java Tue Jun 5 05:02:27 2007
@@ -25,22 +25,22 @@
import org.apache.tools.ant.Project;
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 _id;
+
+ private String _id;
public String getPathid() {
return _pathid;
}
+
public void setPathid(String id) {
_pathid = id;
}
-
+
/**
* @deprecated use setPathid instead
* @param id
@@ -52,25 +52,26 @@
public void doExecute() throws BuildException {
prepareAndCheck();
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");
- }
+ 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");
+ }
}
try {
Path path = new Path(getProject());
getProject().addReference(_pathid, path);
- CacheManager cache = getCacheManager();
+ CacheManager cache = getCacheManager();
for (Iterator iter = getArtifacts().iterator(); iter.hasNext();) {
- Artifact a = (Artifact) iter.next();
- path.createPathElement().setLocation(cache.getArchiveFileInCache(a, cache.getSavedArtifactOrigin(a), isUseOrigin()));
+ Artifact a = (Artifact) iter.next();
+ path.createPathElement().setLocation(
+ cache.getArchiveFileInCache(a, cache.getSavedArtifactOrigin(a), isUseOrigin()));
}
} catch (Exception ex) {
- throw new BuildException("impossible to build ivy path: "+ex, ex);
+ throw new BuildException("impossible to build ivy path: " + ex, ex);
}
-
+
}
}
Modified: incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyCacheTask.java
URL: http://svn.apache.org/viewvc/incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyCacheTask.java?view=diff&rev=544459&r1=544458&r2=544459
==============================================================================
--- incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyCacheTask.java (original)
+++ incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyCacheTask.java Tue Jun 5 05:02:27 2007
@@ -38,12 +38,9 @@
import org.apache.ivy.util.Message;
import org.apache.tools.ant.BuildException;
-
/**
- * Base class for the cache path related classes: cachepath and cachefileset.
- *
- * Most of the behviour is common to the two, since only the produced element differs.
- *
+ * Base class for the cache path related classes: cachepath and cachefileset. Most of the behviour
+ * is common to the two, since only the produced element differs.
*/
public abstract class IvyCacheTask extends IvyPostResolveTask {
@@ -51,12 +48,12 @@
Collection artifacts = getAllArtifacts();
List ret = new ArrayList();
for (Iterator iter = artifacts.iterator(); iter.hasNext();) {
- Artifact artifact = (Artifact)iter.next();
+ Artifact artifact = (Artifact) iter.next();
if (getArtifactFilter().accept(artifact)) {
- ret.add(artifact);
+ ret.add(artifact);
}
}
-
+
return ret;
}
@@ -68,28 +65,31 @@
if (report != null) {
Message.debug("using internal report instance to get artifacts list");
for (int i = 0; i < confs.length; i++) {
- ConfigurationResolveReport configurationReport = report.getConfigurationReport(confs[i]);
+ ConfigurationResolveReport configurationReport = report
+ .getConfigurationReport(confs[i]);
if (configurationReport == null) {
- throw new BuildException("bad confs provided: "+confs[i]+" not found among "+Arrays.asList(report.getConfigurations()));
+ throw new BuildException("bad confs provided: " + confs[i]
+ + " not found among " + Arrays.asList(report.getConfigurations()));
}
- Set revisions = configurationReport.getModuleRevisionIds();
- for (Iterator it = revisions.iterator(); it.hasNext(); ) {
- ModuleRevisionId revId = (ModuleRevisionId) it.next();
- ArtifactDownloadReport[] aReps = configurationReport.getDownloadReports(revId);
- for (int j = 0; j < aReps.length; j++) {
- all.add(aReps[j].getArtifact());
- }
+ Set revisions = configurationReport.getModuleRevisionIds();
+ for (Iterator it = revisions.iterator(); it.hasNext();) {
+ ModuleRevisionId revId = (ModuleRevisionId) it.next();
+ ArtifactDownloadReport[] aReps = configurationReport.getDownloadReports(revId);
+ for (int j = 0; j < aReps.length; j++) {
+ all.add(aReps[j].getArtifact());
+ }
}
}
} else {
Message.debug("using stored report to get artifacts list");
-
+
XmlReportParser parser = new XmlReportParser();
CacheManager cacheMgr = getIvyInstance().getCacheManager(getCache());
for (int i = 0; i < confs.length; i++) {
- File reportFile = cacheMgr.getConfigurationResolveReportInCache(getResolveId(), confs[i]);
- parser.parse(reportFile);
-
+ File reportFile = cacheMgr.getConfigurationResolveReportInCache(getResolveId(),
+ confs[i]);
+ parser.parse(reportFile);
+
Artifact[] artifacts = parser.getArtifacts();
all.addAll(Arrays.asList(artifacts));
}
@@ -97,8 +97,8 @@
return all;
}
- protected CacheManager getCacheManager() {
- CacheManager cache = new CacheManager(getSettings(), getCache());
- return cache;
- }
+ protected CacheManager getCacheManager() {
+ CacheManager cache = new CacheManager(getSettings(), getCache());
+ return cache;
+ }
}