use of org.jetbrains.jps.model.module.JpsModule in project intellij-community by JetBrains.
the class JavaBuilder method addCrossCompilationOptions.
private static void addCrossCompilationOptions(int compilerSdkVersion, List<String> options, CompileContext context, ModuleChunk chunk) {
final JpsJavaCompilerConfiguration compilerConfiguration = JpsJavaExtensionService.getInstance().getOrCreateCompilerConfiguration(context.getProjectDescriptor().getProject());
final String langLevel = getLanguageLevel(chunk.getModules().iterator().next());
final int chunkSdkVersion = getChunkSdkVersion(chunk);
final int targetLanguageLevel = JpsJavaSdkType.parseVersion(langLevel);
if (shouldUseReleaseOption(context, compilerSdkVersion, chunkSdkVersion, targetLanguageLevel)) {
options.add(getReleaseOptionName());
options.add(String.valueOf(targetLanguageLevel));
return;
}
// using older -source, -target and -bootclasspath options
if (!StringUtil.isEmpty(langLevel)) {
options.add("-source");
options.add(langLevel);
}
String bytecodeTarget = null;
for (JpsModule module : chunk.getModules()) {
final String moduleTarget = compilerConfiguration.getByteCodeTargetLevel(module.getName());
if (moduleTarget == null) {
continue;
}
if (bytecodeTarget == null) {
bytecodeTarget = moduleTarget;
} else {
if (moduleTarget.compareTo(bytecodeTarget) < 0) {
// use the lower possible target among modules that form the chunk
bytecodeTarget = moduleTarget;
}
}
}
if (bytecodeTarget == null) {
if (!StringUtil.isEmpty(langLevel)) {
// according to IDEA rule: if not specified explicitly, set target to be the same as source language level
bytecodeTarget = langLevel;
} else {
// last resort and backward compatibility:
// check if user explicitly defined bytecode target in additional compiler options
bytecodeTarget = USER_DEFINED_BYTECODE_TARGET.get(context);
}
}
if (bytecodeTarget != null) {
options.add("-target");
if (chunkSdkVersion > 0 && compilerSdkVersion > chunkSdkVersion) {
// if compiler is newer than module JDK
final int userSpecifiedTargetVersion = JpsJavaSdkType.parseVersion(bytecodeTarget);
if (userSpecifiedTargetVersion > 0 && userSpecifiedTargetVersion <= compilerSdkVersion) {
// if user-specified bytecode version can be determined and is supported by compiler
if (userSpecifiedTargetVersion > chunkSdkVersion) {
// and user-specified bytecode target level is higher than the highest one supported by the target JDK,
// force compiler to use highest-available bytecode target version that is supported by the chunk JDK.
bytecodeTarget = "1." + chunkSdkVersion;
}
}
// otherwise let compiler display compilation error about incorrectly set bytecode target version
}
options.add(bytecodeTarget);
} else {
if (chunkSdkVersion > 0 && compilerSdkVersion > chunkSdkVersion) {
// force lower bytecode target level to match the version of sdk assigned to this chunk
options.add("-target");
options.add("1." + chunkSdkVersion);
}
}
}
use of org.jetbrains.jps.model.module.JpsModule in project intellij-community by JetBrains.
the class BuildTargetConfiguration method isTargetDirty.
public boolean isTargetDirty(CompileContext context) {
final String currentState = getCurrentState(context);
if (!currentState.equals(myConfiguration)) {
LOG.debug(myTarget + " configuration was changed:");
LOG.debug("Old:");
LOG.debug(myConfiguration);
LOG.debug("New:");
LOG.debug(currentState);
LOG.debug(myTarget + " will be recompiled");
if (myTarget instanceof ModuleBuildTarget) {
final JpsModule module = ((ModuleBuildTarget) myTarget).getModule();
synchronized (MODULES_WITH_TARGET_CONFIG_CHANGED_KEY) {
Set<JpsModule> modules = MODULES_WITH_TARGET_CONFIG_CHANGED_KEY.get(context);
if (modules == null) {
MODULES_WITH_TARGET_CONFIG_CHANGED_KEY.set(context, modules = new THashSet<>());
}
modules.add(module);
}
}
return true;
}
return false;
}
use of org.jetbrains.jps.model.module.JpsModule in project intellij-community by JetBrains.
the class CommonTest method testMoveClassToDependentModule.
public void testMoveClassToDependentModule() throws Exception {
JpsModule moduleA = addModule("moduleA", "moduleA/src");
JpsModule moduleB = addModule("moduleB", "moduleB/src");
JpsModuleRootModificationUtil.addDependency(moduleB, moduleA);
doTestBuild(1).assertSuccessful();
}
use of org.jetbrains.jps.model.module.JpsModule in project intellij-community by JetBrains.
the class MarkDirtyTest method testDoNotMarkDirtyCompiledChunks.
public void testDoNotMarkDirtyCompiledChunks() {
//'b.Client' from production sources of 'b' cannot depend on 'a.ShortName' from module 'a' so it shouldn't be marked as dirty.
//Otherwise we can get 'dirty' sources after full make if production of 'b' was compiled before 'a'
JpsModule b = addModule("b", "moduleB/src");
addTestRoot(b, "moduleB/testSrc");
JpsModule a = addModule("a", "moduleA/src");
addTestRoot(a, "moduleA/testSrc");
JpsModuleRootModificationUtil.addDependency(b, a, JpsJavaDependencyScope.TEST, false);
doTestBuild(2).assertSuccessful();
}
use of org.jetbrains.jps.model.module.JpsModule in project intellij-community by JetBrains.
the class MarkDirtyTest method testTransitiveRecompile.
public void testTransitiveRecompile() {
JpsModule module = addModule();
addTestRoot(module, "testSrc");
JpsModule util = addModule("util", "util/src");
addTestRoot(util, "util/testSrc");
JpsModuleRootModificationUtil.addDependency(module, util);
JpsModule lib = addModule("lib", "lib/src");
addTestRoot(lib, "lib/testSrc");
JpsModuleRootModificationUtil.addDependency(util, lib);
doTestBuild(1).assertSuccessful();
}
Aggregations