geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From djen...@apache.org
Subject svn commit: r380294 - in /geronimo/branches/configid/plugins/geronimo-assembly-plugin: ./ src/java/org/apache/geronimo/plugin/assembly/
Date Fri, 24 Feb 2006 01:45:28 GMT
Author: djencks
Date: Thu Feb 23 17:45:26 2006
New Revision: 380294

URL: http://svn.apache.org/viewcvs?rev=380294&view=rev
Log:
Fix the assembly plugin to work with m2 repo and environment object.

Added:
    geronimo/branches/configid/plugins/geronimo-assembly-plugin/src/java/org/apache/geronimo/plugin/assembly/RepoCopier.java
Modified:
    geronimo/branches/configid/plugins/geronimo-assembly-plugin/plugin.jelly
    geronimo/branches/configid/plugins/geronimo-assembly-plugin/src/java/org/apache/geronimo/plugin/assembly/BaseConfigInstaller.java
    geronimo/branches/configid/plugins/geronimo-assembly-plugin/src/java/org/apache/geronimo/plugin/assembly/LocalConfigInstaller.java
    geronimo/branches/configid/plugins/geronimo-assembly-plugin/src/java/org/apache/geronimo/plugin/assembly/RepoConfigInstaller.java

Modified: geronimo/branches/configid/plugins/geronimo-assembly-plugin/plugin.jelly
URL: http://svn.apache.org/viewcvs/geronimo/branches/configid/plugins/geronimo-assembly-plugin/plugin.jelly?rev=380294&r1=380293&r2=380294&view=diff
==============================================================================
--- geronimo/branches/configid/plugins/geronimo-assembly-plugin/plugin.jelly (original)
+++ geronimo/branches/configid/plugins/geronimo-assembly-plugin/plugin.jelly Thu Feb 23 17:45:26
2006
@@ -19,18 +19,22 @@
 <!-- $Rev: 158417 $ $Date: 2005-03-20 23:25:45 -0800 (Sun, 20 Mar 2005) $ -->
 
 <project
-    xmlns:j="jelly:core"
-    xmlns:artifact="artifact"
-    xmlns:ant="jelly:ant"
-    xmlns:define="jelly:define"
-    xmlns:m="jelly:maven"
-    xmlns:velocity="jelly:velocity"
-    xmlns:assemble="geronimo:assembly"
-    >
+        xmlns:j="jelly:core"
+        xmlns:artifact="artifact"
+        xmlns:ant="jelly:ant"
+        xmlns:define="jelly:define"
+        xmlns:m="jelly:maven"
+        xmlns:velocity="jelly:velocity"
+        xmlns:assemble="geronimo:assembly"
+        >
 
     <define:taglib uri="geronimo:assembly">
-        <define:jellybean name="installConfig" className="org.apache.geronimo.plugin.assembly.LocalConfigInstaller"
method="execute"/>
-        <define:jellybean name="installConfigToRepo" className="org.apache.geronimo.plugin.assembly.RepoConfigInstaller"
method="execute"/>
+        <define:jellybean name="installConfig" className="org.apache.geronimo.plugin.assembly.LocalConfigInstaller"
+                          method="execute"/>
+        <define:jellybean name="installConfigToRepo" className="org.apache.geronimo.plugin.assembly.RepoConfigInstaller"
+                          method="execute"/>
+        <define:jellybean name="repoCopier" className="org.apache.geronimo.plugin.assembly.RepoCopier"
+                          method="execute"/>
     </define:taglib>
 
     <goal name="assemble:assemble-prepare">
@@ -39,7 +43,8 @@
             <ant:fileset dir="${geronimo.assembly.src}"/>
         </ant:copy>
         <ant:mkdir dir="${geronimo.assembly.dest}/var/config"/>
-        <velocity:merge basedir="${geronimo.assembly.src}/var/config" template="config.xml"
name="${geronimo.assembly.dest}/var/config/config.xml"/>
+        <velocity:merge basedir="${geronimo.assembly.src}/var/config" template="config.xml"
+                        name="${geronimo.assembly.dest}/var/config/config.xml"/>
     </goal>
 
     <goal name="assemble:assemble-lib">
@@ -50,7 +55,8 @@
                 <j:forEach var="artifact" items="${pom.artifacts}">
                     <j:set var="dependency" value="${artifact.dependency}"/>
                     <j:if test="${dependency.getProperty('geronimo.assemble') == 'library'}">
