use of com.redhat.ceylon.compiler.java.tools.CeyloncTool in project ceylon-compiler by ceylon.
the class CeylonDocToolTests method compileJavaModule.
private void compileJavaModule(String pathname, String... fileNames) throws Exception {
CeyloncTool compiler = new CeyloncTool();
List<String> options = Arrays.asList("-src", pathname, "-out", "build/ceylon-cars", "-cp", CompilerTests.getClassPathAsPath());
JavacFileManager fileManager = compiler.getStandardFileManager(null, null, null);
List<String> qualifiedNames = new ArrayList<String>(fileNames.length);
for (String name : fileNames) {
qualifiedNames.add(pathname + File.separator + name);
}
Iterable<? extends JavaFileObject> fileObjects = fileManager.getJavaFileObjectsFromStrings(qualifiedNames);
JavacTask task = compiler.getTask(null, null, null, options, null, fileObjects);
Boolean ret = task.call();
Assert.assertEquals("Compilation failed", Boolean.TRUE, ret);
}
use of com.redhat.ceylon.compiler.java.tools.CeyloncTool in project ceylon-compiler by ceylon.
the class CeylonDocToolTests method compile.
private void compile(String pathname, String destDir, String moduleName) throws Exception {
CeyloncTool compiler = new CeyloncTool();
List<String> options = Arrays.asList("-src", pathname, "-out", destDir, "-cp", CompilerTests.getClassPathAsPath());
JavacTask task = compiler.getTask(null, null, null, options, Arrays.asList(moduleName), null);
Boolean ret = task.call();
Assert.assertEquals("Compilation failed", Boolean.TRUE, ret);
}
use of com.redhat.ceylon.compiler.java.tools.CeyloncTool in project ceylon-compiler by ceylon.
the class MiscTests method compileSDKOnly.
private void compileSDKOnly(String[] modules, String[] extraModules) {
String sourceDir = "../ceylon-sdk/source";
// don't run this if the SDK is not checked out
File sdkFile = new File(sourceDir);
if (!sdkFile.exists())
return;
java.util.List<String> moduleNames = new ArrayList<String>(modules.length);
for (String module : modules) {
moduleNames.add("ceylon." + module);
}
for (String module : extraModules) {
moduleNames.add(module);
}
CeyloncTool compiler;
try {
compiler = new CeyloncTool();
} catch (VerifyError e) {
System.err.println("ERROR: Cannot run tests! Did you maybe forget to configure the -Xbootclasspath/p: parameter?");
throw e;
}
ErrorCollector errorCollector = new ErrorCollector();
CeyloncFileManager fileManager = (CeyloncFileManager) compiler.getStandardFileManager(null, null, null);
CeyloncTaskImpl task = (CeyloncTaskImpl) compiler.getTask(null, fileManager, errorCollector, Arrays.asList("-sourcepath", sourceDir, "-d", "build/classes-sdk", "-suppress-warnings", "ceylonNamespace", "-cp", getClassPathAsPath()), moduleNames, null);
Boolean result = task.call();
Assert.assertEquals("Compilation of SDK itself failed: " + errorCollector.getAssertionFailureMessage(), Boolean.TRUE, result);
}
use of com.redhat.ceylon.compiler.java.tools.CeyloncTool in project ceylon-compiler by ceylon.
the class IssuesTests_1500_1999 method testBug1969.
@SuppressWarnings("deprecation")
@Test
public void testBug1969() {
java.util.List<File> sourceFiles = new ArrayList<File>(1);
sourceFiles.add(new File(getPackagePath(), "bug19xx/Bug1969.ceylon"));
CeyloncTool runCompiler = makeCompiler();
StringWriter writer = new StringWriter();
CeyloncFileManager runFileManager = (CeyloncFileManager) runCompiler.getStandardFileManager(writer, null, null, null);
// make sure the destination repo exists
new File(destDir).mkdirs();
List<String> options = new LinkedList<String>();
options.addAll(defaultOptions);
if (!options.contains("-src"))
options.addAll(Arrays.asList("-src", getSourcePath()));
if (!options.contains("-cacherep"))
options.addAll(Arrays.asList("-cacherep", getCachePath()));
if (!options.contains("-cp"))
options.addAll(Arrays.asList("-cp", getClassPathAsPath()));
options.add("-verbose");
Iterable<? extends JavaFileObject> compilationUnits1 = runFileManager.getJavaFileObjectsFromFiles(sourceFiles);
CeyloncTaskImpl task = runCompiler.getTask(writer, runFileManager, null, options, null, compilationUnits1);
ErrorCollector collector = new ErrorCollector();
assertCompilesOk(collector, task.call2());
Assert.assertTrue(writer.toString().length() > 0);
}
use of com.redhat.ceylon.compiler.java.tools.CeyloncTool in project ceylon-compiler by ceylon.
the class MiscTests method compileSDKTests.
private void compileSDKTests(String[] modules, String[] extraModules) {
String sourceDir = "../ceylon-sdk/test-source";
String depsDir = "../ceylon-sdk/test-deps";
// don't run this if the SDK is not checked out
File sdkFile = new File(sourceDir);
if (!sdkFile.exists())
return;
java.util.List<String> moduleNames = new ArrayList<String>(modules.length);
for (String module : modules) {
moduleNames.add("test.ceylon." + module);
}
for (String module : extraModules) {
moduleNames.add(module);
}
CeyloncTool compiler;
try {
compiler = new CeyloncTool();
} catch (VerifyError e) {
System.err.println("ERROR: Cannot run tests! Did you maybe forget to configure the -Xbootclasspath/p: parameter?");
throw e;
}
ErrorCollector errorCollector = new ErrorCollector();
CeyloncFileManager fileManager = (CeyloncFileManager) compiler.getStandardFileManager(null, null, null);
CeyloncTaskImpl task = (CeyloncTaskImpl) compiler.getTask(null, fileManager, errorCollector, Arrays.asList("-sourcepath", sourceDir, "-rep", depsDir, "-d", "build/classes-sdk", "-cp", getClassPathAsPath()), moduleNames, null);
Boolean result = task.call();
Assert.assertEquals("Compilation of SDK tests failed:" + errorCollector.getAssertionFailureMessage(), Boolean.TRUE, result);
}
Aggregations