Browse Source

Add the ability to output all EJB jarfiles to a single directory.

Add a new attribute 'flatdestdir'.  Attribute defaults to false, which
maintains the current behaviour. If it is set to true, all jars will
be created directly in the destination dir.

WARNING: If you use this attribute, and have multiple jars with the same
name, they will overwrite each other!

Submitted by:	Tim Fennell <tfenne@rcn.com>


git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@267843 13f79535-47bb-0310-9956-ffa450edef68
master
Conor MacNeill 25 years ago
parent
commit
0dfb55090c
2 changed files with 33 additions and 7 deletions
  1. +1
    -0
      docs/ejb.html
  2. +32
    -7
      src/main/org/apache/tools/ant/taskdefs/optional/ejb/EjbJar.java

+ 1
- 0
docs/ejb.html View File

@@ -12,6 +12,7 @@
<p>by</p>
<!-- Names are in alphabetical order, on last name -->
<ul>
<li>Tim Fennell (<a href="mailto:tfenne@rcn.com">tfenne@rcn.com</a>)</li>
<li>Conor MacNeill (<a href="mailto:conor@cortexebusiness.com.au">conor@cortexebusiness.com.au</a>)</li>
</ul>



+ 32
- 7
src/main/org/apache/tools/ant/taskdefs/optional/ejb/EjbJar.java View File

@@ -250,6 +250,12 @@ public class EjbJar extends MatchingTask {
/** Stores a handle to the directory to put the Jar files in */
private File destdir = null;

/**
* Instance variable that determines whether to use a package structure
* of a flat directory as the destination for the jar files.
*/
private boolean flatdestdir = false;

/** Instance variable that determines whether to generate weblogic jars. */
private boolean generateweblogic = false;

@@ -282,6 +288,14 @@ public class EjbJar extends MatchingTask {
this.destdir = this.project.resolveFile(inDir);
}

/**
* Setter used to store the value of flatdestdir.
* @param inValue a string, either 'true' or 'false'.
*/
public void setFlatdestdir(String inValue) {
this.flatdestdir = Boolean.valueOf(inValue).booleanValue();
}

/**
* Setter used to store the suffix for the generated jar file.
* @param inString the string to use as the suffix.
@@ -415,7 +429,12 @@ public class EjbJar extends MatchingTask {

/**
*
* Helper method invoked by execute() for each WebLogic jar to be built.
* Encapsulates the logic of constructing a java task for calling
* weblogic.ejbc and executing it.
* @param sourceJar java.io.File representing the source (EJB1.1) jarfile.
* @param destJar java.io.File representing the destination, WebLogic
* jarfile.
*/
public void buildWeblogicJar(File sourceJar, File destJar) {
org.apache.tools.ant.taskdefs.Java javaTask = null;
@@ -505,8 +524,8 @@ public class EjbJar extends MatchingTask {
baseName = files[index].substring(0, endBaseName);

/* Parse the ejb deployment descriptor. While it may not
* look like much, passing 'this' in the above method allows
* the parser to call us back when it finds interesting things.
* look like much, we use a SAXParser and an inner class to
* get hold of all the classfile names for the descriptor.
*/
handler = new DescriptorHandler();
saxParser.parse(new InputSource
@@ -516,9 +535,8 @@ public class EjbJar extends MatchingTask {

ejbFiles = handler.getFiles();
/* Now that we've parsed the deployment descriptor we have the
* bean name, so we can figure out all the .xml filenames and
* add them to the set of files for the jar.
/* Now try to locate all of the deployment descriptors for the
* jar, and if they exist, add them to the list of files.
*/

// First the regular deployment descriptor
@@ -547,7 +565,14 @@ public class EjbJar extends MatchingTask {
weblogicDD);
}

// Lastly for the jarfiles
// Lastly create File object for the Jar files. If we are using
// a flat destination dir, then we need to redefine baseName!
if (this.flatdestdir) {
int startName = baseName.lastIndexOf(File.separator);
int endName = baseName.length();
baseName = baseName.substring(startName, endName);
}

jarfile = new File(this.destdir,
baseName
+ this.genericjarsuffix);


Loading…
Cancel
Save