diff --git a/maven-artifact/src/main/java/org/apache/maven/artifact/handler/EjbHandler.java b/maven-artifact/src/main/java/org/apache/maven/artifact/handler/EjbHandler.java new file mode 100644 index 0000000000..4afda3d8e6 --- /dev/null +++ b/maven-artifact/src/main/java/org/apache/maven/artifact/handler/EjbHandler.java @@ -0,0 +1,35 @@ +package org.apache.maven.artifact.handler; + +/* + * Copyright 2001-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. + */ + +/** + * @author Jason van Zyl + * @version $Id$ + */ +public class EjbHandler + extends JarHandler +{ + public String directory() + { + return "ejbs"; + } + + public String packageGoal() + { + return "ejb:ejb"; + } +} diff --git a/maven-artifact/src/main/resources/META-INF/plexus/components.xml b/maven-artifact/src/main/resources/META-INF/plexus/components.xml index 4424880867..a03c3bb696 100644 --- a/maven-artifact/src/main/resources/META-INF/plexus/components.xml +++ b/maven-artifact/src/main/resources/META-INF/plexus/components.xml @@ -86,6 +86,12 @@ + + org.apache.maven.artifact.handler.ArtifactHandler + ejb + org.apache.maven.artifact.handler.EjbHandler + + org.apache.maven.artifact.handler.ArtifactHandler jar diff --git a/maven-core-it/README.txt b/maven-core-it/README.txt index 37ed559e4b..86e4e774c0 100644 --- a/maven-core-it/README.txt +++ b/maven-core-it/README.txt @@ -45,6 +45,8 @@ it0015: Test marmalade-driven mojo support. This will compile supporting java install the plugin, and finally use the new plugin. it0016: Test a WAR generation + +it0017: Test an EJB generation ------------------------------------------------------------------------------- - generated sources diff --git a/maven-core-it/integration-tests.txt b/maven-core-it/integration-tests.txt index 4745ccd700..00786000b0 100644 --- a/maven-core-it/integration-tests.txt +++ b/maven-core-it/integration-tests.txt @@ -12,3 +12,4 @@ it0012 it0013 it0015 it0016 +it0017 diff --git a/maven-core-it/it0017/.cvsignore b/maven-core-it/it0017/.cvsignore new file mode 100644 index 0000000000..dabb615d50 --- /dev/null +++ b/maven-core-it/it0017/.cvsignore @@ -0,0 +1,10 @@ +*~ +*.log +target +*.ipr +*.iws +dist +target +.classpath +.project +log.txt diff --git a/maven-core-it/it0017/expected-results.txt b/maven-core-it/it0017/expected-results.txt new file mode 100644 index 0000000000..50d0cfb5b1 --- /dev/null +++ b/maven-core-it/it0017/expected-results.txt @@ -0,0 +1,4 @@ +target/classes/org/apache/maven/it0017/Person.class +target/maven-core-it0017-1.0.jar +target/maven-core-it0017-1.0.jar!/META-INF/ejbjar.xml +target/maven-core-it0017-1.0.jar!/org/apache/maven/it0017/Person.class diff --git a/maven-core-it/it0017/goals.txt b/maven-core-it/it0017/goals.txt new file mode 100644 index 0000000000..ba3bd78738 --- /dev/null +++ b/maven-core-it/it0017/goals.txt @@ -0,0 +1 @@ +package diff --git a/maven-core-it/it0017/pom.xml b/maven-core-it/it0017/pom.xml new file mode 100644 index 0000000000..c7742c9f2a --- /dev/null +++ b/maven-core-it/it0017/pom.xml @@ -0,0 +1,7 @@ + + 4.0.0 + maven + maven-core-it0017 + ejb + 1.0 + \ No newline at end of file diff --git a/maven-core-it/it0017/src/main/java/org/apache/maven/it0017/Person.java b/maven-core-it/it0017/src/main/java/org/apache/maven/it0017/Person.java new file mode 100644 index 0000000000..b3610c9cc9 --- /dev/null +++ b/maven-core-it/it0017/src/main/java/org/apache/maven/it0017/Person.java @@ -0,0 +1,16 @@ +package org.apache.maven.it0017; + +public class Person +{ + private String name; + + public void setName( String name ) + { + this.name = name; + } + + public String getName() + { + return name; + } +} diff --git a/maven-core-it/it0017/src/main/resources/META-INF/ejb-jar.xml b/maven-core-it/it0017/src/main/resources/META-INF/ejb-jar.xml new file mode 100644 index 0000000000..ef027e8779 --- /dev/null +++ b/maven-core-it/it0017/src/main/resources/META-INF/ejb-jar.xml @@ -0,0 +1,22 @@ + + + + + Hello + org.apache.maven.it0017.HelloHome + org.apache.maven.it0017.Hello + org.apache.maven.it0017.HelloBean + Stateless + Container + + + + + + Hello + * + + Required + + + \ No newline at end of file diff --git a/maven-mboot2/src/main/java/MBoot.java b/maven-mboot2/src/main/java/MBoot.java index 2c25935ff6..048ca2bd54 100644 --- a/maven-mboot2/src/main/java/MBoot.java +++ b/maven-mboot2/src/main/java/MBoot.java @@ -81,10 +81,11 @@ public class MBoot "maven-plugin-tools/maven-plugin-tools-marmalade", "maven-core-it-verifier"}; String[] pluginBuilds = new String[]{"maven-plugins/maven-clean-plugin", "maven-plugins/maven-compiler-plugin", - "maven-plugins/maven-deploy-plugin", "maven-plugins/maven-install-plugin", - "maven-plugins/maven-jar-plugin", "maven-plugins/maven-plugin-plugin", - "maven-plugins/maven-pom-plugin", "maven-plugins/maven-resources-plugin", - "maven-plugins/maven-surefire-plugin", "maven-plugins/maven-war-plugin"}; + "maven-plugins/maven-deploy-plugin", "maven-plugins/maven-ejb-plugin", + "maven-plugins/maven-install-plugin", "maven-plugins/maven-jar-plugin", + "maven-plugins/maven-plugin-plugin", "maven-plugins/maven-pom-plugin", + "maven-plugins/maven-resources-plugin", "maven-plugins/maven-surefire-plugin", + "maven-plugins/maven-war-plugin"}; private static final Map MODELLO_TARGET_VERSIONS; diff --git a/maven-plugins/maven-compiler-plugin/src/main/java/org/apache/maven/plugin/CompilerMojo.java b/maven-plugins/maven-compiler-plugin/src/main/java/org/apache/maven/plugin/CompilerMojo.java index 8effbdef8d..00c4f92014 100644 --- a/maven-plugins/maven-compiler-plugin/src/main/java/org/apache/maven/plugin/CompilerMojo.java +++ b/maven-plugins/maven-compiler-plugin/src/main/java/org/apache/maven/plugin/CompilerMojo.java @@ -64,7 +64,7 @@ public class CompilerMojo { private Compiler compiler = new JavacCompiler(); - private boolean debug = false; + private boolean debug = true; public void execute( PluginExecutionRequest request, PluginExecutionResponse response ) throws Exception @@ -126,7 +126,7 @@ public class CompilerMojo message = "Warning! not present in repository!"; } - request.getLog().debug( "classpathElements[ " + i + " ] = " + classpathElement + ": " + message ); + request.getLog().info( "classpathElements[ " + i + " ] = " + classpathElement + ": " + message ); } } diff --git a/maven-plugins/maven-ejb-plugin/.cvsignore b/maven-plugins/maven-ejb-plugin/.cvsignore new file mode 100644 index 0000000000..cce9515ca7 --- /dev/null +++ b/maven-plugins/maven-ejb-plugin/.cvsignore @@ -0,0 +1,8 @@ +target +*~ +*.log +.classpath +.project +*.ipr +*.iws +*.iml diff --git a/maven-plugins/maven-ejb-plugin/pom.xml b/maven-plugins/maven-ejb-plugin/pom.xml new file mode 100644 index 0000000000..c90afa6d56 --- /dev/null +++ b/maven-plugins/maven-ejb-plugin/pom.xml @@ -0,0 +1,57 @@ + + + maven-plugin-parent + maven + 2.0-SNAPSHOT + + 4.0.0 + maven + maven-ejb-plugin + plugin + Maven EJB Plugin + 1.0-SNAPSHOT + + + plexus + plexus-container-default + 1.0-alpha-2-SNAPSHOT + jar + compile + + + plexus + plexus-archiver + 1.0-alpha-1-SNAPSHOT + jar + compile + + + maven + maven-archiver + 1.0-SNAPSHOT + jar + compile + + + maven + maven-artifact + 2.0-SNAPSHOT + jar + compile + + + maven + maven-core + 2.0-SNAPSHOT + jar + compile + + + maven + maven-model + 2.0-SNAPSHOT + jar + compile + + + \ No newline at end of file diff --git a/maven-plugins/maven-ejb-plugin/src/main/java/org/apache/maven/plugin/ejb/EjbMojo.java b/maven-plugins/maven-ejb-plugin/src/main/java/org/apache/maven/plugin/ejb/EjbMojo.java new file mode 100644 index 0000000000..fd4d725960 --- /dev/null +++ b/maven-plugins/maven-ejb-plugin/src/main/java/org/apache/maven/plugin/ejb/EjbMojo.java @@ -0,0 +1,171 @@ +package org.apache.maven.plugin.jar; + +/* + * Copyright 2001-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. + */ + +import org.apache.maven.archiver.MavenArchiver; +import org.apache.maven.plugin.AbstractPlugin; +import org.apache.maven.plugin.PluginExecutionRequest; +import org.apache.maven.plugin.PluginExecutionResponse; + +import java.io.File; + +/** + * @author Emmanuel Venisse + * @version $Id$ + * @goal ejb + * @phase package + * @description build an ejb + * @parameter name="jarName" + * type="String" + * required="true" + * validator="" + * expression="#project.build.finalName" + * description="" + * @parameter name="compress" + * type="String" + * required="false" + * validator="" + * expression="#maven.ejb.compress" + * default="true" + * description="" + * @parameter name="index" + * type="String" + * required="false" + * validator="" + * expression="#maven.ejb.index" + * default="false" + * description="" + * @parameter name="package" + * type="String" + * required="false" + * validator="" + * expression="#maven.ejb.package" + * description="" + * @parameter name="manifest" + * type="String" + * required="false" + * validator="" + * expression="#maven.ejb.manifest" + * description="" + * @parameter name="mainClass" + * type="String" + * required="false" + * validator="" + * expression="#maven.ejb.mainClass" + * description="" + * @parameter name="addClasspath" + * type="String" + * required="false" + * validator="" + * expression="#maven.ejb.addClasspath" + * default="false" + * description="" + * @parameter name="addExtensions" + * type="String" + * required="false" + * validator="" + * expression="#maven.ejb.addExtensions" + * default="false" + * description="" + * @parameter name="generateClient" + * type="String" + * required="false" + * validator="" + * expression="#maven.ejb.generateclient" + * default="false" + * description="" + * @parameter name="outputDirectory" + * type="String" + * required="true" + * validator="" + * expression="#project.build.outputDirectory" + * description="" + * @parameter name="basedir" + * type="String" + * required="true" + * validator="" + * expression="#project.build.directory" + * description="" + * @parameter name="project" + * type="org.apache.maven.project.MavenProject" + * required="true" + * validator="" + * expression="#project" + * description="current MavenProject instance" + */ +public class EjbMojo + extends AbstractPlugin +{ + /** + * @todo Add license files in META-INF directory. + */ + public void execute( PluginExecutionRequest request, PluginExecutionResponse response ) + throws Exception + { + // ---------------------------------------------------------------------- + // + // ---------------------------------------------------------------------- + + File basedir = new File( (String) request.getParameter( "basedir" ) ); + + String outputDirectory = (String) request.getParameter( "outputDirectory" ); + + String jarName = (String) request.getParameter( "jarName" ); + + boolean generateClient = new Boolean( (String) request.getParameter( "generateClient" ) ).booleanValue(); + + // ---------------------------------------------------------------------- + // + // ---------------------------------------------------------------------- + + request.getLog().info( "Building ejb " + jarName ); + + File jarFile = new File( basedir, jarName + ".jar" ); + + MavenArchiver archiver = new MavenArchiver(); + + archiver.setOutputFile( jarFile ); + + String ejbJarXmlFile = "META-INF/ejb-jar.xml"; + + archiver.getArchiver().addDirectory( new File( outputDirectory ), new String[]{"**/**"}, + new String[]{ejbJarXmlFile, "**/package.html"} ); + + archiver.getArchiver().addFile( new File( outputDirectory, ejbJarXmlFile ), ejbJarXmlFile ); + + // create archive + archiver.createArchive( request ); + + if ( generateClient ) + { + request.getLog().info( "Building ejb client " + jarName + "-client" ); + + File clientJarFile = new File( basedir, jarName + "-client.jar" ); + + MavenArchiver clientArchiver = new MavenArchiver(); + + clientArchiver.setOutputFile( jarFile ); + + clientArchiver.getArchiver().addDirectory( new File( outputDirectory ), new String[]{"**/**"}, + new String[]{"**/*Bean.class", "**/*CMP.class", + "**/*Session.class", "**/package.html"} ); + + // create archive + clientArchiver.createArchive( request ); + } + } +}