geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From djen...@apache.org
Subject svn commit: r648987 - in /geronimo/server/branches/2.1.1: ./ buildsupport/car-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/car/
Date Thu, 17 Apr 2008 07:33:06 GMT
Author: djencks
Date: Thu Apr 17 00:33:00 2008
New Revision: 648987

URL: http://svn.apache.org/viewvc?rev=648987&view=rev
Log:
GERONIMO-3705 port maven build fix to 2.1.1

Modified:
    geronimo/server/branches/2.1.1/buildsupport/car-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/car/AbstractCarMojo.java
    geronimo/server/branches/2.1.1/buildsupport/car-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/car/InstallModulesMojo.java
    geronimo/server/branches/2.1.1/buildsupport/car-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/car/Maven2RepositoryAdapter.java
    geronimo/server/branches/2.1.1/buildsupport/car-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/car/PackageMojo.java
    geronimo/server/branches/2.1.1/pom.xml

Modified: geronimo/server/branches/2.1.1/buildsupport/car-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/car/AbstractCarMojo.java
URL: http://svn.apache.org/viewvc/geronimo/server/branches/2.1.1/buildsupport/car-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/car/AbstractCarMojo.java?rev=648987&r1=648986&r2=648987&view=diff
==============================================================================
--- geronimo/server/branches/2.1.1/buildsupport/car-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/car/AbstractCarMojo.java
(original)
+++ geronimo/server/branches/2.1.1/buildsupport/car-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/car/AbstractCarMojo.java
Thu Apr 17 00:33:00 2008
@@ -27,16 +27,24 @@
 import java.util.List;
 import java.util.Map;
 import java.util.Properties;
+import java.util.Set;
+import java.util.Collections;
 
 import org.apache.maven.artifact.Artifact;
+import org.apache.maven.artifact.factory.ArtifactFactory;
+import org.apache.maven.artifact.resolver.ArtifactResolutionException;
+import org.apache.maven.artifact.resolver.ArtifactResolutionResult;
 import org.apache.maven.artifact.repository.ArtifactRepository;
 import org.apache.maven.plugin.MojoExecutionException;
 import org.apache.maven.plugin.MojoFailureException;
 import org.apache.maven.project.MavenProject;
 import org.apache.maven.project.MavenProjectHelper;
+import org.apache.maven.project.ProjectBuildingException;
+import org.apache.maven.project.artifact.InvalidDependencyVersionException;
 import org.codehaus.mojo.pluginsupport.MojoSupport;
 import org.codehaus.mojo.pluginsupport.dependency.DependencyHelper;
 import org.codehaus.mojo.pluginsupport.dependency.DependencyTree;
+import org.codehaus.mojo.pluginsupport.dependency.DependencyResolutionListener;
 import org.codehaus.mojo.pluginsupport.dependency.DependencyTree.Node;
 import org.codehaus.mojo.pluginsupport.util.ArtifactItem;
 
@@ -81,7 +89,14 @@
      * @component
      */
     protected DependencyHelper dependencyHelper = null;
-    
+    /**
+     * @component
+     * @required
+     * @readonly
+     */
+    protected ArtifactFactory artifactFactory;
+    protected Set<Artifact> dependencies;// = new DependencyTree();
+
     //
     // MojoSupport Hooks
     //
@@ -110,63 +125,27 @@
     /**
      * Generates a properties file with explicit versions of artifacts of the current project
transitivly.
      */
