Repository: ant Updated Branches: refs/heads/master 038e1948e -> edca1db3d
Added unit test for excludes in multi module compilation. Project: http://git-wip-us.apache.org/repos/asf/ant/repo Commit: http://git-wip-us.apache.org/repos/asf/ant/commit/ea99177e Tree: http://git-wip-us.apache.org/repos/asf/ant/tree/ea99177e Diff: http://git-wip-us.apache.org/repos/asf/ant/diff/ea99177e Branch: refs/heads/master Commit: ea99177eb266696cebf3555014301ec6edc7ca5a Parents: 7bd7ed4 Author: Tomas Zezula <[email protected]> Authored: Fri Mar 11 15:44:59 2016 +0100 Committer: Stefan Bodewig <[email protected]> Committed: Mon Mar 21 12:02:59 2016 +0100 ---------------------------------------------------------------------- .../compilers/DefaultCompilerAdapterTest.java | 50 ++++++++++++++++++++ 1 file changed, 50 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ant/blob/ea99177e/src/tests/junit/org/apache/tools/ant/taskdefs/compilers/DefaultCompilerAdapterTest.java ---------------------------------------------------------------------- diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/compilers/DefaultCompilerAdapterTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/compilers/DefaultCompilerAdapterTest.java index 2972cdb..798345b 100644 --- a/src/tests/junit/org/apache/tools/ant/taskdefs/compilers/DefaultCompilerAdapterTest.java +++ b/src/tests/junit/org/apache/tools/ant/taskdefs/compilers/DefaultCompilerAdapterTest.java @@ -306,6 +306,56 @@ public class DefaultCompilerAdapterTest { } } + @Test + public void testMultiModuleCompilationWithExcludes() throws IOException { + final File workDir = createWorkDir("testMMCWE"); + try { + final File src = new File(workDir, "src"); + src.mkdir(); + final File java1 = createFile(src,"main/m1/lin/classes/org/apache/ant/tests/J1.java"); + final File java2 = createFile(src,"main/m3/sol/classes/org/apache/ant/tests/J2.java"); + final File java3 = createFile(src,"main/m3/sol/classes/org/apache/ant/invisible/J3.java"); + final File build = new File(workDir, "build"); + build.mkdirs(); + final Project prj = new Project(); + prj.setBaseDir(workDir); + final LogCapturingJavac javac = new LogCapturingJavac(); + javac.setProject(prj); + final DefaultCompilerAdapter impl = new DefaultCompilerAdapter() { + @Override + public boolean execute() throws BuildException { + setupModernJavacCommand(); + return true; + } + }; + final String moduleSrcPathStr = "src/main/*/{lin,sol}/classes"; + final Path moduleSourcePath = new Path(prj); + moduleSourcePath.setPath(moduleSrcPathStr); + javac.setModulesourcepath(moduleSourcePath); + javac.setSource("9"); + javac.setTarget("9"); + javac.setDestdir(build); + javac.setIncludeantruntime(false); + javac.createExclude().setName("org/**/invisible/**"); + javac.add(impl); + javac.execute(); + final File[] compileList = impl.compileList; + Assert.assertNotNull(compileList); + //J1.java, J2.java has to be in files list but not J3.java + final Set<String> expectedFiles = new TreeSet<String>(); + Collections.addAll(expectedFiles, + java1.getAbsolutePath(), + java2.getAbsolutePath()); + final Set<String> actualFiles = new TreeSet<String>(); + for (File compileFile : compileList) { + actualFiles.add(compileFile.getAbsolutePath()); + } + assertEquals(expectedFiles, actualFiles); + } finally { + delete(workDir); + } + } + private void commonSourceDowngrades(String javaVersion) { testSource("1.3", javaVersion, "If you specify -target 1.1 you now must also specify"
