use of org.eclipse.ceylon.compiler.java.tools.CeyloncTaskImpl in project ceylon by eclipse.
the class CarGenerationTests method testCarMergedManifestComesFirst.
/*
* 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 an existing MANIFEST.MF in resources
*/
@Test
public void testCarMergedManifestComesFirst() throws IOException {
ErrorCollector ec = new ErrorCollector();
List<String> options = new LinkedList<String>();
options.add("-src");
options.add(getPackagePath() + "meta/mergedmanifest/source");
options.add("-res");
options.add(getPackagePath() + "meta/mergedmanifest/resource");
options.addAll(defaultOptions);
CeyloncTaskImpl task = getCompilerTask(options, ec, Arrays.asList("test.mergedmanifest"));
assertTrue(task.call());
File carFile = getModuleArchive("test.mergedmanifest", "1.0");
assertTrue(carFile.exists());
assertTrue(ec.get(Diagnostic.Kind.ERROR).isEmpty());
// When the compiler value overrides a user value, we expect a warning
assertTrue(ec.get(Diagnostic.Kind.WARNING).size() == 1);
assertTrue(ec.get(Diagnostic.Kind.WARNING).iterator().next().equals(new CompilerError(Diagnostic.Kind.WARNING, null, -1, "manifest attribute provided by compiler: ignoring value from 'Bundle-ActivationPolicy' for module 'test.mergedmanifest'")));
try (JarFile car = new JarFile(carFile)) {
Manifest manifest = car.getManifest();
manifest.write(System.err);
assertTrue(manifest != null);
assertEquals("test.mergedmanifest", manifest.getMainAttributes().getValue("Bundle-SymbolicName"));
assertEquals("Baz", manifest.getMainAttributes().getValue("Foo-Bar"));
assertEquals("whatever", manifest.getMainAttributes().getValue("LastLineWithoutNewline"));
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 CarGenerationTests method testCarWithServicesGreet.
/**
* Plain module compilation
*/
@Test
public void testCarWithServicesGreet() throws IOException {
ErrorCollector ec = new ErrorCollector();
List<String> options = new LinkedList<String>();
options.add("-src");
options.add(getPackagePath() + "services/greet1/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.Bonjour");
assertEquals(2, impls.size());
assertEquals(1, services.size());
}
use of org.eclipse.ceylon.compiler.java.tools.CeyloncTaskImpl in project ceylon by eclipse.
the class CarGenerationTests method testCarResourceSimple.
@Test
public void testCarResourceSimple() throws IOException {
List<String> options = new LinkedList<String>();
options.add("-src");
options.add(getPackagePath() + "resmodules/simple/source");
options.add("-res");
options.add(getPackagePath() + "resmodules/simple/resource");
options.addAll(defaultOptions);
CeyloncTaskImpl task = getCompilerTask(options, null, Arrays.asList("test.simple"));
Boolean ret = task.call();
assertTrue(ret);
File carFile = getModuleArchive("test.simple", "1.0");
assertTrue(carFile.exists());
JarFile car = new JarFile(carFile);
ZipEntry moduleClass = car.getEntry("test/simple/README.txt");
assertNotNull(moduleClass);
moduleClass = car.getEntry("test/simple/subdir/SUBDIR.txt");
assertNotNull(moduleClass);
moduleClass = car.getEntry("test/simple/$module_.class");
assertNotNull(moduleClass);
car.close();
}
use of org.eclipse.ceylon.compiler.java.tools.CeyloncTaskImpl in project ceylon by eclipse.
the class CarGenerationTests method testCarResourceDefault.
@Test
public void testCarResourceDefault() throws IOException {
List<String> options = new LinkedList<String>();
options.add("-src");
options.add(getPackagePath() + "resmodules/default/source");
options.add("-res");
options.add(getPackagePath() + "resmodules/default/resource");
options.addAll(defaultOptions);
CeyloncTaskImpl task = getCompilerTask(options, "resmodules/default/resource/README.txt", "resmodules/default/resource/subdir/SUBDIR.txt");
Boolean ret = task.call();
assertTrue(ret);
File carFile = getModuleArchive("default", null);
assertTrue(carFile.exists());
JarFile car = new JarFile(carFile);
ZipEntry moduleClass = car.getEntry("README.txt");
assertNotNull(moduleClass);
moduleClass = car.getEntry("subdir/SUBDIR.txt");
assertNotNull(moduleClass);
car.close();
}
use of org.eclipse.ceylon.compiler.java.tools.CeyloncTaskImpl in project ceylon by eclipse.
the class CarGenerationTests method testCarResourceAlternativeRoot.
@Test
public void testCarResourceAlternativeRoot() throws IOException {
List<String> options = new LinkedList<String>();
options.add("-src");
options.add(getPackagePath() + "resmodules/altrootdir/source");
options.add("-res");
options.add(getPackagePath() + "resmodules/altrootdir/resource");
options.add("-resroot");
options.add("ALTROOT");
options.addAll(defaultOptions);
CeyloncTaskImpl task = getCompilerTask(options, null, Arrays.asList("test.altrootdir"));
Boolean ret = task.call();
assertTrue(ret);
File carFile = getModuleArchive("test.altrootdir", "1.0");
assertTrue(carFile.exists());
JarFile car = new JarFile(carFile);
ZipEntry carEntry = car.getEntry("test/altrootdir/README.txt");
assertNotNull(carEntry);
carEntry = car.getEntry("rootfile");
assertNotNull(carEntry);
carEntry = car.getEntry("test/altrootdir/$module_.class");
assertNotNull(carEntry);
car.close();
}
Aggregations