Search in sources :

Example 51 with CeyloncTaskImpl

use of org.eclipse.ceylon.compiler.java.tools.CeyloncTaskImpl in project ceylon by eclipse.

the class CMRTests method testOverridesCeylonModuleInSourceImport.

@Test
public void testOverridesCeylonModuleInSourceImport() {
    setupBinaryModulesForOverridesCeylonModuleTests();
    ErrorCollector collector = new ErrorCollector();
    CeyloncTaskImpl compilerTask = getCompilerTask(Arrays.asList("-continue", "-src", getPackagePath() + "/modules", "-overrides", getPackagePath() + "modules/overridesCeylonModule/overrides-a-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);
    compareErrors(collector.get(Diagnostic.Kind.WARNING), new CompilerError(Kind.WARNING, null, 1, "all-lowercase ASCII module names are recommended"), new CompilerError(Kind.WARNING, null, 2, "project source module import is overridden in module overrides file: 'a/2' overrides 'a/1'"));
    assert (modulesRetriever.modules != null);
    Module a = modulesRetriever.modules.get("a");
    Module b = modulesRetriever.modules.get("b");
    Module c = modulesRetriever.modules.get("c");
    assert (a != null);
    assert (b != null);
    assert (c != null);
    assertEquals("The version override should not be applied to modules imported in source code", "2", a.getVersion());
    assertEquals("The version override should not be applied to modules imported in source code", "2", b.getVersion());
    assertEquals("The version override should not be applied to modules imported in source code", "2", c.getVersion());
}
Also used : ErrorCollector(org.eclipse.ceylon.compiler.java.test.ErrorCollector) CompilerError(org.eclipse.ceylon.compiler.java.test.CompilerError) CeyloncTaskImpl(org.eclipse.ceylon.compiler.java.tools.CeyloncTaskImpl) Module(org.eclipse.ceylon.model.typechecker.model.Module) Test(org.junit.Test)

Example 52 with CeyloncTaskImpl

use of org.eclipse.ceylon.compiler.java.tools.CeyloncTaskImpl in project ceylon by eclipse.

the class CarGenerationTests method testCarResourceMultipleSub.

private long testCarResourceMultipleSub(boolean reverse) throws IOException {
    List<String> options = new LinkedList<String>();
    options.add("-src");
    options.add(getPackagePath() + "resmodules/multiple/source");
    if (reverse) {
        options.add("-res");
        options.add(getPackagePath() + "resmodules/multiple/resource2");
        options.add("-res");
        options.add(getPackagePath() + "resmodules/multiple/resource");
    } else {
        options.add("-res");
        options.add(getPackagePath() + "resmodules/multiple/resource");
        options.add("-res");
        options.add(getPackagePath() + "resmodules/multiple/resource2");
    }
    options.addAll(defaultOptions);
    CeyloncTaskImpl task = getCompilerTask(options, null, Arrays.asList("test.multiple"));
    Boolean ret = task.call();
    assertTrue(ret);
    File carFile = getModuleArchive("test.multiple", "1.0");
    assertTrue(carFile.exists());
    JarFile car = new JarFile(carFile);
    ZipEntry moduleClass = car.getEntry("test/multiple/README.txt");
    long result = moduleClass.getSize();
    assertNotNull(moduleClass);
    moduleClass = car.getEntry("test/multiple/README2.txt");
    assertNotNull(moduleClass);
    moduleClass = car.getEntry("test/multiple/$module_.class");
    assertNotNull(moduleClass);
    car.close();
    return result;
}
Also used : ZipEntry(java.util.zip.ZipEntry) CeyloncTaskImpl(org.eclipse.ceylon.compiler.java.tools.CeyloncTaskImpl) JarFile(java.util.jar.JarFile) JarFile(java.util.jar.JarFile) File(java.io.File) LinkedList(java.util.LinkedList)

Example 53 with CeyloncTaskImpl

use of org.eclipse.ceylon.compiler.java.tools.CeyloncTaskImpl in project ceylon by eclipse.

the class CarGenerationTests method testCarWithServicesGreetRecompile.

/**
 * Whole module recompilation
 */
@Test
public void testCarWithServicesGreetRecompile() throws IOException {
    // first compile the old version
    testCarWithServicesGreet();
    // then recompile
    ErrorCollector ec = new ErrorCollector();
    List<String> options = new LinkedList<String>();
    options.add("-src");
    options.add(getPackagePath() + "services/greet2/source");
    options.addAll(defaultOptions);
    CeyloncTaskImpl task = getCompilerTask(options, ec, Arrays.asList("services"));
    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.Gday");
    assertContains(impls, "services.Bonjour");
    assertEquals(3, impls.size());
    assertEquals(1, services.size());
}
Also used : Set(java.util.Set) ErrorCollector(org.eclipse.ceylon.compiler.java.test.ErrorCollector) CeyloncTaskImpl(org.eclipse.ceylon.compiler.java.tools.CeyloncTaskImpl) JarFile(java.util.jar.JarFile) File(java.io.File) LinkedList(java.util.LinkedList) Test(org.junit.Test)

Example 54 with CeyloncTaskImpl

use of org.eclipse.ceylon.compiler.java.tools.CeyloncTaskImpl in project ceylon by eclipse.

the class CarGenerationTests method testCarResourceRoot.

@Test
public void testCarResourceRoot() throws IOException {
    List<String> options = new LinkedList<String>();
    options.add("-src");
    options.add(getPackagePath() + "resmodules/rootdir/source");
    options.add("-res");
    options.add(getPackagePath() + "resmodules/rootdir/resource");
    options.addAll(defaultOptions);
    CeyloncTaskImpl task = getCompilerTask(options, null, Arrays.asList("test.rootdir"));
    Boolean ret = task.call();
    assertTrue(ret);
    File carFile = getModuleArchive("test.rootdir", "1.0");
    assertTrue(carFile.exists());
    JarFile car = new JarFile(carFile);
    ZipEntry carEntry = car.getEntry("test/rootdir/README.txt");
    assertNotNull(carEntry);
    carEntry = car.getEntry("rootfile");
    assertNotNull(carEntry);
    carEntry = car.getEntry("rootdir/rootsubdirfile");
    assertNotNull(carEntry);
    carEntry = car.getEntry("test/rootdir/$module_.class");
    assertNotNull(carEntry);
    car.close();
}
Also used : ZipEntry(java.util.zip.ZipEntry) CeyloncTaskImpl(org.eclipse.ceylon.compiler.java.tools.CeyloncTaskImpl) JarFile(java.util.jar.JarFile) JarFile(java.util.jar.JarFile) File(java.io.File) LinkedList(java.util.LinkedList) Test(org.junit.Test)

Example 55 with CeyloncTaskImpl

use of org.eclipse.ceylon.compiler.java.tools.CeyloncTaskImpl in project ceylon by eclipse.

the class CMRTests method testMdlDependenciesFromMavenFail.

@Test(expected = AssertionError.class)
public void testMdlDependenciesFromMavenFail() 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());
    runInJBossModules("run", "org.eclipse.ceylon.compiler.java.test.cmr.modules.sparkframework/1");
}
Also used : CeyloncTaskImpl(org.eclipse.ceylon.compiler.java.tools.CeyloncTaskImpl) Test(org.junit.Test)

