mirror of https://github.com/apache/ant-ivy
IMPROVE: add possibility to avoid overwrite of an ivy variable when setting them in ivyconf.xml (IVY-127)
git-svn-id: https://svn.apache.org/repos/asf/incubator/ivy/trunk@484092 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
caa9a8ed4f
commit
c2ec508538
|
|
@ -5,6 +5,7 @@
|
|||
- NEW: it is now possible to reference existing resolver in resolver containers (IVY-35)
|
||||
- NEW: overwrite attribute in the publish task now let force overwrite of read only files (IVY-83)
|
||||
- NEW: add a conflict manager ("strict") making build fail when a diamond conflict is found (thanks to Christer Jonsson) (IVY-118)
|
||||
- IMPROVE: add possibility to avoid overwrite of an ivy variable when setting them in ivyconf.xml (IVY-127)
|
||||
- IMPROVE: ability to exclude the root project from the buildlist (thanks to Constantine Vetoshev) (IVY-124)
|
||||
- IMPROVE: exclusion of artifacts now works on transitive artifacts, and exclusion can specify organisation and/or module (IVY-116)
|
||||
- IMPROVE: now dynamic revisions replacement by deliver task can be turned off (IVY-120)
|
||||
|
|
|
|||
|
|
@ -41,11 +41,9 @@ import org.xml.sax.SAXException;
|
|||
import fr.jayasoft.ivy.conflict.LatestConflictManager;
|
||||
import fr.jayasoft.ivy.conflict.NoConflictManager;
|
||||
import fr.jayasoft.ivy.conflict.StrictConflictManager;
|
||||
import fr.jayasoft.ivy.event.EndDownloadEvent;
|
||||
import fr.jayasoft.ivy.event.IvyEvent;
|
||||
import fr.jayasoft.ivy.event.IvyListener;
|
||||
import fr.jayasoft.ivy.event.PrepareDownloadEvent;
|
||||
import fr.jayasoft.ivy.event.StartDownloadEvent;
|
||||
import fr.jayasoft.ivy.filter.Filter;
|
||||
import fr.jayasoft.ivy.filter.FilterHelper;
|
||||
import fr.jayasoft.ivy.latest.LatestLexicographicStrategy;
|
||||
|
|
@ -299,19 +297,34 @@ public class Ivy implements TransferListener {
|
|||
}
|
||||
|
||||
public void loadProperties(URL url) throws IOException {
|
||||
loadProperties(url, true);
|
||||
}
|
||||
public void loadProperties(URL url, boolean overwrite) throws IOException {
|
||||
Properties properties = new Properties();
|
||||
properties.load(url.openStream());
|
||||
addAllVariables(properties);
|
||||
addAllVariables(properties, overwrite);
|
||||
}
|
||||
public void loadProperties(File file) throws IOException {
|
||||
loadProperties(file, true);
|
||||
}
|
||||
|
||||
public void loadProperties(File file, boolean overwrite) throws IOException {
|
||||
Properties properties = new Properties();
|
||||
properties.load(new FileInputStream(file));
|
||||
addAllVariables(properties);
|
||||
addAllVariables(properties, overwrite);
|
||||
}
|
||||
|
||||
public void setVariable(String varName, String value) {
|
||||
Message.debug("setting '"+varName+"' to '"+value+"'");
|
||||
_variables.put(varName, substitute(value));
|
||||
setVariable(varName, value, true);
|
||||
}
|
||||
|
||||
public void setVariable(String varName, String value, boolean overwrite) {
|
||||
if (overwrite || !_variables.containsKey(varName)) {
|
||||
Message.debug("setting '"+varName+"' to '"+value+"'");
|
||||
_variables.put(varName, substitute(value));
|
||||
} else {
|
||||
Message.debug("'"+varName+"' already set: discarding '"+value+"'");
|
||||
}
|
||||
}
|
||||
|
||||
public void addAllVariables(Map variables) {
|
||||
|
|
@ -321,10 +334,8 @@ public class Ivy implements TransferListener {
|
|||
public void addAllVariables(Map variables, boolean overwrite) {
|
||||
for (Iterator iter = variables.keySet().iterator(); iter.hasNext();) {
|
||||
String key = (String)iter.next();
|
||||
if (overwrite || !_variables.containsKey(key)) {
|
||||
String val = (String)variables.get(key);
|
||||
setVariable(key, val);
|
||||
}
|
||||
String val = (String)variables.get(key);
|
||||
setVariable(key, val, overwrite);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -145,12 +145,13 @@ public class XmlIvyConfigurationParser extends DefaultHandler {
|
|||
_ivy.setVariable(name, value);
|
||||
} else if ("properties".equals(qName)) {
|
||||
String propFilePath = _ivy.substitute((String)attributes.get("file"));
|
||||
String overwrite = _ivy.substitute((String)attributes.get("overwrite"));
|
||||
try {
|
||||
Message.verbose("loading properties: "+propFilePath);
|
||||
_ivy.loadProperties(new File(propFilePath));
|
||||
_ivy.loadProperties(new File(propFilePath), overwrite == null ? true : Boolean.valueOf(overwrite).booleanValue());
|
||||
} catch (Exception ex) {
|
||||
Message.verbose("failed to load properties as file: trying as url: "+propFilePath);
|
||||
_ivy.loadProperties(new URL(propFilePath));
|
||||
_ivy.loadProperties(new URL(propFilePath), overwrite == null ? true : Boolean.valueOf(overwrite).booleanValue());
|
||||
}
|
||||
} else if ("include".equals(qName)) {
|
||||
String propFilePath = _ivy.substitute((String)attributes.get("file"));
|
||||
|
|
|
|||
Loading…
Reference in New Issue