ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Stumm, Roman" <RSt...@CONET.DE>
Subject ant task EJBC Weblogic 6.0
Date Mon, 05 Mar 2001 15:58:11 GMT
I found ejbc task for former weblogic versions only and wrote a simple new
one for the current version of the BEA Weblogic application server.
 
This is a new task class that simplifies calling weblogic.ejbc (tested with
BEA Weblogic 6.0).
EJBC will only be executed, when the source jar file is newer than the
target jar file
or when the target does not yet exist.
 
Use the source for what you need. I can give no guarantees whatsoever.
 
Greetings
Roman
 
// Sourcecode file: Ejb60.java, maybe change the package name
package de.conet.ant;
 
import org.apache.tools.ant.*;
import org.apache.tools.ant.taskdefs.*;
 
import org.apache.tools.ant.AntClassLoader;
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.Project;
import org.apache.tools.ant.Task;
import org.apache.tools.ant.types.*;
 
import java.io.File;
import java.io.IOException;
import java.lang.reflect.*;
import java.util.*;
 
/**
 * This task simplifies calling weblogic.ejbc (tested with BEA Weblogic
6.0).
 * EJBC will only be executed, when the source jar file is newer than the
target jar file
 * or when the target does not yet exist.
 *
 * This task is a subclass of the ant &lt;java&gt; task, so all elements and
 * attributes of &lt;java&gt; can be used here as well (e.g. jvmarg, etc.
see
 * the ant documentation for the &lt;java&gt; task).
 *<br><br>
 * Note: sourcejar and targetjar are always the first arguments, so any
 * additional args would be handed to ejbc after source and target.<br>
 *<br>
 * Attribute:<br>
 * source (required) - the source ejb jar to process.<br>
 * target (required) - the jar to be generated<br>
 *
 * <br>
 * Example:
 * <pre>
   &lt;project name="EJBC60 usage example" default="ejbc60" basedir=".">
 &lt;taskdef name="ejbc60" classname="de.conet.ant.Ejbc60" />
 &lt;target name="ejbc60">
  &lt;ejbc60
                        source="lib/_std_test.jar"
                        target="lib/testEJB.jar">
                  &lt;classpath refid="EJBC_classpath"/>
  &lt;/ejbc60>
 &lt;/target>
  &lt;/project>
 * </pre>
 */
public class Ejbc60 extends Java {
  private final static String EJBC = "weblogic.ejbc";
 
  private String sourceJar, targetJar;
  private Commandline.Argument sourceJarArg, targetJarArg;
 
  public void init() {
    super.init();
    sourceJarArg = super.createArg();
    targetJarArg = super.createArg();
  }
 
  public void setSource(String jarname) {
    sourceJar = jarname;
  }
  public void setTarget(String jarname) {
    targetJar = jarname;
  }
 
  // The method executing the task
  public void execute() throws BuildException {
    if(sourceJar == null) throw new BuildException("no source was given");
    if(targetJar == null) throw new BuildException("no target was given");
 
    File source = new File(sourceJar);
    if(!source.exists()) throw new BuildException("source " + sourceJar + "
not found.");
 
    File target = new File(targetJar);
    if(!target.exists() || target.lastModified() < source.lastModified()) {
      log("Building " + targetJar);
 
      setClassname(EJBC);
      setFork(true);
      sourceJarArg.setValue(sourceJar);
      targetJarArg.setValue(targetJar);
      super.execute();
    } else {
      log(targetJar  + " is up to date.", Project.MSG_INFO);
    }
  }
}
// END OF SOURCE Ejb60.java
 
Example of a build.xml using the ejb60 task:
 
<project name="EJBC60 usage example" default="ejbc" basedir=".">
 <!-- custom tasks --> 
 <taskdef name="ejbc60" classname="de.conet.ant.Ejbc60" />
 
 <!-- <BEA Weblogic> -->
 <property name="WL_HOME" value="/bea/wlserver6.0" />
 <path id="EJBC_classpath">
  <pathelement
path="${WL_HOME}/lib/weblogic_sp.jar;${WL_HOME}/lib/weblogic.jar" />
 </path>
 <!-- </BEA Weblogic> --> 
 <target name="ejbc">
  <ejbc60 
   source="lib/myEJB_std.jar" 
   target="lib/myEJB.jar" >
   <classpath refid="EJBC_classpath" />
  </ejbc60>
 </target>
</project>
 

Mime
View raw message