Browse Source

add apt args when calling from ant (AjcTask)

Signed-off-by: hsestupin <stupin.sergey@gmail.com>
tags/V1_8_2
hsestupin 9 years ago
parent
commit
ac48f780a4

+ 42
- 0
taskdefs/src/org/aspectj/tools/ant/taskdefs/AjcTask.java View File

@@ -461,6 +461,48 @@ public class AjcTask extends MatchingTask {
return (0 == result.length() ? null : result.toString());
}

/**
* Controls whether annotation processing and/or compilation is done.
* -proc:none means that compilation takes place without annotation processing.
* -proc:only means that only annotation processing is done, without any subsequent compilation.
*/
public void setProc(String proc) {
if (proc.equals("none")) {
cmd.addFlag("-proc:none", true);
} else if (proc.equals("only")) {
cmd.addFlag("-proc:only", true);
}
}

/**
* -processor class1[,class2,class3...]
* Names of the annotation processors to run. This bypasses the default discovery process.
*/
public void setProcessor(String processors) {
cmd.addFlagged("-processor", processors);
}

/**
* -processorpath path
* Specify where to find annotation processors; if this option is not used, the class path will be searched for processors.
*/
public void setProcessorpath(String processorpath) {
cmd.addFlagged("-processorpath", processorpath);
}

/**
* -s dir
* Specify the directory where to place generated source files. The directory must already exist; javac will not create it.
* If a class is part of a package, the compiler puts the source file in a subdirectory reflecting the package name,
* creating directories as needed.
*
* For example, if you specify -s C:\mysrc and the class is called com.mypackage.MyClass,
* then the source file will be placed in C:\mysrc\com\mypackage\MyClass.java.
*/
public void setS(String s) {
cmd.addFlagged("-s", s);
}

public void setIncremental(boolean incremental) {
cmd.addFlag("-incremental", incremental);
inIncrementalMode = incremental;

+ 29
- 0
taskdefs/testsrc/org/aspectj/tools/ant/taskdefs/AjcTaskTest.java View File

@@ -784,6 +784,35 @@ public class AjcTaskTest extends TestCase {
}
}

public void testAptProc() {
AjcTask task = getTask(NOFILE);
task.setProc("none");
checkContains(task.makeCommand(), "-proc:none", true);
task.setProc("only");
checkContains(task.makeCommand(), "-proc:only", true);
}

public void testAptProcessor() {
AjcTask task = getTask(NOFILE);
task.setProcessor("some.SomeClass");
checkContains(task.makeCommand(), "-processor", true);
checkContains(task.makeCommand(), "some.SomeClass", true);
}

public void testAptProcessorpath() {
AjcTask task = getTask(NOFILE);
task.setProcessorpath("some/path");
checkContains(task.makeCommand(), "-processorpath", true);
checkContains(task.makeCommand(), "some/path", true);
}

public void testAptGeneratedDirectory() {
AjcTask task = getTask(NOFILE);
task.setS("some/path");
checkContains(task.makeCommand(), "-s", true);
checkContains(task.makeCommand(), "some/path", true);
}
public void testOutxml () {
File destDir = getTempDir();

Loading…
Cancel
Save