Search in sources :

Example 6 with JpsDummyElement

use of org.jetbrains.jps.model.JpsDummyElement in project intellij-elixir by KronicDeth.

the class MixBuilder method build.

@Override
public void build(@NotNull ElixirTarget target, @NotNull DirtyFilesHolder<ElixirSourceRootDescriptor, ElixirTarget> holder, @NotNull BuildOutputConsumer outputConsumer, @NotNull CompileContext context) throws ProjectBuildException, IOException {
    if (!holder.hasDirtyFiles() && !holder.hasRemovedFiles())
        return;
    JpsModule module = target.getModule();
    JpsProject project = module.getProject();
    ElixirCompilerOptions compilerOptions = JpsElixirCompilerOptionsExtension.getOrCreateExtension(project).getOptions();
    if (!compilerOptions.myUseMixCompiler)
        return;
    String mixPath = getMixExecutablePath(project);
    if (mixPath == null) {
        String errorMessage = "Mix path is not set.";
        context.processMessage(new CompilerMessage(NAME, BuildMessage.Kind.ERROR, errorMessage));
        throw new ProjectBuildException(errorMessage);
    }
    JpsSdk<JpsDummyElement> sdk = ElixirTargetBuilderUtil.getSdk(context, module);
    String elixirPath = JpsElixirSdkType.getScriptInterpreterExecutable(sdk.getHomePath()).getAbsolutePath();
    for (String contentRootUrl : module.getContentRootsList().getUrls()) {
        String contentRootPath = new URL(contentRootUrl).getPath();
        File contentRootDir = new File(contentRootPath);
        File mixConfigFile = new File(contentRootDir, MIX_CONFIG_FILE_NAME);
        if (!mixConfigFile.exists())
            continue;
        runMix(elixirPath, mixPath, contentRootPath, compilerOptions.myAttachDebugInfoEnabled, context);
    }
}
Also used : ProjectBuildException(org.jetbrains.jps.incremental.ProjectBuildException) JpsModule(org.jetbrains.jps.model.module.JpsModule) CompilerMessage(org.jetbrains.jps.incremental.messages.CompilerMessage) JpsProject(org.jetbrains.jps.model.JpsProject) JpsDummyElement(org.jetbrains.jps.model.JpsDummyElement) ElixirCompilerOptions(org.elixir_lang.jps.model.ElixirCompilerOptions) File(java.io.File) URL(java.net.URL)

Example 7 with JpsDummyElement

use of org.jetbrains.jps.model.JpsDummyElement in project intellij-elixir by KronicDeth.

the class ElixirBuilder method getElixircCommandLine.

private static GeneralCommandLine getElixircCommandLine(ElixirTarget target, CompileContext context, ElixirCompilerOptions compilerOptions, Collection<File> files, File outputDirectory) throws ProjectBuildException {
    GeneralCommandLine commandLine = new GeneralCommandLine();
    // get executable
    JpsModule module = target.getModule();
    JpsSdk<JpsDummyElement> sdk = ElixirTargetBuilderUtil.getSdk(context, module);
    File executable = JpsElixirSdkType.getByteCodeCompilerExecutable(sdk.getHomePath());
    List<String> compileFilePaths = getCompileFilePaths(module, target, context, files);
    commandLine.withWorkDirectory(outputDirectory);
    commandLine.setExePath(executable.getAbsolutePath());
    addDependentModuleCodePath(commandLine, module, target, context);
    addCompileOptions(commandLine, compilerOptions);
    commandLine.addParameters(compileFilePaths);
    return commandLine;
}
Also used : JpsDummyElement(org.jetbrains.jps.model.JpsDummyElement) File(java.io.File)

Example 8 with JpsDummyElement

use of org.jetbrains.jps.model.JpsDummyElement in project intellij-community by JetBrains.

the class ClassProcessingBuilder method build.

@Override
public final ExitCode build(CompileContext context, ModuleChunk chunk, DirtyFilesHolder<JavaSourceRootDescriptor, ModuleBuildTarget> dirtyFilesHolder, OutputConsumer outputConsumer) throws ProjectBuildException, IOException {
    if (outputConsumer.getCompiledClasses().isEmpty() || !isEnabled(context, chunk)) {
        return ExitCode.NOTHING_DONE;
    }
    final String progress = getProgressMessage();
    final boolean shouldShowProgress = !StringUtil.isEmptyOrSpaces(progress);
    if (shouldShowProgress) {
        context.processMessage(new ProgressMessage(progress + " [" + chunk.getPresentableShortName() + "]"));
    }
    ExitCode exitCode = ExitCode.NOTHING_DONE;
    try {
        // try using shared finder
        InstrumentationClassFinder finder = CLASS_FINDER.get(context);
        if (finder == null) {
            final Collection<File> platformCp = ProjectPaths.getPlatformCompilationClasspath(chunk, false);
            final Collection<File> classpath = new ArrayList<>();
            classpath.addAll(ProjectPaths.getCompilationClasspath(chunk, false));
            classpath.addAll(ProjectPaths.getSourceRootsWithDependents(chunk).keySet());
            final JpsSdk<JpsDummyElement> sdk = chunk.representativeTarget().getModule().getSdk(JpsJavaSdkType.INSTANCE);
            finder = createInstrumentationClassFinder(sdk, platformCp, classpath, outputConsumer);
            CLASS_FINDER.set(context, finder);
        }
        exitCode = performBuild(context, chunk, finder, outputConsumer);
    } finally {
        if (shouldShowProgress) {
            // cleanup progress
            context.processMessage(new ProgressMessage(""));
        }
    }
    return exitCode;
}
Also used : ProgressMessage(org.jetbrains.jps.incremental.messages.ProgressMessage) InstrumentationClassFinder(com.intellij.compiler.instrumentation.InstrumentationClassFinder) ArrayList(java.util.ArrayList) JpsDummyElement(org.jetbrains.jps.model.JpsDummyElement) File(java.io.File)