-                        <ant:include name="${dependency.getArtifactDirectory()}/${dependency.getType()}s/${dependency.getArtifact()}"/>
+                        <ant:include
+                                name="${dependency.getArtifactDirectory()}/${dependency.getType()}s/${dependency.getArtifact()}"/>
                         <j:set var="hasLib" value="true"/>
                     </j:if>
                 </j:forEach>
@@ -67,7 +73,8 @@
                 <j:forEach var="artifact" items="${pom.artifacts}">
                     <j:set var="dependency" value="${artifact.dependency}"/>
                     <j:if test="${dependency.getProperty('geronimo.assemble') == 'endorsed'}">
-                        <ant:include name="${dependency.getArtifactDirectory()}/${dependency.getType()}s/${dependency.getArtifact()}"/>
+                        <ant:include
+                                name="${dependency.getArtifactDirectory()}/${dependency.getType()}s/${dependency.getArtifact()}"/>
                         <j:set var="hasEndorsed" value="true"/>
                     </j:if>
                 </j:forEach>
@@ -83,7 +90,8 @@
                 <j:forEach var="artifact" items="${pom.artifacts}">
                     <j:set var="dependency" value="${artifact.dependency}"/>
                     <j:if test="${dependency.getProperty('geronimo.assemble') == 'extension'}">
-                        <ant:include name="${dependency.getArtifactDirectory()}/${dependency.getType()}s/${dependency.getArtifact()}"/>
+                        <ant:include
+                                name="${dependency.getArtifactDirectory()}/${dependency.getType()}s/${dependency.getArtifact()}"/>
                         <j:set var="hasExtension" value="true"/>
                     </j:if>
                 </j:forEach>
@@ -96,21 +104,19 @@
 
     <goal name="assemble:assemble-repository">
         <ant:mkdir dir="${geronimo.assembly.dest}/repository"/>
-        <ant:copy todir="${geronimo.assembly.dest}/repository">
-            <ant:fileset dir="${maven.repo.local}">
-                <j:set var="hasRepo" value="false"/>
-                <j:forEach var="artifact" items="${pom.artifacts}">
-                    <j:set var="dependency" value="${artifact.dependency}"/>
-                    <j:if test="${dependency.getProperty('geronimo.assemble') == 'repository'
|| dependency.getProperty('geronimo.assemble') == 'library' || dependency.getProperty('geronimo.assemble')
== 'endorsed' || dependency.getProperty('geronimo.assemble') == 'extension'}">
-                        <ant:include name="${dependency.getArtifactDirectory()}/${dependency.getType()}s/${dependency.getArtifact()}"/>
-                        <j:set var="hasRepo" value="true"/>
-                    </j:if>
-                </j:forEach>
-                <j:if test="${hasRepo == 'false'}">
-                    <ant:exclude name="**/*"/>
-                </j:if>
-            </ant:fileset>
-        </ant:copy>
+        <j:forEach var="artifact" items="${pom.artifacts}">
+            <j:set var="dependency" value="${artifact.dependency}"/>
+            <j:if test="${dependency.getProperty('geronimo.assemble') == 'repository'
|| dependency.getProperty('geronimo.assemble') == 'library' || dependency.getProperty('geronimo.assemble')
== 'endorsed' || dependency.getProperty('geronimo.assemble') == 'extension'}">
+                <assemble:repoCopier
+                        targetRepositoryFile="${geronimo.assembly.dest}/repository"
+                        sourceRepositoryFile="${maven.repo.local}"
+                        groupId="${dependency.getGroupId()}"
+                        artifactId="${dependency.getArtifactId()}"
+                        version="${dependency.getVersion()}"
+                        type="${dependency.getType()}"
+                        />
+            </j:if>
+        </j:forEach>
     </goal>
 
     <goal name="assemble:assemble-unpack">
@@ -121,7 +127,8 @@
                 <j:forEach var="artifact" items="${pom.artifacts}">
                     <j:set var="dependency" value="${artifact.dependency}"/>
                     <j:if test="${dependency.getProperty('geronimo.assemble') == 'unpack'}">
-                        <ant:include name="${dependency.getArtifactDirectory()}/${dependency.getType()}s/${dependency.getArtifact()}"/>
+                        <ant:include
+                                name="${dependency.getArtifactDirectory()}/${dependency.getType()}s/${dependency.getArtifact()}"/>
                         <j:set var="hasUnpack" value="true"/>
                     </j:if>
                 </j:forEach>
@@ -157,7 +164,6 @@
     </goal>
 
 
