Search in sources :

Example 21 with CeyloncTaskImpl

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

the class CMRTests method testMdlCeylonAetherDuplicateImports.

@Test
public void testMdlCeylonAetherDuplicateImports() throws IOException {
    // Try to compile the ceylon module
    ErrorCollector collector = new ErrorCollector();
    CeyloncTaskImpl ceylonTask = getCompilerTask(Arrays.asList("-out", destDir, "-verbose:cmr"), collector, "modules/ceylonAetherDuplicateImports/module.ceylon", "modules/ceylonAetherDuplicateImports/foo.ceylon");
    assertEquals(Boolean.FALSE, ceylonTask.call());
    compareErrors(collector.get(Diagnostic.Kind.ERROR), new CompilerError(23, "duplicate module import: 'org.apache.httpcomponents.httpclient'"), new CompilerError(25, "duplicate module import: 'org.apache.httpcomponents:httpclient'"));
}
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) Test(org.junit.Test)

Example 22 with CeyloncTaskImpl

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

the class CMRTests method testMdlAetherDependencyCustomRelative.

@Test
public void testMdlAetherDependencyCustomRelative() throws IOException {
    // Try to compile the ceylon module
    File settingsFile = new File(getPackagePath(), "modules/aethercustom/settings.xml");
    CeyloncTaskImpl ceylonTask = getCompilerTask(Arrays.asList("-out", destDir, "-rep", "aether:" + settingsFile, "-verbose:cmr"), (DiagnosticListener<? super FileObject>) null, "modules/aethercustom/module.ceylon", "modules/aethercustom/foo.ceylon");
    assertEquals(Boolean.TRUE, ceylonTask.call());
    File restletJar = new File("build/test-cars/cmr-repository", "org/restlet/org.restlet/1.1.10/org.restlet-1.1.10.jar");
    assertTrue(restletJar.exists());
}
Also used : CeyloncTaskImpl(org.eclipse.ceylon.compiler.java.tools.CeyloncTaskImpl) JarFile(java.util.jar.JarFile) ZipFile(java.util.zip.ZipFile) File(java.io.File) Test(org.junit.Test)

Example 23 with CeyloncTaskImpl

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

the class CMRTests method testMdlAetherDependencyCustomAutoActive.

@Test
public void testMdlAetherDependencyCustomAutoActive() throws IOException {
    // Try to compile the ceylon module
    File settingsFile = new File(getPackagePath(), "modules/aethercustom/settings-autoactive.xml");
    CeyloncTaskImpl ceylonTask = getCompilerTask(Arrays.asList("-out", destDir, "-rep", "aether:" + settingsFile.getAbsolutePath(), "-verbose:cmr"), (DiagnosticListener<? super FileObject>) null, "modules/aethercustom/module.ceylon", "modules/aethercustom/foo.ceylon");
    assertEquals(Boolean.TRUE, ceylonTask.call());
    File restletJar = new File("build/test-cars/cmr-repository", "org/restlet/org.restlet/1.1.10/org.restlet-1.1.10.jar");
    assertTrue(restletJar.exists());
}
Also used : CeyloncTaskImpl(org.eclipse.ceylon.compiler.java.tools.CeyloncTaskImpl) JarFile(java.util.jar.JarFile) ZipFile(java.util.zip.ZipFile) File(java.io.File) Test(org.junit.Test)

Example 24 with CeyloncTaskImpl

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

the class CMRTests method testMdlSuppressObsoleteClasses.

@Test
public void testMdlSuppressObsoleteClasses() throws IOException {
    File sourceFile = new File(getPackagePath(), "modules/single/SuppressClass.ceylon");
    copy(new File(getPackagePath(), "modules/single/SuppressClass_1.ceylon"), sourceFile);
    CeyloncTaskImpl compilerTask = getCompilerTask("modules/single/module.ceylon", "modules/single/SuppressClass.ceylon");
    Boolean success = compilerTask.call();
    assertTrue(success);
    File carFile = getModuleArchive("org.eclipse.ceylon.compiler.java.test.cmr.modules.single", "6.6.6");
    assertTrue(carFile.exists());
    ZipFile car = new ZipFile(carFile);
    ZipEntry oneClass = car.getEntry("org/eclipse/ceylon/compiler/java/test/cmr/modules/single/One.class");
    assertNotNull(oneClass);
    ZipEntry twoClass = car.getEntry("org/eclipse/ceylon/compiler/java/test/cmr/modules/single/Two.class");
    assertNotNull(twoClass);
    car.close();
    copy(new File(getPackagePath(), "modules/single/SuppressClass_2.ceylon"), sourceFile);
    compilerTask = getCompilerTask("modules/single/module.ceylon", "modules/single/SuppressClass.ceylon");
    success = compilerTask.call();
    assertTrue(success);
    carFile = getModuleArchive("org.eclipse.ceylon.compiler.java.test.cmr.modules.single", "6.6.6");
    assertTrue(carFile.exists());
    car = new ZipFile(carFile);
    oneClass = car.getEntry("org/eclipse/ceylon/compiler/java/test/cmr/modules/single/One.class");
    assertNotNull(oneClass);
    twoClass = car.getEntry("org/eclipse/ceylon/compiler/java/test/cmr/modules/single/Two.class");
    assertNull(twoClass);
    car.close();
    sourceFile.delete();
}
Also used : ZipFile(java.util.zip.ZipFile) ZipEntry(java.util.zip.ZipEntry) CeyloncTaskImpl(org.eclipse.ceylon.compiler.java.tools.CeyloncTaskImpl) JarFile(java.util.jar.JarFile) ZipFile(java.util.zip.ZipFile) File(java.io.File) Test(org.junit.Test)

Example 25 with CeyloncTaskImpl

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

the class CMRTests method testOverridesCeylonModuleVersionAlterdPackageSharing.

@Test
public void testOverridesCeylonModuleVersionAlterdPackageSharing() {
    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", "modules/overridesCeylonModule/testImportHiddenPackage.ceylon");
    ModulesRetriever modulesRetriever = new ModulesRetriever(compilerTask.getContext());
    compilerTask.setTaskListener(modulesRetriever);
    Boolean result = compilerTask.call();
    Assert.assertEquals(Boolean.FALSE, result);
    compareErrors(collector.get(Diagnostic.Kind.ERROR), new CompilerError(2, "imported package is not visible: package 'b.hidden' is not shared by module 'b'"));
}
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) 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