[MEJB-63] outputDirectory is treated differently to ear, war plugins
Now we have a sourceDirectory and a outputDirectory which behave the
way you expect them to behave.
The sourceDirectory contains those elements which will be archived
and the outputDirectory contains the created archives.
git-svn-id: https://svn.apache.org/repos/asf/maven/plugins/trunk@1648129 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/src/it/reactor/sub/pom.xml b/src/it/reactor/sub/pom.xml
index 79fbee0..ca6f42e 100644
--- a/src/it/reactor/sub/pom.xml
+++ b/src/it/reactor/sub/pom.xml
@@ -44,7 +44,7 @@
<version>@project.version@</version>
<configuration>
<!-- Note the relative path here -->
- <outputDirectory>target/classes</outputDirectory>
+ <sourceDirectory>target/classes</sourceDirectory>
</configuration>
</plugin>
</plugins>
diff --git a/src/main/java/org/apache/maven/plugin/ejb/EjbMojo.java b/src/main/java/org/apache/maven/plugin/ejb/EjbMojo.java
index c655130..d0fe9f4 100644
--- a/src/main/java/org/apache/maven/plugin/ejb/EjbMojo.java
+++ b/src/main/java/org/apache/maven/plugin/ejb/EjbMojo.java
@@ -67,16 +67,17 @@
"**/*Session.class", "**/package.html" };
/**
- * The directory for the generated EJB.
+ * The directory location for the generated EJB.
*/
@Parameter( defaultValue = "${project.build.directory}", required = true, readonly = true )
- private File basedir;
+ private File outputDirectory;
/**
- * Directory that resources are copied to during the build.
+ * Directory that contains the resources which are packaged into
+ * the created archive {@code target/classes}.
*/
- @Parameter( property = "outputDirectory", defaultValue = "${project.build.outputDirectory}" )
- private File outputDirectory;
+ @Parameter( defaultValue = "${project.build.outputDirectory}", required = true )
+ private File sourceDirectory;
/**
* The name of the EJB file to generate.
@@ -254,11 +255,11 @@
throws MojoExecutionException
{
- if ( !outputDirectory.exists() )
+ if ( !sourceDirectory.exists() )
{
- getLog().warn( "The created EJB jar will be empty cause the " + outputDirectory.getPath()
+ getLog().warn( "The created EJB jar will be empty cause the " + sourceDirectory.getPath()
+ " did not exist." );
- outputDirectory.mkdirs();
+ sourceDirectory.mkdirs();
}
if ( getLog().isInfoEnabled() )
@@ -266,7 +267,7 @@
getLog().info( "Building EJB " + jarName + " with EJB version " + ejbVersion );
}
- File jarFile = getEJBJarFile( basedir, jarName, classifier );
+ File jarFile = getEJBJarFile( outputDirectory, jarName, classifier );
MavenArchiver archiver = new MavenArchiver();
@@ -274,7 +275,7 @@
archiver.setOutputFile( jarFile );
- File deploymentDescriptor = new File( outputDirectory, ejbJar );
+ File deploymentDescriptor = new File( sourceDirectory, ejbJar );
/* test EJB version compliance */
checkEJBVersionCompliance( deploymentDescriptor );
@@ -290,7 +291,7 @@
mainJarExcludes = (String[]) excludes.toArray( new String[excludes.size()] );
}
- archiver.getArchiver().addDirectory( outputDirectory, DEFAULT_INCLUDES, mainJarExcludes );
+ archiver.getArchiver().addDirectory( sourceDirectory, DEFAULT_INCLUDES, mainJarExcludes );
if ( deploymentDescriptor.exists() )
{
@@ -369,7 +370,7 @@
excludes = (String[]) clientExcludes.toArray( new String[clientExcludes.size()] );
}
- File clientJarFile = new File( basedir, resultingClientJarNameWithClassifier + ".jar" );
+ File clientJarFile = new File( outputDirectory, resultingClientJarNameWithClassifier + ".jar" );
MavenArchiver clientArchiver = new MavenArchiver();
@@ -379,7 +380,7 @@
try
{
- clientArchiver.getArchiver().addDirectory( outputDirectory, includes, excludes );
+ clientArchiver.getArchiver().addDirectory( sourceDirectory, includes, excludes );
// create archive
clientArchiver.createArchive( session, project, archive );
@@ -444,7 +445,7 @@
this.session, mavenResourcesExecution );
// Create a temporary file that we can copy-and-filter
- File unfilteredDeploymentDescriptor = new File( outputDirectory, ejbJar + ".unfiltered" );
+ File unfilteredDeploymentDescriptor = new File( sourceDirectory, ejbJar + ".unfiltered" );
FileUtils.copyFile( deploymentDescriptor, unfilteredDeploymentDescriptor );
mavenFileFilter.copyFile( unfilteredDeploymentDescriptor, deploymentDescriptor, true,
filterWrappers, getEncoding( unfilteredDeploymentDescriptor ) );
diff --git a/src/test/java/org/apache/maven/plugin/ejb/EjbMojoTest.java b/src/test/java/org/apache/maven/plugin/ejb/EjbMojoTest.java
index 6955cd0..0a91844 100644
--- a/src/test/java/org/apache/maven/plugin/ejb/EjbMojoTest.java
+++ b/src/test/java/org/apache/maven/plugin/ejb/EjbMojoTest.java
@@ -556,8 +556,8 @@
{
final EjbMojo mojo = lookupMojo();
setVariableValueToObject( mojo, "project", project );
- setVariableValueToObject( mojo, "basedir", new File( project.getBuild().getDirectory() ) );
- setVariableValueToObject( mojo, "outputDirectory", new File( project.getBuild().getOutputDirectory() ) );
+ setVariableValueToObject( mojo, "outputDirectory", new File( project.getBuild().getDirectory() ) );
+ setVariableValueToObject( mojo, "sourceDirectory", new File( project.getBuild().getOutputDirectory() ) );
setVariableValueToObject( mojo, "jarName", DEFAULT_JAR_NAME );
setVariableValueToObject( mojo, "clientExcludes", clientExcludes );
setVariableValueToObject( mojo, "clientIncludes", clientIncludes );