Example 9 with JpsDummyElement

use of org.jetbrains.jps.model.JpsDummyElement in project intellij-community by JetBrains.

the class CommonTest method testMoveClassToDependentModuleWithSameOutput.

public void testMoveClassToDependentModuleWithSameOutput() throws Exception {
    final JpsSdk<JpsDummyElement> sdk = getOrCreateJdk();
    final String commonOutput = getAbsolutePath("out");
    JpsModule moduleA = addModule("moduleA", new String[] { getAbsolutePath("moduleA/src") }, commonOutput, commonOutput, sdk);
    JpsModule moduleB = addModule("moduleB", new String[] { getAbsolutePath("moduleB/src") }, commonOutput, commonOutput, sdk);
    JpsModuleRootModificationUtil.addDependency(moduleB, moduleA);
    doTestBuild(1).assertSuccessful();
}
Also used : JpsModule(org.jetbrains.jps.model.module.JpsModule) JpsDummyElement(org.jetbrains.jps.model.JpsDummyElement)

Example 10 with JpsDummyElement

use of org.jetbrains.jps.model.JpsDummyElement in project intellij-community by JetBrains.

the class JavaBuilderUtil method ensureModuleHasJdk.

@NotNull
public static JpsSdk<JpsDummyElement> ensureModuleHasJdk(JpsModule module, CompileContext context, final String compilerName) throws ProjectBuildException {
    JpsSdkReference<JpsDummyElement> reference = module.getSdkReference(JpsJavaSdkType.INSTANCE);
    if (reference == null) {
        context.processMessage(new CompilerMessage(compilerName, BuildMessage.Kind.ERROR, "JDK isn't specified for module '" + module.getName() + "'"));
        throw new StopBuildException();
    }
    JpsTypedLibrary<JpsSdk<JpsDummyElement>> sdkLibrary = reference.resolve();
    if (sdkLibrary == null) {
        context.processMessage(new CompilerMessage(compilerName, BuildMessage.Kind.ERROR, "Cannot find JDK '" + reference.getSdkName() + "' for module '" + module.getName() + "'"));
        throw new StopBuildException();
    }
    return sdkLibrary.getProperties();
}
Also used : CompilerMessage(org.jetbrains.jps.incremental.messages.CompilerMessage) JpsDummyElement(org.jetbrains.jps.model.JpsDummyElement) JpsSdk(org.jetbrains.jps.model.library.sdk.JpsSdk) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

JpsDummyElement (org.jetbrains.jps.model.JpsDummyElement)11 File (java.io.File)7 NotNull (org.jetbrains.annotations.NotNull)4 CompilerMessage (org.jetbrains.jps.incremental.messages.CompilerMessage)4 JpsModule (org.jetbrains.jps.model.module.JpsModule)4 ProjectBuildException (org.jetbrains.jps.incremental.ProjectBuildException)3 ProgressMessage (org.jetbrains.jps.incremental.messages.ProgressMessage)3 InstrumentationClassFinder (com.intellij.compiler.instrumentation.InstrumentationClassFinder)2 THashSet (gnu.trove.THashSet)2 IOException (java.io.IOException)2 ProjectBuilderLogger (org.jetbrains.jps.builders.logging.ProjectBuilderLogger)2 JpsProject (org.jetbrains.jps.model.JpsProject)2 EnhancerRunner (com.intellij.appengine.rt.EnhancerRunner)1 ApplicationStarter (com.intellij.openapi.application.ApplicationStarter)1 PathManager (com.intellij.openapi.application.PathManager)1 Logger (com.intellij.openapi.diagnostic.Logger)1 ProcessCanceledException (com.intellij.openapi.progress.ProcessCanceledException)1 ProgressIndicator (com.intellij.openapi.progress.ProgressIndicator)1 ProgressManager (com.intellij.openapi.progress.ProgressManager)1 com.intellij.openapi.projectRoots (com.intellij.openapi.projectRoots)1