Re: [aspectwerkz-dev] Re: [aspectwerkz-user] Re: problems with ant task

Jonas Bonér <[email protected]> Tue, 5 Oct 2004 10:03:53 +0200
Newsgroups gmane.comp.java.aspectwerkz.devel
Message-ID <[email protected]>
This is the command line option.  (java ...AnnotationC -src ... etc.)
In the Ant task you can wrap it in anything you like, filesets or not.

The AnnotationC.API accepts a String array, so it should be very
straight forward to impl.

API: 

  public static void compile(final String[] sourcePath,
                               final String classPath,
                               String destDir,
                               final String annotationPropetiesFile)

/Jonas

On Tue, 05 Oct 2004 10:42:39 +0300, the_mindstorm
<[email protected]> wrote:
> Quote [Jonas Bonér]:
> 
> > Hey Mindstorm.
> >
> > I have impl support for multiple source dirs now.
> > Syntax is: -src bla/dir1;bla/dir2;dir3
> >
> > In HEAD. Will commit to 1.0 branch as well, later, for now just copy
> > it if you like.
> >
> > /Jonas
> 
> Jonas why shouldn't we go the fileset way? I think it is more generic than multiple directories. (my
> 2c - I have Alex backing me for this too ;-) )
> 
> ./the_mindstorm
> 
> 
> 
> >
> >
> > On Tue, 05 Oct 2004 01:58:46 +0300, pope <[email protected]> wrote:
> >
> >>
> >>Quote [the_mindstorm]:
> >>
> >>
> >>>Quote [Jonas Bonér]:
> >>>
> >>>
> >>>>Hi Mikael.
> >>>>
> >>>>We currently do not have an Ant task that is up to date. But we do
> >>>>need one. Care to help out? I can give you some guiding if you need/want.
> >>>>Thanks.
> >>>>
> >>>>/Jonas
> >>>>
> >>>>
> >>>>On Mon, 04 Oct 2004 16:14:49 +0200, Mikael Berglund
> >>>><[email protected]> wrote:
> >>>>
> >>>>
> >>>>>Jonas Bonér wrote:
> >>>>>
> >>>>>
> >>>>>>The ant task for the offline compiler is really nasty and is
> >>>>>>deprecated. It should be removed to
> >>>>>>avoid usage and confusion. I anyone happens to write one that
> >>>>>>actually works please send it to me.
> >>>>>>I always use AspectWerkzC directly using the <java ..> task.
> >>>>>
> >>>>>
> >>>>>Hello,
> >>>>>
> >>>>>what is the status on this? It would be really convenient to
> >>>>>have an Ant task for this. The dependency on environment
> >>>>>variables makes it more diffucult for us to make an easy to
> >>>>>set up build environment.
> >>>>>
> >>>>>Regards,
> >>>>>Mikael
> >>>>>
> >>>>>
> >>>>>
> >>>>>>--- Ivo Houbrechts <[email protected]> wrote:
> >>>>>>
> >>>>>>
> >>>>>>
> >>>>>>>Hi there,
> >>>>>>>
> >>>>>>>I tried aspectwerkz for the first time and I couldn't get the
> >>>>>>>OfflineTransformationTask to work. I noticed that the ant task calls
> >>>>>>>Runtime.getRuntime().exec to run aspectwerkz.bat (or .sh) which in
> >>>>>>>turn
> >>>>>>>runs the AspectWerkzC class's main(). I think that the problem is with
> >>>>>>>windows not being able to handle long command lines (long classpath).
> >>>>>>>I solved this problem by calling the AspectWerkzC class directly from
> >>>>>>>ant, which is much cleaner in my opinion. I hope however that in the
> >>>>>>>future there will be an ant task that excepts a nested <path> for the
> >>>>>>>compile path and that doesn't make use of environment variables
> >>>>>>>anymore.
> >>>>>>>
> >>>>>>>Here's my ant target:
> >>>>>>>
> >>>>>>><target depends="compile" name="aspectwerkz" description="compile
> >>>>>>>aspects">
> >>>>>>><pathconvert property="compilePath"
> >>>>>>> dirsep="${file.separator}"
> >>>>>>> pathsep="${path.separator}">
> >>>>>>>  <path>
> >>>>>>>  <fileset dir="${my.lib.dir}">
> >>>>>>>  <include name="*.jar"/>
> >>>>>>>  </fileset>
> >>>>>>>  </path>
> >>>>>>></pathconvert>
> >>>>>>>
> >>>>>>><java classname="org.codehaus.aspectwerkz.compiler.AspectWerkzC"
> >>>>>>>              fork="true">
> >>>>>>>  <classpath>
> >>>>>>>    <fileset dir="${aspectwerkz.home}/lib">
> >>>>>>>      <include name="*.jar"/>
> >>>>>>>    </fileset>
> >>>>>>>  </classpath>
> >>>>>>>  <sysproperty key="aspectwerkz.transform.filter" value="no"/>
> >>>>>>>  <sysproperty key="aspectwerkz.definition.file"
> >>>>>>>   value="${my.conf.dir}/aspectwerkz.xml"/>
> >>>>>>>  <sysproperty key="aspectwerkz.home" value="${aspectwerkz.home}"/>
> >>>>>>>  <arg value="-verbose"/>
> >>>>>>>  <arg value="-cp"/>
> >>>>>>>  <arg value="${compilePath}"/>
> >>>>>>>  <arg value="${my.classes.totransform.dir}"/>
> >>>>>>></java>
> >>>>>>></target>
> >>>>>>>
> >>>This is a draft one. It would be nice to allow setting more than one
> >>>source/classes directory.
> >>
> >>The changed required in AnnotationC would not be so dramatic for allowing multiple src, respectively
> >>multiple class directories. At least these are my 2c.
> >>Another option would be to let AnnotationC work on something similar to Ant filesets (the most generic).
> >>
> >>Pls let me know.
> >>
> >>./the_mindstorm
> >>
> >>
> >>>./the_mindstorm
> >>>
> >>>
> >>>------------------------------------------------------------------------
> >>>
> >>>/*
> >>> * $Id$
> >>> * $Date$
> >>> */
> >>>package net.noco.dtogen.ant;
> >>>
> >>>import java.io.File;
> >>>
> >>>import org.apache.tools.ant.BuildException;
> >>>import org.apache.tools.ant.Task;
> >>>import org.apache.tools.ant.taskdefs.Java;
> >>>import org.apache.tools.ant.types.Commandline;
> >>>import org.apache.tools.ant.types.Path;
> >>>import org.apache.tools.ant.types.Reference;
> >>>
> >>>
> >>>/**
> >>> * Offiline weaving task.
> >>> *
> >>> * @author <a href='mailto:[email protected]'>the_mindstorm(at)evolva(dot)ro</a>
> >>> * @version $Revision$
> >>> */
> >>>public class OfflineWeaverTask extends Task {
> >>>      protected Path classpath;
> >>>      protected boolean verbose;
> >>>      protected File srcDir;
> >>>      protected File clsDir;
> >>>      protected File customs;
> >>>
> >>>      public void setVerbose(boolean isVerbose) {
> >>>              this.verbose = true;
> >>>      }
> >>>
> >>>      public void setSrcDir(File src) {
> >>>              this.srcDir = src;
> >>>      }
> >>>
> >>>      public void setClassDir(File dir) {
> >>>              this.clsDir = dir;
> >>>      }
> >>>
> >>>      public void setCustomAnnotations(File file) {
> >>>              this.customs = file;
> >>>      }
> >>>
> >>>      public void setClasspath(Path path) {
> >>>              this.classpath = path;
> >>>      }
> >>>
> >>>      public void setClasspathRef(Reference reference) {
> >>>              this.classpath = new Path(getProject());
> >>>              this.classpath.setRefid(reference);
> >>>      }
> >>>
> >>>      public void execute() throws BuildException {
> >>>              if(this.srcDir==null || !this.srcDir.isDirectory()) {
> >>>                      throw new BuildException("srcDir ["+this.srcDir+"] is not a valid source directory");
> >>>              }
> >>>              if(this.clsDir==null || !this.clsDir.isDirectory()) {
> >>>                      throw new BuildException("classDir ["+this.srcDir+"] is not a valid classes directory");
> >>>              }
> >>>              if(this.customs==null || !this.customs.isFile()) {
> >>>                      throw new BuildException("customAnnotations ["+this.customs+"] is not a valid annotations file");
> >>>              }
> >>>
> >>>              Java java = new Java();
> >>>
> >>>              java.setClassname("org.codehaus.aspectwerkz.annotation.AnnotationC");
> >>>              java.setProject(getProject());
> >>>              java.setFork(true);
> >>>              java.setClasspath(this.classpath);
> >>>              Commandline.Argument lineArgs = java.createArg();
> >>>
> >>>              StringBuffer argsBuf = new StringBuffer();
> >>>
> >>>              if(this.verbose) {
> >>>                      argsBuf.append("-verbose ");
> >>>              }
> >>>              argsBuf.append("-src ")
> >>>                      .append(this.srcDir.getAbsolutePath())
> >>>                      .append(" -classes ")
> >>>                      .append(this.clsDir.getAbsolutePath())
> >>>                      .append(" -custom ")
> >>>                      .append(this.customs.getAbsolutePath());
> >>>
> >>>              java.execute();
> >>>      }
> >>>}
> >>
> >>
> >
> 
>