conor 01/06/26 04:05:30
Modified: src/main/org/apache/tools/ant/taskdefs/optional/ejb
EjbJar.java GenericDeploymentTool.java
Log:
Allow the manifest to be specified in the ejbjar task. This adds the given
manifest
to the generic jar fed to the appserver ejb compiler.
PR: 980
Submitted by: [EMAIL PROTECTED] (Robert Watkins)
Revision Changes Path
1.21 +18 -0
jakarta-ant/src/main/org/apache/tools/ant/taskdefs/optional/ejb/EjbJar.java
Index: EjbJar.java
===================================================================
RCS file:
/home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/optional/ejb/EjbJar.java,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -r1.20 -r1.21
--- EjbJar.java 2001/06/25 15:17:30 1.20
+++ EjbJar.java 2001/06/26 11:05:13 1.21
@@ -167,6 +167,11 @@
* from the descriptor information
*/
public NamingScheme namingScheme;
+
+ /**
+ * The Manifest file
+ */
+ public File manifest;
};
@@ -303,6 +308,19 @@
return supportFileSet;
}
+
+ /**
+ * Set the Manifest file to use when jarring.
+ *
+ * As of EJB 1.1, manifest files are no longer used to configure the
EJB. However, they
+ * still have a vital importance if the EJB is intended to be packaged
in an EAR file.
+ * By adding "Class-Path" settings to a Manifest file, the EJB can look
for classes inside
+ * the EAR file itself, allowing for easier deployment. This is
outlined in the J2EE
+ * specification, and all J2EE components are meant to support it.
+ */
+ public void setManifest(File manifest) {
+ config.manifest = manifest;
+ }
/**
* Set the srcdir attribute. The source directory is the directory that
contains
1.20 +43 -16
jakarta-ant/src/main/org/apache/tools/ant/taskdefs/optional/ejb/GenericDeploymentTool.java
Index: GenericDeploymentTool.java
===================================================================
RCS file:
/home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/optional/ejb/GenericDeploymentTool.java,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -r1.19 -r1.20
--- GenericDeploymentTool.java 2001/06/25 15:17:31 1.19
+++ GenericDeploymentTool.java 2001/06/26 11:05:17 1.20
@@ -570,7 +570,7 @@
* This method checks the timestamp on each file listed in the <code>
* ejbFiles</code> and compares them to the timestamp on the
<code>jarFile
* </code>. If the <code>jarFile</code>'s timestamp is more recent than
- * each EJB file, <code>false</code> is returned. Otherwise, <code>true
+ * each EJB file, <code>true</code> is returned. Otherwise, <code>false
* </code> is returned.
*
* @param ejbFiles Hashtable of EJB classes (and other) files that will
be
@@ -581,28 +581,32 @@
* is up to date
*/
protected boolean needToRebuild(Hashtable ejbFiles, File jarFile) {
- // By default we assume we need to build.
- boolean needBuild = true;
-
if (jarFile.exists()) {
- long lastBuild = jarFile.lastModified();
+ long lastBuild = jarFile.lastModified();
+ if (config.manifest != null && config.manifest.exists() &&
+ config.manifest.lastModified() > lastBuild) {
+ log("Build needed because manifest " + config.manifest + "
is out of date",
+ Project.MSG_VERBOSE);
+ return true;
+ }
+
+
Iterator fileIter = ejbFiles.values().iterator();
- // Set the need build to false until we find out otherwise.
- needBuild = false;
// Loop through the files seeing if any has been touched
// more recently than the destination jar.
- while( (needBuild == false) && (fileIter.hasNext()) ) {
+ while(fileIter.hasNext()) {
File currentFile = (File) fileIter.next();
- needBuild = ( lastBuild < currentFile.lastModified() );
- if (needBuild) {
+ if (lastBuild < currentFile.lastModified()) {
log("Build needed because " + currentFile.getPath() + "
is out of date",
Project.MSG_VERBOSE);
+ return true;
}
}
+ return false;
}
- return needBuild;
+ return true;
}
/**
@@ -640,13 +644,36 @@
jarfile.getParentFile().mkdirs();
jarfile.createNewFile();
- String defaultManifest =
"/org/apache/tools/ant/defaultManifest.mf";
- InputStream in =
this.getClass().getResourceAsStream(defaultManifest);
- if ( in == null ) {
- throw new BuildException ( "Could not find: " +
defaultManifest );
+ InputStream in = null;
+ Manifest manifest = null;
+ try {
+ if (config.manifest != null) {
+ in = new FileInputStream(config.manifest);
+ if ( in == null ) {
+ throw new BuildException("Could not find manifest
file: " + config.manifest,
+ getLocation());
+ }
+ }
+ else {
+ String defaultManifest =
"/org/apache/tools/ant/defaultManifest.mf";
+ in =
this.getClass().getResourceAsStream(defaultManifest);
+ if ( in == null ) {
+ throw new BuildException("Could not find default
manifest: " + defaultManifest,
+ getLocation());
+ }
+ }
+
+ manifest = new Manifest(in);
+ }
+ catch (IOException e) {
+ throw new BuildException ("Unable to read manifest", e,
getLocation());
+ }
+ finally {
+ if (in != null) {
+ in.close();
+ }
}
- Manifest manifest = new Manifest(in);
// Create the streams necessary to write the jarfile
jarStream = new JarOutputStream(new FileOutputStream(jarfile),
manifest);