-
     <!-- todo automatically add libraries listed in an executable's MCP in the right place,
relative to it -->
     <goal name="assemble:assemble-configurations">
         <j:set var="configStoreDir" value="${geronimo.assembly.dest}/config-store"/>
@@ -169,16 +175,17 @@
             <j:if test="${dependency.type == 'car'}">
                 <j:if test="${dependency.getProperty('geronimo.assemble') == 'install'}">
                     <assemble:installConfig
-                        targetRoot="${geronimo.assembly.dest}"
-                        targetConfigStore="config-store"
-                        targetRepository="repository"
-                        sourceRepository="${maven.repo.local}"
-                        artifact="${dependency.getGroupId()}/${dependency.getArtifactId()}/${dependency.getVersion()}/${dependency.getType()}"/>
+                            targetRoot="${geronimo.assembly.dest}"
+                            targetConfigStore="config-store"
+                            targetRepository="repository"
+                            sourceRepository="${maven.repo.local}"
+                            artifact="${dependency.getGroupId()}/${dependency.getArtifactId()}/${dependency.getVersion()}/${dependency.getType()}"/>
                 </j:if>
 
                 <!-- handle executable configs -->
                 <j:if test="${dependency.getProperty('geronimo.assemble.executable') !=
null}">
-                    <j:set var="exe" value="${geronimo.assembly.dest}/${dependency.getProperty('geronimo.assemble.executable')}"/>
+                    <j:set var="exe"
+                           value="${geronimo.assembly.dest}/${dependency.getProperty('geronimo.assemble.executable')}"/>
                     <ant:copy tofile="${exe}" file="${artifact.file}"/>
                     <ant:chmod file="${exe}" perm="ugo+rx"/>
                 </j:if>
@@ -196,16 +203,17 @@
             <j:if test="${dependency.type == 'car'}">
                 <j:if test="${dependency.getProperty('geronimo.assemble') == 'install'}">
                     <assemble:installConfigToRepo
-                        targetRoot="${geronimo.assembly.dest}"
-                        targetConfigStore="config-store"
-                        targetRepository="repository"
-                        sourceRepository="${maven.repo.local}"
-                        artifact="${dependency.getGroupId()}/${dependency.getArtifactId()}/${dependency.getVersion()}/${dependency.getType()}"/>
+                            targetRoot="${geronimo.assembly.dest}"
+                            targetConfigStore="config-store"
+                            targetRepository="repository"
+                            sourceRepository="${maven.repo.local}"
+                            artifact="${dependency.getGroupId()}/${dependency.getArtifactId()}/${dependency.getVersion()}/${dependency.getType()}"/>
                 </j:if>
 
                 <!-- handle executable configs -->
                 <j:if test="${dependency.getProperty('geronimo.assemble.executable') !=
null}">
-                    <j:set var="exe" value="${geronimo.assembly.dest}/${dependency.getProperty('geronimo.assemble.executable')}"/>
+                    <j:set var="exe"
+                           value="${geronimo.assembly.dest}/${dependency.getProperty('geronimo.assemble.executable')}"/>
                     <ant:copy tofile="${exe}" file="${artifact.file}"/>
                     <ant:chmod file="${exe}" perm="ugo+rx"/>
                 </j:if>
@@ -221,7 +229,8 @@
         <attainGoal name="assemble:assemble-schemas"/>
     </goal>
 
-    <goal name="assemble:assemble-to-repo" prereqs="assemble:assemble-prepare" description="Assemble
a Geronimo installation">
+    <goal name="assemble:assemble-to-repo" prereqs="assemble:assemble-prepare"
+          description="Assemble a Geronimo installation">
         <attainGoal name="assemble:assemble-repository"/>
         <attainGoal name="assemble:assemble-lib"/>
         <attainGoal name="assemble:assemble-unpack"/>
@@ -230,43 +239,46 @@
         <attainGoal name="assemble:assemble-schemas"/>
     </goal>
     <goal name="assemble:assemble-installer-helpers">
-        <ant:copy todir="${geronimo.assembly.dest}/var/temp" >
-           <ant:fileset file="${maven.repo.local}/geronimo/plugins/geronimo-assembly-plugin-${geronimo_assembly_plugin_version}.jar"/>
+        <ant:copy todir="${geronimo.assembly.dest}/var/temp">
+            <ant:fileset
+                    file="${maven.repo.local}/geronimo/plugins/geronimo-assembly-plugin-${geronimo_assembly_plugin_version}.jar"/>
         </ant:copy>
