List of usage examples for org.aspectj.tools.ant.taskdefs AjcTask AjcTask
public AjcTask()
From source file:org.mitre.sim.analysis.task.CodeAnalysisTask.java
License:Open Source License
public void execute() throws BuildException { //set defaults for attributes: genaj if (genajdir == null) genajdir = new File("generated-aj"); if (verbose)/*from w w w . java 2 s .co m*/ log("sourceroots: " + sourceroots, Project.MSG_INFO); if (verbose && inpath != null) log("inpath: " + inpath, Project.MSG_INFO); if (verbose && injars != null) log("injars: " + injars, Project.MSG_INFO); if (verbose) log("classpath: " + classpath, Project.MSG_INFO); if (verbose) log("destdir: " + destdir, Project.MSG_INFO); if (verbose) log("genajdir: " + genajdir, Project.MSG_INFO); try { if (injars != null) analyzer = new Analyzer(injars.list(), classpath.list(), genajdir, verbose); else if (inpath != null) analyzer = new Analyzer(inpath.list(), classpath.list(), genajdir, verbose); else throw new BuildException("One of injars or inpath must be specified."); analyzer.analyze(); } catch (AnalysisException ex) { throw new BuildException(ex); } ajcTask = new AjcTask(); ajcTask.setTaskName(getTaskName() + "-ajc"); ajcTask.setClasspath(classpath); ajcTask.setFailonerror(failonerror); //append genajdir to passed-in sourceroots if (sourceroots == null) { sourceroots = new Path(getProject(), genajdir.toString()); } else { sourceroots.append(new Path(getProject(), genajdir.toString())); } if (verbose) log("sourceroots mod: " + sourceroots); ajcTask.setSourceRoots(sourceroots); ajcTask.setInpath(inpath); ajcTask.setInjars(injars); ajcTask.setDestdir(destdir); ajcTask.execute(); }
From source file:org.mitre.sim.ant.taskdefs.TortugaTask.java
License:Open Source License
/** * Performs the AspectJ Compilation/*w ww.ja v a2 s . c o m*/ * @throws BuildException */ private void compile() throws BuildException { AjcTask ajc = new AjcTask(); ajc.setProject(getProject()); ajc.setTaskName(getTaskName() + "-ajc"); Path ajcPath = (Path) sourceroots.clone(); Path scratchPath = new Path(ajcPath.getProject(), scratchdir.getAbsolutePath()); ajcPath.add(scratchPath); ajc.setSourceRoots(ajcPath); ajc.setDestdir(destdir); if (!aspectJ5) ajc.setXReweavable(true); //true by default as of AJ 5 //Whenever we're ready to allow test programs to be Java 5 source, we need //to tell ajc to expect Java 5 source // String ajv = getProject().getProperty("ant.java.version"); // log("ant.java.version:" + ajv, Project.MSG_INFO); // ajc.setSource(ajv); //for now, copy source attribute off tortuga task invocation ajc.setSource(source); if (destdir.exists()) { Path destDirPath = new Path(this.getProject(), destdir.getAbsolutePath()); ajc.setInpath(destDirPath); } File tortugaJar = findTortugaJar(); if (tortugaJar == null) throw new BuildException("Can't find tortuga JAR"); Path aspectPath = new Path(getProject(), tortugaJar.getAbsolutePath()); ajc.setAspectpath(aspectPath); ajc.setFork(true); ajc.setForkclasspath(classpath); ajc.setMaxmem("256M"); ajc.execute(); }