ivy:settings and ivy:retrieve with explicit id causes unwarranted DEPRECATED
warning
------------------------------------------------------------------------------------
Key: IVY-634
URL: https://issues.apache.org/jira/browse/IVY-634
Project: Ivy
Issue Type: Bug
Components: Core
Affects Versions: unspecified
Environment: trunk revision 588353
Reporter: Jacob Grydholt Jensen
Priority: Minor
I use the following build.xml and do an ant resolve. Notice that a retrieve
task is run using the id="hubba" defined in the target named ivy-setup.
<project name="hello-ivy" default="resolve"
xmlns:ivy="antlib:org.apache.ivy.ant">
<!-- some variables used -->
<property name="lib.dir" value="lib" />
<property name="build.dir" value="build" />
<property name="src.dir" value="src" />
<target name="ivy-setup" description="--> read settings">
<ivy:settings id="hubba" file="./ivysettings.xml" />
</target>
<!-- =================================
target: resolve
================================= -->
<target name="resolve" depends="ivy-setup" description="--> retreive
dependencies with ivy">
<ivy:retrieve settingsRef="hubba"/>
</target>
<!-- =================================
target: report
================================= -->
<target name="report" depends="resolve" description="--> generates a report
of dependencies">
<ivy:report todir="${build.dir}"/>
</target>
<!-- =================================
target: clean-cache
================================= -->
<target name="clean-cache" description="--> clean the ivy cache">
<ivy:cleancache />
</target>
</project>
The ivysettings.xml file referenced is a copy of the default file:
<ivysettings>
<settings defaultResolver="default"/>
<include url="${ivy.default.settings.dir}/ivysettings-public.xml"/>
<include url="${ivy.default.settings.dir}/ivysettings-shared.xml"/>
<include url="${ivy.default.settings.dir}/ivysettings-local.xml"/>
<include url="${ivy.default.settings.dir}/ivysettings-main-chain.xml"/>
<include
url="${ivy.default.settings.dir}/ivysettings-default-chain.xml"/>
</ivysettings>
When I run the ant target I get the following deprecation warning:
Buildfile: build.xml
ivy-setup:
resolve:
[ivy:retrieve] :: Ivy 2.0.0-beta1-local-20071025224054 - 20071025224054 ::
http://ant.apache.org/ivy/ ::
[ivy:retrieve] :: loading settings :: file =
/home/grydholt/ivy-work/tutorial/ivysettings.xml
[ivy:retrieve] No ivy:settings found for the default reference 'ivy.instance'.
A default instance will be used
[ivy:retrieve] ivy.conf.file = /home/grydholt/ivy-work/tutorial/ivysettings.xml
[ivy:retrieve] DEPRECATED: 'ivy.conf.file' is deprecated, use
'ivy.settings.file' instead
[ivy:retrieve] :: loading settings :: file =
/home/grydholt/ivy-work/tutorial/ivysettings.xml
[ivy:retrieve] :: resolving dependencies :: [ apache | hello-ivy | [EMAIL
PROTECTED] ]
[ivy:retrieve] confs: [default]
I find it strange that the settings file seems to be loaded twice. Anyway, the
DEPRECATED-warning is unwarranted. I think the problem stems from the following
two pieces of code. First, in IvySettings.java:
public void setSettingsVariables(File settingsFile) {
try {
setVariable("ivy.settings.dir", new
File(settingsFile.getAbsolutePath()).getParent());
setDeprecatedVariable("ivy.conf.dir", "ivy.settings.dir");
setVariable("ivy.settings.file", settingsFile.getAbsolutePath());
setDeprecatedVariable("ivy.conf.file", "ivy.settings.file");
setVariable("ivy.settings.url",
settingsFile.toURL().toExternalForm());
setDeprecatedVariable("ivy.conf.url", "ivy.settings.url");
} catch (MalformedURLException e) {
IllegalArgumentException iae = new IllegalArgumentException(
"given file cannot be transformed to url: " + settingsFile);
iae.initCause(e);
throw iae;
}
}
/**
* Sets a deprecated variable with the value of the new variable
*
* @param deprecatedKey
* the deprecated variable name
* @param newKey
* the new variable name
*/
private void setDeprecatedVariable(String deprecatedKey, String newKey) {
setVariable(deprecatedKey, getVariable(newKey));
}
It looks as though the ivy.conf.file receives the value of the
ivy.settings.file. So if ivy.settings.file is non-null, then so will
ivy.conf.file be.
Now, for the second piece of code, from IvyAntSettings.java:
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");
}
We see that if ivy.conf.file is set, we will get a deprecation warning.
Summing up. If ivy.settings.file is set, then ivy.conf.file will be set. And
when ivy.conf.file is set, we get a deprecation error.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.