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);
}
}
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;
}
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;
}
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();
}
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();
}
Aggregations