geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jdil...@apache.org
Subject svn commit: r705650 [2/2] - in /geronimo/gshell/trunk: ./ gshell-application/src/main/java/org/apache/geronimo/gshell/application/ gshell-application/src/main/java/org/apache/geronimo/gshell/application/plugin/ gshell-assembly/src/main/underlay/etc/ gs...
Date Fri, 17 Oct 2008 15:53:21 GMT
Modified: geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/plugin/PluginManagerImpl.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/plugin/PluginManagerImpl.java?rev=705650&r1=705649&r2=705650&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/plugin/PluginManagerImpl.java
(original)
+++ geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/plugin/PluginManagerImpl.java
Fri Oct 17 08:53:19 2008
@@ -24,23 +24,27 @@
 import org.apache.geronimo.gshell.application.ClassPath;
 import org.apache.geronimo.gshell.application.plugin.Plugin;
 import org.apache.geronimo.gshell.application.plugin.PluginManager;
-import org.apache.geronimo.gshell.artifact.ArtifactManager;
 import org.apache.geronimo.gshell.chronos.StopWatch;
 import org.apache.geronimo.gshell.event.Event;
 import org.apache.geronimo.gshell.event.EventListener;
 import org.apache.geronimo.gshell.event.EventManager;
 import org.apache.geronimo.gshell.event.EventPublisher;
-import org.apache.geronimo.gshell.model.application.PluginArtifact;
+import org.apache.geronimo.gshell.model.Artifact;
 import org.apache.geronimo.gshell.spring.BeanContainer;
 import org.apache.geronimo.gshell.spring.BeanContainerAware;
 import org.apache.geronimo.gshell.wisdom.application.ApplicationConfiguredEvent;
 import org.apache.geronimo.gshell.wisdom.application.ClassPathImpl;
 import org.apache.geronimo.gshell.xstore.XStore;
 import org.apache.geronimo.gshell.xstore.XStoreRecord;
-import org.apache.maven.artifact.Artifact;
-import org.apache.maven.artifact.factory.ArtifactFactory;
-import org.apache.maven.artifact.resolver.ArtifactResolutionRequest;
-import org.apache.maven.artifact.resolver.ArtifactResolutionResult;
+import org.apache.ivy.Ivy;
+import org.apache.ivy.core.module.descriptor.Configuration;
+import org.apache.ivy.core.module.descriptor.DefaultDependencyDescriptor;
+import org.apache.ivy.core.module.descriptor.DefaultModuleDescriptor;
+import org.apache.ivy.core.module.descriptor.ModuleDescriptor;
+import org.apache.ivy.core.module.id.ModuleRevisionId;
+import org.apache.ivy.core.report.ArtifactDownloadReport;
+import org.apache.ivy.core.report.ResolveReport;
+import org.apache.ivy.core.resolve.ResolveOptions;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -65,9 +69,6 @@
     private ApplicationManager applicationManager;
 
     @Autowired
-    private ArtifactManager artifactManager;
-
-    @Autowired
     private EventManager eventManager;
 
     @Autowired
@@ -76,6 +77,9 @@
     @Autowired
     private XStore xstore;
 
+    @Autowired
+    private Ivy ivy;
+
     private BeanContainer container;
 
     private Set<Plugin> plugins = new LinkedHashSet<Plugin>();
@@ -111,9 +115,9 @@
 
         log.debug("Loading plugins for application: {}", application.getId());
 
-        List<PluginArtifact> artifacts = application.getModel().getPlugins();
+        List<Artifact> artifacts = application.getModel().getPlugins();
 
-        for (PluginArtifact artifact : artifacts) {
+        for (Artifact artifact : artifacts) {
             try {
                 loadPlugin(application, artifact);
             }
@@ -123,7 +127,7 @@
         }
     }
 
