FIX: ivy.cache.dir.${settingsRef} is set to default instead of the defaultCacheDir from the ivysettings.xml after ivy:resolve (IVY-898)

git-svn-id: https://svn.apache.org/repos/asf/ant/ivy/core/trunk@694036 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Maarten Coene 2008-09-10 22:25:06 +00:00
parent aa67426d68
commit eadc1e3453
7 changed files with 83 additions and 2 deletions

View File

@ -111,6 +111,7 @@ for detailed view of each issue, please consult http://issues.apache.org/jira/br
- IMPROVEMENT: Add a memory cache for the module descriptor that are parsed from the cache (IVY-883)
- IMPROVEMENT: Improve performance (IVY-872)
- FIX: ivy.cache.dir.${settingsRef} is set to default instead of the defaultCacheDir from the ivysettings.xml after ivy:resolve (IVY-898)
- FIX: Ivy ibiblio resolver chokes on variables while checking descriptor consistency (IVY-818)
- FIX: Enable consistent support of the configuration negation operator (IVY-894) (thanks to Patrick Woodworth)
- FIX: add variable expansion in extra attributes (IVY-798)

View File

@ -201,6 +201,10 @@ public class IvyAntSettings extends DataType {
public void setUrl(String confUrl) throws MalformedURLException {
this.url = new URL(confUrl);
}
public void setUrl(URL url) {
this.url = url;
}
/*
* This is usually not necessary to define a reference in Ant, but it's the only

View File

@ -89,6 +89,13 @@ public class IvyConfigure extends Task {
public void setUrl(String url) throws MalformedURLException {
settings.setUrl(url);
}
public void setUrl(URL url) {
if (url == null) {
throw new NullPointerException("Cannot set a null URL");
}
settings.setUrl(url);
}
public String getRealm() {
return settings.getRealm();

View File

@ -371,7 +371,6 @@ public class IvySettings implements SortEngineSettings, PublishEngineSettings, P
} else {
getDefaultIvyUserDir();
}
getDefaultCache();
loadDefaultProperties();
try {
@ -397,7 +396,6 @@ public class IvySettings implements SortEngineSettings, PublishEngineSettings, P
} else {
getDefaultIvyUserDir();
}
getDefaultCache();
loadDefaultProperties();
new XmlSettingsParser(this).parse(settingsURL);

View File

@ -54,6 +54,35 @@ public class IvyConfigureTest extends TestCase {
task.setSettingsRef(ref);
return task.getIvyInstance();
}
public void testDefaultCacheDir() {
// test with an URL
configure.setUrl(getClass().getResource("ivysettings-defaultCacheDir.xml"));
configure.setSettingsId("test");
configure.execute();
assertEquals(new File("mycache").getAbsolutePath(), project.getProperty("ivy.cache.dir.test"));
// test with a File
project = new Project();
configure = new IvyConfigure();
configure.setProject(project);
configure.setFile(new File("test/java/org/apache/ivy/ant/ivysettings-defaultCacheDir.xml"));
configure.setSettingsId("test2");
configure.execute();
assertEquals(new File("mycache").getAbsolutePath(), project.getProperty("ivy.cache.dir.test2"));
// test if no defaultCacheDir is specified
project = new Project();
configure = new IvyConfigure();
configure.setProject(project);
configure.setFile(new File("test/java/org/apache/ivy/ant/ivysettings-noDefaultCacheDir.xml"));
configure.setSettingsId("test3");
configure.execute();
assertNotNull(project.getProperty("ivy.cache.dir.test3"));
}
public void testDefault() throws Exception {
// by default settings look in the current directory for an ivysettings.xml file...

View File

@ -0,0 +1,21 @@
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
<ivysettings>
<caches defaultCacheDir="${ivy.basedir}/mycache" />
</ivysettings>

View File

@ -0,0 +1,21 @@
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
<ivysettings>
<caches />
</ivysettings>