use of org.apache.tools.ant.types.Path in project ant by apache.
the class DefaultCompilerAdapterTest method testSingleModuleCompilation.
@Test
public void testSingleModuleCompilation() throws IOException {
final File workDir = createWorkDir("testSMC");
try {
final File src = new File(workDir, "src");
src.mkdir();
final File java1 = createFile(src, "org/apache/ant/tests/J1.java");
final File java2 = createFile(src, "org/apache/ant/tests/J2.java");
final File modules = new File(workDir, "modules");
modules.mkdir();
final Project prj = new Project();
prj.setBaseDir(workDir);
final LogCapturingJavac javac = new LogCapturingJavac();
javac.setProject(prj);
final Commandline[] cmd = new Commandline[1];
final DefaultCompilerAdapter impl = new DefaultCompilerAdapter() {
@Override
public boolean execute() throws BuildException {
cmd[0] = setupModernJavacCommand();
return true;
}
};
final Path srcPath = new Path(prj);
srcPath.setLocation(src);
javac.setSrcdir(srcPath);
javac.createModulepath().setLocation(modules);
javac.setSource("9");
javac.setTarget("9");
javac.setIncludeantruntime(false);
javac.add(impl);
javac.execute();
assertNotNull(cmd[0]);
final List<String> cmdLine = Arrays.asList(cmd[0].getCommandline());
// No modulesourcepath
assertEquals(-1, cmdLine.indexOf("--module-source-path"));
// The -sourcepath has to be followed by src
int index = cmdLine.indexOf("-sourcepath");
assertTrue(index != -1 && index < cmdLine.size() - 1);
assertEquals(src.getAbsolutePath(), cmdLine.get(index + 1));
// The --module-path has to be followed by modules
index = cmdLine.indexOf("--module-path");
assertTrue(index != -1 && index < cmdLine.size() - 1);
assertEquals(modules.getAbsolutePath(), cmdLine.get(index + 1));
// J1.java & J2.java has to be in files list
final Set<String> expected = new TreeSet<String>();
Collections.addAll(expected, java1.getAbsolutePath(), java2.getAbsolutePath());
final Set<String> actual = new TreeSet<String>(cmdLine.subList(cmdLine.size() - 2, cmdLine.size()));
assertEquals(expected, actual);
} finally {
delete(workDir);
}
}
use of org.apache.tools.ant.types.Path in project ant by apache.
the class DefaultCompilerAdapterTest method releaseIsIgnoredForJava8.
@Test
public void releaseIsIgnoredForJava8() {
LogCapturingJavac javac = new LogCapturingJavac();
Project p = new Project();
javac.setProject(p);
javac.setCompiler("javac8");
javac.setSource("6");
javac.setTarget("6");
javac.setRelease("6");
javac.setSourcepath(new Path(p));
SourceTargetHelperNoOverride sth = new SourceTargetHelperNoOverride();
sth.setJavac(javac);
Commandline cmd = new Commandline();
sth.setupModernJavacCommandlineSwitches(cmd);
assertContains("Support for javac --release has been added in " + "Java9 ignoring it", javac.getLog());
String[] args = cmd.getCommandline();
assertEquals(7, args.length);
assertEquals("-classpath", args[0]);
assertEquals("-target", args[2]);
assertEquals("6", args[3]);
assertEquals("-g:none", args[4]);
assertEquals("-source", args[5]);
assertEquals("6", args[6]);
}
use of org.apache.tools.ant.types.Path in project ant by apache.
the class Concat method createPath.
// Nested element creators.
/**
* Path of files to concatenate.
* @return the path used for concatenating
* @since Ant 1.6
*/
public Path createPath() {
Path path = new Path(getProject());
add(path);
return path;
}
use of org.apache.tools.ant.types.Path in project ant by apache.
the class ModifiedSelectorTest method setUp.
// ===================== JUnit stuff =====================
@Before
public void setUp() {
// init the testclasses path object
Project prj = selectorRule.getProject();
testclasses = new Path(prj, prj.getProperty("build.tests.value"));
}
use of org.apache.tools.ant.types.Path in project ant by apache.
the class SOSTest method testCheckinFileFlags.
/**
* Test CheckInFile option flags
*/
@Test
public void testCheckinFileFlags() {
String[] sTestCmdLine = { "soscmd", "-command", "CheckInFile", "-file", SRC_FILE, "-server", SOS_SERVER_PATH, "-name", SOS_USERNAME, "-password", SOS_PASSWORD, "-database", VSS_SERVER_PATH, "-project", DS_VSS_PROJECT_PATH, "-verbose", "-nocompress", "-nocache", "-workdir", project.getBaseDir().getAbsolutePath() + File.separator + LOCAL_PATH, "-log", SRC_COMMENT };
// Set up a SOSCheckin task
SOSCheckin sosCheckin = new SOSCheckin();
sosCheckin.setProject(project);
sosCheckin.setVssServerPath(VSS_SERVER_PATH);
sosCheckin.setSosServerPath(SOS_SERVER_PATH);
sosCheckin.setProjectPath(VSS_PROJECT_PATH);
sosCheckin.setFile(SRC_FILE);
sosCheckin.setComment(SRC_COMMENT);
sosCheckin.setUsername(SOS_USERNAME);
sosCheckin.setPassword(SOS_PASSWORD);
sosCheckin.setLocalPath(new Path(project, LOCAL_PATH));
sosCheckin.setNoCache(true);
sosCheckin.setNoCompress(true);
sosCheckin.setVerbose(true);
sosCheckin.setRecursive(true);
commandline = sosCheckin.buildCmdLine();
checkCommandLines(sTestCmdLine, commandline.getCommandline());
}
Aggregations