Hi,
I was looking at the jonas 2.0 as a candidate for an ant build. I really like the way
jakarta is set up with
bin, src, docs at the top level of the project. We also add lib, classes, and release.
lib and classes can be used
in a shared area for team development.
Is Ant being used now for building objectweb/jonas? I downloaded a src version of
Jonas and it's using make.
Eric :-)
Markus Blaurock wrote:
> >
> > Christophe Ney wrote:
> >
> > > Markus,
> > >
> > > This hasn't been done yet, but we are very interested
> > > in any contribution/experience report on this subject.
> > >
>
> I've written a taskdef Class for GenIC. That means
> one can use a tag "GenIC" in the build.xml file.
> It works well, but it still doesn't detect changes
> in the ejb-jar-xml-file, so it executes everytime it is
> encountered.
>
> One can use this tag by compiling the class, putting it
> in the classpath so ant can find it and
> adding the following tag to an "init" target in the build.xml
> file.
> <taskdef name="GenIC" classname="mytaskdefs.Genic" />
>
> The tag can be used as follows:
> <GenIC base="dir/where/you/want/the/classes"
> xmlfile="the/deplydesc.xml" />
>
> Any comments, questions or flames welcome :)
>
> --
> gruss
> markus
>
>
> ------------------------------------------------------------------------
> /*
> * The Apache Software License, Version 1.1
> *
> * Copyright (c) 1999 The Apache Software Foundation. All rights
> * reserved.
> *
> * Redistribution and use in source and binary forms, with or without
> * modification, are permitted provided that the following conditions
> * are met:
> *
> * 1. Redistributions of source code must retain the above copyright
> * notice, this list of conditions and the following disclaimer.
> *
> * 2. Redistributions in binary form must reproduce the above copyright
> * notice, this list of conditions and the following disclaimer in
> * the documentation and/or other materials provided with the
> * distribution.
> *
> * 3. The end-user documentation included with the redistribution, if
> * any, must include the following acknowlegement:
> * "This product includes software developed by the
> * Apache Software Foundation (http://www.apache.org/)."
> * Alternately, this acknowlegement may appear in the software itself,
> * if and wherever such third-party acknowlegements normally appear.
> *
> * 4. The names "The Jakarta Project", "Tomcat", and "Apache Software
> * Foundation" must not be used to endorse or promote products derived
> * from this software without prior written permission. For written
> * permission, please contact [EMAIL PROTECTED]
> *
> * 5. Products derived from this software may not be called "Apache"
> * nor may "Apache" appear in their names without prior written
> * permission of the Apache Group.
> *
> * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
> * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
> * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
> * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
> * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
> * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
> * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
> * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
> * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
> * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
> * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
> * SUCH DAMAGE.
> * ====================================================================
> *
> * This software consists of voluntary contributions made by many
> * individuals on behalf of the Apache Software Foundation. For more
> * information on the Apache Software Foundation, please see
> * <http://www.apache.org/>.
> */
>
> package mytaskdefs;
>
> import org.apache.tools.ant.*;
> import java.io.*;
> import java.util.StringTokenizer;
> import org.objectweb.jonas.tools.GenIC;
> import org.objectweb.jonas.tools.GenICException;
> import org.objectweb.jonas.lib.BeanNaming;
> import org.objectweb.jonas.deployment.api.DeploymentDesc;
> import org.objectweb.jonas.deployment.api.BeanDesc;
> import org.objectweb.jonas.deployment.api.DeploymentDescException;
>
> /**
> * Task to compile XML-DeploymentDescriptors with GenIC from Jonas
> *
> * following arguments are possible :
> * <ul>
> * <li>base: The base directory for the compiled stubs and skeletons
> * <li>xmlfile: The XML-file that contains the Deployment Desc
> * <li>clientstubs: Flag to generated the files for a client only (test)
> * </ul>
> * Of these arguments, the <b>base</b> and <b>xmlfile</b> are required.
> * <p>
> *
> * @author [EMAIL PROTECTED]
> * @author [EMAIL PROTECTED]
> * @author [EMAIL PROTECTED]
> */
>
> public class Genic extends Task {
>
> private String base;
> private String xmlfile;
> private String compileClasspath;
> private boolean clientstubs = false;
>
> public void setBase(String base) {
> this.base = base;
> }
>
> public void setXmlfile(String xmlfile) {
> this.xmlfile = xmlfile;
> }
>
> public void setClientstubs(String clientstubs) {
> this.clientstubs = Project.toBoolean(clientstubs);
> }
>
> /**
> * Set the classpath to be used for this compilation.
> */
> public void setClasspath(String classpath) {
> compileClasspath = project.translatePath(classpath);
> }
>
> public void execute() throws BuildException {
> File baseFile = project.resolveFile(base);
> String xmlfilename
>=project.resolveFile(xmlfile).getAbsolutePath();
> String classpath = getCompileClasspath(baseFile);
> boolean isHelp = false;
> boolean isVerbose = false;
> boolean isKeepGenerated = false;
> boolean isImplPropag = true;
> boolean isCompil = true;
> boolean isWithError = false;
> String nameJavaC = new String("javac");
> String optionsJavaC = new String("-classpath " + classpath);
> String optionsRmiC = new String("-classpath " + classpath);
>
> // Parts of the following code are copied from
>GenIC.java (jonas)
> try {
> DeploymentDesc ejbJarDD = null;
> ejbJarDD =
>DeploymentDesc.getInstance(xmlfilename,
>
>
> BeanNaming.getJonasXmlName(xmlfilename));
> BeanDesc[] beansDD =
>ejbJarDD.getBeanDesc();
> project.log("Working on Deployment
>Descriptor "+ xmlfilename);
> for (int i=0; i<beansDD.length; i++) {
> GenIC gwc = new GenIC(beansDD[i], baseFile.getAbsolutePath(),
>isImplPropag);
> gwc.genImplRemoteClass(isWithError);
> gwc.genImplHomeClass(isWithError);
> gwc.genImplHandleClass(isWithError);
> if (isCompil) {
> gwc.compilImplClasses(nameJavaC, optionsJavaC, optionsRmiC);
> }
> if (!isKeepGenerated) {
> gwc.clean();
> }
> gwc = null; // parano
> }
> } catch (GenICException e) {
> throw new BuildException("GenIC ERROR: " + e.getMessage());
> } catch (DeploymentDescException e) {
> throw new BuildException("GenIC
>ERROR: When reading the Deployment Descriptors for "+xmlfilename + "\n" +
>e.getMessage());
> }
> }
>
> /**
> * Builds the compilation classpath.
> */
>
> // XXX
> // we need a way to not use the current classpath.
>
> private String getCompileClasspath(File baseFile) {
> StringBuffer classpath = new StringBuffer();
>
> // add dest dir to classpath so that previously compiled and
> // untouched classes are on classpath
> classpath.append(baseFile.getAbsolutePath());
>
> // add our classpath to the mix
>
> if (compileClasspath != null) {
> addExistingToClasspath(classpath,compileClasspath);
> }
>
> // add the system classpath
>
> addExistingToClasspath(classpath,System.getProperty("java.class.path"));
> // in jdk 1.2, the system classes are not on the visible classpath.
>
> if (Project.getJavaVersion().startsWith("1.2")) {
> String bootcp = System.getProperty("sun.boot.class.path");
> if (bootcp != null) {
> addExistingToClasspath(classpath, bootcp);
> }
> }
> return classpath.toString();
> }
>
> /**
> * Takes a classpath-like string, and adds each element of
> * this string to a new classpath, if the components exist.
> * Components that don't exist, aren't added.
> * We do this, because jikes issues warnings for non-existant
> * files/dirs in his classpath, and these warnings are pretty
> * annoying.
> * @param target - target classpath
> * @param source - source classpath
> * to get file objects.
> */
> private void addExistingToClasspath(StringBuffer target,String source) {
> StringTokenizer tok = new StringTokenizer(source,
> System.getProperty("path.separator"), false);
> while (tok.hasMoreTokens()) {
> File f = project.resolveFile(tok.nextToken());
>
> if (f.exists()) {
> target.append(File.pathSeparator);
> target.append(f.getAbsolutePath());
> } else {
> project.log("Dropping from classpath: "+
> f.getAbsolutePath(),project.MSG_VERBOSE);
> }
> }
>
> }
> }
----
To unsubscribe, send email to [EMAIL PROTECTED] and
include in the body of the message "unsubscribe jonas-users".
For general help, send email to [EMAIL PROTECTED] and
include in the body of the message "help".