use of org.eclipse.ceylon.cmr.ceylon.loader.ModuleGraph.Module in project ceylon by eclipse.
the class CeylonWarTool method addLibEntries.
protected void addLibEntries(final List<ArtifactResult> staticMetamodelEntries) throws MalformedURLException {
final List<String> libs = new ArrayList<>();
loader.visitModules(new ModuleGraph.Visitor() {
@Override
public void visit(Module module) {
if (module.artifact != null) {
File artifact = module.artifact.artifact();
try {
if (artifact != null) {
staticMetamodelEntries.add(module.artifact);
// write the metamodel, but not the jar, for provided modules
if (isProvided(module.name, module.version))
return;
final String moduleName = module.name;
// use "-" for the version separator
// use ".jar" so they'll get loaded by the container classloader
String version = module.version;
String versionSuffix = version != null && !version.isEmpty() ? "-" + version : "";
final String name = ModuleUtil.moduleName(moduleName).replace(":", ".") + versionSuffix + ".jar";
if (name.contains("/") || name.contains("\\") || name.length() == 0) {
throw new ToolUsageError(CeylonWarMessages.msg("module.name.illegal", name));
}
addSpec(new URLEntrySpec(artifact.toURI().toURL(), "WEB-INF/lib/" + name));
libs.add(name);
}
} catch (IOException x) {
// lame
throw new RuntimeException(x);
}
}
}
});
}
use of org.eclipse.ceylon.cmr.ceylon.loader.ModuleGraph.Module in project ceylon by eclipse.
the class CeylonJigsawTool method run.
@Override
public void run() throws Exception {
for (ModuleSpec module : modules) {
String moduleName = module.getName();
String version = checkModuleVersionsOrShowSuggestions(moduleName, module.isVersioned() ? module.getVersion() : null, ModuleQuery.Type.JVM, Versions.JVM_BINARY_MAJOR_VERSION, Versions.JVM_BINARY_MINOR_VERSION, // JS binary but don't care since JVM
null, // JS binary but don't care since JVM
null, null);
if (version == null)
return;
loadModule(null, moduleName, version);
if (!force)
errorOnConflictingModule(moduleName, version);
}
// force loading the module which contains the main
loadModule(null, "org.eclipse.ceylon.java.main", Versions.CEYLON_VERSION_NUMBER);
loader.resolve();
if (!out.exists()) {
if (!out.mkdirs()) {
throw new ToolUsageError(Messages.msg(bundle, "jigsaw.folder.error", out));
}
}
final List<ArtifactResult> staticMetamodelEntries = new ArrayList<>();
loader.visitModules(new ModuleGraph.Visitor() {
@Override
public void visit(Module module) {
if (module.artifact != null) {
File file = module.artifact.artifact();
try {
if (file != null) {
append(file.getAbsolutePath());
newline();
staticMetamodelEntries.add(module.artifact);
String name = file.getName();
if (name.endsWith(".car"))
name = name.substring(0, name.length() - 4) + ".jar";
Files.copy(file.toPath(), new File(out, name).toPath(), StandardCopyOption.REPLACE_EXISTING);
}
} catch (IOException x) {
// lame
throw new RuntimeException(x);
}
}
}
});
if (staticMetamodel) {
JvmBackendUtil.writeStaticMetamodel(out, staticMetamodelEntries, jdkProvider);
}
flush();
}
use of org.eclipse.ceylon.cmr.ceylon.loader.ModuleGraph.Module in project ceylon by eclipse.
the class CeylonMavenExportTool method run.
@Override
public void run() throws Exception {
String firstModuleName = null;
for (ModuleSpec module : modules) {
String moduleName = module.getName();
String version = checkModuleVersionsOrShowSuggestions(moduleName, module.isVersioned() ? module.getVersion() : null, ModuleQuery.Type.JVM, Versions.JVM_BINARY_MAJOR_VERSION, Versions.JVM_BINARY_MINOR_VERSION, // JS binary but don't care since JVM
null, // JS binary but don't care since JVM
null, null);
if (version == null)
return;
if (firstModuleName == null) {
firstModuleName = moduleName;
}
System.err.println("Doing " + module);
loadModule(null, moduleName, version);
}
// FIXME: we probably want to allow exporting of multiple versions
loader.resolve();
final File outputFolder = applyCwd(out != null ? out : new File("maven-repository"));
if (!outputFolder.exists()) {
FileUtil.mkdirs(outputFolder);
} else {
// FIXME: error if regular file?
// FIXME: or add, don't delete?
FileUtil.delete(outputFolder);
}
final List<ArtifactResult> writtenModules = new LinkedList<>();
final List<ArtifactResult> externalDependencies = new LinkedList<>();
final Set<String> directImports = new HashSet<>();
loader.visitModules(new ModuleGraph.Visitor() {
@Override
public void visit(ModuleGraph.Module module) {
if (module.artifact == null || module.artifact.artifact() == null)
return;
// FIXME: skip Maven modules?
if (forImport || forSdkImport) {
if (forImport && !module.artifact.groupId().equals("org.ceylon-lang")) {
externalDependencies.add(module.artifact);
return;
}
if (forSdkImport && !directlyListed(module.artifact.name())) {
if (!module.artifact.groupId().equals("org.ceylon-lang")) {
externalDependencies.add(module.artifact);
}
return;
}
makeMavenImportFolder(module, outputFolder, directImports);
writtenModules.add(module.artifact);
} else
makeMavenModule(module, outputFolder, directImports);
}
});
if (forImport || forSdkImport) {
makeMavenImportSpecialFolders(writtenModules, externalDependencies, outputFolder, directImports);
}
flush();
}
use of org.eclipse.ceylon.cmr.ceylon.loader.ModuleGraph.Module in project ceylon by eclipse.
the class CeylonClasspathTool method run.
@Override
public void run() throws Exception {
// we do depend on having a Main
loadModule(null, "org.eclipse.ceylon.java.main", Versions.CEYLON_VERSION_NUMBER);
for (ModuleSpec module : modules) {
String moduleName = module.getName();
String version = checkModuleVersionsOrShowSuggestions(moduleName, module.isVersioned() ? module.getVersion() : null, ModuleQuery.Type.JVM, Versions.JVM_BINARY_MAJOR_VERSION, Versions.JVM_BINARY_MINOR_VERSION, // JS binary but don't care since JVM
null, // JS binary but don't care since JVM
null, null);
if (version == null)
continue;
loadModule(null, moduleName, version);
if (!force)
errorOnConflictingModule(moduleName, version);
}
loader.resolve();
loader.visitModules(new ModuleGraph.Visitor() {
boolean once = true;
@Override
public void visit(Module module) {
if (module.artifact != null) {
File file = module.artifact.artifact();
try {
if (file != null) {
if (once)
once = false;
else
append(File.pathSeparator);
append(file.getAbsolutePath());
}
} catch (IOException x) {
// lame
throw new RuntimeException(x);
}
}
}
});
flush();
}
Aggregations