Search in sources :

Example 11 with CompilerModuleExtension

use of com.intellij.openapi.roots.CompilerModuleExtension in project android by JetBrains.

the class CompilerSettingsSetup method setOutputPaths.

public void setOutputPaths(@NotNull ModifiableRootModel moduleModel, @NotNull File mainOutputPath, @Nullable File testOutputPath) {
    CompilerModuleExtension compilerSettings = moduleModel.getModuleExtension(CompilerModuleExtension.class);
    if (compilerSettings == null) {
        String msg = String.format("No compiler extension is found for module '%1$s'", moduleModel.getModule().getName());
        Logger.getInstance(getClass()).warn(msg);
        return;
    }
    compilerSettings.inheritCompilerOutputPath(false);
    compilerSettings.setCompilerOutputPath(pathToIdeaUrl(mainOutputPath));
    if (testOutputPath != null) {
        compilerSettings.setCompilerOutputPathForTests(pathToIdeaUrl(testOutputPath));
    }
}
Also used : CompilerModuleExtension(com.intellij.openapi.roots.CompilerModuleExtension)

Example 12 with CompilerModuleExtension

use of com.intellij.openapi.roots.CompilerModuleExtension in project android by JetBrains.

the class ModuleClassLoader method loadClassFromModule.

@Nullable
private Class<?> loadClassFromModule(Module module, String name) {
    if (module.isDisposed()) {
        return null;
    }
    final CompilerModuleExtension extension = CompilerModuleExtension.getInstance(module);
    if (extension == null) {
        return null;
    }
    if (LOG.isDebugEnabled()) {
        LOG.debug(String.format("loadClassFromModule(%s, %s)", anonymize(module), anonymizeClassName(name)));
    }
    VirtualFile vOutFolder = extension.getCompilerOutputPath();
    VirtualFile classFile = null;
    if (vOutFolder == null) {
        AndroidFacet facet = AndroidFacet.getInstance(module);
        if (facet != null && facet.requiresAndroidModel()) {
            AndroidModel androidModel = facet.getAndroidModel();
            if (androidModel != null) {
                classFile = androidModel.getClassJarProvider().findModuleClassFile(name, module);
            }
        }
    } else {
        classFile = ClassJarProvider.findClassFileInPath(vOutFolder, name);
    }
    if (classFile != null) {
        return loadClassFile(name, classFile);
    }
    if (LOG.isDebugEnabled()) {
        LOG.debug("  Class not found");
    }
    return null;
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) AndroidModel(com.android.tools.idea.model.AndroidModel) CompilerModuleExtension(com.intellij.openapi.roots.CompilerModuleExtension) AndroidFacet(org.jetbrains.android.facet.AndroidFacet) Nullable(org.jetbrains.annotations.Nullable)

Aggregations

CompilerModuleExtension (com.intellij.openapi.roots.CompilerModuleExtension)12 Module (com.intellij.openapi.module.Module)5 VirtualFile (com.intellij.openapi.vfs.VirtualFile)5 Nullable (org.jetbrains.annotations.Nullable)3 ContentEntry (com.intellij.openapi.roots.ContentEntry)2 NotNull (org.jetbrains.annotations.NotNull)2 AndroidModuleModel (com.android.tools.idea.gradle.project.model.AndroidModuleModel)1 AndroidModel (com.android.tools.idea.model.AndroidModel)1 Application (com.intellij.openapi.application.Application)1 DumbProgressIndicator (com.intellij.openapi.progress.DumbProgressIndicator)1 ModuleRootManager (com.intellij.openapi.roots.ModuleRootManager)1 SourceFolder (com.intellij.openapi.roots.SourceFolder)1 Computable (com.intellij.openapi.util.Computable)1 VirtualFilePointer (com.intellij.openapi.vfs.pointers.VirtualFilePointer)1 ClassData (com.intellij.rt.coverage.data.ClassData)1 LineData (com.intellij.rt.coverage.data.LineData)1 ClassPathEntry (com.intellij.rt.coverage.util.classFinder.ClassPathEntry)1 FactoryMap (com.intellij.util.containers.FactoryMap)1 File (java.io.File)1 FileInputStream (java.io.FileInputStream)1