use of org.eclipse.ceylon.common.ModuleSpec in project ceylon by eclipse.
the class ModuleInfo method getExportedPackages.
public List<ModuleSpec> getExportedPackages() {
String value = osgiAttributes.getValue("Export-Package");
List<ModuleSpec> ret = new LinkedList<>();
if (value != null) {
for (String pkg : split(value, ",")) {
String[] details = split(pkg, ";");
String name = details[0];
// GRRR: API of ModuleInfo
String version = "";
for (int i = 1; i < details.length; i++) {
if (details[i].startsWith("version=")) {
version = unquote(details[i].substring(8));
break;
}
}
ret.add(new ModuleSpec(null, name, version));
}
}
return ret;
}
use of org.eclipse.ceylon.common.ModuleSpec in project ceylon by eclipse.
the class InteropTests method testJava9Module.
/**
* Warning: this test requires a build with "ant -Djigsaw=true clean dist" and to run on Java 9+Jigsaw
*/
@Test
public void testJava9Module() throws Throwable {
Assume.assumeTrue("Runs on JDK9", JDKUtils.jdk == JDKUtils.JDK.JDK9);
assertErrors(new String[] { "java9/user/runError.ceylon", "java9/user/package.ceylon" }, Arrays.asList("-out", destDir, "-rep", "test/java9/modules"), null, new CompilerError(1, "imported package is not shared: 'com.ceylon.java9.internal'"));
ErrorCollector c = new ErrorCollector();
assertCompilesOk(c, getCompilerTask(Arrays.asList("-out", destDir, "-rep", "test/java9/modules"), c, "java9/user/run.ceylon", "java9/user/package.ceylon").call2());
// check that we do not have a module-info.class
File archive = getModuleArchive("org.eclipse.ceylon.compiler.java.test.interop.java9.user", "1");
try (ZipFile zf = new ZipFile(archive)) {
ZipEntry entry = zf.getEntry("module-info.class");
assertNull(entry);
}
c = new ErrorCollector();
assertCompilesOk(c, getCompilerTask(Arrays.asList("-out", destDir, "-rep", "test/java9/modules", "-module-info"), c, "java9/user/run.ceylon", "java9/user/package.ceylon").call2());
// check that we do have a module-info.class
try (ZipFile zf = new ZipFile(archive)) {
ZipEntry entry = zf.getEntry("module-info.class");
assertNotNull(entry);
}
run("org.eclipse.ceylon.compiler.java.test.interop.java9.user.run", new ModuleWithArtifact("org.eclipse.ceylon.compiler.java.test.interop.java9.user", "1"), new ModuleWithArtifact("com.ceylon.java9", "123", "test/java9/modules", "jar"));
assertEquals(0, runInJava9(new String[] { destDir, "test/java9/modules", "../dist/dist/repo" }, new ModuleSpec(null, "org.eclipse.ceylon.compiler.java.test.interop.java9.user", "1"), Collections.<String>emptyList()));
}
use of org.eclipse.ceylon.common.ModuleSpec in project ceylon by eclipse.
the class Main method main.
/**
* <p>
* Main entry point, invoke with: <code>moduleSpec</code> <code>mainJavaClassName</code> <code>args*</code>.
* </p>
* <p>
* <b>WARNING:</b> this code will call @{link {@link System#exit(int)} if the arguments
* are incorrect or missing. This is really only intended to be called from the <code>java</code>
* command-line. All it does is parse the arguments and invoke
* @{link {@link Main#runModule(String, String, String, String...)}.
* </p>
*/
public static void main(String[] args) {
// WARNING: keep in sync with Main2
int idx = 0;
boolean allowMissingModules = false;
String overrides = null;
for (int i = 0; i < args.length; i++) {
String arg = args[i];
if (!arg.startsWith("-"))
break;
if (arg.equals("--allow-missing-modules")) {
allowMissingModules = true;
} else if (arg.equals("--overrides") || arg.equals("--maven-overrides")) {
if (i + 1 >= args.length) {
usage();
}
overrides = args[++i];
idx++;
} else
usage();
idx++;
}
if (args.length < (2 + idx)) {
usage();
}
ModuleSpec moduleSpec = ModuleSpec.parse(args[idx], Option.VERSION_REQUIRED);
String version;
if (moduleSpec.getName().equals(org.eclipse.ceylon.model.typechecker.model.Module.DEFAULT_MODULE_NAME))
version = null;
else
version = moduleSpec.getVersion();
String[] moduleArgs = Arrays.copyOfRange(args, 2 + idx, args.length);
instance().allowMissingModules(allowMissingModules).overrides(overrides).run(moduleSpec.getName(), version, args[idx + 1], moduleArgs);
}
use of org.eclipse.ceylon.common.ModuleSpec in project ceylon by eclipse.
the class Main2 method main.
/**
* Same as Main except takes its main class as optional parameter.
*/
public static void main(String[] args) {
// WARNING: keep in sync with Main
int idx = 0;
boolean allowMissingModules = false;
String overrides = null;
String runClassOrMethod = null;
for (int i = 0; i < args.length; i++) {
String arg = args[i];
if (!arg.startsWith("-"))
break;
if (arg.equals("--allow-missing-modules")) {
allowMissingModules = true;
} else if (arg.equals("--overrides") || arg.equals("--maven-overrides")) {
if (i + 1 >= args.length) {
usage();
}
overrides = args[++i];
idx++;
} else if (arg.equals("--run")) {
if (i + 1 >= args.length) {
usage();
}
runClassOrMethod = args[++i];
idx++;
} else
usage();
idx++;
}
if (args.length < (1 + idx)) {
usage();
}
ModuleSpec moduleSpec = ModuleSpec.parse(args[idx], Option.VERSION_REQUIRED);
String version;
if (moduleSpec.getName().equals(org.eclipse.ceylon.model.typechecker.model.Module.DEFAULT_MODULE_NAME))
version = null;
else
version = moduleSpec.getVersion();
String[] moduleArgs = Arrays.copyOfRange(args, 1 + idx, args.length);
Main.instance().allowMissingModules(allowMissingModules).overrides(overrides).run(moduleSpec.getName(), version, runSpecToJavaClass(moduleSpec.getName(), runClassOrMethod), moduleArgs);
}
use of org.eclipse.ceylon.common.ModuleSpec in project ceylon by eclipse.
the class LanguageCompiler method initProcessAnnotations.
@Override
public void initProcessAnnotations(Iterable<? extends Processor> processors) {
java.util.List<String> aptModules = options.getMulti(Option.CEYLONAPT);
if (aptModules != null) {
CeyloncFileManager dfm = (CeyloncFileManager) fileManager;
RepositoryManager repositoryManager = dfm.getRepositoryManager();
final Set<ModuleSpec> visited = new HashSet<>();
StatusPrinterAptProgressListener progressListener = null;
if (sp != null) {
progressListener = new StatusPrinterAptProgressListener(sp) {
@Override
protected long getNumberOfModulesResolved() {
return visited.size();
}
};
sp.clearLine();
sp.log("Starting APT resolving");
}
for (String aptModule : aptModules) {
ModuleSpec moduleSpec = ModuleSpec.parse(aptModule);
addDependenciesToAptPath(repositoryManager, moduleSpec, visited, progressListener);
}
if (sp != null) {
sp.clearLine();
sp.log("Done APT resolving");
}
// we only run APT if asked explicitly with the --apt flag
super.initProcessAnnotations(processors);
}
// else don't do anything, which will leave the "processAnnotations" field to false
}
Aggregations