mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
external make: java builder does not explicitly depend on ui designer settings (IDEA-94679 external make should check if UIDesigner plugin is enabled)
This commit is contained in:
@@ -35,7 +35,6 @@
|
||||
<orderEntry type="module" module-name="jps-model-api" />
|
||||
<orderEntry type="module" module-name="jps-model-serialization" />
|
||||
<orderEntry type="module" module-name="jps-model-impl" />
|
||||
<orderEntry type="module" module-name="ui-designer-jps-plugin" />
|
||||
<orderEntry type="library" scope="TEST" name="Groovy" level="project" />
|
||||
</component>
|
||||
</module>
|
||||
|
||||
@@ -55,8 +55,6 @@ import org.jetbrains.jps.model.java.LanguageLevel;
|
||||
import org.jetbrains.jps.model.java.compiler.*;
|
||||
import org.jetbrains.jps.model.library.sdk.JpsSdk;
|
||||
import org.jetbrains.jps.model.module.JpsModule;
|
||||
import org.jetbrains.jps.uiDesigner.model.JpsUiDesignerConfiguration;
|
||||
import org.jetbrains.jps.uiDesigner.model.JpsUiDesignerExtensionService;
|
||||
|
||||
import javax.tools.*;
|
||||
import java.io.*;
|
||||
@@ -116,6 +114,8 @@ public class JavaBuilder extends ModuleLevelBuilder {
|
||||
private static final Key<Callbacks.Backend> DELTA_MAPPINGS_CALLBACK_KEY = Key.create("_dependency_data_");
|
||||
private final Executor myTaskRunner;
|
||||
private static final List<ClassPostProcessor> ourClassProcessors = new ArrayList<ClassPostProcessor>();
|
||||
private static boolean OPTION_ENABLE_FORMS_INSTRUMENTATION = false;
|
||||
private static boolean OPTION_COPY_FORMS_RUNTIME_CLASSES = false;
|
||||
|
||||
static {
|
||||
registerClassPostProcessor(new ClassPostProcessor() {
|
||||
@@ -165,6 +165,22 @@ public class JavaBuilder extends ModuleLevelBuilder {
|
||||
ourClassProcessors.add(processor);
|
||||
}
|
||||
|
||||
public static boolean isFormsInstrumentationEnabled() {
|
||||
return OPTION_ENABLE_FORMS_INSTRUMENTATION;
|
||||
}
|
||||
|
||||
public static void setFormsInstrumentationEnabled(boolean enabled) {
|
||||
OPTION_ENABLE_FORMS_INSTRUMENTATION = enabled;
|
||||
}
|
||||
|
||||
public static boolean isCopyFormsRuntime() {
|
||||
return OPTION_COPY_FORMS_RUNTIME_CLASSES;
|
||||
}
|
||||
|
||||
public static void setCopyFormsRuntime(boolean copy) {
|
||||
OPTION_COPY_FORMS_RUNTIME_CLASSES = copy;
|
||||
}
|
||||
|
||||
public JavaBuilder(Executor tasksExecutor) {
|
||||
super(BuilderCategory.TRANSLATOR);
|
||||
myTaskRunner = new SequentialTaskExecutor(tasksExecutor);
|
||||
@@ -263,7 +279,13 @@ public class JavaBuilder extends ModuleLevelBuilder {
|
||||
String message = e.getMessage();
|
||||
if (message == null) {
|
||||
final ByteArrayOutputStream out = new ByteArrayOutputStream();
|
||||
e.printStackTrace(new PrintStream(out));
|
||||
final PrintStream stream = new PrintStream(out);
|
||||
try {
|
||||
e.printStackTrace(stream);
|
||||
}
|
||||
finally {
|
||||
stream.close();
|
||||
}
|
||||
message = "Internal error: \n" + out.toString();
|
||||
}
|
||||
context.processMessage(new CompilerMessage(BUILDER_NAME, BuildMessage.Kind.ERROR, message));
|
||||
@@ -312,8 +334,7 @@ public class JavaBuilder extends ModuleLevelBuilder {
|
||||
|
||||
final ProjectPaths paths = context.getProjectPaths();
|
||||
final ProjectDescriptor pd = context.getProjectDescriptor();
|
||||
final boolean addNotNullAssertions = JpsJavaExtensionService.getInstance().getOrCreateCompilerConfiguration(
|
||||
pd.getProject()).isAddNotNullAssertions();
|
||||
final boolean addNotNullAssertions = JpsJavaExtensionService.getInstance().getOrCreateCompilerConfiguration(pd.getProject()).isAddNotNullAssertions();
|
||||
|
||||
JavaBuilderUtil.ensureModuleHasJdk(chunk.representativeTarget().getModule(), context, BUILDER_NAME);
|
||||
final Collection<File> classpath = paths.getCompilationClasspath(chunk, false/*context.isProjectRebuild()*/);
|
||||
@@ -327,6 +348,18 @@ public class JavaBuilder extends ModuleLevelBuilder {
|
||||
try {
|
||||
if (hasSourcesToCompile) {
|
||||
exitCode = ExitCode.OK;
|
||||
|
||||
if (OPTION_COPY_FORMS_RUNTIME_CLASSES && !forms.isEmpty()) {
|
||||
for (ModuleBuildTarget target : chunk.getTargets()) {
|
||||
if (!target.isTests()) {
|
||||
final File outputDir = target.getOutputDir();
|
||||
if (outputDir != null) {
|
||||
CopyResourcesUtil.copyFormsRuntime(outputDir.getAbsolutePath(), false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
final Set<File> srcPath = new HashSet<File>();
|
||||
final BuildRootIndex index = pd.getBuildRootIndex();
|
||||
for (ModuleBuildTarget target : chunk.getTargets()) {
|
||||
@@ -365,21 +398,10 @@ public class JavaBuilder extends ModuleLevelBuilder {
|
||||
final InstrumentationClassFinder finder = createInstrumentationClassFinder(platformCp, classpath, chunkSourcePath, outputSink);
|
||||
|
||||
try {
|
||||
if (!forms.isEmpty()) {
|
||||
if (OPTION_ENABLE_FORMS_INSTRUMENTATION && !forms.isEmpty()) {
|
||||
try {
|
||||
context.processMessage(new ProgressMessage("Instrumenting forms [" + chunkName + "]"));
|
||||
instrumentForms(context, chunk, chunkSourcePath, finder, forms, outputSink);
|
||||
JpsUiDesignerConfiguration configuration = JpsUiDesignerExtensionService.getInstance().getUiDesignerConfiguration(pd.getProject());
|
||||
if (configuration != null && configuration.isCopyFormsRuntimeToOutput()) {
|
||||
for (ModuleBuildTarget target : chunk.getTargets()) {
|
||||
if (!target.isTests()) {
|
||||
final File outputDir = target.getOutputDir();
|
||||
if (outputDir != null) {
|
||||
CopyResourcesUtil.copyFormsRuntime(outputDir.getAbsolutePath(), false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
finally {
|
||||
context.processMessage(new ProgressMessage("Finished instrumenting forms [" + chunkName + "]"));
|
||||
|
||||
+4
@@ -29,5 +29,9 @@ public abstract class JpsElementExtensionSerializerBase<E extends JpsElement> {
|
||||
|
||||
public abstract void loadExtension(@NotNull E e, @NotNull Element componentTag);
|
||||
|
||||
// called when no corresponding component tag was found in xml configs
|
||||
public void loadExtensionWithDefaultSettings(@NotNull E e) {
|
||||
}
|
||||
|
||||
public abstract void saveExtension(@NotNull E e, @NotNull Element componentTag);
|
||||
}
|
||||
|
||||
@@ -37,6 +37,9 @@ public abstract class JpsLoaderBase {
|
||||
if (componentTag != null) {
|
||||
serializer.loadExtension(element, componentTag);
|
||||
}
|
||||
else {
|
||||
serializer.loadExtensionWithDefaultSettings(element);
|
||||
}
|
||||
}
|
||||
else {
|
||||
LOG.debug("Cannot load component " + serializer.getComponentName() + ": " + configFile + " doesn't exist");
|
||||
|
||||
+3
@@ -158,6 +158,9 @@ public class JpsProjectLoader extends JpsLoaderBase {
|
||||
if (component != null) {
|
||||
serializer.loadExtension(myProject, component);
|
||||
}
|
||||
else {
|
||||
serializer.loadExtensionWithDefaultSettings(myProject);
|
||||
}
|
||||
}
|
||||
}
|
||||
loadModules(iprRoot, projectSdkType);
|
||||
|
||||
+3
@@ -1,6 +1,7 @@
|
||||
package org.jetbrains.jps.uiDesigner.model.impl;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jps.incremental.java.JavaBuilder;
|
||||
import org.jetbrains.jps.model.JpsElementChildRole;
|
||||
import org.jetbrains.jps.model.ex.JpsElementBase;
|
||||
import org.jetbrains.jps.model.ex.JpsElementChildRoleBase;
|
||||
@@ -40,6 +41,7 @@ public class JpsUiDesignerConfigurationImpl extends JpsElementBase<JpsUiDesigner
|
||||
public void setCopyFormsRuntimeToOutput(boolean value) {
|
||||
if (myState.COPY_FORMS_RUNTIME_TO_OUTPUT != value) {
|
||||
myState.COPY_FORMS_RUNTIME_TO_OUTPUT = value;
|
||||
JavaBuilder.setCopyFormsRuntime(value);
|
||||
fireElementChanged();
|
||||
}
|
||||
}
|
||||
@@ -53,6 +55,7 @@ public class JpsUiDesignerConfigurationImpl extends JpsElementBase<JpsUiDesigner
|
||||
public void setInstrumentClasses(boolean value) {
|
||||
if (myState.INSTRUMENT_CLASSES != value) {
|
||||
myState.INSTRUMENT_CLASSES = value;
|
||||
JavaBuilder.setFormsInstrumentationEnabled(value);
|
||||
fireElementChanged();
|
||||
}
|
||||
}
|
||||
|
||||
+7
@@ -28,6 +28,13 @@ public class JpsUiDesignerConfigurationSerializer extends JpsProjectExtensionSer
|
||||
JpsUiDesignerExtensionService.getInstance().setUiDesignerConfiguration(element, new JpsUiDesignerConfigurationImpl(state));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadExtensionWithDefaultSettings(@NotNull JpsProject project) {
|
||||
final JpsUiDesignerConfigurationImpl.UiDesignerConfigurationState defaultState =
|
||||
new JpsUiDesignerConfigurationImpl.UiDesignerConfigurationState();
|
||||
JpsUiDesignerExtensionService.getInstance().setUiDesignerConfiguration(project, new JpsUiDesignerConfigurationImpl(defaultState));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveExtension(@NotNull JpsProject element, @NotNull Element componentTag) {
|
||||
JpsUiDesignerConfiguration configuration = JpsUiDesignerExtensionService.getInstance().getUiDesignerConfiguration(element);
|
||||
|
||||
+3
@@ -2,6 +2,7 @@ package org.jetbrains.jps.uiDesigner.model.impl;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jps.incremental.java.JavaBuilder;
|
||||
import org.jetbrains.jps.model.JpsProject;
|
||||
import org.jetbrains.jps.uiDesigner.model.JpsUiDesignerConfiguration;
|
||||
import org.jetbrains.jps.uiDesigner.model.JpsUiDesignerExtensionService;
|
||||
@@ -18,6 +19,8 @@ public class JpsUiDesignerExtensionServiceImpl extends JpsUiDesignerExtensionSer
|
||||
|
||||
@Override
|
||||
public void setUiDesignerConfiguration(@NotNull JpsProject project, @NotNull JpsUiDesignerConfiguration configuration) {
|
||||
JavaBuilder.setCopyFormsRuntime(configuration.isCopyFormsRuntimeToOutput());
|
||||
JavaBuilder.setFormsInstrumentationEnabled(configuration.isInstrumentClasses());
|
||||
project.getContainer().setChild(JpsUiDesignerConfigurationImpl.ROLE, configuration);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
<orderEntry type="module" module-name="jps-model-api" />
|
||||
<orderEntry type="module" module-name="jps-model-impl" scope="TEST" />
|
||||
<orderEntry type="module" module-name="jps-model-serialization" />
|
||||
<orderEntry type="module" module-name="jps-builders" />
|
||||
</component>
|
||||
</module>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user