IVY-1515 : useCacheOnly should allow lookup of changing dependencies in cache
Thanks to Ilya
diff --git a/doc/release-notes.html b/doc/release-notes.html
index 0c34994..3c514c0 100644
--- a/doc/release-notes.html
+++ b/doc/release-notes.html
@@ -62,6 +62,7 @@
- FIX: PomModuleDescriptorParser should parse licenses from parent POM (IVY-1526) (Thanks to Jaikiran Pai)
- FIX: dynamic revisions are not cached per resolver (IVY-1430) (Thanks to Stephen Haberman)
- FIX: Dependencies failed using branch attribute (and extra attributes) (IVY-1141) (Thanks to Stephen Haberman)
+- FIX: useCacheOnly should allow lookup of changing dependencies in cache (IVY-1515) (Thanks to Ilya)
- IMPROVEMENT: Optimization: limit the revision numbers scanned if revision prefix is specified (Thanks to Ernestas Vaiciukevičius)
@@ -141,6 +142,7 @@
<li>Scott Hebert</li>
<li>Payam Hekmat</li>
<li>Achim Huegen</li>
+<li>Ilya</li>
<li>Matt Inger</li>
<li>Anders Jacobsson</li>
<li>Anders Janmyr</li>
diff --git a/src/java/org/apache/ivy/core/cache/CacheMetadataOptions.java b/src/java/org/apache/ivy/core/cache/CacheMetadataOptions.java
index a1c77b4..8f827c4 100644
--- a/src/java/org/apache/ivy/core/cache/CacheMetadataOptions.java
+++ b/src/java/org/apache/ivy/core/cache/CacheMetadataOptions.java
@@ -32,6 +32,8 @@
private boolean checkTTL = true;
+ private boolean useCacheOnly = false;
+
public Namespace getNamespace() {
return namespace;
}
@@ -85,4 +87,13 @@
public boolean isCheckTTL() {
return checkTTL;
}
+
+ public CacheMetadataOptions setUseCacheOnly(boolean useCacheOnly) {
+ this.useCacheOnly = useCacheOnly;
+ return this;
+ }
+
+ public boolean isUseCacheOnly() {
+ return useCacheOnly;
+ }
}
diff --git a/src/java/org/apache/ivy/core/cache/DefaultRepositoryCacheManager.java b/src/java/org/apache/ivy/core/cache/DefaultRepositoryCacheManager.java
index f6b2206..d6f33b7 100644
--- a/src/java/org/apache/ivy/core/cache/DefaultRepositoryCacheManager.java
+++ b/src/java/org/apache/ivy/core/cache/DefaultRepositoryCacheManager.java
@@ -686,7 +686,7 @@
Message.verbose("don't use cache for " + mrid + ": checkModified=true");
return null;
}
- if (isChanging(dd, requestedRevisionId, options)) {
+ if (!options.isUseCacheOnly() && isChanging(dd, requestedRevisionId, options)) {
Message.verbose("don't use cache for " + mrid + ": changing=true");
return null;
}
diff --git a/src/java/org/apache/ivy/plugins/resolver/AbstractResolver.java b/src/java/org/apache/ivy/plugins/resolver/AbstractResolver.java
index ef422d4..7c5af9e 100644
--- a/src/java/org/apache/ivy/plugins/resolver/AbstractResolver.java
+++ b/src/java/org/apache/ivy/plugins/resolver/AbstractResolver.java
@@ -435,6 +435,7 @@
.setCheckmodified(
data.getOptions().isUseCacheOnly() ? Boolean.FALSE : checkmodified)
.setValidate(doValidate(data)).setNamespace(getNamespace())
+ .setUseCacheOnly(data.getOptions().isUseCacheOnly())
.setForce(data.getOptions().isRefresh())
.setListener(getDownloadListener(getDownloadOptions(data.getOptions())));
}
diff --git a/test/java/org/apache/ivy/core/resolve/ResolveTest.java b/test/java/org/apache/ivy/core/resolve/ResolveTest.java
index 234e469..7f734d4 100644
--- a/test/java/org/apache/ivy/core/resolve/ResolveTest.java
+++ b/test/java/org/apache/ivy/core/resolve/ResolveTest.java
@@ -5599,6 +5599,27 @@
assertFalse(report.hasError());
}
+ public void testUseCacheOnlyWithChanging() throws Exception {
+ ResolveOptions option = getResolveOptions(new String[] {"*"});
+ option.setValidate(false);
+
+ ivy.getSettings().setDefaultUseOrigin(true);
+
+ URL url = new File("test/repositories/1/usecacheonly/mod4/ivys/ivy-1.0.xml").toURI()
+ .toURL();
+
+ // normal resolve, the file goes in the cache
+ ResolveReport report = ivy.resolve(url, option);
+ assertFalse(report.hasError());
+
+ option.setUseCacheOnly(true);
+
+ // use cache only, hit the cache
+ report = ivy.resolve(url, option);
+ assertFalse(report.hasError());
+
+ }
+
public void testUnpack() throws Exception {
ResolveOptions options = getResolveOptions(new String[] {"*"});
diff --git a/test/repositories/1/usecacheonly/mod4/ivys/ivy-1.0.xml b/test/repositories/1/usecacheonly/mod4/ivys/ivy-1.0.xml
new file mode 100644
index 0000000..233e65e
--- /dev/null
+++ b/test/repositories/1/usecacheonly/mod4/ivys/ivy-1.0.xml
@@ -0,0 +1,27 @@
+<!--
+ 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.
+-->
+<ivy-module version="1.0">
+ <info organisation="usecacheonly" module="mod4" revision="1.0" />
+ <configurations>
+ <conf name="default" />
+ </configurations>
+ <dependencies>
+ <dependency org="usecacheonly" name="mod5" rev="[1.0, 2.0)" changing="true" />
+ </dependencies>
+</ivy-module>
diff --git a/test/repositories/1/usecacheonly/mod4/jars/mod4-1.0.jar b/test/repositories/1/usecacheonly/mod4/jars/mod4-1.0.jar
new file mode 100644
index 0000000..945c9b4
--- /dev/null
+++ b/test/repositories/1/usecacheonly/mod4/jars/mod4-1.0.jar
@@ -0,0 +1 @@
+.
\ No newline at end of file
diff --git a/test/repositories/1/usecacheonly/mod5/ivys/ivy-1.0.0-SNAPSHOT.xml b/test/repositories/1/usecacheonly/mod5/ivys/ivy-1.0.0-SNAPSHOT.xml
new file mode 100644
index 0000000..16e0415
--- /dev/null
+++ b/test/repositories/1/usecacheonly/mod5/ivys/ivy-1.0.0-SNAPSHOT.xml
@@ -0,0 +1,24 @@
+<!--
+ 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.
+-->
+<ivy-module version="1.0">
+ <info organisation="usecacheonly" module="mod5" revision="1.0.0-SNAPSHOT" />
+ <configurations>
+ <conf name="default" />
+ </configurations>
+</ivy-module>
diff --git a/test/repositories/1/usecacheonly/mod5/jars/mod5-1.0.0-SNAPSHOT.jar b/test/repositories/1/usecacheonly/mod5/jars/mod5-1.0.0-SNAPSHOT.jar
new file mode 100644
index 0000000..945c9b4
--- /dev/null
+++ b/test/repositories/1/usecacheonly/mod5/jars/mod5-1.0.0-SNAPSHOT.jar
@@ -0,0 +1 @@
+.
\ No newline at end of file