summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBoris Brodski2013-09-18 07:50:00 (EDT)
committer Boris Brodski2013-09-18 07:50:00 (EDT)
commit0e4440bc2700d934cd3a306ea8fd116271b75954 (patch)
treebb979551cbb6513eed1d541d7b1dfe8f197b05b2
parent8124ba646df7348ecc97d39eddb5c752a306c627 (diff)
downloadorg.eclipse.xtext-0e4440bc2700d934cd3a306ea8fd116271b75954.zip
org.eclipse.xtext-0e4440bc2700d934cd3a306ea8fd116271b75954.tar.gz
org.eclipse.xtext-0e4440bc2700d934cd3a306ea8fd116271b75954.tar.bz2
[bug 417177] Fix Xtend compiler multiple source directories bugrefs/changes/51/16551/1
Complete rewrite of XtendBatchCompiler.configureWorkspace(). The previous implementation lacks support for multiple source directories. Beside that, it made use of org.eclipse.xtend.lib.macro.file.Path class. This led to issues on Windows (absolute paths, like C:\, couldn't be detected). The new implementation uses concepts from AbstractXtendCompilerMojo.configureWorkspace(List<String>, String), like suggested in the review comment from Sven. Signed-off-by: Boris Brodski <brodsky_boris@yahoo.com>
-rw-r--r--plugins/org.eclipse.xtend.core/src/org/eclipse/xtend/core/compiler/batch/XtendBatchCompiler.java113
-rw-r--r--tests/org.eclipse.xtend.core.tests/batch-compiler-data/bug417177/dir1/src1/mypackage/Bug417177_1.xtend7
-rw-r--r--tests/org.eclipse.xtend.core.tests/batch-compiler-data/bug417177/dir2/dir2a/src2/mypackage/Bug417177_2.xtend7
-rw-r--r--tests/org.eclipse.xtend.core.tests/batch-compiler-data/bug417177/dir3/.gitignore0
-rw-r--r--tests/org.eclipse.xtend.core.tests/src/org/eclipse/xtend/core/tests/compiler/batch/TestBatchCompiler.xtend203
-rw-r--r--tests/org.eclipse.xtend.core.tests/xtend-gen/org/eclipse/xtend/core/tests/compiler/batch/TestBatchCompiler.java548
6 files changed, 860 insertions, 18 deletions
diff --git a/plugins/org.eclipse.xtend.core/src/org/eclipse/xtend/core/compiler/batch/XtendBatchCompiler.java b/plugins/org.eclipse.xtend.core/src/org/eclipse/xtend/core/compiler/batch/XtendBatchCompiler.java
index df96099..3d91a8f 100644
--- a/plugins/org.eclipse.xtend.core/src/org/eclipse/xtend/core/compiler/batch/XtendBatchCompiler.java
+++ b/plugins/org.eclipse.xtend.core/src/org/eclipse/xtend/core/compiler/batch/XtendBatchCompiler.java
@@ -13,6 +13,7 @@ import java.io.Writer;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLClassLoader;
+import java.util.ArrayList;
import java.util.List;
import org.apache.log4j.Logger;
@@ -27,7 +28,6 @@ import org.eclipse.jdt.annotation.Nullable;
import org.eclipse.jdt.core.compiler.batch.BatchCompiler;
import org.eclipse.xtend.core.macro.ProcessorInstanceForJvmTypeProvider;
import org.eclipse.xtend.core.xtend.XtendFile;
-import org.eclipse.xtend.lib.macro.file.Path;
import org.eclipse.xtext.common.types.JvmAnnotationType;
import org.eclipse.xtext.common.types.JvmDeclaredType;
import org.eclipse.xtext.common.types.JvmEnumerationType;
@@ -261,24 +261,117 @@ public class XtendBatchCompiler {
this.fileEncoding = encoding;
}
- public void configureWorkspace() {
- Path source = new Path(new File(sourcePath).getAbsolutePath());
- Path target = new Path(new File(outputPath).getAbsolutePath());
- Path commonRoot = source;
- while (!target.startsWith(commonRoot)) {
- commonRoot = commonRoot.getParent();
+ public boolean configureWorkspace() {
+ List<File> sourceFileList = getSourcePathFileList();
+ File outputFile = getOutputPathFile();
+ if (sourceFileList == null || outputFile == null) {
+ return false;
}
+
+ File commonRoot = determineCommonRoot(outputFile, sourceFileList);
+
+ // We don't want to use root ("/") as a workspace folder, didn't we?
+ if (commonRoot == null || commonRoot.getParent() == null
+ || commonRoot.getParentFile().getParent() == null) {
+ log.error("All source folders and the output folder should have "
+ + "a common parent non-top level folder (like project folder)");
+ for (File sourceFile : sourceFileList) {
+ log.error("(Source folder: '" + sourceFile + "')");
+ }
+ log.error("(Output folder: '" + outputFile + "')");
+ return false;
+ }
+
WorkspaceConfig workspaceConfig = new WorkspaceConfig(commonRoot.getParent().toString());
- ProjectConfig projectConfig = new ProjectConfig(commonRoot.getLastSegment());
- projectConfig.addSourceFolderMapping(source.relativize(commonRoot).toString(), target.relativize(commonRoot).toString());
+ ProjectConfig projectConfig = new ProjectConfig(commonRoot.getName());
+
+ java.net.URI commonURI = commonRoot.toURI();
+ java.net.URI relativizedTarget = commonURI.relativize(outputFile.toURI());
+ if (relativizedTarget.isAbsolute()) {
+ log.error("Target folder '" + outputFile
+ + "' must be a child of the project folder '" + commonRoot + "'");
+ return false;
+ }
+
+ for (File source : sourceFileList) {
+ java.net.URI relativizedSrc = commonURI.relativize(source.toURI());
+ if (relativizedSrc.isAbsolute()) {
+ log.error("Source folder '" + source
+ + "' must be a child of the project folder '" + commonRoot + "'");
+ return false;
+ }
+ projectConfig.addSourceFolderMapping(relativizedSrc.getPath(), relativizedTarget.getPath());
+ }
workspaceConfig.addProjectConfig(projectConfig);
workspaceConfigProvider.setWorkspaceConfig(workspaceConfig);
+ return true;
+ }
+
+ private File getOutputPathFile() {
+ try {
+ return new File(outputPath).getCanonicalFile();
+ } catch (IOException e) {
+ log.error("Invalid target folder '" + outputPath + "' (" + e.getMessage() + ")");
+ return null;
+ }
+ }
+
+ private List<File> getSourcePathFileList() {
+ List<File> sourceFileList = new ArrayList<File>();
+ for (String path : getSourcePathDirectories()) {
+ try {
+ sourceFileList.add(new File(path).getCanonicalFile());
+ } catch (IOException e) {
+ log.error("Invalid source folder '" + path + "' (" + e.getMessage() + ")");
+ return null;
+ }
+ }
+ return sourceFileList;
+ }
+
+ private File determineCommonRoot(File outputFile, List<File> sourceFileList) {
+ List<File> pathList = new ArrayList<File>(sourceFileList);
+ pathList.add(outputFile);
+
+ List<List<File>> pathParts = new ArrayList<List<File>>();
+
+ for (File path : pathList) {
+ List<File> partsList = new ArrayList<File>();
+ File subdir = path;
+ while (subdir != null) {
+ partsList.add(subdir);
+ subdir = subdir.getParentFile();
+ }
+ pathParts.add(partsList);
+ }
+ int i = 1;
+ File result = null;
+ while (true) {
+ File compareWith = null;
+ for (List<File> parts : pathParts) {
+ if (parts.size() < i) {
+ return result;
+ }
+ File part = parts.get(parts.size() - i);
+ if (compareWith == null) {
+ compareWith = part;
+ } else {
+ if (!compareWith.equals(part)) {
+ return result;
+ }
+ }
+ }
+ result = compareWith;
+ i++;
+ }
}
public boolean compile() {
try {
if (workspaceConfigProvider.getWorkspaceConfig() == null) {
- configureWorkspace();
+ if (!configureWorkspace()) {
+ return false;
+ }
}
ResourceSet resourceSet = resourceSetProvider.get();
File classDirectory = createTempDir("classes");
diff --git a/tests/org.eclipse.xtend.core.tests/batch-compiler-data/bug417177/dir1/src1/mypackage/Bug417177_1.xtend b/tests/org.eclipse.xtend.core.tests/batch-compiler-data/bug417177/dir1/src1/mypackage/Bug417177_1.xtend
new file mode 100644
index 0000000..0b6523d
--- /dev/null
+++ b/tests/org.eclipse.xtend.core.tests/batch-compiler-data/bug417177/dir1/src1/mypackage/Bug417177_1.xtend
@@ -0,0 +1,7 @@
+package mypackage
+
+class Bug417177_1 {
+ def static void test() {
+ new Bug417177_2()
+ }
+} \ No newline at end of file
diff --git a/tests/org.eclipse.xtend.core.tests/batch-compiler-data/bug417177/dir2/dir2a/src2/mypackage/Bug417177_2.xtend b/tests/org.eclipse.xtend.core.tests/batch-compiler-data/bug417177/dir2/dir2a/src2/mypackage/Bug417177_2.xtend
new file mode 100644
index 0000000..de55245
--- /dev/null
+++ b/tests/org.eclipse.xtend.core.tests/batch-compiler-data/bug417177/dir2/dir2a/src2/mypackage/Bug417177_2.xtend
@@ -0,0 +1,7 @@
+package mypackage
+
+class Bug417177_2 {
+ def static void test() {
+ new Bug417177_1()
+ }
+} \ No newline at end of file
diff --git a/tests/org.eclipse.xtend.core.tests/batch-compiler-data/bug417177/dir3/.gitignore b/tests/org.eclipse.xtend.core.tests/batch-compiler-data/bug417177/dir3/.gitignore
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tests/org.eclipse.xtend.core.tests/batch-compiler-data/bug417177/dir3/.gitignore
diff --git a/tests/org.eclipse.xtend.core.tests/src/org/eclipse/xtend/core/tests/compiler/batch/TestBatchCompiler.xtend b/tests/org.eclipse.xtend.core.tests/src/org/eclipse/xtend/core/tests/compiler/batch/TestBatchCompiler.xtend
index 709569d..847d131 100644
--- a/tests/org.eclipse.xtend.core.tests/src/org/eclipse/xtend/core/tests/compiler/batch/TestBatchCompiler.xtend
+++ b/tests/org.eclipse.xtend.core.tests/src/org/eclipse/xtend/core/tests/compiler/batch/TestBatchCompiler.xtend
@@ -42,6 +42,9 @@ class TestBatchCompiler {
static String BUG396747_SRC_DIRECTORY = "./batch-compiler-data/bug396747"
static String BUG410594_SRC_DIRECTORY = "./batch-compiler-data/bug410594"
static String BUG416262_SRC_DIRECTORY = "./batch-compiler-data/bug416262"
+ static String BUG417177_SRC_DIRECTORY_1 = "./batch-compiler-data/bug417177/dir1/src1/"
+ static String BUG417177_SRC_DIRECTORY_2 = "./batch-compiler-data/bug417177/dir2/dir2a/src2"
+ static String BUG417177_OUTPUT_DIRECTORY = "./batch-compiler-data/bug417177/dir3/bin"
static String TEMP_DIRECTORY = "./test-temp-dir"
static String TEMP_DIRECTORY_WITH_SPACES = "./test temp dir"
@@ -71,9 +74,9 @@ class TestBatchCompiler {
}
@Test def void testWorkspaceConfig() {
- batchCompiler.configureWorkspace();
+ assertTrue(batchCompiler.configureWorkspace());
val config = workspaceConfigProvider.get
- assertEquals(new File('..').canonicalFile.absolutePath, config.absoluteFileSystemPath)
+ assertEquals(new File('..').canonicalPath, config.absoluteFileSystemPath)
val project = config.projects.values.head
val projectPath = "/"+new File(".").canonicalFile.name
assertEquals(projectPath, project.rootPath.toString)
@@ -83,6 +86,189 @@ class TestBatchCompiler {
assertEquals(projectPath+"/test-result",target.toString)
}
+ @Test def void testWorkspaceConfigMultipleSourceDirs1() {
+ batchCompiler.sourcePath = '''ws/prj1/src«File.pathSeparator»ws/prj1/src-gen'''
+ batchCompiler.outputPath = '''ws/prj1/bin'''
+
+ assertTrue(batchCompiler.configureWorkspace());
+
+ val config = workspaceConfigProvider.get
+ assertEquals(new File('ws').canonicalPath, config.absoluteFileSystemPath)
+ val project = config.projects.values.head
+ assertEquals("/prj1", project.rootPath.toString)
+ assertEquals(2, project.sourceFolderMappings.size)
+ val keyPaths = project.sourceFolderMappings.keySet.sortBy[lastSegment]
+ keyPaths.get(0) => [
+ assertEquals("/prj1/src", toString)
+ assertEquals("/prj1/bin", project.sourceFolderMappings.get(it).toString)
+ ]
+ keyPaths.get(1) => [
+ assertEquals("/prj1/src-gen", toString)
+ assertEquals("/prj1/bin", project.sourceFolderMappings.get(it).toString)
+ ]
+ }
+
+ @Test def void testWorkspaceConfigMultipleSourceDirs2AbsPaths() {
+ batchCompiler.sourcePath = '''/tmp/ws/prj1/src«File.pathSeparator»/tmp/ws/prj1/src-gen'''
+ batchCompiler.outputPath = '''/tmp/ws/prj1/bin'''
+
+ assertTrue(batchCompiler.configureWorkspace());
+
+ val config = workspaceConfigProvider.get
+ assertEquals(new File('/tmp/ws').canonicalPath, config.absoluteFileSystemPath)
+ val project = config.projects.values.head
+ assertEquals("/prj1", project.rootPath.toString)
+ assertEquals(2, project.sourceFolderMappings.size)
+ val keyPaths = project.sourceFolderMappings.keySet.sortBy[lastSegment]
+ keyPaths.get(0) => [
+ assertEquals("/prj1/src", toString)
+ assertEquals("/prj1/bin", project.sourceFolderMappings.get(it).toString)
+ ]
+ keyPaths.get(1) => [
+ assertEquals("/prj1/src-gen", toString)
+ assertEquals("/prj1/bin", project.sourceFolderMappings.get(it).toString)
+ ]
+ }
+
+ @Test def void testWorkspaceConfigMultipleSourceDirs3() {
+ batchCompiler.sourcePath = '''ws/prj1/dir1/src«File.pathSeparator»ws/prj1/src-gen'''
+ batchCompiler.outputPath = '''ws/prj1/dir2/bin'''
+
+ assertTrue(batchCompiler.configureWorkspace());
+
+ val config = workspaceConfigProvider.get
+ assertEquals(new File('ws').canonicalPath, config.absoluteFileSystemPath)
+ val project = config.projects.values.head
+ assertEquals("/prj1", project.rootPath.toString)
+ assertEquals(2, project.sourceFolderMappings.size)
+ val keyPaths = project.sourceFolderMappings.keySet.sortBy[lastSegment]
+ keyPaths.get(0) => [
+ assertEquals("/prj1/dir1/src", toString)
+ assertEquals("/prj1/dir2/bin", project.sourceFolderMappings.get(it).toString)
+ ]
+ keyPaths.get(1) => [
+ assertEquals("/prj1/src-gen", toString)
+ assertEquals("/prj1/dir2/bin", project.sourceFolderMappings.get(it).toString)
+ ]
+ }
+
+ @Test def void testWorkspaceConfigMultipleSourceDirs4() {
+ batchCompiler.sourcePath = '''ws/prj1/src«File.pathSeparator»ws/prj1/dir1/src-gen'''
+ batchCompiler.outputPath = '''ws/prj1/bin'''
+
+ assertTrue(batchCompiler.configureWorkspace());
+
+ val config = workspaceConfigProvider.get
+ assertEquals(new File('ws').canonicalPath, config.absoluteFileSystemPath)
+ val project = config.projects.values.head
+ assertEquals("/prj1", project.rootPath.toString)
+ assertEquals(2, project.sourceFolderMappings.size)
+ val keyPaths = project.sourceFolderMappings.keySet.sortBy[lastSegment]
+ keyPaths.get(0) => [
+ assertEquals("/prj1/src", toString)
+ assertEquals("/prj1/bin", project.sourceFolderMappings.get(it).toString)
+ ]
+ keyPaths.get(1) => [
+ assertEquals("/prj1/dir1/src-gen", toString)
+ assertEquals("/prj1/bin", project.sourceFolderMappings.get(it).toString)
+ ]
+ }
+
+ @Test def void testWorkspaceConfigMultipleSourceDirs5() {
+ batchCompiler.sourcePath = '''ws/prj1/dir1/dir1a/src«File.pathSeparator»ws/prj1/dir3/dir3a/src-gen'''
+ batchCompiler.outputPath = '''ws/prj1/dir2/dir2a/bin'''
+
+ assertTrue(batchCompiler.configureWorkspace());
+
+ val config = workspaceConfigProvider.get
+ assertEquals(new File('ws').canonicalPath, config.absoluteFileSystemPath)
+ val project = config.projects.values.head
+ assertEquals("/prj1", project.rootPath.toString)
+ assertEquals(2, project.sourceFolderMappings.size)
+ val keyPaths = project.sourceFolderMappings.keySet.sortBy[lastSegment]
+ keyPaths.get(0) => [
+ assertEquals("/prj1/dir1/dir1a/src", toString)
+ assertEquals("/prj1/dir2/dir2a/bin", project.sourceFolderMappings.get(it).toString)
+ ]
+ keyPaths.get(1) => [
+ assertEquals("/prj1/dir3/dir3a/src-gen", toString)
+ assertEquals("/prj1/dir2/dir2a/bin", project.sourceFolderMappings.get(it).toString)
+ ]
+ }
+
+ @Test def void testWorkspaceConfigMultipleSourceDirs6() {
+ batchCompiler.sourcePath = '''dir1/ws/prj1/dir2/dir3/dir4/src1«File.pathSeparator
+ »dir1/ws/prj1/dir2/dir3/src2«File.pathSeparator
+ »dir1/ws/prj1/dir2/src3«File.pathSeparator
+ »dir1/ws/prj1/src4'''
+ batchCompiler.outputPath = '''dir1/ws/prj1/dir2/dir3/dir4/dir5/bin'''
+
+ assertTrue(batchCompiler.configureWorkspace());
+
+ val config = workspaceConfigProvider.get
+ assertEquals(new File('dir1/ws').canonicalPath, config.absoluteFileSystemPath)
+ val project = config.projects.values.head
+ assertEquals("/prj1", project.rootPath.toString)
+ assertEquals(4, project.sourceFolderMappings.size)
+ val keyPaths = project.sourceFolderMappings.keySet.sortBy[lastSegment]
+ keyPaths.get(0) => [
+ assertEquals("/prj1/dir2/dir3/dir4/src1", toString)
+ assertEquals("/prj1/dir2/dir3/dir4/dir5/bin", project.sourceFolderMappings.get(it).toString)
+ ]
+ keyPaths.get(1) => [
+ assertEquals("/prj1/dir2/dir3/src2", toString)
+ assertEquals("/prj1/dir2/dir3/dir4/dir5/bin", project.sourceFolderMappings.get(it).toString)
+ ]
+ keyPaths.get(2) => [
+ assertEquals("/prj1/dir2/src3", toString)
+ assertEquals("/prj1/dir2/dir3/dir4/dir5/bin", project.sourceFolderMappings.get(it).toString)
+ ]
+ keyPaths.get(3) => [
+ assertEquals("/prj1/src4", toString)
+ assertEquals("/prj1/dir2/dir3/dir4/dir5/bin", project.sourceFolderMappings.get(it).toString)
+ ]
+ }
+
+ @Test def void testWorkspaceConfigSameDir() {
+ batchCompiler.sourcePath = "ws/prj1"
+ batchCompiler.outputPath = "ws/prj1"
+
+ assertTrue(batchCompiler.configureWorkspace());
+
+ val config = workspaceConfigProvider.get
+ assertEquals(new File('ws').canonicalPath, config.absoluteFileSystemPath)
+ val project = config.projects.values.head
+ assertEquals("/prj1", project.rootPath.toString)
+ assertEquals(1, project.sourceFolderMappings.size)
+ val keyPaths = project.sourceFolderMappings.keySet.sortBy[lastSegment]
+ keyPaths.get(0) => [
+ assertEquals("/prj1", toString)
+ assertEquals("/prj1", project.sourceFolderMappings.get(it).toString)
+ ]
+ }
+
+ @Test def void testWorkspaceConfigWithoutCommonProjectDir() {
+ batchCompiler.sourcePath = '''/tmp/ws/prj1/src'''
+ batchCompiler.outputPath = '''/usr/local/tmp/ws/prj1/bin'''
+
+ assertFalse(batchCompiler.configureWorkspace());
+ }
+
+ @Test def void testWorkspaceConfigWithoutCommonWorkspaceDir() {
+ batchCompiler.sourcePath = '''/tmp/src'''
+ batchCompiler.outputPath = '''/tmp/bin'''
+
+ assertFalse(batchCompiler.configureWorkspace());
+ }
+
+ @Test def void testWorkspaceConfigWithTopLevelCommonWorkspaceDir() {
+ batchCompiler.sourcePath = '''/tmp/prj/src'''
+ batchCompiler.outputPath = '''/tmp/prj/bin'''
+
+ assertTrue(batchCompiler.configureWorkspace());
+ }
+
+
@Test
def void bug368551() {
batchCompiler.tempDirectory = TEMP_DIRECTORY_WITH_SPACES
@@ -122,6 +308,19 @@ class TestBatchCompiler {
batchCompiler.sourcePath = BUG416262_SRC_DIRECTORY
assertTrue("Compiling funny file pass", batchCompiler.compile)
}
+
+ @Test
+ def void bug417177() {
+ val outputDir = new File(BUG417177_OUTPUT_DIRECTORY)
+ outputDir.mkdirs();
+ new File(outputDir, "mypackage/Bug417177_1.java").delete
+ new File(outputDir, "mypackage/Bug417177_2.java").delete
+ batchCompiler.sourcePath = '''«BUG417177_SRC_DIRECTORY_1»«File.pathSeparator»«BUG417177_SRC_DIRECTORY_2»'''
+ batchCompiler.outputPath = BUG417177_OUTPUT_DIRECTORY
+ assertTrue("Compiling files from multiple source directories", batchCompiler.compile)
+ assertTrue(new File(outputDir, "mypackage/Bug417177_1.java").exists)
+ assertTrue(new File(outputDir, "mypackage/Bug417177_2.java").exists)
+ }
@Test
def void testActiveAnnotatons1() {
diff --git a/tests/org.eclipse.xtend.core.tests/xtend-gen/org/eclipse/xtend/core/tests/compiler/batch/TestBatchCompiler.java b/tests/org.eclipse.xtend.core.tests/xtend-gen/org/eclipse/xtend/core/tests/compiler/batch/TestBatchCompiler.java
index b850740..291efaa 100644
--- a/tests/org.eclipse.xtend.core.tests/xtend-gen/org/eclipse/xtend/core/tests/compiler/batch/TestBatchCompiler.java
+++ b/tests/org.eclipse.xtend.core.tests/xtend-gen/org/eclipse/xtend/core/tests/compiler/batch/TestBatchCompiler.java
@@ -17,6 +17,7 @@ import java.util.Set;
import org.eclipse.xtend.core.compiler.batch.XtendBatchCompiler;
import org.eclipse.xtend.core.tests.RuntimeInjectorProvider;
import org.eclipse.xtend.lib.macro.file.Path;
+import org.eclipse.xtend2.lib.StringConcatenation;
import org.eclipse.xtext.junit4.InjectWith;
import org.eclipse.xtext.junit4.XtextRunner;
import org.eclipse.xtext.util.Files;
@@ -25,7 +26,10 @@ import org.eclipse.xtext.xbase.file.RuntimeWorkspaceConfigProvider;
import org.eclipse.xtext.xbase.file.WorkspaceConfig;
import org.eclipse.xtext.xbase.lib.Conversions;
import org.eclipse.xtext.xbase.lib.Exceptions;
+import org.eclipse.xtext.xbase.lib.Functions.Function1;
import org.eclipse.xtext.xbase.lib.IterableExtensions;
+import org.eclipse.xtext.xbase.lib.ObjectExtensions;
+import org.eclipse.xtext.xbase.lib.Procedures.Procedure1;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
@@ -59,6 +63,12 @@ public class TestBatchCompiler {
private static String BUG416262_SRC_DIRECTORY = "./batch-compiler-data/bug416262";
+ private static String BUG417177_SRC_DIRECTORY_1 = "./batch-compiler-data/bug417177/dir1/src1/";
+
+ private static String BUG417177_SRC_DIRECTORY_2 = "./batch-compiler-data/bug417177/dir2/dir2a/src2";
+
+ private static String BUG417177_OUTPUT_DIRECTORY = "./batch-compiler-data/bug417177/dir3/bin";
+
private static String TEMP_DIRECTORY = "./test-temp-dir";
private static String TEMP_DIRECTORY_WITH_SPACES = "./test temp dir";
@@ -113,19 +123,19 @@ public class TestBatchCompiler {
@Test
public void testWorkspaceConfig() {
try {
- this.batchCompiler.configureWorkspace();
+ boolean _configureWorkspace = this.batchCompiler.configureWorkspace();
+ Assert.assertTrue(_configureWorkspace);
final WorkspaceConfig config = this.workspaceConfigProvider.get();
File _file = new File("..");
- File _canonicalFile = _file.getCanonicalFile();
- String _absolutePath = _canonicalFile.getAbsolutePath();
+ String _canonicalPath = _file.getCanonicalPath();
String _absoluteFileSystemPath = config.getAbsoluteFileSystemPath();
- Assert.assertEquals(_absolutePath, _absoluteFileSystemPath);
+ Assert.assertEquals(_canonicalPath, _absoluteFileSystemPath);
Map<String,ProjectConfig> _projects = config.getProjects();
Collection<ProjectConfig> _values = _projects.values();
final ProjectConfig project = IterableExtensions.<ProjectConfig>head(_values);
File _file_1 = new File(".");
- File _canonicalFile_1 = _file_1.getCanonicalFile();
- String _name = _canonicalFile_1.getName();
+ File _canonicalFile = _file_1.getCanonicalFile();
+ String _name = _canonicalFile.getName();
final String projectPath = ("/" + _name);
Path _rootPath = project.getRootPath();
String _string = _rootPath.toString();
@@ -147,6 +157,507 @@ public class TestBatchCompiler {
}
@Test
+ public void testWorkspaceConfigMultipleSourceDirs1() {
+ try {
+ StringConcatenation _builder = new StringConcatenation();
+ _builder.append("ws/prj1/src");
+ _builder.append(File.pathSeparator, "");
+ _builder.append("ws/prj1/src-gen");
+ this.batchCompiler.setSourcePath(_builder.toString());
+ StringConcatenation _builder_1 = new StringConcatenation();
+ _builder_1.append("ws/prj1/bin");
+ this.batchCompiler.setOutputPath(_builder_1.toString());
+ boolean _configureWorkspace = this.batchCompiler.configureWorkspace();
+ Assert.assertTrue(_configureWorkspace);
+ final WorkspaceConfig config = this.workspaceConfigProvider.get();
+ File _file = new File("ws");
+ String _canonicalPath = _file.getCanonicalPath();
+ String _absoluteFileSystemPath = config.getAbsoluteFileSystemPath();
+ Assert.assertEquals(_canonicalPath, _absoluteFileSystemPath);
+ Map<String,ProjectConfig> _projects = config.getProjects();
+ Collection<ProjectConfig> _values = _projects.values();
+ final ProjectConfig project = IterableExtensions.<ProjectConfig>head(_values);
+ Path _rootPath = project.getRootPath();
+ String _string = _rootPath.toString();
+ Assert.assertEquals("/prj1", _string);
+ Map<Path,Path> _sourceFolderMappings = project.getSourceFolderMappings();
+ int _size = _sourceFolderMappings.size();
+ Assert.assertEquals(2, _size);
+ Map<Path,Path> _sourceFolderMappings_1 = project.getSourceFolderMappings();
+ Set<Path> _keySet = _sourceFolderMappings_1.keySet();
+ final Function1<Path,String> _function = new Function1<Path,String>() {
+ public String apply(final Path it) {
+ String _lastSegment = it.getLastSegment();
+ return _lastSegment;
+ }
+ };
+ final List<Path> keyPaths = IterableExtensions.<Path, String>sortBy(_keySet, _function);
+ Path _get = keyPaths.get(0);
+ final Procedure1<Path> _function_1 = new Procedure1<Path>() {
+ public void apply(final Path it) {
+ String _string = it.toString();
+ Assert.assertEquals("/prj1/src", _string);
+ Map<Path,Path> _sourceFolderMappings = project.getSourceFolderMappings();
+ Path _get = _sourceFolderMappings.get(it);
+ String _string_1 = _get.toString();
+ Assert.assertEquals("/prj1/bin", _string_1);
+ }
+ };
+ ObjectExtensions.<Path>operator_doubleArrow(_get, _function_1);
+ Path _get_1 = keyPaths.get(1);
+ final Procedure1<Path> _function_2 = new Procedure1<Path>() {
+ public void apply(final Path it) {
+ String _string = it.toString();
+ Assert.assertEquals("/prj1/src-gen", _string);
+ Map<Path,Path> _sourceFolderMappings = project.getSourceFolderMappings();
+ Path _get = _sourceFolderMappings.get(it);
+ String _string_1 = _get.toString();
+ Assert.assertEquals("/prj1/bin", _string_1);
+ }
+ };
+ ObjectExtensions.<Path>operator_doubleArrow(_get_1, _function_2);
+ } catch (Throwable _e) {
+ throw Exceptions.sneakyThrow(_e);
+ }
+ }
+
+ @Test
+ public void testWorkspaceConfigMultipleSourceDirs2AbsPaths() {
+ try {
+ StringConcatenation _builder = new StringConcatenation();
+ _builder.append("/tmp/ws/prj1/src");
+ _builder.append(File.pathSeparator, "");
+ _builder.append("/tmp/ws/prj1/src-gen");
+ this.batchCompiler.setSourcePath(_builder.toString());
+ StringConcatenation _builder_1 = new StringConcatenation();
+ _builder_1.append("/tmp/ws/prj1/bin");
+ this.batchCompiler.setOutputPath(_builder_1.toString());
+ boolean _configureWorkspace = this.batchCompiler.configureWorkspace();
+ Assert.assertTrue(_configureWorkspace);
+ final WorkspaceConfig config = this.workspaceConfigProvider.get();
+ File _file = new File("/tmp/ws");
+ String _canonicalPath = _file.getCanonicalPath();
+ String _absoluteFileSystemPath = config.getAbsoluteFileSystemPath();
+ Assert.assertEquals(_canonicalPath, _absoluteFileSystemPath);
+ Map<String,ProjectConfig> _projects = config.getProjects();
+ Collection<ProjectConfig> _values = _projects.values();
+ final ProjectConfig project = IterableExtensions.<ProjectConfig>head(_values);
+ Path _rootPath = project.getRootPath();
+ String _string = _rootPath.toString();
+ Assert.assertEquals("/prj1", _string);
+ Map<Path,Path> _sourceFolderMappings = project.getSourceFolderMappings();
+ int _size = _sourceFolderMappings.size();
+ Assert.assertEquals(2, _size);
+ Map<Path,Path> _sourceFolderMappings_1 = project.getSourceFolderMappings();
+ Set<Path> _keySet = _sourceFolderMappings_1.keySet();
+ final Function1<Path,String> _function = new Function1<Path,String>() {
+ public String apply(final Path it) {
+ String _lastSegment = it.getLastSegment();
+ return _lastSegment;
+ }
+ };
+ final List<Path> keyPaths = IterableExtensions.<Path, String>sortBy(_keySet, _function);
+ Path _get = keyPaths.get(0);
+ final Procedure1<Path> _function_1 = new Procedure1<Path>() {
+ public void apply(final Path it) {
+ String _string = it.toString();
+ Assert.assertEquals("/prj1/src", _string);
+ Map<Path,Path> _sourceFolderMappings = project.getSourceFolderMappings();
+ Path _get = _sourceFolderMappings.get(it);
+ String _string_1 = _get.toString();
+ Assert.assertEquals("/prj1/bin", _string_1);
+ }
+ };
+ ObjectExtensions.<Path>operator_doubleArrow(_get, _function_1);
+ Path _get_1 = keyPaths.get(1);
+ final Procedure1<Path> _function_2 = new Procedure1<Path>() {
+ public void apply(final Path it) {
+ String _string = it.toString();
+ Assert.assertEquals("/prj1/src-gen", _string);
+ Map<Path,Path> _sourceFolderMappings = project.getSourceFolderMappings();
+ Path _get = _sourceFolderMappings.get(it);
+ String _string_1 = _get.toString();
+ Assert.assertEquals("/prj1/bin", _string_1);
+ }
+ };
+ ObjectExtensions.<Path>operator_doubleArrow(_get_1, _function_2);
+ } catch (Throwable _e) {
+ throw Exceptions.sneakyThrow(_e);
+ }
+ }
+
+ @Test
+ public void testWorkspaceConfigMultipleSourceDirs3() {
+ try {
+ StringConcatenation _builder = new StringConcatenation();
+ _builder.append("ws/prj1/dir1/src");
+ _builder.append(File.pathSeparator, "");
+ _builder.append("ws/prj1/src-gen");
+ this.batchCompiler.setSourcePath(_builder.toString());
+ StringConcatenation _builder_1 = new StringConcatenation();
+ _builder_1.append("ws/prj1/dir2/bin");
+ this.batchCompiler.setOutputPath(_builder_1.toString());
+ boolean _configureWorkspace = this.batchCompiler.configureWorkspace();
+ Assert.assertTrue(_configureWorkspace);
+ final WorkspaceConfig config = this.workspaceConfigProvider.get();
+ File _file = new File("ws");
+ String _canonicalPath = _file.getCanonicalPath();
+ String _absoluteFileSystemPath = config.getAbsoluteFileSystemPath();
+ Assert.assertEquals(_canonicalPath, _absoluteFileSystemPath);
+ Map<String,ProjectConfig> _projects = config.getProjects();
+ Collection<ProjectConfig> _values = _projects.values();
+ final ProjectConfig project = IterableExtensions.<ProjectConfig>head(_values);
+ Path _rootPath = project.getRootPath();
+ String _string = _rootPath.toString();
+ Assert.assertEquals("/prj1", _string);
+ Map<Path,Path> _sourceFolderMappings = project.getSourceFolderMappings();
+ int _size = _sourceFolderMappings.size();
+ Assert.assertEquals(2, _size);
+ Map<Path,Path> _sourceFolderMappings_1 = project.getSourceFolderMappings();
+ Set<Path> _keySet = _sourceFolderMappings_1.keySet();
+ final Function1<Path,String> _function = new Function1<Path,String>() {
+ public String apply(final Path it) {
+ String _lastSegment = it.getLastSegment();
+ return _lastSegment;
+ }
+ };
+ final List<Path> keyPaths = IterableExtensions.<Path, String>sortBy(_keySet, _function);
+ Path _get = keyPaths.get(0);
+ final Procedure1<Path> _function_1 = new Procedure1<Path>() {
+ public void apply(final Path it) {
+ String _string = it.toString();
+ Assert.assertEquals("/prj1/dir1/src", _string);
+ Map<Path,Path> _sourceFolderMappings = project.getSourceFolderMappings();
+ Path _get = _sourceFolderMappings.get(it);
+ String _string_1 = _get.toString();
+ Assert.assertEquals("/prj1/dir2/bin", _string_1);
+ }
+ };
+ ObjectExtensions.<Path>operator_doubleArrow(_get, _function_1);
+ Path _get_1 = keyPaths.get(1);
+ final Procedure1<Path> _function_2 = new Procedure1<Path>() {
+ public void apply(final Path it) {
+ String _string = it.toString();
+ Assert.assertEquals("/prj1/src-gen", _string);
+ Map<Path,Path> _sourceFolderMappings = project.getSourceFolderMappings();
+ Path _get = _sourceFolderMappings.get(it);
+ String _string_1 = _get.toString();
+ Assert.assertEquals("/prj1/dir2/bin", _string_1);
+ }
+ };
+ ObjectExtensions.<Path>operator_doubleArrow(_get_1, _function_2);
+ } catch (Throwable _e) {
+ throw Exceptions.sneakyThrow(_e);
+ }
+ }
+
+ @Test
+ public void testWorkspaceConfigMultipleSourceDirs4() {
+ try {
+ StringConcatenation _builder = new StringConcatenation();
+ _builder.append("ws/prj1/src");
+ _builder.append(File.pathSeparator, "");
+ _builder.append("ws/prj1/dir1/src-gen");
+ this.batchCompiler.setSourcePath(_builder.toString());
+ StringConcatenation _builder_1 = new StringConcatenation();
+ _builder_1.append("ws/prj1/bin");
+ this.batchCompiler.setOutputPath(_builder_1.toString());
+ boolean _configureWorkspace = this.batchCompiler.configureWorkspace();
+ Assert.assertTrue(_configureWorkspace);
+ final WorkspaceConfig config = this.workspaceConfigProvider.get();
+ File _file = new File("ws");
+ String _canonicalPath = _file.getCanonicalPath();
+ String _absoluteFileSystemPath = config.getAbsoluteFileSystemPath();
+ Assert.assertEquals(_canonicalPath, _absoluteFileSystemPath);
+ Map<String,ProjectConfig> _projects = config.getProjects();
+ Collection<ProjectConfig> _values = _projects.values();
+ final ProjectConfig project = IterableExtensions.<ProjectConfig>head(_values);
+ Path _rootPath = project.getRootPath();
+ String _string = _rootPath.toString();
+ Assert.assertEquals("/prj1", _string);
+ Map<Path,Path> _sourceFolderMappings = project.getSourceFolderMappings();
+ int _size = _sourceFolderMappings.size();
+ Assert.assertEquals(2, _size);
+ Map<Path,Path> _sourceFolderMappings_1 = project.getSourceFolderMappings();
+ Set<Path> _keySet = _sourceFolderMappings_1.keySet();
+ final Function1<Path,String> _function = new Function1<Path,String>() {
+ public String apply(final Path it) {
+ String _lastSegment = it.getLastSegment();
+ return _lastSegment;
+ }
+ };
+ final List<Path> keyPaths = IterableExtensions.<Path, String>sortBy(_keySet, _function);
+ Path _get = keyPaths.get(0);
+ final Procedure1<Path> _function_1 = new Procedure1<Path>() {
+ public void apply(final Path it) {
+ String _string = it.toString();
+ Assert.assertEquals("/prj1/src", _string);
+ Map<Path,Path> _sourceFolderMappings = project.getSourceFolderMappings();
+ Path _get = _sourceFolderMappings.get(it);
+ String _string_1 = _get.toString();
+ Assert.assertEquals("/prj1/bin", _string_1);
+ }
+ };
+ ObjectExtensions.<Path>operator_doubleArrow(_get, _function_1);
+ Path _get_1 = keyPaths.get(1);
+ final Procedure1<Path> _function_2 = new Procedure1<Path>() {
+ public void apply(final Path it) {
+ String _string = it.toString();
+ Assert.assertEquals("/prj1/dir1/src-gen", _string);
+ Map<Path,Path> _sourceFolderMappings = project.getSourceFolderMappings();
+ Path _get = _sourceFolderMappings.get(it);
+ String _string_1 = _get.toString();
+ Assert.assertEquals("/prj1/bin", _string_1);
+ }
+ };
+ ObjectExtensions.<Path>operator_doubleArrow(_get_1, _function_2);
+ } catch (Throwable _e) {
+ throw Exceptions.sneakyThrow(_e);
+ }
+ }
+
+ @Test
+ public void testWorkspaceConfigMultipleSourceDirs5() {
+ try {
+ StringConcatenation _builder = new StringConcatenation();
+ _builder.append("ws/prj1/dir1/dir1a/src");
+ _builder.append(File.pathSeparator, "");
+ _builder.append("ws/prj1/dir3/dir3a/src-gen");
+ this.batchCompiler.setSourcePath(_builder.toString());
+ StringConcatenation _builder_1 = new StringConcatenation();
+ _builder_1.append("ws/prj1/dir2/dir2a/bin");
+ this.batchCompiler.setOutputPath(_builder_1.toString());
+ boolean _configureWorkspace = this.batchCompiler.configureWorkspace();
+ Assert.assertTrue(_configureWorkspace);
+ final WorkspaceConfig config = this.workspaceConfigProvider.get();
+ File _file = new File("ws");
+ String _canonicalPath = _file.getCanonicalPath();
+ String _absoluteFileSystemPath = config.getAbsoluteFileSystemPath();
+ Assert.assertEquals(_canonicalPath, _absoluteFileSystemPath);
+ Map<String,ProjectConfig> _projects = config.getProjects();
+ Collection<ProjectConfig> _values = _projects.values();
+ final ProjectConfig project = IterableExtensions.<ProjectConfig>head(_values);
+ Path _rootPath = project.getRootPath();
+ String _string = _rootPath.toString();
+ Assert.assertEquals("/prj1", _string);
+ Map<Path,Path> _sourceFolderMappings = project.getSourceFolderMappings();
+ int _size = _sourceFolderMappings.size();
+ Assert.assertEquals(2, _size);
+ Map<Path,Path> _sourceFolderMappings_1 = project.getSourceFolderMappings();
+ Set<Path> _keySet = _sourceFolderMappings_1.keySet();
+ final Function1<Path,String> _function = new Function1<Path,String>() {
+ public String apply(final Path it) {
+ String _lastSegment = it.getLastSegment();
+ return _lastSegment;
+ }
+ };
+ final List<Path> keyPaths = IterableExtensions.<Path, String>sortBy(_keySet, _function);
+ Path _get = keyPaths.get(0);
+ final Procedure1<Path> _function_1 = new Procedure1<Path>() {
+ public void apply(final Path it) {
+ String _string = it.toString();
+ Assert.assertEquals("/prj1/dir1/dir1a/src", _string);
+ Map<Path,Path> _sourceFolderMappings = project.getSourceFolderMappings();
+ Path _get = _sourceFolderMappings.get(it);
+ String _string_1 = _get.toString();
+ Assert.assertEquals("/prj1/dir2/dir2a/bin", _string_1);
+ }
+ };
+ ObjectExtensions.<Path>operator_doubleArrow(_get, _function_1);
+ Path _get_1 = keyPaths.get(1);
+ final Procedure1<Path> _function_2 = new Procedure1<Path>() {
+ public void apply(final Path it) {
+ String _string = it.toString();
+ Assert.assertEquals("/prj1/dir3/dir3a/src-gen", _string);
+ Map<Path,Path> _sourceFolderMappings = project.getSourceFolderMappings();
+ Path _get = _sourceFolderMappings.get(it);
+ String _string_1 = _get.toString();
+ Assert.assertEquals("/prj1/dir2/dir2a/bin", _string_1);
+ }
+ };
+ ObjectExtensions.<Path>operator_doubleArrow(_get_1, _function_2);
+ } catch (Throwable _e) {
+ throw Exceptions.sneakyThrow(_e);
+ }
+ }
+
+ @Test
+ public void testWorkspaceConfigMultipleSourceDirs6() {
+ try {
+ StringConcatenation _builder = new StringConcatenation();
+ _builder.append("dir1/ws/prj1/dir2/dir3/dir4/src1");
+ _builder.append(File.pathSeparator, "");
+ _builder.append("dir1/ws/prj1/dir2/dir3/src2");
+ _builder.append(File.pathSeparator, "");
+ _builder.append("dir1/ws/prj1/dir2/src3");
+ _builder.append(File.pathSeparator, "");
+ _builder.append("dir1/ws/prj1/src4");
+ this.batchCompiler.setSourcePath(_builder.toString());
+ StringConcatenation _builder_1 = new StringConcatenation();
+ _builder_1.append("dir1/ws/prj1/dir2/dir3/dir4/dir5/bin");
+ this.batchCompiler.setOutputPath(_builder_1.toString());
+ boolean _configureWorkspace = this.batchCompiler.configureWorkspace();
+ Assert.assertTrue(_configureWorkspace);
+ final WorkspaceConfig config = this.workspaceConfigProvider.get();
+ File _file = new File("dir1/ws");
+ String _canonicalPath = _file.getCanonicalPath();
+ String _absoluteFileSystemPath = config.getAbsoluteFileSystemPath();
+ Assert.assertEquals(_canonicalPath, _absoluteFileSystemPath);
+ Map<String,ProjectConfig> _projects = config.getProjects();
+ Collection<ProjectConfig> _values = _projects.values();
+ final ProjectConfig project = IterableExtensions.<ProjectConfig>head(_values);
+ Path _rootPath = project.getRootPath();
+ String _string = _rootPath.toString();
+ Assert.assertEquals("/prj1", _string);
+ Map<Path,Path> _sourceFolderMappings = project.getSourceFolderMappings();
+ int _size = _sourceFolderMappings.size();
+ Assert.assertEquals(4, _size);
+ Map<Path,Path> _sourceFolderMappings_1 = project.getSourceFolderMappings();
+ Set<Path> _keySet = _sourceFolderMappings_1.keySet();
+ final Function1<Path,String> _function = new Function1<Path,String>() {
+ public String apply(final Path it) {
+ String _lastSegment = it.getLastSegment();
+ return _lastSegment;
+ }
+ };
+ final List<Path> keyPaths = IterableExtensions.<Path, String>sortBy(_keySet, _function);
+ Path _get = keyPaths.get(0);
+ final Procedure1<Path> _function_1 = new Procedure1<Path>() {
+ public void apply(final Path it) {
+ String _string = it.toString();
+ Assert.assertEquals("/prj1/dir2/dir3/dir4/src1", _string);
+ Map<Path,Path> _sourceFolderMappings = project.getSourceFolderMappings();
+ Path _get = _sourceFolderMappings.get(it);
+ String _string_1 = _get.toString();
+ Assert.assertEquals("/prj1/dir2/dir3/dir4/dir5/bin", _string_1);
+ }
+ };
+ ObjectExtensions.<Path>operator_doubleArrow(_get, _function_1);
+ Path _get_1 = keyPaths.get(1);
+ final Procedure1<Path> _function_2 = new Procedure1<Path>() {
+ public void apply(final Path it) {
+ String _string = it.toString();
+ Assert.assertEquals("/prj1/dir2/dir3/src2", _string);
+ Map<Path,Path> _sourceFolderMappings = project.getSourceFolderMappings();
+ Path _get = _sourceFolderMappings.get(it);
+ String _string_1 = _get.toString();
+ Assert.assertEquals("/prj1/dir2/dir3/dir4/dir5/bin", _string_1);
+ }
+ };
+ ObjectExtensions.<Path>operator_doubleArrow(_get_1, _function_2);
+ Path _get_2 = keyPaths.get(2);
+ final Procedure1<Path> _function_3 = new Procedure1<Path>() {
+ public void apply(final Path it) {
+ String _string = it.toString();
+ Assert.assertEquals("/prj1/dir2/src3", _string);
+ Map<Path,Path> _sourceFolderMappings = project.getSourceFolderMappings();
+ Path _get = _sourceFolderMappings.get(it);
+ String _string_1 = _get.toString();
+ Assert.assertEquals("/prj1/dir2/dir3/dir4/dir5/bin", _string_1);
+ }
+ };
+ ObjectExtensions.<Path>operator_doubleArrow(_get_2, _function_3);
+ Path _get_3 = keyPaths.get(3);
+ final Procedure1<Path> _function_4 = new Procedure1<Path>() {
+ public void apply(final Path it) {
+ String _string = it.toString();
+ Assert.assertEquals("/prj1/src4", _string);
+ Map<Path,Path> _sourceFolderMappings = project.getSourceFolderMappings();
+ Path _get = _sourceFolderMappings.get(it);
+ String _string_1 = _get.toString();
+ Assert.assertEquals("/prj1/dir2/dir3/dir4/dir5/bin", _string_1);
+ }
+ };
+ ObjectExtensions.<Path>operator_doubleArrow(_get_3, _function_4);
+ } catch (Throwable _e) {
+ throw Exceptions.sneakyThrow(_e);
+ }
+ }
+
+ @Test
+ public void testWorkspaceConfigSameDir() {
+ try {
+ this.batchCompiler.setSourcePath("ws/prj1");
+ this.batchCompiler.setOutputPath("ws/prj1");
+ boolean _configureWorkspace = this.batchCompiler.configureWorkspace();
+ Assert.assertTrue(_configureWorkspace);
+ final WorkspaceConfig config = this.workspaceConfigProvider.get();
+ File _file = new File("ws");
+ String _canonicalPath = _file.getCanonicalPath();
+ String _absoluteFileSystemPath = config.getAbsoluteFileSystemPath();
+ Assert.assertEquals(_canonicalPath, _absoluteFileSystemPath);
+ Map<String,ProjectConfig> _projects = config.getProjects();
+ Collection<ProjectConfig> _values = _projects.values();
+ final ProjectConfig project = IterableExtensions.<ProjectConfig>head(_values);
+ Path _rootPath = project.getRootPath();
+ String _string = _rootPath.toString();
+ Assert.assertEquals("/prj1", _string);
+ Map<Path,Path> _sourceFolderMappings = project.getSourceFolderMappings();
+ int _size = _sourceFolderMappings.size();
+ Assert.assertEquals(1, _size);
+ Map<Path,Path> _sourceFolderMappings_1 = project.getSourceFolderMappings();
+ Set<Path> _keySet = _sourceFolderMappings_1.keySet();
+ final Function1<Path,String> _function = new Function1<Path,String>() {
+ public String apply(final Path it) {
+ String _lastSegment = it.getLastSegment();
+ return _lastSegment;
+ }
+ };
+ final List<Path> keyPaths = IterableExtensions.<Path, String>sortBy(_keySet, _function);
+ Path _get = keyPaths.get(0);
+ final Procedure1<Path> _function_1 = new Procedure1<Path>() {
+ public void apply(final Path it) {
+ String _string = it.toString();
+ Assert.assertEquals("/prj1", _string);
+ Map<Path,Path> _sourceFolderMappings = project.getSourceFolderMappings();
+ Path _get = _sourceFolderMappings.get(it);
+ String _string_1 = _get.toString();
+ Assert.assertEquals("/prj1", _string_1);
+ }
+ };
+ ObjectExtensions.<Path>operator_doubleArrow(_get, _function_1);
+ } catch (Throwable _e) {
+ throw Exceptions.sneakyThrow(_e);
+ }
+ }
+
+ @Test
+ public void testWorkspaceConfigWithoutCommonProjectDir() {
+ StringConcatenation _builder = new StringConcatenation();
+ _builder.append("/tmp/ws/prj1/src");
+ this.batchCompiler.setSourcePath(_builder.toString());
+ StringConcatenation _builder_1 = new StringConcatenation();
+ _builder_1.append("/usr/local/tmp/ws/prj1/bin");
+ this.batchCompiler.setOutputPath(_builder_1.toString());
+ boolean _configureWorkspace = this.batchCompiler.configureWorkspace();
+ Assert.assertFalse(_configureWorkspace);
+ }
+
+ @Test
+ public void testWorkspaceConfigWithoutCommonWorkspaceDir() {
+ StringConcatenation _builder = new StringConcatenation();
+ _builder.append("/tmp/src");
+ this.batchCompiler.setSourcePath(_builder.toString());
+ StringConcatenation _builder_1 = new StringConcatenation();
+ _builder_1.append("/tmp/bin");
+ this.batchCompiler.setOutputPath(_builder_1.toString());
+ boolean _configureWorkspace = this.batchCompiler.configureWorkspace();
+ Assert.assertFalse(_configureWorkspace);
+ }
+
+ @Test
+ public void testWorkspaceConfigWithTopLevelCommonWorkspaceDir() {
+ StringConcatenation _builder = new StringConcatenation();
+ _builder.append("/tmp/prj/src");
+ this.batchCompiler.setSourcePath(_builder.toString());
+ StringConcatenation _builder_1 = new StringConcatenation();
+ _builder_1.append("/tmp/prj/bin");
+ this.batchCompiler.setOutputPath(_builder_1.toString());
+ boolean _configureWorkspace = this.batchCompiler.configureWorkspace();
+ Assert.assertTrue(_configureWorkspace);
+ }
+
+ @Test
public void bug368551() {
this.batchCompiler.setTempDirectory(TestBatchCompiler.TEMP_DIRECTORY_WITH_SPACES);
this.batchCompiler.setSourcePath(TestBatchCompiler.XTEND_SRC_DIRECTORY);
@@ -199,6 +710,31 @@ public class TestBatchCompiler {
}
@Test
+ public void bug417177() {
+ File _file = new File(TestBatchCompiler.BUG417177_OUTPUT_DIRECTORY);
+ final File outputDir = _file;
+ outputDir.mkdirs();
+ File _file_1 = new File(outputDir, "mypackage/Bug417177_1.java");
+ _file_1.delete();
+ File _file_2 = new File(outputDir, "mypackage/Bug417177_2.java");
+ _file_2.delete();
+ StringConcatenation _builder = new StringConcatenation();
+ _builder.append(TestBatchCompiler.BUG417177_SRC_DIRECTORY_1, "");
+ _builder.append(File.pathSeparator, "");
+ _builder.append(TestBatchCompiler.BUG417177_SRC_DIRECTORY_2, "");
+ this.batchCompiler.setSourcePath(_builder.toString());
+ this.batchCompiler.setOutputPath(TestBatchCompiler.BUG417177_OUTPUT_DIRECTORY);
+ boolean _compile = this.batchCompiler.compile();
+ Assert.assertTrue("Compiling files from multiple source directories", _compile);
+ File _file_3 = new File(outputDir, "mypackage/Bug417177_1.java");
+ boolean _exists = _file_3.exists();
+ Assert.assertTrue(_exists);
+ File _file_4 = new File(outputDir, "mypackage/Bug417177_2.java");
+ boolean _exists_1 = _file_4.exists();
+ Assert.assertTrue(_exists_1);
+ }
+
+ @Test
public void testActiveAnnotatons1() {
this.batchCompiler.setSourcePath("./batch-compiler-data/activeAnnotations1");
boolean _compile = this.batchCompiler.compile();