You are viewing a plain text version of this content. The canonical link for it is here.
Posted to scm@geronimo.apache.org by dj...@apache.org on 2005/11/22 05:59:07 UTC
svn commit: r348085 - in /geronimo/trunk: assemblies/j2ee-installer/
assemblies/j2ee-installer/src/ plugins/geronimo-assembly-plugin/
plugins/geronimo-assembly-plugin/src/java/org/apache/geronimo/plugin/assembly/
Author: djencks
Date: Mon Nov 21 20:59:00 2005
New Revision: 348085
URL: http://svn.apache.org/viewcvs?rev=348085&view=rev
Log:
make the assembly plugin more flexible, plugging in source and targets
Added:
geronimo/trunk/assemblies/j2ee-installer/
- copied from r348063, geronimo/trunk/assemblies/j2ee-jetty-server/
geronimo/trunk/assemblies/j2ee-installer/LICENSE.txt
- copied unchanged from r348059, geronimo/trunk/assemblies/j2ee-jetty-server/LICENSE.txt
geronimo/trunk/assemblies/j2ee-installer/NOTICE.txt
- copied unchanged from r348059, geronimo/trunk/assemblies/j2ee-jetty-server/NOTICE.txt
geronimo/trunk/assemblies/j2ee-installer/maven.xml
- copied, changed from r348059, geronimo/trunk/assemblies/j2ee-jetty-server/maven.xml
geronimo/trunk/assemblies/j2ee-installer/project.properties
- copied unchanged from r348059, geronimo/trunk/assemblies/j2ee-jetty-server/project.properties
geronimo/trunk/assemblies/j2ee-installer/project.xml
- copied unchanged from r348059, geronimo/trunk/assemblies/j2ee-jetty-server/project.xml
geronimo/trunk/assemblies/j2ee-installer/src/
- copied from r348059, geronimo/trunk/assemblies/j2ee-jetty-server/src/
geronimo/trunk/plugins/geronimo-assembly-plugin/src/java/org/apache/geronimo/plugin/assembly/BaseConfigInstaller.java
geronimo/trunk/plugins/geronimo-assembly-plugin/src/java/org/apache/geronimo/plugin/assembly/RepoConfigInstaller.java
Modified:
geronimo/trunk/plugins/geronimo-assembly-plugin/plugin.jelly
geronimo/trunk/plugins/geronimo-assembly-plugin/src/java/org/apache/geronimo/plugin/assembly/LocalConfigInstaller.java
Copied: geronimo/trunk/assemblies/j2ee-installer/maven.xml (from r348059, geronimo/trunk/assemblies/j2ee-jetty-server/maven.xml)
URL: http://svn.apache.org/viewcvs/geronimo/trunk/assemblies/j2ee-installer/maven.xml?p2=geronimo/trunk/assemblies/j2ee-installer/maven.xml&p1=geronimo/trunk/assemblies/j2ee-jetty-server/maven.xml&r1=348059&r2=348085&rev=348085&view=diff
==============================================================================
--- geronimo/trunk/assemblies/j2ee-jetty-server/maven.xml (original)
+++ geronimo/trunk/assemblies/j2ee-installer/maven.xml Mon Nov 21 20:59:00 2005
@@ -21,6 +21,6 @@
<project default="default"
>
- <goal name="default" prereqs="geronimo:package-assembly"/>
+ <goal name="default" prereqs="geronimo:assemble-to-repo"/>
</project>
Modified: geronimo/trunk/plugins/geronimo-assembly-plugin/plugin.jelly
URL: http://svn.apache.org/viewcvs/geronimo/trunk/plugins/geronimo-assembly-plugin/plugin.jelly?rev=348085&r1=348084&r2=348085&view=diff
==============================================================================
--- geronimo/trunk/plugins/geronimo-assembly-plugin/plugin.jelly (original)
+++ geronimo/trunk/plugins/geronimo-assembly-plugin/plugin.jelly Mon Nov 21 20:59:00 2005
@@ -30,6 +30,7 @@
<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:taglib>
<goal name="geronimo:assemble-prepare">
@@ -102,7 +103,6 @@
</ant:copy>
</goal>
- <!-- todo automatically add dependencies from configurations into the repo -->
<!-- todo automatically add libraries listed in an executable's MCP in the right place, relative to it -->
<goal name="geronimo:assemble-configurations">
<j:set var="configStoreDir" value="${geronimo.assembly.dest}/config-store"/>
@@ -114,11 +114,38 @@
<j:if test="${dependency.type == 'car'}">
<j:if test="${dependency.getProperty('geronimo.assemble') == 'install'}">
<assemble:installConfig
- root="${geronimo.assembly.dest}"
- configStore="config-store"
- repository="repository"
- mavenRepoLocal="${maven.repo.local}"
- artifact="${artifact.file}"/>
+ targetRoot="${geronimo.assembly.dest}"
+ targetConfigStore="config-store"
+ targetRepository="repository"
+ sourceRepository="${maven.repo.local}"
+ artifact="${dependency.getArtifactDirectory()}/${dependency.getType()}s/${dependency.getArtifact()}"/>
+ </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')}"/>
+ <ant:copy tofile="${exe}" file="${artifact.file}"/>
+ <ant:chmod file="${exe}" perm="ugo+rx"/>
+ </j:if>
+ </j:if>
+ </j:forEach>
+ </goal>
+
+ <goal name="geronimo:assemble-configurations-to-repo">
+ <j:set var="configStoreDir" value="${geronimo.assembly.dest}/config-store"/>
+ <ant:delete dir="${configStoreDir}"/>
+ <ant:mkdir dir="${configStoreDir}"/>
+ <ant:mkdir dir="${geronimo.assembly.dest}/repository"/>
+ <j:forEach var="artifact" items="${pom.artifacts}">
+ <j:set var="dependency" value="${artifact.dependency}"/>
+ <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.getArtifactDirectory()}/${dependency.getType()}s/${dependency.getArtifact()}"/>
</j:if>
<!-- handle executable configs -->
@@ -135,6 +162,12 @@
<attainGoal name="geronimo:assemble-repository"/>
<attainGoal name="geronimo:assemble-lib"/>
<attainGoal name="geronimo:assemble-configurations"/>
+ </goal>
+
+ <goal name="geronimo:assemble-to-repo" prereqs="geronimo:assemble-prepare" description="Assemble a Geronimo installation">
+ <attainGoal name="geronimo:assemble-repository"/>
+ <attainGoal name="geronimo:assemble-lib"/>
+ <attainGoal name="geronimo:assemble-configurations-to-repo"/>
</goal>
<goal name="geronimo:jar-assembly" prereqs="geronimo:assemble">
Added: geronimo/trunk/plugins/geronimo-assembly-plugin/src/java/org/apache/geronimo/plugin/assembly/BaseConfigInstaller.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/plugins/geronimo-assembly-plugin/src/java/org/apache/geronimo/plugin/assembly/BaseConfigInstaller.java?rev=348085&view=auto
==============================================================================
--- geronimo/trunk/plugins/geronimo-assembly-plugin/src/java/org/apache/geronimo/plugin/assembly/BaseConfigInstaller.java (added)
+++ geronimo/trunk/plugins/geronimo-assembly-plugin/src/java/org/apache/geronimo/plugin/assembly/BaseConfigInstaller.java Mon Nov 21 20:59:00 2005
@@ -0,0 +1,140 @@
+/**
+ *
+ * Copyright 2005 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 java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.List;
+import java.util.Iterator;
+import java.net.URI;
+import java.net.URL;
+
+import org.apache.geronimo.system.configuration.LocalConfigStore;
+import org.apache.geronimo.system.repository.FileSystemRepository;
+import org.apache.geronimo.kernel.repository.Repository;
+import org.apache.geronimo.kernel.repository.FileWriteMonitor;
+import org.apache.geronimo.kernel.config.InvalidConfigException;
+import org.apache.geronimo.gbean.GBeanData;
+
+/**
+ * @version $Rev: $ $Date: $
+ */
+public class BaseConfigInstaller {
+ /**
+ * root file of the targetConfigStore and TargetRepository. Typically $GERONIMO_HOME of the
+ * geronimo server being assembled
+ */
+ protected File targetRoot;
+ /**
+ * location of the target config store relative to targetRoot. Typically "config-store"
+ */
+ protected String targetConfigStore;
+ /**
+ * location of the target repository relative to targetRoot. Typically "repository"
+ */
+ protected String targetRepository;
+ /**
+ * location of the configuration to be installed relative to the sourceRepository
+ */
+ private String artifact;
+ /**
+ * location of the source repository for the dependencies
+ */
+ private File sourceRepository;
+ protected URI sourceRepositoryURI;
+
+ public File getTargetRoot() {
+ return targetRoot;
+ }
+
+ public void setTargetRoot(File targetRoot) {
+ this.targetRoot = targetRoot;
+ }
+
+ public String getTargetConfigStore() {
+ return targetConfigStore;
+ }
+
+ public void setTargetConfigStore(String targetConfigStore) {
+ this.targetConfigStore = targetConfigStore;
+ }
+
+ public String getTargetRepository() {
+ return targetRepository;
+ }
+
+ public void setTargetRepository(String targetRepository) {
+ this.targetRepository = targetRepository;
+ }
+
+ public String getArtifact() {
+ return artifact;
+ }
+
+ public void setArtifact(String artifact) {
+ this.artifact = artifact;
+ }
+
+ public File getSourceRepository() {
+ return sourceRepository;
+ }
+
+ public void setSourceRepository(File sourceRepository) {
+ this.sourceRepository = sourceRepository;
+ sourceRepositoryURI = sourceRepository.toURI();
+ }
+
+ protected void execute(InstallAdapter installAdapter, Repository sourceRepo, FileSystemRepository targetRepo) throws IOException, InvalidConfigException {
+ List dependencies = installAdapter.install(sourceRepo, artifact);
+ System.out.println("Installed configuration " + artifact);
+
+ FileWriteMonitor monitor = new StartFileWriteMonitor();
+
+ for (Iterator iterator = dependencies.iterator(); iterator.hasNext();) {
+ URI dependency = (URI) iterator.next();
+ if (!sourceRepo.hasURI(dependency)) {
+ throw new RuntimeException("Dependency: " + dependency + " not found in local maven repo: for configuration: " + artifact);
+ }
+ if (!targetRepo.hasURI(dependency)) {
+ URL sourceURL = sourceRepo.getURL(dependency);
+ InputStream in = sourceURL.openStream();
+ targetRepo.copyToRepository(in, dependency, monitor);
+ }
+ }
+ }
+
+ protected interface InstallAdapter {
+
+ List install(Repository sourceRepo, String artifactPath) throws IOException, InvalidConfigException;
+
+ }
+
+ protected static class StartFileWriteMonitor implements FileWriteMonitor {
+ public void writeStarted(String fileDescription) {
+ System.out.println("Copying " + fileDescription);
+ }
+
+ public void writeProgress(int bytes) {
+
+ }
+
+ public void writeComplete(int bytes) {
+
+ }
+ }
+}
Modified: geronimo/trunk/plugins/geronimo-assembly-plugin/src/java/org/apache/geronimo/plugin/assembly/LocalConfigInstaller.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/plugins/geronimo-assembly-plugin/src/java/org/apache/geronimo/plugin/assembly/LocalConfigInstaller.java?rev=348085&r1=348084&r2=348085&view=diff
==============================================================================
--- geronimo/trunk/plugins/geronimo-assembly-plugin/src/java/org/apache/geronimo/plugin/assembly/LocalConfigInstaller.java (original)
+++ geronimo/trunk/plugins/geronimo-assembly-plugin/src/java/org/apache/geronimo/plugin/assembly/LocalConfigInstaller.java Mon Nov 21 20:59:00 2005
@@ -19,88 +19,41 @@
import java.io.File;
import java.io.IOException;
-import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URI;
import java.net.URL;
-import java.util.Iterator;
import java.util.List;
import org.apache.geronimo.gbean.GBeanData;
-import org.apache.geronimo.kernel.repository.FileWriteMonitor;
+import org.apache.geronimo.kernel.config.InvalidConfigException;
import org.apache.geronimo.kernel.repository.Repository;
import org.apache.geronimo.system.configuration.LocalConfigStore;
import org.apache.geronimo.system.repository.FileSystemRepository;
/**
- * JellyBean that installs configuration artifacts into a LocalConfigurationStore
+ * JellyBean that installs configuration artifacts into a LocalConfigurationStore, It also copies all
+ * configuration dependencies into the repository
*
* @version $Rev: 156292 $ $Date: 2005-03-05 18:48:02 -0800 (Sat, 05 Mar 2005) $
*/
-public class LocalConfigInstaller {
- private File root;
- private String configStore;
- private String repository;
- private File artifact;
- private File mavenRepoLocal;
- private URI mavenRepoLocalURI;
-
- public File getRoot() {
- return root;
- }
-
- public void setRoot(File root) {
- this.root = root;
- }
-
- public String getConfigStore() {
- return configStore;
- }
-
- public void setConfigStore(String configStore) {
- this.configStore = configStore;
- }
-
- public String getRepository() {
- return repository;
- }
-
- public void setRepository(String repository) {
- this.repository = repository;
- }
-
- public File getArtifact() {
- return artifact;
- }
-
- public void setArtifact(File artifact) {
- this.artifact = artifact;
- }
-
- public File getMavenRepoLocal() {
- return mavenRepoLocal;
- }
-
- public void setMavenRepoLocal(File mavenRepoLocal) {
- this.mavenRepoLocal = mavenRepoLocal;
- mavenRepoLocalURI = mavenRepoLocal.toURI();
- }
+public class LocalConfigInstaller extends BaseConfigInstaller {
public void execute() throws Exception {
- LocalConfigStore store = new LocalConfigStore(new File(root, configStore));
+ final LocalConfigStore store = new LocalConfigStore(new File(targetRoot, targetConfigStore));
store.doStart();
- GBeanData config;
- try {
- config = store.install2(artifact.toURL());
- System.out.println("Installed configuration " + config.getAttribute("id"));
- } finally{
- store.doStop();
- }
- URI rootURI = root.toURI().resolve(repository);
+ InstallAdapter installAdapter = new InstallAdapter() {
+
+ public List install(Repository sourceRepo, String artifactPath) throws IOException, InvalidConfigException {
+ URL artifact = sourceRepo.getURL(URI.create(artifactPath));
+ GBeanData config = store.install2(artifact);
+ List dependencies = (List) config.getAttribute("dependencies");
+ return dependencies;
+ }
+ };
Repository sourceRepo = new Repository() {
public boolean hasURI(URI uri) {
- uri = mavenRepoLocalURI.resolve(uri);
+ uri = sourceRepositoryURI.resolve(uri);
if ("file".equals(uri.getScheme())) {
return new File(uri).canRead();
} else {
@@ -114,39 +67,24 @@
}
public URL getURL(URI uri) throws MalformedURLException {
- uri = mavenRepoLocalURI.resolve(uri);
+ uri = sourceRepositoryURI.resolve(uri);
return uri.toURL();
}
};
-
+ URI rootURI = targetRoot.toURI().resolve(targetRepository);
FileSystemRepository targetRepo = new FileSystemRepository(rootURI, null);
targetRepo.doStart();
- List dependencies = (List) config.getAttribute("dependencies");
- FileWriteMonitor monitor = new FileWriteMonitor() {
-
- public void writeStarted(String fileDescription) {
- System.out.println("Copying " + fileDescription);
- }
- public void writeProgress(int bytes) {
-
- }
-
- public void writeComplete(int bytes) {
-
- }
- };
-
- for (Iterator iterator = dependencies.iterator(); iterator.hasNext();) {
- URI dependency = (URI) iterator.next();
- if (!sourceRepo.hasURI(dependency)) {
- throw new RuntimeException("Dependency: " + dependency + " not found in local maven repo: for configuration: " + config.getAttribute("id"));
- }
- if (!targetRepo.hasURI(dependency)) {
- URL sourceURL = sourceRepo.getURL(dependency);
- InputStream in = sourceURL.openStream();
- targetRepo.copyToRepository(in, dependency, monitor);
+ try {
+ try {
+ execute(installAdapter, sourceRepo, targetRepo);
+ } finally {
+ store.doStop();
}
+ } finally {
+ targetRepo.doStop();
}
+
}
+
}
Added: geronimo/trunk/plugins/geronimo-assembly-plugin/src/java/org/apache/geronimo/plugin/assembly/RepoConfigInstaller.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/plugins/geronimo-assembly-plugin/src/java/org/apache/geronimo/plugin/assembly/RepoConfigInstaller.java?rev=348085&view=auto
==============================================================================
--- geronimo/trunk/plugins/geronimo-assembly-plugin/src/java/org/apache/geronimo/plugin/assembly/RepoConfigInstaller.java (added)
+++ geronimo/trunk/plugins/geronimo-assembly-plugin/src/java/org/apache/geronimo/plugin/assembly/RepoConfigInstaller.java Mon Nov 21 20:59:00 2005
@@ -0,0 +1,117 @@
+/**
+ *
+ * Copyright 2003-2004 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 java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.ObjectInputStream;
+import java.net.MalformedURLException;
+import java.net.URI;
+import java.net.URL;
+import java.util.List;
+
+import org.apache.geronimo.gbean.GBeanData;
+import org.apache.geronimo.kernel.config.InvalidConfigException;
+import org.apache.geronimo.kernel.repository.Repository;
+import org.apache.geronimo.system.repository.FileSystemRepository;
+
+/**
+ * JellyBean that installs configuration artifacts into a repository based ConfigurationStore, It also copies all
+ * configuration dependencies into the repository
+ *
+ * @version $Rev: 156292 $ $Date: 2005-03-05 18:48:02 -0800 (Sat, 05 Mar 2005) $
+ */
+public class RepoConfigInstaller extends BaseConfigInstaller {
+
+ public void execute() throws Exception {
+ Repository sourceRepo = new Repository() {
+
+ public boolean hasURI(URI uri) {
+ uri = sourceRepositoryURI.resolve(uri);
+ if ("file".equals(uri.getScheme())) {
+ return new File(uri).canRead();
+ } else {
+ try {
+ uri.toURL().openStream().close();
+ return true;
+ } catch (IOException e) {
+ return false;
+ }
+ }
+ }
+
+ public URL getURL(URI uri) throws MalformedURLException {
+ uri = sourceRepositoryURI.resolve(uri);
+ return uri.toURL();
+ }
+ };
+ URI rootURI = targetRoot.toURI().resolve(targetRepository);
+ FileSystemRepository targetRepo = new FileSystemRepository(rootURI, null);
+ InstallAdapter installAdapter = new CopyConfigStore(targetRepo);
+ targetRepo.doStart();
+
+ try {
+ execute(installAdapter, sourceRepo, targetRepo);
+ } finally {
+ targetRepo.doStop();
+ }
+
+ }
+
+ private static class CopyConfigStore implements InstallAdapter {
+
+ private final FileSystemRepository targetRepo;
+
+ public CopyConfigStore(FileSystemRepository targetRepo) {
+ this.targetRepo = targetRepo;
+ }
+
+ public List install(Repository sourceRepo, String artifactPath) throws IOException, InvalidConfigException {
+ URI destination = URI.create(artifactPath);
+ URL sourceURL = sourceRepo.getURL(destination);
+ InputStream in = sourceURL.openStream();
+ try {
+ if (!targetRepo.hasURI(destination)) {
+ targetRepo.copyToRepository(in, destination, new StartFileWriteMonitor());
+ }
+ } finally {
+ in.close();
+ }
+ URL targetURL = targetRepo.getURL(destination);
+ GBeanData config = new GBeanData();
+ URL baseURL = new URL("jar:" + targetURL.toString() + "!/");
+ InputStream jis = null;
+ try {
+ URL stateURL = new URL(baseURL, "META-INF/config.ser");
+ jis = stateURL.openStream();
+ ObjectInputStream ois = new ObjectInputStream(jis);
+ config.readExternal(ois);
+ } catch (ClassNotFoundException e) {
+ throw new InvalidConfigException("Unable to load class from config: " + destination, e);
+ } finally {
+ if (jis != null) {
+ jis.close();
+ }
+ }
+ List dependencies = (List) config.getAttribute("dependencies");
+ return dependencies;
+ }
+ }
+
+}