mirror of
https://gitflic.ru/project/openide/openide.git
synced 2025-12-13 15:52:01 +07:00
support -proc:full option requirement (IDEA-359954)
(cherry picked from commit 5509dc25f0934fbdfc801b3780e8f72d4f7be7e9) IJ-CR-146769 GitOrigin-RevId: deda4a64d2305843841b88b8c7e0743a176331d2
This commit is contained in:
committed by
intellij-monorepo-bot
parent
23c1b47d6e
commit
0980804342
@@ -29,6 +29,7 @@ import org.jetbrains.jps.backwardRefs.JavaBackwardReferenceIndexWriter;
|
||||
import org.jetbrains.jps.builders.*;
|
||||
import org.jetbrains.jps.builders.impl.DirtyFilesHolderBase;
|
||||
import org.jetbrains.jps.builders.impl.TargetOutputIndexImpl;
|
||||
import org.jetbrains.jps.builders.impl.java.JavacCompilerTool;
|
||||
import org.jetbrains.jps.builders.java.*;
|
||||
import org.jetbrains.jps.builders.logging.ProjectBuilderLogger;
|
||||
import org.jetbrains.jps.builders.storage.BuildDataCorruptedException;
|
||||
@@ -79,6 +80,10 @@ public final class JavaBuilder extends ModuleLevelBuilder {
|
||||
|
||||
private static final String USE_MODULE_PATH_ONLY_OPTION = "compiler.force.module.path";
|
||||
|
||||
// the compiler sdk version from which specifying -proc:full is required for annotation processing to work
|
||||
// if the option is set, it will override the hardcoded logic in 'addCompilerOptions'
|
||||
private static final String PROC_FULL_REQUIRED_OPTION = "compiler.proc.full.required";
|
||||
|
||||
public static final String BUILDER_ID = "java";
|
||||
public static final Key<Boolean> IS_ENABLED = Key.create("_java_compiler_enabled_");
|
||||
public static final FileFilter JAVA_SOURCES_FILTER = FileFilters.withExtension(JAVA_EXTENSION);
|
||||
@@ -91,9 +96,10 @@ public final class JavaBuilder extends ModuleLevelBuilder {
|
||||
private static final List<String> COMPILABLE_EXTENSIONS = Collections.singletonList(JAVA_EXTENSION);
|
||||
|
||||
private static final String PROC_ONLY_OPTION = "-proc:only";
|
||||
private static final String PROC_FULL_OPTION = "-proc:full";
|
||||
private static final String PROC_NONE_OPTION = "-proc:none";
|
||||
private static final String RELEASE_OPTION = "--release";
|
||||
private static final String TARGET_OPTION = "-target";
|
||||
private static final String PROC_NONE_OPTION = "-proc:none";
|
||||
private static final String PROCESSORPATH_OPTION = "-processorpath";
|
||||
private static final String ENCODING_OPTION = "-encoding";
|
||||
private static final String ENABLE_PREVIEW_OPTION = "--enable-preview";
|
||||
@@ -104,7 +110,7 @@ public final class JavaBuilder extends ModuleLevelBuilder {
|
||||
TARGET_OPTION, RELEASE_OPTION, "-d"
|
||||
);
|
||||
private static final Set<String> FILTERED_SINGLE_OPTIONS = Set.of(
|
||||
"-g", "-deprecation", "-nowarn", "-verbose", PROC_NONE_OPTION, PROC_ONLY_OPTION, "-proceedOnError"
|
||||
"-g", "-deprecation", "-nowarn", "-verbose", PROC_NONE_OPTION, PROC_ONLY_OPTION, PROC_FULL_OPTION, "-proceedOnError"
|
||||
);
|
||||
private static final Set<String> POSSIBLY_CONFLICTING_OPTIONS = Set.of(
|
||||
SOURCE_OPTION, SYSTEM_OPTION, "--boot-class-path", "-bootclasspath", "--class-path", "-classpath", "-cp", PROCESSORPATH_OPTION, "-sourcepath", "--module-path", "-p", "--module-source-path"
|
||||
@@ -112,6 +118,7 @@ public final class JavaBuilder extends ModuleLevelBuilder {
|
||||
|
||||
private static final List<ClassPostProcessor> ourClassProcessors = new ArrayList<>();
|
||||
private static final @Nullable File ourDefaultRtJar;
|
||||
private static final int ourProcFullRequiredFrom; // 0, if not set
|
||||
static {
|
||||
File rtJar = null;
|
||||
StringTokenizer tokenizer = new StringTokenizer(System.getProperty("sun.boot.class.path", ""), File.pathSeparator, false);
|
||||
@@ -123,6 +130,14 @@ public final class JavaBuilder extends ModuleLevelBuilder {
|
||||
}
|
||||
}
|
||||
ourDefaultRtJar = rtJar;
|
||||
|
||||
int procFullRequired = 0;
|
||||
try {
|
||||
procFullRequired = Math.max(Integer.parseInt(System.getProperty(PROC_FULL_REQUIRED_OPTION, "0")), 0);
|
||||
}
|
||||
catch (NumberFormatException ignored) {
|
||||
}
|
||||
ourProcFullRequiredFrom = procFullRequired;
|
||||
}
|
||||
|
||||
private static final class CompilableModuleTypesHolder {
|
||||
@@ -933,7 +948,7 @@ public final class JavaBuilder extends ModuleLevelBuilder {
|
||||
vmOptions.addAll(extension.getOptions(compilingTool, compilerSdkVersion));
|
||||
}
|
||||
|
||||
addCompilationOptions(compilerSdkVersion, compilationOptions, context, chunk, profile, true);
|
||||
addCompilationOptions(compilerSdkVersion, compilingTool, compilationOptions, context, chunk, profile, true);
|
||||
|
||||
return Pair.create(vmOptions, compilationOptions);
|
||||
}
|
||||
@@ -953,11 +968,11 @@ public final class JavaBuilder extends ModuleLevelBuilder {
|
||||
}
|
||||
|
||||
public static void addCompilationOptions(List<? super String> options, CompileContext context, ModuleChunk chunk, @Nullable ProcessorConfigProfile profile) {
|
||||
addCompilationOptions(JavaVersion.current().feature, options, context, chunk, profile, false);
|
||||
addCompilationOptions(JavaVersion.current().feature, JavaBuilderUtil.findCompilingTool(JavacCompilerTool.ID), options, context, chunk, profile, false);
|
||||
}
|
||||
|
||||
private static void addCompilationOptions(
|
||||
int compilerSdkVersion, List<? super String> options, CompileContext context, ModuleChunk chunk, @Nullable ProcessorConfigProfile profile, boolean procOnlySupported
|
||||
int compilerSdkVersion, JavaCompilingTool compilingTool, List<? super String> options, CompileContext context, ModuleChunk chunk, @Nullable ProcessorConfigProfile profile, boolean procOnlySupported
|
||||
) {
|
||||
if (!options.contains(ENCODING_OPTION)) {
|
||||
final CompilerEncodingConfiguration config = context.getProjectDescriptor().getEncodingConfiguration();
|
||||
@@ -987,6 +1002,21 @@ public final class JavaBuilder extends ModuleLevelBuilder {
|
||||
if (procOnlySupported && profile.isProcOnly()) {
|
||||
options.add(PROC_ONLY_OPTION);
|
||||
}
|
||||
else {
|
||||
// for newer compilers need to enable annotation processing explicitly
|
||||
|
||||
if (ourProcFullRequiredFrom > 0 /*the requirement explicitly configured*/) {
|
||||
if (compilerSdkVersion >= ourProcFullRequiredFrom) {
|
||||
options.add(PROC_FULL_OPTION);
|
||||
}
|
||||
}
|
||||
else {
|
||||
// by default required for javac from version 23
|
||||
if (compilerSdkVersion > 22 && isJavac(compilingTool)){
|
||||
options.add(PROC_FULL_OPTION);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
final File srcOutput = ProjectPaths.getAnnotationProcessorGeneratedSourcesOutputDir(
|
||||
chunk.getModules().iterator().next(), chunk.containsTests(), profile
|
||||
|
||||
Reference in New Issue
Block a user