-        <ant:copy todir="${geronimo.assembly.dest}/var/temp" >
-           <ant:fileset file="${maven.repo.local}/geronimo/jars/geronimo-installer-processing-${pom.currentVersion}.jar"/>
+        <ant:copy todir="${geronimo.assembly.dest}/var/temp">
+            <ant:fileset
+                    file="${maven.repo.local}/geronimo/jars/geronimo-installer-processing-${pom.currentVersion}.jar"/>
         </ant:copy>
         <j:set var="configStoreDir" value="${geronimo.assembly.dest}/config-store"/>
         <!--        <ant:delete dir="${configStoreDir}"/>-->
         <ant:mkdir dir="${configStoreDir}"/>
         <ant:mkdir dir="${geronimo.assembly.dest}/var/config"/>
-        <j:file name="${geronimo.assembly.dest}/var/config/configure.xml" outputMode="xml"
escapeText="false" trim="true" prettyPrint="false">
-           &lt;!-- used only for install. This file may be removed. --&gt;
-           &lt;configurations&gt;
-        <j:set var="DS" value="$" />
-        <j:set var="LB" value="{" />
-        <j:set var="RB" value="}" />
-        <j:forEach var="artifact" items="${pom.artifacts}">
-            <!-- One for each configuration -->
-            <j:set var="dependency" value="${artifact.dependency}"/>
-            <j:if test="${dependency.type == 'car'}">
+        <j:file name="${geronimo.assembly.dest}/var/config/configure.xml" outputMode="xml"
escapeText="false"
+                trim="true" prettyPrint="false">
+            &lt;!-- used only for install. This file may be removed. --&gt;
+            &lt;configurations&gt;
+            <j:set var="DS" value="$"/>
+            <j:set var="LB" value="{"/>
+            <j:set var="RB" value="}"/>
+            <j:forEach var="artifact" items="${pom.artifacts}">
+                <!-- One for each configuration -->
+                <j:set var="dependency" value="${artifact.dependency}"/>
+                <j:if test="${dependency.type == 'car'}">
 
                     &lt;configuration&gt;
-                <j:if test="${dependency.getProperty('geronimo.assemble') == 'install'}">
-                    <j:set var="PACK" value="${dependency.getProperty('geronimo.pack')}"/>
-                      &lt;artifact&gt;${dependency.getGroupId()}/${dependency.getArtifactId()}/${dependency.getVersion()}/${dependency.getType()}&lt;/artifact&gt;
-                      &lt;selected&gt;${DS}${LB}${PACK}${RB}&lt;/selected&gt;
-                </j:if>
-                <!-- handle executable configs -->
-                <j:if test="${dependency.getProperty('geronimo.assemble.executable') !=
null}">
-                    <j:set var="exe" value="${dependency.getProperty('geronimo.assemble.executable')}"/>
-                      &lt;executable&gt;${exe}&lt;/executable&gt;
-                </j:if>
+                    <j:if test="${dependency.getProperty('geronimo.assemble') == 'install'}">
+                        <j:set var="PACK" value="${dependency.getProperty('geronimo.pack')}"/>
+                        &lt;artifact&gt;${dependency.getGroupId()}/${dependency.getArtifactId()}/${dependency.getVersion()}/${dependency.getType()}&lt;/artifact&gt;
+                        &lt;selected&gt;${DS}${LB}${PACK}${RB}&lt;/selected&gt;
+                    </j:if>
+                    <!-- handle executable configs -->
+                    <j:if test="${dependency.getProperty('geronimo.assemble.executable')
!= null}">
+                        <j:set var="exe" value="${dependency.getProperty('geronimo.assemble.executable')}"/>
+                        &lt;executable&gt;${exe}&lt;/executable&gt;
+                    </j:if>
                     &lt;/configuration&gt;
 
-            </j:if>
-        </j:forEach>
-           &lt;/configurations&gt;
+                </j:if>
+            </j:forEach>
+            &lt;/configurations&gt;
         </j:file>
     </goal>
 
@@ -279,45 +291,45 @@
              Explicitly set execute permission on script files so builds on windows are consistent
with unix -->
 
         <!-- Establish patternset used by later fixcrlf processing -->
-        <ant:fileset dir="${geronimo.assembly.dest}" >
+        <ant:fileset dir="${geronimo.assembly.dest}">
             <!-- Patterns for text based files.  We don't touch *.bat as svn
                  should have eol-style set property to CRLF and *.sh we
                  force to have LF line endings (handle building on windows).  -->
             <ant:patternset id="geronimo.fixcrlf.patternset">
