ant-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From maart...@apache.org
Subject svn commit: r699482 - in /ant/ivy/core/trunk: CHANGES.txt src/java/org/apache/ivy/plugins/parser/m2/PomModuleDescriptorBuilder.java src/java/org/apache/ivy/plugins/parser/m2/PomModuleDescriptorParser.java
Date Fri, 26 Sep 2008 20:16:10 GMT
Author: maartenc
Date: Fri Sep 26 13:16:10 2008
New Revision: 699482

URL: http://svn.apache.org/viewvc?rev=699482&view=rev
Log:
FIX: Maven packaging of "pom" should add a "jar" artifact if present (IVY-920)

Modified:
    ant/ivy/core/trunk/CHANGES.txt
    ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/parser/m2/PomModuleDescriptorBuilder.java
    ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/parser/m2/PomModuleDescriptorParser.java

Modified: ant/ivy/core/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/CHANGES.txt?rev=699482&r1=699481&r2=699482&view=diff
==============================================================================
--- ant/ivy/core/trunk/CHANGES.txt (original)
+++ ant/ivy/core/trunk/CHANGES.txt Fri Sep 26 13:16:10 2008
@@ -88,6 +88,7 @@
 - FIX: Ivy can't handle bare POM ${groupId} property (IVY-913) (thanks to Tom Widmer)
 - FIX: Properties needed to parse version in POM (IVY-914) (thanks to Tom Widmer)
 - 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)
 
    2.0.0-rc1
 =====================================

Modified: ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/parser/m2/PomModuleDescriptorBuilder.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/parser/m2/PomModuleDescriptorBuilder.java?rev=699482&r1=699481&r2=699482&view=diff
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/parser/m2/PomModuleDescriptorBuilder.java
(original)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/parser/m2/PomModuleDescriptorBuilder.java
Fri Sep 26 13:16:10 2008
@@ -31,6 +31,7 @@
 import java.util.Map.Entry;
 
 import org.apache.ivy.Ivy;
+import org.apache.ivy.core.cache.ArtifactOrigin;
 import org.apache.ivy.core.module.descriptor.Artifact;
 import org.apache.ivy.core.module.descriptor.Configuration;
 import org.apache.ivy.core.module.descriptor.DefaultArtifact;
@@ -50,8 +51,10 @@
 import org.apache.ivy.plugins.matcher.ExactPatternMatcher;
 import org.apache.ivy.plugins.matcher.PatternMatcher;
 import org.apache.ivy.plugins.parser.ModuleDescriptorParser;
+import org.apache.ivy.plugins.parser.ParserSettings;
 import org.apache.ivy.plugins.parser.m2.PomReader.PomDependencyData;
 import org.apache.ivy.plugins.repository.Resource;
+import org.apache.ivy.plugins.resolver.DependencyResolver;
 import org.apache.ivy.util.Message;
 
 
@@ -187,9 +190,11 @@
     private ModuleRevisionId mrid;
 
     private DefaultArtifact mainArtifact;
+    
+    private ParserSettings parserSettings;
 
     
-    public PomModuleDescriptorBuilder(ModuleDescriptorParser parser, Resource res) {
+    public PomModuleDescriptorBuilder(ModuleDescriptorParser parser, Resource res, ParserSettings
ivySettings) {
         ivyModuleDescriptor = new DefaultModuleDescriptor(parser, res);
         ivyModuleDescriptor.setResolvedPublicationDate(new Date(res.getLastModified()));
         for (int i = 0; i < MAVEN2_CONFIGURATIONS.length; i++) {
@@ -197,6 +202,7 @@
         }
         ivyModuleDescriptor.setMappingOverride(true);
         ivyModuleDescriptor.addExtraAttributeNamespace("m", Ivy.getIvyHomeURL() + "maven");
+        parserSettings = ivySettings;
     }
 
 
@@ -232,7 +238,19 @@
          * cover all cases.
          */
         if ("pom".equals(packaging)) {
-            // no artifact defined!
+            // no artifact defined! Add the default artifact if it exist.
+            DependencyResolver resolver = parserSettings.getResolver(mrid);
+            
+            if (resolver != null) {
+                DefaultArtifact artifact = new DefaultArtifact(mrid, new Date(), artifactId,
"jar", "jar");
+                ArtifactOrigin artifactOrigin = resolver.locate(artifact);
+                
+                if (!ArtifactOrigin.isUnknown(artifactOrigin)) {
+                    mainArtifact = artifact;
+                    ivyModuleDescriptor.addArtifact("master", mainArtifact);
+                }
+            }
+
             return;
         } else if (JAR_PACKAGINGS.contains(packaging)) {
             ext = "jar";

Modified: ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/parser/m2/PomModuleDescriptorParser.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/parser/m2/PomModuleDescriptorParser.java?rev=699482&r1=699481&r2=699482&view=diff
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/parser/m2/PomModuleDescriptorParser.java
(original)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/parser/m2/PomModuleDescriptorParser.java
Fri Sep 26 13:16:10 2008
@@ -108,7 +108,7 @@
     public ModuleDescriptor parseDescriptor(ParserSettings ivySettings, URL descriptorURL,

             Resource res, boolean validate) throws ParseException, IOException {
         
-        PomModuleDescriptorBuilder mdBuilder = new PomModuleDescriptorBuilder(this, res);
+        PomModuleDescriptorBuilder mdBuilder = new PomModuleDescriptorBuilder(this, res,
ivySettings);
         
         try {           
             PomReader domReader = new PomReader(descriptorURL, res);            



Mime
View raw message