Aggregations

CeyloncTaskImpl (org.eclipse.ceylon.compiler.java.tools.CeyloncTaskImpl)62 Test (org.junit.Test)51 File (java.io.File)34 JarFile (java.util.jar.JarFile)26 LinkedList (java.util.LinkedList)23 ErrorCollector (org.eclipse.ceylon.compiler.java.test.ErrorCollector)23 ZipEntry (java.util.zip.ZipEntry)13 ZipFile (java.util.zip.ZipFile)13 CompilerError (org.eclipse.ceylon.compiler.java.test.CompilerError)12 ExitState (org.eclipse.ceylon.compiler.java.launcher.Main.ExitState)7 CeyloncTool (org.eclipse.ceylon.compiler.java.tools.CeyloncTool)6 ArrayList (java.util.ArrayList)5 CeyloncFileManager (org.eclipse.ceylon.compiler.java.tools.CeyloncFileManager)5 TaskEvent (org.eclipse.ceylon.langtools.source.util.TaskEvent)4 TaskListener (org.eclipse.ceylon.langtools.source.util.TaskListener)4 Set (java.util.Set)3 DiagnosticListener (org.eclipse.ceylon.javax.tools.DiagnosticListener)3 JCCompilationUnit (org.eclipse.ceylon.langtools.tools.javac.tree.JCTree.JCCompilationUnit)3 Module (org.eclipse.ceylon.model.typechecker.model.Module)3 Ignore (org.junit.Ignore)3