mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
supported annotation processing for compiling evaluator
This commit is contained in:
@@ -21,6 +21,7 @@
|
||||
<orderEntry type="module" module-name="java-impl" />
|
||||
<orderEntry type="module" module-name="platform-impl" />
|
||||
<orderEntry type="module" module-name="util" />
|
||||
<orderEntry type="module" module-name="jps-builders" />
|
||||
</component>
|
||||
<component name="copyright">
|
||||
<Base>
|
||||
|
||||
+6
-1
@@ -15,6 +15,7 @@
|
||||
*/
|
||||
package com.intellij.debugger.ui.impl.watch;
|
||||
|
||||
import com.intellij.compiler.CompilerConfiguration;
|
||||
import com.intellij.compiler.server.BuildManager;
|
||||
import com.intellij.debugger.engine.evaluation.EvaluateException;
|
||||
import com.intellij.debugger.engine.evaluation.EvaluationContextImpl;
|
||||
@@ -37,6 +38,8 @@ import com.intellij.psi.PsiFile;
|
||||
import com.intellij.refactoring.extractMethodObject.ExtractLightMethodObjectHandler;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jps.incremental.java.JavaBuilder;
|
||||
import org.jetbrains.jps.model.java.compiler.AnnotationProcessingConfiguration;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
@@ -62,12 +65,13 @@ public class CompilingEvaluatorImpl extends CompilingEvaluator {
|
||||
}
|
||||
});
|
||||
final List<String> options = new ArrayList<>();
|
||||
options.add("-proc:none"); // for our purposes annotation processing is not needed
|
||||
options.add("-encoding");
|
||||
options.add("UTF-8");
|
||||
final List<File> platformClasspath = new ArrayList<>();
|
||||
final List<File> classpath = new ArrayList<>();
|
||||
AnnotationProcessingConfiguration profile = null;
|
||||
if (module != null) {
|
||||
profile = CompilerConfiguration.getInstance(module.getProject()).getAnnotationProcessingConfiguration(module);
|
||||
final ModuleRootManager rootManager = ModuleRootManager.getInstance(module);
|
||||
for (String s : rootManager.orderEntries().compileOnly().recursively().exportedOnly().withoutSdk().getPathsList().getPathList()) {
|
||||
classpath.add(new File(s));
|
||||
@@ -76,6 +80,7 @@ public class CompilingEvaluatorImpl extends CompilingEvaluator {
|
||||
platformClasspath.add(new File(s));
|
||||
}
|
||||
}
|
||||
JavaBuilder.addAnnotationProcessingOptions(options, profile);
|
||||
|
||||
final Pair<Sdk, JavaSdkVersion> runtime = BuildManager.getBuildProcessRuntimeSdk(myEvaluationContext.getProject());
|
||||
final JavaSdkVersion buildRuntimeVersion = runtime.getSecond();
|
||||
|
||||
@@ -677,24 +677,7 @@ public class JavaBuilder extends ModuleLevelBuilder {
|
||||
|
||||
addCrossCompilationOptions(compilerSdkVersion, options, context, chunk);
|
||||
|
||||
if (profile != null && profile.isEnabled()) {
|
||||
// configuring annotation processing
|
||||
if (!profile.isObtainProcessorsFromClasspath()) {
|
||||
final String processorsPath = profile.getProcessorPath();
|
||||
options.add("-processorpath");
|
||||
options.add(FileUtil.toSystemDependentName(processorsPath.trim()));
|
||||
}
|
||||
|
||||
final Set<String> processors = profile.getProcessors();
|
||||
if (!processors.isEmpty()) {
|
||||
options.add("-processor");
|
||||
options.add(StringUtil.join(processors, ","));
|
||||
}
|
||||
|
||||
for (Map.Entry<String, String> optionEntry : profile.getProcessorOptions().entrySet()) {
|
||||
options.add("-A" + optionEntry.getKey() + "=" + optionEntry.getValue());
|
||||
}
|
||||
|
||||
if (addAnnotationProcessingOptions(options, profile)) {
|
||||
final File srcOutput = ProjectPaths.getAnnotationProcessorGeneratedSourcesOutputDir(
|
||||
chunk.getModules().iterator().next(), chunk.containsTests(), profile
|
||||
);
|
||||
@@ -704,11 +687,39 @@ public class JavaBuilder extends ModuleLevelBuilder {
|
||||
options.add(srcOutput.getPath());
|
||||
}
|
||||
}
|
||||
else {
|
||||
options.add("-proc:none");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param options
|
||||
* @param profile
|
||||
* @return true if annotation processing is enabled and corresponding options were added, false if profile is null or disabled
|
||||
*/
|
||||
public static boolean addAnnotationProcessingOptions(List<String> options, @Nullable AnnotationProcessingConfiguration profile) {
|
||||
if (profile == null || !profile.isEnabled()) {
|
||||
options.add("-proc:none");
|
||||
return false;
|
||||
}
|
||||
|
||||
// configuring annotation processing
|
||||
if (!profile.isObtainProcessorsFromClasspath()) {
|
||||
final String processorsPath = profile.getProcessorPath();
|
||||
options.add("-processorpath");
|
||||
options.add(FileUtil.toSystemDependentName(processorsPath.trim()));
|
||||
}
|
||||
|
||||
final Set<String> processors = profile.getProcessors();
|
||||
if (!processors.isEmpty()) {
|
||||
options.add("-processor");
|
||||
options.add(StringUtil.join(processors, ","));
|
||||
}
|
||||
|
||||
for (Map.Entry<String, String> optionEntry : profile.getProcessorOptions().entrySet()) {
|
||||
options.add("-A" + optionEntry.getKey() + "=" + optionEntry.getValue());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
private static void addCrossCompilationOptions(final int compilerSdkVersion, final List<String> options, final CompileContext context, final ModuleChunk chunk) {
|
||||
final JpsJavaCompilerConfiguration compilerConfiguration = JpsJavaExtensionService.getInstance().getOrCreateCompilerConfiguration(
|
||||
context.getProjectDescriptor().getProject()
|
||||
|
||||
Reference in New Issue
Block a user