initial version of EJB plugin

git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@163520 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Emmanuel Venisse 2005-03-10 17:14:39 +00:00
parent 5dc8cb4f33
commit 2ef5d9ad39
15 changed files with 347 additions and 6 deletions

View File

@ -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 <a href="mailto:jason@maven.org">Jason van Zyl</a>
* @version $Id$
*/
public class EjbHandler
extends JarHandler
{
public String directory()
{
return "ejbs";
}
public String packageGoal()
{
return "ejb:ejb";
}
}

View File

@ -86,6 +86,12 @@
</requirements>
</component>
<component>
<role>org.apache.maven.artifact.handler.ArtifactHandler</role>
<role-hint>ejb</role-hint>
<implementation>org.apache.maven.artifact.handler.EjbHandler</implementation>
</component>
<component>
<role>org.apache.maven.artifact.handler.ArtifactHandler</role>
<role-hint>jar</role-hint>

View File

@ -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

View File

@ -12,3 +12,4 @@ it0012
it0013
it0015
it0016
it0017

View File

@ -0,0 +1,10 @@
*~
*.log
target
*.ipr
*.iws
dist
target
.classpath
.project
log.txt

View File

@ -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

View File

@ -0,0 +1 @@
package

View File

@ -0,0 +1,7 @@
<model>
<modelVersion>4.0.0</modelVersion>
<groupId>maven</groupId>
<artifactId>maven-core-it0017</artifactId>
<packaging>ejb</packaging>
<version>1.0</version>
</model>

View File

@ -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;
}
}

View File

@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<ejb-jar>
<enterprise-beans>
<session>
<ejb-name>Hello</ejb-name>
<home>org.apache.maven.it0017.HelloHome</home>
<remote>org.apache.maven.it0017.Hello</remote>
<ejb-class>org.apache.maven.it0017.HelloBean</ejb-class>
<session-type>Stateless</session-type>
<transaction-type>Container</transaction-type>
</session>
</enterprise-beans>
<assembly-descriptor>
<container-transaction>
<method>
<ejb-name>Hello</ejb-name>
<method-name>*</method-name>
</method>
<trans-attribute>Required</trans-attribute>
</container-transaction>
</assembly-descriptor>
</ejb-jar>

View File

@ -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;

View File

@ -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 );
}
}

View File

@ -0,0 +1,8 @@
target
*~
*.log
.classpath
.project
*.ipr
*.iws
*.iml

View File

@ -0,0 +1,57 @@
<model>
<parent>
<artifactId>maven-plugin-parent</artifactId>
<groupId>maven</groupId>
<version>2.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>maven</groupId>
<artifactId>maven-ejb-plugin</artifactId>
<packaging>plugin</packaging>
<name>Maven EJB Plugin</name>
<version>1.0-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>plexus</groupId>
<artifactId>plexus-container-default</artifactId>
<version>1.0-alpha-2-SNAPSHOT</version>
<type>jar</type>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>plexus</groupId>
<artifactId>plexus-archiver</artifactId>
<version>1.0-alpha-1-SNAPSHOT</version>
<type>jar</type>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>maven</groupId>
<artifactId>maven-archiver</artifactId>
<version>1.0-SNAPSHOT</version>
<type>jar</type>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>maven</groupId>
<artifactId>maven-artifact</artifactId>
<version>2.0-SNAPSHOT</version>
<type>jar</type>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>maven</groupId>
<artifactId>maven-core</artifactId>
<version>2.0-SNAPSHOT</version>
<type>jar</type>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>maven</groupId>
<artifactId>maven-model</artifactId>
<version>2.0-SNAPSHOT</version>
<type>jar</type>
<scope>compile</scope>
</dependency>
</dependencies>
</model>

View File

@ -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 <a href="evenisse@apache.org">Emmanuel Venisse</a>
* @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 );
}
}
}