Search in sources :

Example 6 with RepositoryManager

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);
}
Also used : ArrayList(java.util.ArrayList) JavaCompiler(javax.tools.JavaCompiler) StandardJavaFileManager(javax.tools.StandardJavaFileManager) RepositoryManager(com.redhat.ceylon.cmr.api.RepositoryManager) ArtifactContext(com.redhat.ceylon.cmr.api.ArtifactContext) File(java.io.File) CompilationTask(javax.tools.JavaCompiler.CompilationTask)

Example 7 with RepositoryManager

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);
}
Also used : ModuleSpec(com.redhat.ceylon.common.tools.ModuleSpec) HashMap(java.util.HashMap) RepositoryManager(com.redhat.ceylon.cmr.api.RepositoryManager)

Aggregations

RepositoryManager (com.redhat.ceylon.cmr.api.RepositoryManager)7 ArtifactContext (com.redhat.ceylon.cmr.api.ArtifactContext)4 File (java.io.File)3 ModuleSpec (com.redhat.ceylon.common.tools.ModuleSpec)2 Context (com.redhat.ceylon.compiler.typechecker.context.Context)2 VFS (com.redhat.ceylon.compiler.typechecker.io.VFS)2 ArtifactResult (com.redhat.ceylon.model.cmr.ArtifactResult)2 RepositoryManagerBuilder (com.redhat.ceylon.cmr.api.RepositoryManagerBuilder)1 InvalidArchiveException (com.redhat.ceylon.cmr.impl.InvalidArchiveException)1 RuntimeModelLoader (com.redhat.ceylon.compiler.java.runtime.model.RuntimeModelLoader)1 RuntimeModuleManager (com.redhat.ceylon.compiler.java.runtime.model.RuntimeModuleManager)1 TypeCheckerBuilder (com.redhat.ceylon.compiler.typechecker.TypeCheckerBuilder)1 ModuleSourceMapper (com.redhat.ceylon.compiler.typechecker.analyzer.ModuleSourceMapper)1 PhasedUnit (com.redhat.ceylon.compiler.typechecker.context.PhasedUnit)1 PhasedUnits (com.redhat.ceylon.compiler.typechecker.context.PhasedUnits)1 ModuleManagerFactory (com.redhat.ceylon.compiler.typechecker.util.ModuleManagerFactory)1 Modules (com.redhat.ceylon.model.typechecker.model.Modules)1 ModuleManager (com.redhat.ceylon.model.typechecker.util.ModuleManager)1 Context (com.sun.tools.javac.util.Context)1 ArrayList (java.util.ArrayList)1