-                <ant:include name="**/*.dtd" />
-                <ant:include name="**/*.ent" />
-                <ant:include name="**/*.htm" />
-                <ant:include name="**/*.html" />
-                <ant:include name="**/*.java" />
-                <ant:include name="**/*.js" />
-                <ant:include name="**/*.jsp" />
-                <ant:include name="**/*.properties" />
-                <ant:include name="**/*.sql" />
-                <ant:include name="**/*.txt" />
-                <ant:include name="**/*.wsdl" />
-                <ant:include name="**/*.xml" />
-                <ant:include name="**/*.xsd" />
-                <ant:include name="**/*.xsl" />
-                <ant:include name="STATUS" />
+                <ant:include name="**/*.dtd"/>
+                <ant:include name="**/*.ent"/>
+                <ant:include name="**/*.htm"/>
+                <ant:include name="**/*.html"/>
+                <ant:include name="**/*.java"/>
+                <ant:include name="**/*.js"/>
+                <ant:include name="**/*.jsp"/>
+                <ant:include name="**/*.properties"/>
+                <ant:include name="**/*.sql"/>
+                <ant:include name="**/*.txt"/>
+                <ant:include name="**/*.wsdl"/>
+                <ant:include name="**/*.xml"/>
+                <ant:include name="**/*.xsd"/>
+                <ant:include name="**/*.xsl"/>
+                <ant:include name="STATUS"/>
             </ant:patternset>
         </ant:fileset>
 
         <!-- ensure shell scripts have LF end of lines for both the
              tar.gz and zip file -->
         <ant:fixcrlf srcdir="${geronimo.assembly.dest}" eol="lf">
-            <ant:include name="**/*.sh" />
+            <ant:include name="**/*.sh"/>
         </ant:fixcrlf>
 
         <!-- Create a zip file -->
         <j:if test="${context.getVariable('geronimo.assembly.zip') == 'true'}">
             <ant:echo>Preparing CRLF line endings in text based files for zip
-            distribution</ant:echo>
+                distribution</ant:echo>
             <!-- The zip distribution shall have CRLF line
             endings and is targeted at Windows platforms.  Non-Windows platforms
             should use the tar distribution, as it contains extra file attributes
             such as permissions. Since we cannot assume we are running on a Windows
             platform, we fix line endings in the zip distribution to be CRLF's. -->
-            <ant:fixcrlf  srcdir="${geronimo.assembly.dest}" eol="crlf">
+            <ant:fixcrlf srcdir="${geronimo.assembly.dest}" eol="crlf">
                 <patternset refid="geronimo.fixcrlf.patternset"/>
             </ant:fixcrlf>
 
@@ -370,7 +382,7 @@
         <j:if test="${context.getVariable('geronimo.assembly.tar') == 'true'}">
             <ant:mkdir dir="${maven.repo.local}/${pom.groupId}/distributions"/>
             <ant:copy file="${maven.build.dir}/${maven.final.name}.tar.gz"
-                todir="${maven.repo.local}/${pom.groupId}/distributions"/>
+                      todir="${maven.repo.local}/${pom.groupId}/distributions"/>
             <!--            <artifact:install-->
             <!--                artifact="${maven.build.dir}/${maven.final.name}.tar.gz"-->
             <!--                type="distribution-targz"-->
@@ -380,7 +392,7 @@
         <j:if test="${context.getVariable('geronimo.assembly.zip') == 'true'}">
             <ant:mkdir dir="${maven.repo.local}/${pom.groupId}/distributions"/>
             <ant:copy file="${maven.build.dir}/${maven.final.name}.zip"
-                todir="${maven.repo.local}/${pom.groupId}/distributions"/>
+                      todir="${maven.repo.local}/${pom.groupId}/distributions"/>
             <!--            <artifact:install-->
             <!--                artifact="${maven.build.dir}/${maven.final.name}.zip"-->
             <!--                type="distribution-zip"-->

