use of com.redhat.ceylon.cmr.api.RepositoryManager in project ceylon-compiler by ceylon.
the class CeylonDocToolTests method compileSdkJavaFiles.
/**
* This is disgusting, but the current CeylonDoc doesn't handle source files, so we need to compile them first,
* and we do it using javac to avoid compiling the whole SDK for one java file.
*/
private void compileSdkJavaFiles() throws FileNotFoundException, IOException {
// put it all in a special folder
File dir = new File("build", "CeylonDocToolTest/" + name.getMethodName());
if (dir.exists()) {
FileUtil.delete(dir);
}
dir.mkdirs();
// download a required jar
RepositoryManager repoManager = CeylonUtils.repoManager().buildManager();
File undertowCoreModule = repoManager.getArtifact(new ArtifactContext("io.undertow.core", "1.0.0.Beta20", ".jar"));
File narnyaModule = repoManager.getArtifact(new ArtifactContext("org.jboss.narayana.jta", "5.1.1.Final", ".jar"));
File languageModule = repoManager.getArtifact(new ArtifactContext(AbstractModelLoader.CEYLON_LANGUAGE, TypeChecker.LANGUAGE_MODULE_VERSION, ".car"));
// fire up the java compiler
JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
assertNotNull("Missing Java compiler, this test is probably being run with a JRE instead of a JDK!", compiler);
List<String> options = Arrays.asList("-sourcepath", "../ceylon-sdk/source", "-d", dir.getAbsolutePath(), "-classpath", undertowCoreModule.getAbsolutePath() + File.pathSeparator + narnyaModule.getAbsolutePath() + File.pathSeparator + languageModule.getAbsolutePath());
StandardJavaFileManager fileManager = compiler.getStandardFileManager(null, null, null);
String[] fileNames = new String[] { "ceylon/net/http/server/internal/JavaHelper.java", "ceylon/interop/java/internal/javaBooleanArray_.java", "ceylon/interop/java/internal/javaByteArray_.java", "ceylon/interop/java/internal/javaCharArray_.java", "ceylon/interop/java/internal/javaDoubleArray_.java", "ceylon/interop/java/internal/javaFloatArray_.java", "ceylon/interop/java/internal/javaIntArray_.java", "ceylon/interop/java/internal/javaLongArray_.java", "ceylon/interop/java/internal/javaObjectArray_.java", "ceylon/interop/java/internal/javaShortArray_.java", "ceylon/interop/java/internal/javaStringArray_.java", "ceylon/interop/java/internal/Util.java", "ceylon/transaction/internal/RecoveryHelper.java", "ceylon/transaction/internal/RecoveryXAResource.java" };
List<String> qualifiedNames = new ArrayList<String>(fileNames.length);
for (String name : fileNames) {
qualifiedNames.add("../ceylon-sdk/source/" + name);
}
Iterable<? extends JavaFileObject> fileObjects = fileManager.getJavaFileObjectsFromStrings(qualifiedNames);
CompilationTask task = compiler.getTask(null, null, null, options, null, fileObjects);
Boolean ret = task.call();
Assert.assertEquals("Compilation failed", Boolean.TRUE, ret);
// now we need to zip it up
makeCarFromClassFiles(dir, fileNames, "ceylon.net", Versions.CEYLON_VERSION_NUMBER);
makeCarFromClassFiles(dir, fileNames, "ceylon.interop.java", Versions.CEYLON_VERSION_NUMBER);
makeCarFromClassFiles(dir, fileNames, "ceylon.transaction", Versions.CEYLON_VERSION_NUMBER);
}
use of com.redhat.ceylon.cmr.api.RepositoryManager in project ceylon-compiler by ceylon.
the class CeylonP2Tool method run.
@Override
public void run() throws Exception {
RepositoryManager repoManager = getRepositoryManager();
Map<String, ModuleInfo> allModules = new HashMap<>();
for (ModuleSpec module : modules) {
String version = findModuleVersion(module);
msg("collecting.modules", module.toString());
newline();
collectModules(repoManager, module.getName(), version, allModules);
}
// now purge empty modules
purgeMissingModules(allModules);
Map<String, Feature> features = collectFeatures();
Map<String, Category> categoriesByName = null;
if (categories != null) {
categoriesByName = parseCategories(features);
}
msg("generating.artifacts");
newline();
printArtifacts(allModules, features);
msg("generating.content");
newline();
printContent(allModules, features, categoriesByName);
}
Aggregations