use of org.eclipse.ceylon.compiler.java.tools.CeyloncTaskImpl in project ceylon by eclipse.
the class CarGenerationTests method testCarWithServicesGreetIncremental.
/**
* Incremental compilation (adding a service implementation)
*/
@Test
public void testCarWithServicesGreetIncremental() throws IOException {
// first compile the old version
testCarWithServicesGreet();
// then recompile
ErrorCollector ec = new ErrorCollector();
List<String> options = new LinkedList<String>(defaultOptions);
options.add("-src");
options.add(getPackagePath() + "services/greet2/source");
CeyloncTaskImpl task = getCompilerTask(options, ec, "services/greet2/source/services/Gday.ceylon");
assertTrue(task.call());
File carFile = getModuleArchive("services", "1.0");
assertTrue(carFile.exists());
Map<String, Set<String>> services = MetaInfServices.parseAllServices(carFile);
Set<String> impls = services.get("services.Greeter");
assertNotNull(impls);
assertContains(impls, "services.HelloWorld");
assertContains(impls, "services.Bonjour");
assertContains(impls, "services.Gday");
assertEquals(3, impls.size());
assertEquals(1, services.size());
}
use of org.eclipse.ceylon.compiler.java.tools.CeyloncTaskImpl in project ceylon by eclipse.
the class CarGenerationTests method testCarGeneratedManifestComesFirst.
/*
* Although not in the JAR specification, there are tools and APIs
* which rely on the MANIFEST.MF being the first file entry in a Jar file.
*
* Test for the case of a compiler-generated MANIFEST.MF
*/
@Test
public void testCarGeneratedManifestComesFirst() throws IOException {
ErrorCollector ec = new ErrorCollector();
List<String> options = new LinkedList<String>();
options.add("-src");
options.add(getPackagePath() + "meta/generatedmanifest/source");
options.addAll(defaultOptions);
CeyloncTaskImpl task = getCompilerTask(options, ec, Arrays.asList("test.generatedmanifest"));
assertTrue(task.call());
assertTrue(ec.get(Diagnostic.Kind.ERROR, Diagnostic.Kind.WARNING).isEmpty());
File carFile = getModuleArchive("test.generatedmanifest", "1.0");
assertTrue(carFile.exists());
try (JarFile car = new JarFile(carFile)) {
Manifest manifest = car.getManifest();
assertTrue(manifest != null);
assertEquals("test.generatedmanifest", manifest.getMainAttributes().getValue("Bundle-SymbolicName"));
Enumeration<JarEntry> entries = car.entries();
assertTrue(entries.hasMoreElements());
JarEntry entry = entries.nextElement();
assertEquals("META-INF/", entry.getName());
assertTrue(entry.isDirectory());
entry = entries.nextElement();
assertEquals("META-INF/MANIFEST.MF", entry.getName());
assertTrue(!entry.isDirectory());
}
// Now test incremental compilation
task = getCompilerTask(options, ec, "meta/generatedmanifest/source/test/generatedmanifest/run.ceylon");
assertTrue(task.call());
assertTrue(carFile.exists());
assertTrue(ec.get(Diagnostic.Kind.ERROR, Diagnostic.Kind.WARNING).isEmpty());
try (JarFile car = new JarFile(carFile)) {
Manifest manifest = car.getManifest();
assertTrue(manifest != null);
assertEquals("test.generatedmanifest", manifest.getMainAttributes().getValue("Bundle-SymbolicName"));
Enumeration<JarEntry> entries = car.entries();
assertTrue(entries.hasMoreElements());
JarEntry entry = entries.nextElement();
assertEquals("META-INF/", entry.getName());
assertTrue(entry.isDirectory());
entry = entries.nextElement();
assertEquals("META-INF/MANIFEST.MF", entry.getName());
assertTrue(!entry.isDirectory());
}
}
use of org.eclipse.ceylon.compiler.java.tools.CeyloncTaskImpl in project ceylon by eclipse.
the class CMRTests method testOverridesCeylonModuleVersionProducesJavaModule.
@Test
public void testOverridesCeylonModuleVersionProducesJavaModule() {
setupBinaryModulesForOverridesCeylonModuleTests();
ErrorCollector collector = new ErrorCollector();
CeyloncTaskImpl compilerTask = getCompilerTask(Arrays.asList("-src", getPackagePath() + "/modules", "-overrides", getPackagePath() + "modules/overridesCeylonModule/overrides-b-version.xml"), collector, "modules/overridesCeylonModule/module.ceylon");
ModulesRetriever modulesRetriever = new ModulesRetriever(compilerTask.getContext());
compilerTask.setTaskListener(modulesRetriever);
Boolean result = compilerTask.call();
Assert.assertEquals(Boolean.TRUE, result);
assert (modulesRetriever.modules != null);
Module b = modulesRetriever.modules.get("b");
assert (b != null);
assertEquals("The Ceylon module 'b' is now seen as a Java module when a version override is applied", false, b.isJava());
}
use of org.eclipse.ceylon.compiler.java.tools.CeyloncTaskImpl in project ceylon by eclipse.
the class CMRTests method testMdlApacheSpark.
@Ignore("It takes ages to download about 200 jars")
@Test
public void testMdlApacheSpark() throws Throwable {
// initially run both without offline, then it's much faster
CeyloncTaskImpl ceylonTask = getCompilerTask(Arrays.asList("-out", destDir, "-offline"), "modules/apachespark/module.ceylon", "modules/apachespark/test.ceylon");
assertEquals("Compilation failed", Boolean.TRUE, ceylonTask.call());
runInJBossModules("run", "org.eclipse.ceylon.compiler.java.test.cmr.modules.apachespark/1", Arrays.<String>asList("--flat-classpath", "--offline", "--maven-overrides", getPackagePath() + "/modules/apachespark/overrides.xml"));
}
use of org.eclipse.ceylon.compiler.java.tools.CeyloncTaskImpl in project ceylon by eclipse.
the class CMRTests method testMdlDependenciesFromMavenFlatClasspath.
@Test
public void testMdlDependenciesFromMavenFlatClasspath() throws Throwable {
Assume.assumeTrue("Runs on JDK8", JDKUtils.jdk == JDKUtils.JDK.JDK8);
CeyloncTaskImpl ceylonTask = getCompilerTask(Arrays.asList("-out", destDir), "modules/sparkframework/module.ceylon", "modules/sparkframework/test.ceylon");
assertEquals("Compilation failed", Boolean.TRUE, ceylonTask.call());
// flat classpath via API
runInJBossModules("run", "org.eclipse.ceylon.compiler.java.test.cmr.modules.sparkframework/1", Arrays.asList("--flat-classpath", "--overrides", getPackagePath() + "/modules/sparkframework/overrides-log.xml"));
// and via main without aether
runInMainApi(destDir, new ModuleSpec(null, "org.eclipse.ceylon.compiler.java.test.cmr.modules.sparkframework", "1"), "org.eclipse.ceylon.compiler.java.test.cmr.modules.sparkframework.run_", Arrays.<String>asList(), false);
// and via main with aether
runInMainApi(destDir, new ModuleSpec(null, "org.eclipse.ceylon.compiler.java.test.cmr.modules.sparkframework", "1"), Arrays.asList(new ModuleSpec(null, "org.eclipse.ceylon.module-resolver-aether", Versions.CEYLON_VERSION_NUMBER)), "org.eclipse.ceylon.compiler.java.test.cmr.modules.sparkframework.run_", Arrays.<String>asList(), false);
}
Aggregations