Modified: geronimo/branches/configid/plugins/geronimo-assembly-plugin/src/java/org/apache/geronimo/plugin/assembly/BaseConfigInstaller.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/configid/plugins/geronimo-assembly-plugin/src/java/org/apache/geronimo/plugin/assembly/BaseConfigInstaller.java?rev=380294&r1=380293&r2=380294&view=diff
==============================================================================
--- geronimo/branches/configid/plugins/geronimo-assembly-plugin/src/java/org/apache/geronimo/plugin/assembly/BaseConfigInstaller.java
(original)
+++ geronimo/branches/configid/plugins/geronimo-assembly-plugin/src/java/org/apache/geronimo/plugin/assembly/BaseConfigInstaller.java
Thu Feb 23 17:45:26 2006
@@ -19,8 +19,14 @@
 import org.apache.geronimo.gbean.GBeanData;
 import org.apache.geronimo.kernel.config.InvalidConfigException;
 import org.apache.geronimo.kernel.repository.Artifact;
+import org.apache.geronimo.kernel.repository.ArtifactManager;
+import org.apache.geronimo.kernel.repository.ArtifactResolver;
+import org.apache.geronimo.kernel.repository.DefaultArtifactManager;
+import org.apache.geronimo.kernel.repository.DefaultArtifactResolver;
 import org.apache.geronimo.kernel.repository.Environment;
 import org.apache.geronimo.kernel.repository.FileWriteMonitor;
+import org.apache.geronimo.kernel.repository.ListableRepository;
+import org.apache.geronimo.kernel.repository.MissingDependencyException;
 import org.apache.geronimo.kernel.repository.Repository;
 import org.apache.geronimo.kernel.repository.WriteableRepository;
 
@@ -28,6 +34,7 @@
 import java.io.FileInputStream;
 import java.io.IOException;
 import java.io.InputStream;
+import java.util.ArrayList;
 import java.util.Iterator;
 import java.util.LinkedHashSet;
 
@@ -97,19 +104,28 @@
         this.sourceRepository = sourceRepository;
     }
 
