IVY-1515 : useCacheOnly should allow lookup of changing dependencies in cache

Thanks to Ilya
This commit is contained in:
Nicolas Lalevée 2015-09-06 17:28:23 +02:00
parent 3fd058c02a
commit 12e1aaf5f6
9 changed files with 89 additions and 1 deletions

View File

@ -62,6 +62,7 @@ List of changes since Ivy 2.4.0:
- 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 @@ Here is the list of people who have contributed source code and documentation up
<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>

View File

@ -32,6 +32,8 @@ public class CacheMetadataOptions extends CacheDownloadOptions {
private boolean checkTTL = true;
private boolean useCacheOnly = false;
public Namespace getNamespace() {
return namespace;
}
@ -85,4 +87,13 @@ public class CacheMetadataOptions extends CacheDownloadOptions {
public boolean isCheckTTL() {
return checkTTL;
}
public CacheMetadataOptions setUseCacheOnly(boolean useCacheOnly) {
this.useCacheOnly = useCacheOnly;
return this;
}
public boolean isUseCacheOnly() {
return useCacheOnly;
}
}

View File

@ -686,7 +686,7 @@ public class DefaultRepositoryCacheManager implements RepositoryCacheManager, Iv
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;
}

View File

@ -435,6 +435,7 @@ public abstract class AbstractResolver implements DependencyResolver, HasLatestS
.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())));
}

View File

@ -5599,6 +5599,27 @@ public class ResolveTest extends TestCase {
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[] {"*"});

View File

@ -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>

View File

@ -0,0 +1 @@
.

View File

@ -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>