Repository: ant-ivy Updated Branches: refs/heads/master 895834440 -> bc4f6b930
Fix IVY-982 by subtracting negated entries from wildcard bin Project: http://git-wip-us.apache.org/repos/asf/ant-ivy/repo Commit: http://git-wip-us.apache.org/repos/asf/ant-ivy/commit/18a830db Tree: http://git-wip-us.apache.org/repos/asf/ant-ivy/tree/18a830db Diff: http://git-wip-us.apache.org/repos/asf/ant-ivy/diff/18a830db Branch: refs/heads/master Commit: 18a830dbcf75dec4d404ed6a5b231b1633c67952 Parents: 8958344 Author: aprelev <[email protected]> Authored: Mon Aug 6 18:05:48 2018 +0300 Committer: Gintas Grigelionis <[email protected]> Committed: Tue Aug 7 14:27:07 2018 +0200 ---------------------------------------------------------------------- .../descriptor/DefaultDependencyDescriptor.java | 6 +++ .../apache/ivy/core/resolve/ResolveTest.java | 49 ++++++++++++++++++++ .../org/apache/ivy/core/resolve/ivy-982.xml | 37 +++++++++++++++ 3 files changed, 92 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/18a830db/src/java/org/apache/ivy/core/module/descriptor/DefaultDependencyDescriptor.java ---------------------------------------------------------------------- diff --git a/src/java/org/apache/ivy/core/module/descriptor/DefaultDependencyDescriptor.java b/src/java/org/apache/ivy/core/module/descriptor/DefaultDependencyDescriptor.java index 645cbd7..942d6fb 100644 --- a/src/java/org/apache/ivy/core/module/descriptor/DefaultDependencyDescriptor.java +++ b/src/java/org/apache/ivy/core/module/descriptor/DefaultDependencyDescriptor.java @@ -356,6 +356,12 @@ public class DefaultDependencyDescriptor implements DependencyDescriptor { } if (defConfs != null) { ret.addAll(defConfs); + + // Fixes bugs IVY-1547, IVY-982 which have to do with + // negation (e.g. `*, !foo`) not working on the left side of the maps-to operator. + List<String> excludedConfs = confs.get("!" + moduleConfiguration); + if (excludedConfs != null) + ret.removeAll(excludedConfs); } Collection<String> replacedRet = new LinkedHashSet<>(); http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/18a830db/test/java/org/apache/ivy/core/resolve/ResolveTest.java ---------------------------------------------------------------------- diff --git a/test/java/org/apache/ivy/core/resolve/ResolveTest.java b/test/java/org/apache/ivy/core/resolve/ResolveTest.java index 6564a26..5e58e32 100644 --- a/test/java/org/apache/ivy/core/resolve/ResolveTest.java +++ b/test/java/org/apache/ivy/core/resolve/ResolveTest.java @@ -4335,6 +4335,55 @@ public class ResolveTest { assertTrue(getArchiveFileInCache("org5", "mod5.1", "4.1", "art51B", "jar", "jar").exists()); } + + /** + * Test for issues IVY-982 and IVY-1547, + * which have to do with resolve engine ignoring negated configurations + * on the left side of the maps-to operator. + */ + + @Test + public void testResolveWithNegation() throws Exception { + ConfigurationResolveReport crp; + ResolveReport report = ivy.resolve(new File( + "test/java/org/apache/ivy/core/resolve/ivy-982.xml"), + getResolveOptions(new String[] {"*"})); + + // mod1.2: A->default + // mod2.1: *,!A->A + // mod2.2: *,!A->myconf1; *,!A,!B->myconf2 + assertFalse(report.hasError()); + + ModuleRevisionId mod12 = ModuleRevisionId.newInstance("org1", "mod1.2", "2.0"); + ModuleRevisionId mod21 = ModuleRevisionId.newInstance("org2", "mod2.1", "0.5"); + ModuleRevisionId mod22 = ModuleRevisionId.newInstance("org2", "mod2.2", "0.9"); + + crp = report.getConfigurationReport("A"); + assertTrue(crp.getDependency(mod12) != null); + assertTrue(Arrays.asList(crp.getDependency(mod12).getConfigurations(crp.getConfiguration())) + .containsAll(Collections.singletonList("default"))); + assertEquals(crp.getDependency(mod21), null); + assertEquals(crp.getDependency(mod22), null); + + crp = report.getConfigurationReport("B"); + assertEquals(crp.getDependency(mod12), null); + assertTrue(crp.getDependency(mod21) != null); + assertTrue(Arrays.asList(crp.getDependency(mod21).getConfigurations(crp.getConfiguration())) + .containsAll(Collections.singletonList("A"))); + assertTrue(crp.getDependency(mod22) != null); + assertTrue(Arrays.asList(crp.getDependency(mod22).getConfigurations(crp.getConfiguration())) + .containsAll(Collections.singletonList("myconf1"))); + + crp = report.getConfigurationReport("C"); + assertEquals(crp.getDependency(mod12), null); + assertTrue(crp.getDependency(mod21) != null); + assertTrue(Arrays.asList(crp.getDependency(mod21).getConfigurations(crp.getConfiguration())) + .containsAll(Collections.singletonList("A"))); + assertTrue(crp.getDependency(mod22) != null); + assertTrue(Arrays.asList(crp.getDependency(mod22).getConfigurations(crp.getConfiguration())) + .containsAll(Arrays.asList("myconf1", "myconf2"))); + } + @Test public void testResolveIntersectConfiguration1() throws Exception { // mod5.2;3.0 -> mod5.1;4.4 (*->@) http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/18a830db/test/java/org/apache/ivy/core/resolve/ivy-982.xml ---------------------------------------------------------------------- diff --git a/test/java/org/apache/ivy/core/resolve/ivy-982.xml b/test/java/org/apache/ivy/core/resolve/ivy-982.xml new file mode 100644 index 0000000..90d490a --- /dev/null +++ b/test/java/org/apache/ivy/core/resolve/ivy-982.xml @@ -0,0 +1,37 @@ +<!-- + 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" xmlns:e="http://ant.apache.org/ivy/extra"> + <info organisation="org.apache" + module="ivy-982" + revision="0.1" + /> + <configurations> + <conf name="A"/> + <conf name="B"/> + <conf name="C"/> + </configurations> + <dependencies> + <dependency org="org1" name="mod1.2" rev="2.0" + conf="A->default"/> + <dependency org="org2" name="mod2.1" rev="0.5" + conf="*,!A->A"/> + <dependency org="org2" name="mod2.2" rev="0.9" + conf="*,!A->myconf1; *,!A,!B->myconf2"/> + </dependencies> +</ivy-module>
