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 2004/01/24 20:50:04 UTC
cvs commit: incubator-geronimo/modules/maven-plugin maven.xml plugin.jelly project.xml
djencks 2004/01/24 11:50:04
Modified: . maven.xml
modules/deployment/src/java/org/apache/geronimo/deployment
ModuleDeployer.java
modules/deployment/src/java/org/apache/geronimo/deployment/tools
DeployCommand.java
Added: modules/maven-plugin maven.xml plugin.jelly project.xml
Log:
maven plugin for running DeployCommand. Example target in top-level maven.xml file (although the files referenced are missing)
Revision Changes Path
1.56 +16 -5 incubator-geronimo/maven.xml
Index: maven.xml
===================================================================
RCS file: /home/cvs/incubator-geronimo/maven.xml,v
retrieving revision 1.55
retrieving revision 1.56
diff -u -r1.55 -r1.56
--- maven.xml 22 Jan 2004 01:37:44 -0000 1.55
+++ maven.xml 24 Jan 2004 19:50:04 -0000 1.56
@@ -8,11 +8,20 @@
xmlns:ant="jelly:ant"
xmlns:maven="jelly:maven"
xmlns:define="jelly:define"
+ xmlns:deploy="geronimo:deploy"
xmlns:aggregate="local:aggregate"
xmlns:modules="local:modules">
<j:set var="release.id" value="${pom.standardToLegacyId(pom.id)}-${pom.currentVersion}"/>
+ <goal name="deploy:test">
+ <ant:echo message="in deploy:test"/>
+ <deploy:deploy
+ deployconfigid="org/apache/geronimo/Default"
+ deployoutfile="target/Test.car"
+ deployurl="geronimo-service.xml"/>
+ <ant:echo message="did deploy:test"/>
+ </goal>
<!-- ======= -->
<!-- Modules -->
<!-- ======= -->
@@ -670,12 +679,13 @@
<include name="concurrent-1.3.2.jar"/>
</fileset>
<!-- connector openjca loading test -->
- <fileset dir="${maven.repo.local}/openejb-jca/jars">
+ <!-- uncomment if you want to load this connector. Also set the path in bootstrapped-service.xml-->
+ <!--fileset dir="${maven.repo.local}/openejb-jca/jars">
<include name="openejb-jca-DEV.jar"/>
</fileset>
<fileset dir="${maven.repo.local}/hsqldb/jars">
<include name="hsqldb-1.7.1.jar"/>
- </fileset>
+ </fileset-->
<!-- WebDAV, not required for boot. To be fixed.-->
<fileset dir="${maven.repo.local}/tomcat/jars">
<include name="catalina-5.0.16.jar"/>
@@ -765,12 +775,13 @@
<include name="concurrent-1.3.2.jar"/>
</fileset>
<!-- connector openjca loading test -->
- <fileset dir="${maven.repo.local}/openejb-jca/jars">
+ <!-- uncomment if you want to load this connector. Also set the path in bootstrapped-service.xml-->
+ <!--fileset dir="${maven.repo.local}/openejb-jca/jars">
<include name="openejb-jca-DEV.jar"/>
</fileset>
<fileset dir="${maven.repo.local}/hsqldb/jars">
<include name="hsqldb-1.7.1.jar"/>
- </fileset>
+ </fileset-->
<!-- WebDAV, not required for boot. To be fixed.-->
<fileset dir="${maven.repo.local}/tomcat/jars">
<include name="catalina-5.0.16.jar"/>
1.3 +7 -2 incubator-geronimo/modules/deployment/src/java/org/apache/geronimo/deployment/ModuleDeployer.java
Index: ModuleDeployer.java
===================================================================
RCS file: /home/cvs/incubator-geronimo/modules/deployment/src/java/org/apache/geronimo/deployment/ModuleDeployer.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- ModuleDeployer.java 24 Jan 2004 02:56:23 -0000 1.2
+++ ModuleDeployer.java 24 Jan 2004 19:50:04 -0000 1.3
@@ -156,7 +156,12 @@
}
ClassLoader cl;
if (parent == null) {
- cl = new URLClassLoader(urls);
+ //Use in maven plugin seems to require access to the classloader used to load this class,
+ //not just the SystemClassLoader. DeployCommand sets the thread context classloader.
+ // If I understand Maven correctly it will load using a classloader including the
+ //dependencies specified in the plugins project.xml file.
+ //cl = new URLClassLoader(urls);
+ cl = new URLClassLoader(urls, Thread.currentThread().getContextClassLoader());
} else {
cl = new URLClassLoader(urls, parent.getClassLoader());
}
1.6 +54 -10 incubator-geronimo/modules/deployment/src/java/org/apache/geronimo/deployment/tools/DeployCommand.java
Index: DeployCommand.java
===================================================================
RCS file: /home/cvs/incubator-geronimo/modules/deployment/src/java/org/apache/geronimo/deployment/tools/DeployCommand.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- DeployCommand.java 23 Jan 2004 19:58:17 -0000 1.5
+++ DeployCommand.java 24 Jan 2004 19:50:04 -0000 1.6
@@ -63,18 +63,20 @@
import java.net.URISyntaxException;
import java.net.URL;
import java.util.ArrayList;
+import java.util.Iterator;
import java.util.List;
+import java.util.StringTokenizer;
import java.util.jar.JarOutputStream;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
-import org.apache.geronimo.deployment.URLDeployer;
+import org.apache.geronimo.deployment.DeploymentException;
import org.apache.geronimo.deployment.NoDeployerException;
-import org.apache.geronimo.deployment.util.FileUtil;
+import org.apache.geronimo.deployment.URLDeployer;
import org.apache.geronimo.deployment.service.ServiceDeployer;
-import org.apache.geronimo.deployment.DeploymentException;
+import org.apache.geronimo.deployment.util.FileUtil;
import org.apache.geronimo.deployment.util.URLInfo;
import org.apache.geronimo.deployment.util.URLType;
@@ -89,9 +91,20 @@
public DeployCommand(File configFile, URI configID, File workDir, List deployers) {
this.configFile = configFile;
+ Thread.currentThread().setContextClassLoader(this.getClass().getClassLoader());
batcher = new URLDeployer(null, configID, deployers, workDir);
}
+ public DeployCommand(File configFile, URI configID, File workDir, List deployers, List urls) throws IOException, DeploymentException, NoDeployerException {
+ this.configFile = configFile;
+ Thread.currentThread().setContextClassLoader(this.getClass().getClassLoader());
+ batcher = new URLDeployer(null, configID, deployers, workDir);
+ for (Iterator iterator = urls.iterator(); iterator.hasNext();) {
+ URL url = (URL) iterator.next();
+ add(url);
+ }
+ }
+
public void add(URL url) throws IOException, DeploymentException, NoDeployerException {
URLType type = URLType.getType(url);
batcher.addSource(new URLInfo(url, type));
@@ -105,6 +118,23 @@
jos.close();
}
+ //used by maven plugin
+ public static void deploy(String configIDString, String outfile, String urlsString) throws IOException, URISyntaxException, DeploymentException, NoDeployerException {
+ URI configID = null;
+ configID = new URI(configIDString);
+ List urls = new ArrayList();
+ for (StringTokenizer st = new StringTokenizer(urlsString, ","); st.hasMoreTokens();) {
+ String url = st.nextToken();
+ File source = new File(url);
+ urls.add(source.toURL());
+ }
+ File configFile = new File(outfile);
+ File workDir = createWorkDir();
+ List deployers = getDeployers();
+ DeployCommand deployer = new DeployCommand(configFile, configID, workDir, deployers, urls);
+ deployer.deploy();
+ }
+
public static void main(String[] args) {
if (args.length < 3) {
System.err.println("usage: " + DeployCommand.class.getName() + " <configID> <outfile> <url>+");
@@ -119,31 +149,38 @@
System.exit(1);
throw new AssertionError();
}
+ System.out.println("found configID: " + configID);
File configFile = new File(args[1]);
File workDir;
try {
- workDir = File.createTempFile("deployer", "");
- workDir.delete();
- workDir.mkdir();
+ workDir = createWorkDir();
} catch (IOException e) {
System.err.println("Unable to create working directory");
System.exit(2);
throw new AssertionError();
}
+ System.out.println("work dir: " + workDir.getAbsolutePath());
List deployers = getDeployers();
- DeployCommand deployer = new DeployCommand(configFile, configID, workDir, deployers);
int status = 0;
+ List urls = new ArrayList();
try {
for (int i = 2; i < args.length; i++) {
File source = new File(args[i]);
- deployer.add(source.toURL());
+ urls.add(source.toURL());
}
- deployer.deploy();
} catch (Exception e) {
e.printStackTrace();
status = 2;
+ }
+ try {
+ DeployCommand deployer = new DeployCommand(configFile, configID, workDir, deployers, urls);
+ deployer.deploy();
+ System.out.println("deployed successfully");
+ } catch (Exception e) {
+ e.printStackTrace();
+ status = 3;
} finally {
FileUtil.recursiveDelete(workDir);
}
@@ -159,6 +196,13 @@
} catch (ParserConfigurationException e) {
throw new AssertionError("Unable to instantiate XML Parser");
}
+ }
+
+ private static File createWorkDir() throws IOException {
+ File workDir = File.createTempFile("deployer", "");
+ workDir.delete();
+ workDir.mkdir();
+ return workDir;
}
}
1.1 incubator-geronimo/modules/maven-plugin/maven.xml
Index: maven.xml
===================================================================
<?xml version="1.0" encoding="UTF-8"?>
<!-- $Revision: 1.1 $ $Date: 2004/01/24 19:50:04 $ -->
<project default="default"
xmlns:j="jelly:core"
xmlns:u="jelly:util"
xmlns:ant="jelly:ant"
xmlns:maven="jelly:maven"
xmlns:define="jelly:define"
xmlns:deploy="geronimo:deploy">
<!-- ================= -->
<!-- Global Properties -->
<!-- ================= -->
<!-- Determine what the top-level project root is -->
<j:set var="project.root" value="${pom.parentBasedir().getParentFile().getCanonicalFile()}"/>
<!-- Load the global properties -->
<ant:property file="${project.root}/etc/global.properties"/>
<!-- ==================== -->
<!-- Default Global Goals -->
<!-- ==================== -->
<goal name="default">
<attainGoal name="plugin:install"/>
</goal>
<goal name="build">
<attainGoal name="default"/>
</goal>
<goal name="rebuild">
<attainGoal name="clean"/>
<attainGoal name="build"/>
</goal>
</project>
1.1 incubator-geronimo/modules/maven-plugin/plugin.jelly
Index: plugin.jelly
===================================================================
<?xml version="1.0"?>
<!-- ================================================================== -->
<!-- Geronimo deployment plugin -->
<!-- ================================================================== -->
<project xmlns:j="jelly:core"
xmlns:u="jelly:util"
xmlns:ant="jelly:ant"
xmlns:maven="jelly:maven"
xmlns:define="jelly:define"
xmlns:deploy="geronimo:deploy"
>
<define:taglib uri="geronimo:deploy">
<!-- DeployCommand <configID> <outfile> <url>+ -->
<!-- DeployCommand org/apache/geronimo/Default /tmp/default.car jetty-service.xml -->
<define:tag name="deploy" xmlns="jelly:ant">
<j:if test="${deployconfigid == null}">
<fail>Missing required attribute: deployconfigid</fail>
</j:if>
<j:if test="${deployoutfile == null}">
<fail>Missing required attribute: deployoutfile</fail>
</j:if>
<j:if test="${deployurl == null}">
<fail>Missing required attribute: deployurl</fail>
</j:if>
<j:invokeStatic var="dummy" className="org.apache.geronimo.deployment.tools.DeployCommand" method="deploy">
<j:arg type="java.lang.String" value="${deployconfigid}"/>
<j:arg type="java.lang.String" value="${deployoutfile}"/>
<j:arg type="java.lang.String" value="${deployurl}"/>
</j:invokeStatic>
</define:tag>
</define:taglib>
</project>
1.1 incubator-geronimo/modules/maven-plugin/project.xml
Index: project.xml
===================================================================
<?xml version="1.0" encoding="ISO-8859-1"?>
<project>
<pomVersion>3</pomVersion>
<id>geronimo-maven-plugin</id>
<name>Geronimo maven deployment plugin</name>
<groupId>geronimo</groupId>
<currentVersion>DEV</currentVersion>
<organization>
<name>Apache Software Foundation</name>
<url>http://www.apache.org/</url>
<logo></logo>
</organization>
<inceptionYear>2004</inceptionYear>
<package>org.apache.geronimo</package>
<logo></logo>
<dependencies>
<dependency>
<groupId>xml-commons-resolver</groupId>
<artifactId>xml-commons-resolver</artifactId>
<version>1.1</version>
<properties>
<classloader>root</classloader>
</properties>
</dependency>
<dependency>
<groupId>geronimo</groupId>
<artifactId>geronimo-common</artifactId>
<version>DEV</version>
<properties>
<classloader>root</classloader>
</properties>
</dependency>
<dependency>
<groupId>geronimo</groupId>
<artifactId>geronimo-kernel</artifactId>
<version>DEV</version>
<properties>
<classloader>root</classloader>
</properties>
</dependency>
<dependency>
<groupId>geronimo</groupId>
<artifactId>geronimo-deployment</artifactId>
<version>DEV</version>
<properties>
<classloader>root</classloader>
</properties>
</dependency>
<dependency>
<id>commons-logging</id>
<version>1.0.3</version>
<url>http://jakarta.apache.org/commons/logging/</url>
<properties>
<classloader>root</classloader>
</properties>
</dependency>
<dependency>
<id>log4j</id>
<version>1.2.8</version>
<url>http://jakarta.apache.org/log4j</url>
<properties>
<classloader>root</classloader>
</properties>
</dependency>
<dependency>
<id>mx4j</id>
<version>SNAPSHOT</version>
<properties>
<classloader>root</classloader>
</properties>
</dependency>
<dependency>
<id>cglib</id>
<version>HEAD-20031109</version>
<url>http://cglib.sourceforge.net</url>
<properties>
<classloader>root</classloader>
</properties>
</dependency>
</dependencies>
<build>
<sourceDirectory>src/main</sourceDirectory>
<unitTestSourceDirectory>src/test</unitTestSourceDirectory>
<unitTest>
<includes>
<include>**/*Test.java</include>
</includes>
</unitTest>
<resources>
<resource>
<directory>src/plugin-resources</directory>
<targetPath>plugin-resources</targetPath>
</resource>
<resource>
<directory>.</directory>
<includes>
<include>plugin.jelly</include>
<include>plugin.properties</include>
<include>project.properties</include>
<include>project.xml</include>
</includes>
</resource>
</resources>
</build>
</project>