-    protected void execute(InstallAdapter installAdapter, Repository sourceRepo, WriteableRepository
targetRepo) throws IOException, InvalidConfigException {
+    protected void execute(InstallAdapter installAdapter, ListableRepository sourceRepo,
WriteableRepository targetRepo) throws IOException, InvalidConfigException, MissingDependencyException
{
         Artifact configId = Artifact.create(artifact);
-        execute(configId, installAdapter, sourceRepo,  targetRepo);
+        ArtifactManager artifactManager = new DefaultArtifactManager();
+        ArtifactResolver artifactResolver = new DefaultArtifactResolver(artifactManager,
sourceRepo);
+        execute(configId, installAdapter, sourceRepo, targetRepo, artifactManager, artifactResolver);
     }
 
-    protected void execute(Artifact configId, InstallAdapter installAdapter, Repository sourceRepo,
WriteableRepository targetRepo) throws IOException, InvalidConfigException {
+    protected void execute(Artifact configId, InstallAdapter installAdapter, Repository sourceRepo,
WriteableRepository targetRepo, ArtifactManager artifactManager, ArtifactResolver artifactResolver)
throws IOException, InvalidConfigException, MissingDependencyException {
         if (installAdapter.containsConfiguration(configId)) {
             System.out.println("Configuration " + configId + " already present in configuration
store");
             return;
         }
         GBeanData config = installAdapter.install(sourceRepo, configId);
         Environment environment = (Environment) config.getAttribute("environment");
+        LinkedHashSet imports = environment.getImports();
+        recursiveExecute(artifactResolver, imports, installAdapter, sourceRepo, targetRepo,
artifactManager);
+
+        LinkedHashSet references = environment.getReferences();
+        recursiveExecute(artifactResolver, references, installAdapter, sourceRepo, targetRepo,
artifactManager);
+
         LinkedHashSet dependencies = environment.getDependencies();
+        dependencies = recursiveResolve(artifactResolver, dependencies, sourceRepo);
         System.out.println("Installed configuration " + configId);
 
         FileWriteMonitor monitor = new StartFileWriteMonitor();
@@ -129,9 +145,30 @@
         if (parentId != null) {
             for (int i = 0; i < parentId.length; i++) {
                 Artifact parent = parentId[i];
-                execute(parent, installAdapter, sourceRepo, targetRepo);
+                execute(parent, installAdapter, sourceRepo, targetRepo, artifactManager,
artifactResolver);
+            }
+        }
+    }
+
+    private void recursiveExecute(ArtifactResolver artifactResolver, LinkedHashSet imports,
InstallAdapter installAdapter, Repository sourceRepo, WriteableRepository targetRepo, ArtifactManager
artifactManager) throws MissingDependencyException, IOException, InvalidConfigException {
+        imports = artifactResolver.resolve(imports);
+        for (Iterator iterator = imports.iterator(); iterator.hasNext();) {
+            Artifact parentId = (Artifact) iterator.next();
+            execute(parentId, installAdapter, sourceRepo, targetRepo, artifactManager, artifactResolver);
+        }
+    }
+
+    private LinkedHashSet recursiveResolve(ArtifactResolver artifactResolver, LinkedHashSet
dependencies, Repository repository) throws MissingDependencyException {
+        dependencies = artifactResolver.resolve(dependencies);
+        for (Iterator iterator = new ArrayList(dependencies).iterator(); iterator.hasNext();)
{
+            Artifact dependency = (Artifact) iterator.next();
+            if (repository.contains(dependency)) {
+                LinkedHashSet subDependencies = repository.getDependencies(dependency);
+                subDependencies = recursiveResolve(artifactResolver, subDependencies, repository);
+                dependencies.addAll(subDependencies);
             }
         }
+        return dependencies;
     }
 
     protected interface InstallAdapter {
@@ -141,7 +178,7 @@
         boolean containsConfiguration(Artifact configID);
     }
 
-    protected static class StartFileWriteMonitor implements FileWriteMonitor {
+    static class StartFileWriteMonitor implements FileWriteMonitor {
         public void writeStarted(String fileDescription) {
             System.out.println("Copying " + fileDescription);
         }

Modified: geronimo/branches/configid/plugins/geronimo-assembly-plugin/src/java/org/apache/geronimo/plugin/assembly/LocalConfigInstaller.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/configid/plugins/geronimo-assembly-plugin/src/java/org/apache/geronimo/plugin/assembly/LocalConfigInstaller.java?rev=380294&r1=380293&r2=380294&view=diff
==============================================================================
--- geronimo/branches/configid/plugins/geronimo-assembly-plugin/src/java/org/apache/geronimo/plugin/assembly/LocalConfigInstaller.java
(original)
+++ geronimo/branches/configid/plugins/geronimo-assembly-plugin/src/java/org/apache/geronimo/plugin/assembly/LocalConfigInstaller.java
Thu Feb 23 17:45:26 2006
@@ -21,6 +21,7 @@
 import org.apache.geronimo.kernel.config.InvalidConfigException;
 import org.apache.geronimo.kernel.config.NoSuchConfigException;
 import org.apache.geronimo.kernel.repository.Artifact;
+import org.apache.geronimo.kernel.repository.ListableRepository;
 import org.apache.geronimo.kernel.repository.Repository;
 import org.apache.geronimo.system.configuration.LocalConfigStore;
 import org.apache.geronimo.system.repository.Maven1Repository;
@@ -45,7 +46,7 @@
             public GBeanData install(Repository sourceRepo, Artifact configId) throws IOException,
InvalidConfigException {
                 File artifact = sourceRepo.getLocation(configId);
                 store.install(artifact.toURL(), configId);
-                GBeanData config = null;
+                GBeanData config;
                 try {
                     config = store.loadConfiguration(configId);
                 } catch (NoSuchConfigException e) {
@@ -58,7 +59,7 @@
                 return store.containsConfiguration(configID);
             }
         };
-        Repository sourceRepo = new Maven1Repository(getSourceRepository());
+        ListableRepository sourceRepo = new Maven1Repository(getSourceRepository());
         Maven2Repository targetRepo = new Maven2Repository(new File(targetRoot, targetRepository));
 
         try {

Modified: geronimo/branches/configid/plugins/geronimo-assembly-plugin/src/java/org/apache/geronimo/plugin/assembly/RepoConfigInstaller.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/configid/plugins/geronimo-assembly-plugin/src/java/org/apache/geronimo/plugin/assembly/RepoConfigInstaller.java?rev=380294&r1=380293&r2=380294&view=diff
==============================================================================
--- geronimo/branches/configid/plugins/geronimo-assembly-plugin/src/java/org/apache/geronimo/plugin/assembly/RepoConfigInstaller.java
(original)
+++ geronimo/branches/configid/plugins/geronimo-assembly-plugin/src/java/org/apache/geronimo/plugin/assembly/RepoConfigInstaller.java
Thu Feb 23 17:45:26 2006
@@ -17,21 +17,22 @@
 
 package org.apache.geronimo.plugin.assembly;
 
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.ObjectInputStream;
-import java.net.URL;
-
 import org.apache.geronimo.gbean.GBeanData;
 import org.apache.geronimo.kernel.config.InvalidConfigException;
 import org.apache.geronimo.kernel.repository.Artifact;
+import org.apache.geronimo.kernel.repository.ListableRepository;
 import org.apache.geronimo.kernel.repository.Repository;
 import org.apache.geronimo.kernel.repository.WriteableRepository;
 import org.apache.geronimo.system.repository.Maven1Repository;
 import org.apache.geronimo.system.repository.Maven2Repository;
 
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.ObjectInputStream;
+import java.net.URL;
+
 /**
  * JellyBean that installs configuration artifacts into a repository based ConfigurationStore,
 It also copies all
  * configuration dependencies into the repository
@@ -41,7 +42,7 @@
 public class RepoConfigInstaller extends BaseConfigInstaller {
 
     public void execute() throws Exception {
-        Repository sourceRepo = new Maven1Repository(getSourceRepository());
+        ListableRepository sourceRepo = new Maven1Repository(getSourceRepository());
         Maven2Repository targetRepo = new Maven2Repository(new File(targetRoot, targetRepository));
         InstallAdapter installAdapter = new CopyConfigStore(targetRepo);
 

Added: geronimo/branches/configid/plugins/geronimo-assembly-plugin/src/java/org/apache/geronimo/plugin/assembly/RepoCopier.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/configid/plugins/geronimo-assembly-plugin/src/java/org/apache/geronimo/plugin/assembly/RepoCopier.java?rev=380294&view=auto
==============================================================================
--- geronimo/branches/configid/plugins/geronimo-assembly-plugin/src/java/org/apache/geronimo/plugin/assembly/RepoCopier.java
(added)
+++ geronimo/branches/configid/plugins/geronimo-assembly-plugin/src/java/org/apache/geronimo/plugin/assembly/RepoCopier.java
Thu Feb 23 17:45:26 2006
@@ -0,0 +1,102 @@
+/**
+ *
+ * Copyright 2006 The Apache Software Foundation
+ *
+ *  Licensed 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.
+ */
+
+package org.apache.geronimo.plugin.assembly;
+
+import org.apache.geronimo.kernel.repository.Artifact;
+import org.apache.geronimo.kernel.repository.MissingDependencyException;
+import org.apache.geronimo.kernel.repository.Repository;
+import org.apache.geronimo.kernel.repository.WriteableRepository;
+import org.apache.geronimo.system.repository.Maven1Repository;
+import org.apache.geronimo.system.repository.Maven2Repository;
+
+import java.io.File;
+import java.io.IOException;
+
+/**
+ * @version $Rev:$ $Date:$
+ */
+public class RepoCopier {
+
+    private File sourceRepositoryFile;
+    private File targetRepositoryFile;
+    private String groupId;
+    private String artifactId;
+    private String version;
+    private String type;
+
+    public File getSourceRepositoryFile() {
+        return sourceRepositoryFile;
+    }
+
+    public void setSourceRepositoryFile(File sourceRepositoryFile) {
+        this.sourceRepositoryFile = sourceRepositoryFile;
+    }
+
+    public File getTargetRepositoryFile() {
+        return targetRepositoryFile;
+    }
+
+    public void setTargetRepositoryFile(File targetRepositoryFile) {
+        this.targetRepositoryFile = targetRepositoryFile;
+    }
+
+    public String getGroupId() {
+        return groupId;
+    }
+
+    public void setGroupId(String groupId) {
+        this.groupId = groupId;
+    }
+
+    public String getArtifactId() {
+        return artifactId;
+    }
+
+    public void setArtifactId(String artifactId) {
+        this.artifactId = artifactId;
+    }
+
+    public String getVersion() {
+        return version;
+    }
+
+    public void setVersion(String version) {
+        this.version = version;
+    }
+
+    public String getType() {
+        return type;
+    }
+
+    public void setType(String type) {
+        this.type = type;
+    }
+
+    public void execute() throws MissingDependencyException, IOException {
+        Artifact configId = new Artifact(groupId, artifactId, version, type);
+        Repository sourceRepository = new Maven1Repository(sourceRepositoryFile);
+        WriteableRepository targetRepository = new Maven2Repository(targetRepositoryFile);
+        if (!sourceRepository.contains(configId)) {
+            throw new MissingDependencyException("source repository at " + sourceRepositoryFile
+ " does not contain artifact " + configId);
+        }
+        if (!targetRepository.contains(configId)) {
+            File sourceFile = sourceRepository.getLocation(configId);
+            targetRepository.copyToRepository(sourceFile, configId, new BaseConfigInstaller.StartFileWriteMonitor());
+        }
+    }
+}



Mime
View raw message