-    protected void generateExplicitVersionProperties(final File outputFile, DependencyTree
dependencies) throws MojoExecutionException, IOException {
+    protected void generateExplicitVersionProperties(final File outputFile, Set<org.apache.maven.artifact.Artifact>
dependencies) throws MojoExecutionException, IOException {
         log.debug("Generating explicit version properties: " + outputFile);
 
         // Generate explicit_versions for all our dependencies...
         Properties props = new Properties();
-        
-        try {
 
-            Node root = dependencies.getRootNode();
-            
-            // Skip the root node
-            Iterator children = root.getChildren().iterator();
-            while (children.hasNext()) {
-                Node child = (Node) children.next();
-                appendExplicitVersionProperties(child, props);
+        for (org.apache.maven.artifact.Artifact artifact: dependencies) {
+            String name = artifact.getGroupId() + "/" + artifact.getArtifactId() + "//" +
artifact.getType();
+            String value = artifact.getGroupId() + "/" + artifact.getArtifactId() + "/" +
artifact.getVersion() + "/" + artifact.getType();
+
+            if (log.isDebugEnabled()) {
+                log.debug("Setting " + name + "=" + value);
             }
+            props.setProperty(name, value);
         }
-        catch (Exception e) {
-            throw new MojoExecutionException("Failed to determine project dependencies",
e);
-        }
-        
         BufferedOutputStream output = new BufferedOutputStream(new FileOutputStream(outputFile));
         props.store(output, null);
         output.flush();
         output.close();
     }
-    
-    private void appendExplicitVersionProperties(final Node node, final Properties props)
{
-        assert node != null;
-        assert props != null;
-        
-        Artifact artifact = node.getArtifact();
-        if ("test".equals(artifact.getScope())) {
-            if (log.isDebugEnabled()) {
-                log.debug("Skipping artifact with scope test: " + artifact);
-            }
-            return;
-        }
-        
-        String name = artifact.getGroupId() + "/" + artifact.getArtifactId() + "//" + artifact.getType();
-        String value = artifact.getGroupId() + "/" + artifact.getArtifactId() + "/" + artifact.getVersion()
+ "/" + artifact.getType();
-        
-        if (log.isDebugEnabled()) {
-            log.debug("Setting " + name + "=" + value);
-        }
-        props.setProperty(name, value);
-        
-        if (!node.getChildren().isEmpty()) {
-            Iterator children = node.getChildren().iterator();
-            
-            while (children.hasNext()) {
-                Node child = (Node) children.next();
-                appendExplicitVersionProperties(child, props);
-            }
-        }
-    }
-
+   
     protected static File getArchiveFile(final File basedir, final String finalName, String
classifier) {
         if (classifier == null) {
             classifier = "";
@@ -246,6 +225,26 @@
             return false;
         }
         return true;
+    }
+
+    protected void getDependencies(MavenProject project) throws ProjectBuildingException,
InvalidDependencyVersionException, ArtifactResolutionException {
+        Map managedVersions = DependencyHelper.getManagedVersionMap(project, artifactFactory);
+
+        if (project.getDependencyArtifacts() == null) {
+            project.setDependencyArtifacts(project.createArtifacts(artifactFactory, null,
null));
+        }
+
+        ArtifactResolutionResult artifactResolutionResult = dependencyHelper.getArtifactCollector().collect(
+                project.getDependencyArtifacts(),
+                project.getArtifact(),
+                managedVersions,
+                getArtifactRepository(),
+                project.getRemoteArtifactRepositories(),
+                dependencyHelper.getArtifactMetadataSource(),
+                null,
+                Collections.emptyList());
+
+        dependencies = artifactResolutionResult.getArtifacts();
     }
 
     protected class ArtifactLookupImpl

Modified: geronimo/server/branches/2.1.1/buildsupport/car-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/car/InstallModulesMojo.java
URL: http://svn.apache.org/viewvc/geronimo/server/branches/2.1.1/buildsupport/car-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/car/InstallModulesMojo.java?rev=648987&r1=648986&r2=648987&view=diff
==============================================================================
--- geronimo/server/branches/2.1.1/buildsupport/car-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/car/InstallModulesMojo.java
(original)
+++ geronimo/server/branches/2.1.1/buildsupport/car-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/car/InstallModulesMojo.java
Thu Apr 17 00:33:00 2008
@@ -135,7 +135,7 @@
     private Set installedArtifacts = new HashSet();
 
     protected void doExecute() throws Exception {
-        DependencyTree dependencies = dependencyHelper.getDependencies(project);
+        getDependencies(project);
         Maven2RepositoryAdapter.ArtifactLookup lookup = new ArtifactLookupImpl(new HashMap<Artifact,
org.apache.maven.artifact.Artifact>());
         SourceRepository sourceRepo = new Maven2RepositoryAdapter(dependencies, lookup);
         PluginListType pluginList = new PluginListType();

Modified: geronimo/server/branches/2.1.1/buildsupport/car-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/car/Maven2RepositoryAdapter.java
URL: http://svn.apache.org/viewvc/geronimo/server/branches/2.1.1/buildsupport/car-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/car/Maven2RepositoryAdapter.java?rev=648987&r1=648986&r2=648987&view=diff
==============================================================================
--- geronimo/server/branches/2.1.1/buildsupport/car-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/car/Maven2RepositoryAdapter.java
(original)
+++ geronimo/server/branches/2.1.1/buildsupport/car-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/car/Maven2RepositoryAdapter.java
Thu Apr 17 00:33:00 2008
@@ -21,7 +21,7 @@
 
 import java.io.File;
 import java.io.IOException;
-import java.util.Iterator;
+import java.util.Set;
 import java.util.SortedSet;
 import java.util.TreeSet;
 
@@ -37,7 +37,6 @@
 import org.apache.geronimo.system.plugin.SourceRepository;
 import org.apache.geronimo.system.plugin.model.PluginListType;
 import org.apache.geronimo.system.repository.Maven2Repository;
-import org.codehaus.mojo.pluginsupport.dependency.DependencyTree;
 
 /**
  * Helps adapt Geronimo repositories to Maven repositories for packaging building.
@@ -47,9 +46,9 @@
 public class Maven2RepositoryAdapter extends Maven2Repository implements SourceRepository
{
     private ArtifactLookup lookup;
 
-    private DependencyTree dependencyTree;
+    private Set<org.apache.maven.artifact.Artifact> dependencyTree;
 
-    public Maven2RepositoryAdapter(DependencyTree dependencyTree, final ArtifactLookup lookup)
{
+    public Maven2RepositoryAdapter(Set<org.apache.maven.artifact.Artifact> dependencyTree,
final ArtifactLookup lookup) {
         super(lookup.getBasedir());
         this.dependencyTree = dependencyTree;
         this.lookup = lookup;
@@ -63,23 +62,21 @@
 
     public SortedSet list() {
         TreeSet<Artifact> list = new TreeSet<Artifact>();
-        listInternal(list, dependencyTree.getRootNode(), null, null, null, null);
+        listInternal(list, null, null, null, null);
         return list;
     }
 
     public SortedSet list(Artifact query) {
         TreeSet<Artifact> list = new TreeSet<Artifact>();
-        listInternal(list, dependencyTree.getRootNode(), query.getGroupId(), query.getArtifactId(),
query.getVersion(), query.getType());
+        listInternal(list, query.getGroupId(), query.getArtifactId(), query.getVersion(),
query.getType());
         return list;
     }
 
-    private void listInternal(TreeSet<Artifact> list, DependencyTree.Node node, String
groupId, String artifactId, Version version, String type) {
-        if (matches(node.getArtifact(), groupId, artifactId, version, type)) {
-            list.add(mavenToGeronimoArtifact(node.getArtifact()));
-        }
-        for (Iterator iterator = node.getChildren().iterator(); iterator.hasNext();) {
-            DependencyTree.Node childNode = (DependencyTree.Node) iterator.next();
-            listInternal(list, childNode, groupId, artifactId, version, type);
+    private void listInternal(TreeSet<Artifact> list, String groupId, String artifactId,
Version version, String type) {
+        for (org.apache.maven.artifact.Artifact artifact: dependencyTree) {
+            if (matches(artifact, groupId, artifactId, version, type)) {
+                list.add(mavenToGeronimoArtifact(artifact));
+            }
         }
     }
 
@@ -132,7 +129,7 @@
     static {
         GBeanInfoBuilder infoFactory = GBeanInfoBuilder.createStatic(Maven2RepositoryAdapter.class,
"Repository");
         infoFactory.addAttribute("lookup", ArtifactLookup.class, true);
-        infoFactory.addAttribute("dependencies", DependencyTree.class, true);
+        infoFactory.addAttribute("dependencies", Set.class, true);
         infoFactory.setConstructor(new String[]{"dependencies", "lookup"});
         GBEAN_INFO = infoFactory.getBeanInfo();
     }

Modified: geronimo/server/branches/2.1.1/buildsupport/car-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/car/PackageMojo.java
URL: http://svn.apache.org/viewvc/geronimo/server/branches/2.1.1/buildsupport/car-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/car/PackageMojo.java?rev=648987&r1=648986&r2=648987&view=diff
==============================================================================
--- geronimo/server/branches/2.1.1/buildsupport/car-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/car/PackageMojo.java
(original)
+++ geronimo/server/branches/2.1.1/buildsupport/car-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/car/PackageMojo.java
Thu Apr 17 00:33:00 2008
@@ -21,7 +21,6 @@
 
 import java.io.File;
 import java.net.URI;
-import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.HashMap;
 import java.util.HashSet;
@@ -51,13 +50,8 @@
 import org.apache.geronimo.system.configuration.RepositoryConfigurationStore;
 import org.apache.geronimo.system.repository.Maven2Repository;
 import org.apache.geronimo.system.resolver.ExplicitDefaultArtifactResolver;
-import org.apache.maven.archiver.MavenArchiveConfiguration;
 import org.apache.maven.artifact.Artifact;
-import org.apache.maven.artifact.factory.ArtifactFactory;
-import org.apache.maven.project.MavenProject;
-import org.codehaus.mojo.pluginsupport.dependency.DependencyTree;
 import org.codehaus.mojo.pluginsupport.util.ArtifactItem;
-import org.codehaus.plexus.archiver.jar.JarArchiver;
 import org.codehaus.plexus.util.FileUtils;
 
 /**
@@ -72,13 +66,6 @@
     extends AbstractCarMojo
 {
 
-    /**
-     * @component
-     * @required
-     * @readonly
-     */
-    private ArtifactFactory artifactFactory;
-
 
     /**
      * Directory containing the generated archive.
@@ -224,25 +211,7 @@
             log.debug("Using module file: " + moduleFile);
         }
 
-        MavenProject depsProject = new MavenProject(project);
-        List<org.apache.maven.model.Dependency> projectDeps = new ArrayList<org.apache.maven.model.Dependency>();
-        for (org.apache.maven.model.Dependency dep: (List<org.apache.maven.model.Dependency>)project.getDependencies())
{
-            org.apache.maven.model.Dependency newDep = new org.apache.maven.model.Dependency();
-            newDep.setArtifactId(dep.getArtifactId());
-            newDep.setGroupId(dep.getGroupId());
-            newDep.setClassifier(dep.getClassifier());
-            newDep.setExclusions(dep.getExclusions());
-            newDep.setOptional(dep.isOptional());
-            newDep.setSystemPath(dep.getSystemPath());
-            newDep.setType(dep.getType());
-            newDep.setVersion(dep.getVersion());
- // don't copy scope
-
-            projectDeps.add(newDep);
-        }
-        depsProject.setDependencies(projectDeps);
-        depsProject.setDependencyArtifacts(depsProject.createArtifacts(artifactFactory, null,
null));
-        dependencies.setRootNode(dependencyHelper.getDependencies(depsProject).getRootNode());
+        getDependencies(project);
 
         generateExplicitVersionProperties(explicitResolutionProperties, dependencies);
 
@@ -307,8 +276,6 @@
     private AbstractName targetRepositoryAName;
 
     private boolean targetSet;
-
-    private DependencyTree dependencies = new DependencyTree();
 
     public void buildPackage() throws Exception {
         log.info("Packaging module configuration: " + planFile);

Modified: geronimo/server/branches/2.1.1/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/server/branches/2.1.1/pom.xml?rev=648987&r1=648986&r2=648987&view=diff
==============================================================================
--- geronimo/server/branches/2.1.1/pom.xml (original)
+++ geronimo/server/branches/2.1.1/pom.xml Thu Apr 17 00:33:00 2008
@@ -2155,7 +2155,7 @@
                                 
                                 <!-- Require Maven 2.0.5 - 2.0.7, 2.0.8+ currently barfs
-->
                                 <requireMavenVersion>
-                                    <version>[2.0.5,2.0.7]</version>
+                                    <version>[2.0.5,2.0.9]</version>
                                 </requireMavenVersion>
                             </rules>
                         </configuration>



Mime
View raw message