-    private void loadPlugin(final Application application, final PluginArtifact artifact)
throws Exception {
+    private void loadPlugin(final Application application, final Artifact artifact) throws
Exception {
         assert application != null;
         assert artifact != null;
 
@@ -157,7 +161,7 @@
         eventPublisher.publish(new PluginLoadedEvent(plugin, artifact));
     }
 
-    private ClassPath loadClassPath(final Application application, final PluginArtifact artifact)
throws Exception {
+    private ClassPath loadClassPath(final Application application, final Artifact artifact)
throws Exception {
         assert application != null;
         assert artifact != null;
 
@@ -174,7 +178,7 @@
             record.set(classPath);
         }
         record.close();
-        
+
         if (log.isDebugEnabled()) {
             log.debug("Plugin classpath:");
 
@@ -186,35 +190,73 @@
         return classPath;
     }
 
-    public void loadPlugin(final PluginArtifact artifact) throws Exception {
+    public void loadPlugin(final Artifact artifact) throws Exception {
         assert applicationManager != null;
         loadPlugin(applicationManager.getApplication(), artifact);
     }
 
-    private Set<Artifact> resolveArtifacts(final Application application, final PluginArtifact
artifact) throws Exception {
+    private Set<Artifact> resolveArtifacts(final Application application, final Artifact
artifact) throws Exception {
         assert application != null;
         assert artifact != null;
 
         log.debug("Resolving plugin artifacts");
-        
-        ArtifactResolutionRequest request = new ArtifactResolutionRequest();
-        request.setFilter(new PluginArtifactFilter(application));
 
         Set<Artifact> artifacts = new LinkedHashSet<Artifact>();
-        assert artifactManager != null;
-        ArtifactFactory factory = artifactManager.getArtifactFactory();
 
-        Artifact pluginArtifact = factory.createArtifact(artifact.getGroupId(), artifact.getArtifactId(),
artifact.getVersion(), /*scope*/null, artifact.getType());
-        assert pluginArtifact != null;
+        ResolveOptions options = new ResolveOptions();
+        options.setOutputReport(true);
+        options.setTransitive(true);
+        options.setArtifactFilter(new PluginArtifactFilter(application));
+
+        ModuleDescriptor md = createPluginModuleDescriptor(artifact);
+
+        StopWatch watch = new StopWatch(true);
 
-        log.debug("Plugin artifact: {}", pluginArtifact);
+        ResolveReport resolveReport = ivy.resolve(md, options);
 
-        artifacts.add(pluginArtifact);
+        log.debug("Resolve completed in: {}", watch);
 
-        request.setArtifactDependencies(artifacts);
+        if (resolveReport.hasError()) {
+            log.error("Report has errors:");
+            // noinspection unchecked
+            List<String> problems = resolveReport.getAllProblemMessages();
+            for (String problem : problems) {
+                log.error("    {}", problem);
+            }
+        }
+
+        log.debug("Plugin artifacts:");
+        for (ArtifactDownloadReport downloadReport : resolveReport.getAllArtifactsReports())
{
+            org.apache.ivy.core.module.descriptor.Artifact downloadedArtifact = downloadReport.getArtifact();
+            ModuleRevisionId id = downloadedArtifact.getModuleRevisionId();
+
+            Artifact resolved = new Artifact();
+            resolved.setGroupId(id.getOrganisation());
+            resolved.setArtifactId(id.getName());
+            resolved.setVersion(id.getRevision());
+            resolved.setType(downloadedArtifact.getType());
+            resolved.setFile(downloadReport.getLocalFile());
+            artifacts.add(resolved);
+            
+            log.debug("    {}", resolved.getId());
+        }
+
+        return artifacts;
+    }
+
+    private ModuleDescriptor createPluginModuleDescriptor(final Artifact artifact) {
+        assert artifact != null;
 
-        ArtifactResolutionResult result = artifactManager.resolve(request);
+        ModuleRevisionId pluginId = ModuleRevisionId.newInstance("gshell.plugin-" + artifact.getGroupId(),
artifact.getArtifactId(), artifact.getVersion());
+        DefaultModuleDescriptor md = new DefaultModuleDescriptor(pluginId, "integration",
null, true);
+        md.addConfiguration(new Configuration("default"));
+        md.setLastModified(System.currentTimeMillis());
+
+        ModuleRevisionId depId = ModuleRevisionId.newInstance(artifact.getGroupId(), artifact.getArtifactId(),
artifact.getVersion());
+        DefaultDependencyDescriptor dd = new DefaultDependencyDescriptor(md, depId, /* force
*/ false, /* changing*/ false, /* transitive */ true);
+        dd.addDependencyConfiguration("default", "default");
+        md.addDependency(dd);
 
-        return result.getArtifacts();
+        return md;
     }
 }
\ No newline at end of file

Modified: geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/shell/ShellImpl.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/shell/ShellImpl.java?rev=705650&r1=705649&r2=705650&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/shell/ShellImpl.java
(original)
+++ geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/shell/ShellImpl.java
Fri Oct 17 08:53:19 2008
@@ -31,7 +31,7 @@
 import org.apache.geronimo.gshell.console.completer.AggregateCompleter;
 import org.apache.geronimo.gshell.io.IO;
 import org.apache.geronimo.gshell.io.Closer;
-import org.apache.geronimo.gshell.model.application.Branding;
+import org.apache.geronimo.gshell.model.Branding;
 import org.apache.geronimo.gshell.notification.ExitNotification;
 import org.apache.geronimo.gshell.shell.Shell;
 import org.apache.geronimo.gshell.shell.ShellContext;

Modified: geronimo/gshell/trunk/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/pom.xml?rev=705650&r1=705649&r2=705650&view=diff
==============================================================================
--- geronimo/gshell/trunk/pom.xml (original)
+++ geronimo/gshell/trunk/pom.xml Fri Oct 17 08:53:19 2008
@@ -104,12 +104,6 @@
             </dependency>
 
             <dependency>
-                <groupId>org.codehaus.plexus</groupId>
-                <artifactId>plexus-utils</artifactId>
-                <version>1.5.5</version>
-            </dependency>
-
-            <dependency>
                 <groupId>junit</groupId>
                 <artifactId>junit</artifactId>
                 <version>3.8.2</version>
@@ -186,12 +180,6 @@
 
             <dependency>
                 <groupId>org.apache.geronimo.gshell.support</groupId>
-                <artifactId>gshell-artifact</artifactId>
-                <version>1.0-alpha-2-SNAPSHOT</version>
-            </dependency>
-
-            <dependency>
-                <groupId>org.apache.geronimo.gshell.support</groupId>
                 <artifactId>gshell-io</artifactId>
                 <version>1.0-alpha-2-SNAPSHOT</version>
             </dependency>



Mime
View raw message