Author: maartenc Date: Tue Sep 30 13:34:15 2008 New Revision: 700571 URL: http://svn.apache.org/viewvc?rev=700571&view=rev Log: FIX: Maven Pom reader doesn't handle optional dependencies correctly in some instances (IVY-926) (thanks to Phil Messenger)
Modified: ant/ivy/core/trunk/CHANGES.txt ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/parser/m2/PomReader.java ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/parser/m2/PomModuleDescriptorParserTest.java ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/parser/m2/test-optional.pom Modified: ant/ivy/core/trunk/CHANGES.txt URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/CHANGES.txt?rev=700571&r1=700570&r2=700571&view=diff ============================================================================== --- ant/ivy/core/trunk/CHANGES.txt (original) +++ ant/ivy/core/trunk/CHANGES.txt Tue Sep 30 13:34:15 2008 @@ -53,6 +53,7 @@ Bernard Niset David Maplesden Glen Marchesani + Phil Messenger Mathias Muller Peter Oxenham Emmanuel Pellereau @@ -90,6 +91,7 @@ - FIX: build.xml: checkstyle + checkstyle-report dont work together (IVY-919) - FIX: Maven packaging of "pom" should add a "jar" artifact if present (IVY-920) - FIX: StackOverflow when using ivy:settings with "ivy.instance" as id (IVY-924) +- FIX: Maven Pom reader doesn't handle optional dependencies correctly in some instances (IVY-926) (thanks to Phil Messenger) 2.0.0-rc1 ===================================== Modified: ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/parser/m2/PomReader.java URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/parser/m2/PomReader.java?rev=700571&r1=700570&r2=700571&view=diff ============================================================================== --- ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/parser/m2/PomReader.java (original) +++ ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/parser/m2/PomReader.java Tue Sep 30 13:34:15 2008 @@ -364,7 +364,8 @@ } public boolean isOptional() { - return getFirstChildElement(depElement, OPTIONAL) != null; + Element e = getFirstChildElement(depElement, OPTIONAL); + return (e != null) && "true".equalsIgnoreCase(getTextContent(e)); } public List /*<ModuleId>*/ getExcludedModules() { Modified: ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/parser/m2/PomModuleDescriptorParserTest.java URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/parser/m2/PomModuleDescriptorParserTest.java?rev=700571&r1=700570&r2=700571&view=diff ============================================================================== --- ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/parser/m2/PomModuleDescriptorParserTest.java (original) +++ ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/parser/m2/PomModuleDescriptorParserTest.java Tue Sep 30 13:34:15 2008 @@ -384,7 +384,7 @@ DependencyDescriptor[] dds = md.getDependencies(); assertNotNull(dds); - assertEquals(2, dds.length); + assertEquals(3, dds.length); assertEquals(ModuleRevisionId.newInstance("commons-logging", "commons-logging", "1.0.4"), dds[0].getDependencyRevisionId()); assertEquals(new HashSet(Arrays.asList(new String[] {"optional"})), new HashSet(Arrays @@ -402,6 +402,15 @@ new HashSet(Arrays.asList(dds[1].getDependencyConfigurations("compile")))); assertEquals(new HashSet(Arrays.asList(new String[] {"runtime(*)"})), new HashSet(Arrays .asList(dds[1].getDependencyConfigurations("runtime")))); + + assertEquals(ModuleRevisionId.newInstance("cglib", "cglib-extra", "2.0.2"), dds[2] + .getDependencyRevisionId()); + assertEquals(new HashSet(Arrays.asList(new String[] {"compile", "runtime"})), new HashSet( + Arrays.asList(dds[2].getModuleConfigurations()))); + assertEquals(new HashSet(Arrays.asList(new String[] {"master(*)", "compile(*)"})), + new HashSet(Arrays.asList(dds[2].getDependencyConfigurations("compile")))); + assertEquals(new HashSet(Arrays.asList(new String[] {"runtime(*)"})), new HashSet(Arrays + .asList(dds[2].getDependencyConfigurations("runtime")))); } public void testDependenciesWithScope() throws Exception { Modified: ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/parser/m2/test-optional.pom URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/parser/m2/test-optional.pom?rev=700571&r1=700570&r2=700571&view=diff ============================================================================== --- ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/parser/m2/test-optional.pom (original) +++ ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/parser/m2/test-optional.pom Tue Sep 30 13:34:15 2008 @@ -33,12 +33,18 @@ <groupId>commons-logging</groupId> <artifactId>commons-logging</artifactId> <version>1.0.4</version> - <optional/> + <optional>true</optional> </dependency> <dependency> <groupId>cglib</groupId> <artifactId>cglib</artifactId> <version>2.0.2</version> </dependency> + <dependency> + <groupId>cglib</groupId> + <artifactId>cglib-extra</artifactId> + <version>2.0.2</version> + <optional>false</optional> + </dependency> </dependencies> </project>