use of com.intellij.compiler.CompilerWorkspaceConfiguration in project intellij-community by JetBrains.
the class CompilerUIConfigurable method reset.
public void reset() {
final CompilerConfigurationImpl configuration = (CompilerConfigurationImpl) CompilerConfiguration.getInstance(myProject);
final CompilerWorkspaceConfiguration workspaceConfiguration = CompilerWorkspaceConfiguration.getInstance(myProject);
myCbAutoShowFirstError.setSelected(workspaceConfiguration.AUTO_SHOW_ERRORS_IN_EDITOR);
myCbDisplayNotificationPopup.setSelected(workspaceConfiguration.DISPLAY_NOTIFICATION_POPUP);
myCbClearOutputDirectory.setSelected(workspaceConfiguration.CLEAR_OUTPUT_DIRECTORY);
myCbAssertNotNull.setSelected(configuration.isAddNotNullAssertions());
myCbEnableAutomake.setSelected(workspaceConfiguration.MAKE_PROJECT_ON_SAVE);
myCbParallelCompilation.setSelected(workspaceConfiguration.PARALLEL_COMPILATION);
myCbRebuildOnDependencyChange.setSelected(workspaceConfiguration.REBUILD_ON_DEPENDENCY_CHANGE);
// for compatibility with older projects
final int javacPreferred = JavacConfiguration.getOptions(myProject, JavacConfiguration.class).MAXIMUM_HEAP_SIZE;
myHeapSizeField.setText(String.valueOf(configuration.getBuildProcessHeapSize(javacPreferred)));
final String options = workspaceConfiguration.COMPILER_PROCESS_ADDITIONAL_VM_OPTIONS;
myVMOptionsField.setText(options == null ? "" : options.trim());
mySharedVMOptionsField.setText(configuration.getBuildProcessVMOptions());
configuration.convertPatterns();
myResourcePatternsField.setText(patternsToString(configuration.getResourceFilePatterns()));
if (PowerSaveMode.isEnabled()) {
myEnableAutomakeLegendLabel.setText("(disabled in Power Save mode)");
myEnableAutomakeLegendLabel.setFont(myEnableAutomakeLegendLabel.getFont().deriveFont(Font.BOLD));
} else {
myEnableAutomakeLegendLabel.setText("(only works while not running / debugging)");
myEnableAutomakeLegendLabel.setFont(myEnableAutomakeLegendLabel.getFont().deriveFont(Font.PLAIN));
}
}
use of com.intellij.compiler.CompilerWorkspaceConfiguration in project android by JetBrains.
the class AndroidCompileUtil method initializeGenSourceRoot.
@Nullable
private static VirtualFile initializeGenSourceRoot(@NotNull ModifiableRootModel model, @Nullable String sourceRootPath, boolean createIfNotExist, boolean excludeInNonExternalMode, @NotNull Ref<Boolean> modelChangedFlag) {
if (sourceRootPath == null) {
return null;
}
VirtualFile sourceRoot = null;
if (createIfNotExist) {
final VirtualFile root = createSourceRootIfNotExist(sourceRootPath, model, modelChangedFlag);
if (root != null) {
sourceRoot = root;
}
}
if (sourceRoot == null) {
sourceRoot = LocalFileSystem.getInstance().findFileByPath(sourceRootPath);
}
if (sourceRoot != null && excludeInNonExternalMode) {
final Module module = model.getModule();
final CompilerWorkspaceConfiguration config = CompilerWorkspaceConfiguration.getInstance(module.getProject());
}
return sourceRoot;
}
use of com.intellij.compiler.CompilerWorkspaceConfiguration in project intellij-community by JetBrains.
the class BuildManager method launchBuildProcess.
private OSProcessHandler launchBuildProcess(Project project, final int port, final UUID sessionId, boolean requestProjectPreload) throws ExecutionException {
final String compilerPath;
final String vmExecutablePath;
JavaSdkVersion sdkVersion = null;
final String forcedCompiledJdkHome = Registry.stringValue(COMPILER_PROCESS_JDK_PROPERTY);
if (StringUtil.isEmptyOrSpaces(forcedCompiledJdkHome)) {
// choosing sdk with which the build process should be run
final Pair<Sdk, JavaSdkVersion> pair = getBuildProcessRuntimeSdk(project);
final Sdk projectJdk = pair.first;
sdkVersion = pair.second;
final Sdk internalJdk = JavaAwareProjectJdkTableImpl.getInstanceEx().getInternalJdk();
// validate tools.jar presence
final JavaSdkType projectJdkType = (JavaSdkType) projectJdk.getSdkType();
if (FileUtil.pathsEqual(projectJdk.getHomePath(), internalJdk.getHomePath())) {
// important: because internal JDK can be either JDK or JRE,
// this is the most universal way to obtain tools.jar path in this particular case
final JavaCompiler systemCompiler = ToolProvider.getSystemJavaCompiler();
if (systemCompiler == null) {
throw new ExecutionException("No system java compiler is provided by the JRE. Make sure tools.jar is present in IntelliJ IDEA classpath.");
}
compilerPath = ClasspathBootstrap.getResourcePath(systemCompiler.getClass());
} else {
compilerPath = projectJdkType.getToolsPath(projectJdk);
if (compilerPath == null) {
throw new ExecutionException("Cannot determine path to 'tools.jar' library for " + projectJdk.getName() + " (" + projectJdk.getHomePath() + ")");
}
}
vmExecutablePath = projectJdkType.getVMExecutablePath(projectJdk);
} else {
compilerPath = new File(forcedCompiledJdkHome, "lib/tools.jar").getAbsolutePath();
vmExecutablePath = new File(forcedCompiledJdkHome, "bin/java").getAbsolutePath();
}
final CompilerConfiguration projectConfig = CompilerConfiguration.getInstance(project);
final CompilerWorkspaceConfiguration config = CompilerWorkspaceConfiguration.getInstance(project);
final GeneralCommandLine cmdLine = new GeneralCommandLine();
cmdLine.setExePath(vmExecutablePath);
//cmdLine.addParameter("-XX:MaxPermSize=150m");
//cmdLine.addParameter("-XX:ReservedCodeCacheSize=64m");
boolean isProfilingMode = false;
String userDefinedHeapSize = null;
final List<String> userAdditionalOptionsList = new SmartList<>();
final String userAdditionalVMOptions = config.COMPILER_PROCESS_ADDITIONAL_VM_OPTIONS;
final boolean userLocalOptionsActive = !StringUtil.isEmptyOrSpaces(userAdditionalVMOptions);
final String additionalOptions = userLocalOptionsActive ? userAdditionalVMOptions : projectConfig.getBuildProcessVMOptions();
if (!StringUtil.isEmptyOrSpaces(additionalOptions)) {
final StringTokenizer tokenizer = new StringTokenizer(additionalOptions, " ", false);
while (tokenizer.hasMoreTokens()) {
final String option = tokenizer.nextToken();
if (StringUtil.startsWithIgnoreCase(option, "-Xmx")) {
if (userLocalOptionsActive) {
userDefinedHeapSize = option;
}
} else {
if ("-Dprofiling.mode=true".equals(option)) {
isProfilingMode = true;
}
userAdditionalOptionsList.add(option);
}
}
}
if (userDefinedHeapSize != null) {
cmdLine.addParameter(userDefinedHeapSize);
} else {
final int heapSize = projectConfig.getBuildProcessHeapSize(JavacConfiguration.getOptions(project, JavacConfiguration.class).MAXIMUM_HEAP_SIZE);
cmdLine.addParameter("-Xmx" + heapSize + "m");
}
if (SystemInfo.isMac && sdkVersion != null && JavaSdkVersion.JDK_1_6.equals(sdkVersion) && Registry.is("compiler.process.32bit.vm.on.mac")) {
// unfortunately -d32 is supported on jdk 1.6 only
cmdLine.addParameter("-d32");
}
cmdLine.addParameter("-Djava.awt.headless=true");
if (sdkVersion != null && sdkVersion.ordinal() < JavaSdkVersion.JDK_1_9.ordinal()) {
//-Djava.endorsed.dirs is not supported in JDK 9+, may result in abnormal process termination
// turn off all jre customizations for predictable behaviour
cmdLine.addParameter("-Djava.endorsed.dirs=\"\"");
}
if (IS_UNIT_TEST_MODE) {
cmdLine.addParameter("-Dtest.mode=true");
}
// always run eclipse compiler in single-threaded mode
cmdLine.addParameter("-Djdt.compiler.useSingleThread=true");
if (requestProjectPreload) {
cmdLine.addParameter("-Dpreload.project.path=" + FileUtil.toCanonicalPath(getProjectPath(project)));
cmdLine.addParameter("-Dpreload.config.path=" + FileUtil.toCanonicalPath(PathManager.getOptionsPath()));
}
final String shouldGenerateIndex = System.getProperty(GlobalOptions.GENERATE_CLASSPATH_INDEX_OPTION);
if (shouldGenerateIndex != null) {
cmdLine.addParameter("-D" + GlobalOptions.GENERATE_CLASSPATH_INDEX_OPTION + "=" + shouldGenerateIndex);
}
cmdLine.addParameter("-D" + GlobalOptions.COMPILE_PARALLEL_OPTION + "=" + Boolean.toString(config.PARALLEL_COMPILATION));
cmdLine.addParameter("-D" + GlobalOptions.REBUILD_ON_DEPENDENCY_CHANGE_OPTION + "=" + Boolean.toString(config.REBUILD_ON_DEPENDENCY_CHANGE));
if (Boolean.TRUE.equals(Boolean.valueOf(System.getProperty("java.net.preferIPv4Stack", "false")))) {
cmdLine.addParameter("-Djava.net.preferIPv4Stack=true");
}
// this will make netty initialization faster on some systems
cmdLine.addParameter("-Dio.netty.initialSeedUniquifier=" + ThreadLocalRandom.getInitialSeedUniquifier());
for (String option : userAdditionalOptionsList) {
cmdLine.addParameter(option);
}
if (isProfilingMode) {
cmdLine.addParameter("-agentlib:yjpagent=disablealloc,delay=10000,sessionname=ExternalBuild");
}
// debugging
int debugPort = -1;
if (myBuildProcessDebuggingEnabled) {
debugPort = Registry.intValue("compiler.process.debug.port");
if (debugPort <= 0) {
try {
debugPort = NetUtils.findAvailableSocketPort();
} catch (IOException e) {
throw new ExecutionException("Cannot find free port to debug build process", e);
}
}
if (debugPort > 0) {
cmdLine.addParameter("-XX:+HeapDumpOnOutOfMemoryError");
cmdLine.addParameter("-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=" + debugPort);
}
}
if (!Registry.is("compiler.process.use.memory.temp.cache")) {
cmdLine.addParameter("-D" + GlobalOptions.USE_MEMORY_TEMP_CACHE_OPTION + "=false");
}
// javac's VM should use the same default locale that IDEA uses in order for javac to print messages in 'correct' language
cmdLine.setCharset(mySystemCharset);
cmdLine.addParameter("-D" + CharsetToolkit.FILE_ENCODING_PROPERTY + "=" + mySystemCharset.name());
cmdLine.addParameter("-D" + JpsGlobalLoader.FILE_TYPES_COMPONENT_NAME_KEY + "=" + FileTypeManagerImpl.getFileTypeComponentName());
String[] propertiesToPass = { "user.language", "user.country", "user.region", PathManager.PROPERTY_PATHS_SELECTOR, "idea.case.sensitive.fs" };
for (String name : propertiesToPass) {
final String value = System.getProperty(name);
if (value != null) {
cmdLine.addParameter("-D" + name + "=" + value);
}
}
cmdLine.addParameter("-D" + PathManager.PROPERTY_HOME_PATH + "=" + PathManager.getHomePath());
cmdLine.addParameter("-D" + PathManager.PROPERTY_CONFIG_PATH + "=" + PathManager.getConfigPath());
cmdLine.addParameter("-D" + PathManager.PROPERTY_PLUGINS_PATH + "=" + PathManager.getPluginsPath());
cmdLine.addParameter("-D" + GlobalOptions.LOG_DIR_OPTION + "=" + FileUtil.toSystemIndependentName(getBuildLogDirectory().getAbsolutePath()));
cmdLine.addParameters(myFallbackJdkParams);
cmdLine.addParameter("-Dio.netty.noUnsafe=true");
final File workDirectory = getBuildSystemDirectory();
//noinspection ResultOfMethodCallIgnored
workDirectory.mkdirs();
final File projectSystemRoot = getProjectSystemDirectory(project);
if (projectSystemRoot != null) {
cmdLine.addParameter("-Djava.io.tmpdir=" + FileUtil.toSystemIndependentName(projectSystemRoot.getPath()) + "/" + TEMP_DIR_NAME);
}
for (BuildProcessParametersProvider provider : project.getExtensions(BuildProcessParametersProvider.EP_NAME)) {
final List<String> args = provider.getVMArguments();
cmdLine.addParameters(args);
}
@SuppressWarnings("UnnecessaryFullyQualifiedName") final Class<?> launcherClass = org.jetbrains.jps.cmdline.Launcher.class;
final List<String> launcherCp = new ArrayList<>();
launcherCp.add(ClasspathBootstrap.getResourcePath(launcherClass));
launcherCp.addAll(BuildProcessClasspathManager.getLauncherClasspath(project));
launcherCp.add(compilerPath);
ClasspathBootstrap.appendJavaCompilerClasspath(launcherCp, shouldIncludeEclipseCompiler(projectConfig));
cmdLine.addParameter("-classpath");
cmdLine.addParameter(classpathToString(launcherCp));
cmdLine.addParameter(launcherClass.getName());
final List<String> cp = ClasspathBootstrap.getBuildProcessApplicationClasspath();
cp.addAll(myClasspathManager.getBuildProcessPluginsClasspath(project));
if (isProfilingMode) {
cp.add(new File(workDirectory, "yjp-controller-api-redist.jar").getPath());
}
cmdLine.addParameter(classpathToString(cp));
cmdLine.addParameter(BuildMain.class.getName());
cmdLine.addParameter(Boolean.valueOf(System.getProperty("java.net.preferIPv6Addresses", "false")) ? "::1" : "127.0.0.1");
cmdLine.addParameter(Integer.toString(port));
cmdLine.addParameter(sessionId.toString());
cmdLine.addParameter(FileUtil.toSystemIndependentName(workDirectory.getPath()));
cmdLine.setWorkDirectory(workDirectory);
try {
ApplicationManager.getApplication().getMessageBus().syncPublisher(BuildManagerListener.TOPIC).beforeBuildProcessStarted(project, sessionId);
} catch (Throwable e) {
LOG.error(e);
}
final OSProcessHandler processHandler = new OSProcessHandler(cmdLine) {
@Override
protected boolean shouldDestroyProcessRecursively() {
return true;
}
@NotNull
@Override
protected BaseOutputReader.Options readerOptions() {
return BaseOutputReader.Options.BLOCKING;
}
};
processHandler.addProcessListener(new ProcessAdapter() {
@Override
public void onTextAvailable(ProcessEvent event, Key outputType) {
// re-translate builder's output to idea.log
final String text = event.getText();
if (!StringUtil.isEmptyOrSpaces(text)) {
if (ProcessOutputTypes.SYSTEM.equals(outputType)) {
if (LOG.isDebugEnabled()) {
LOG.debug("BUILDER_PROCESS [" + outputType.toString() + "]: " + text.trim());
}
} else {
LOG.info("BUILDER_PROCESS [" + outputType.toString() + "]: " + text.trim());
}
}
}
});
if (debugPort > 0) {
processHandler.putUserData(COMPILER_PROCESS_DEBUG_PORT, debugPort);
}
return processHandler;
}
use of com.intellij.compiler.CompilerWorkspaceConfiguration in project intellij-community by JetBrains.
the class CompilerUIConfigurable method isModified.
public boolean isModified() {
final CompilerWorkspaceConfiguration workspaceConfiguration = CompilerWorkspaceConfiguration.getInstance(myProject);
boolean isModified = !myDisabledSettings.contains(Setting.AUTO_SHOW_FIRST_ERROR_IN_EDITOR) && ComparingUtils.isModified(myCbAutoShowFirstError, workspaceConfiguration.AUTO_SHOW_ERRORS_IN_EDITOR);
isModified |= !myDisabledSettings.contains(Setting.DISPLAY_NOTIFICATION_POPUP) && ComparingUtils.isModified(myCbDisplayNotificationPopup, workspaceConfiguration.DISPLAY_NOTIFICATION_POPUP);
isModified |= !myDisabledSettings.contains(Setting.AUTO_MAKE) && ComparingUtils.isModified(myCbEnableAutomake, workspaceConfiguration.MAKE_PROJECT_ON_SAVE);
isModified |= !myDisabledSettings.contains(Setting.PARALLEL_COMPILATION) && ComparingUtils.isModified(myCbParallelCompilation, workspaceConfiguration.PARALLEL_COMPILATION);
isModified |= !myDisabledSettings.contains(Setting.REBUILD_MODULE_ON_DEPENDENCY_CHANGE) && ComparingUtils.isModified(myCbRebuildOnDependencyChange, workspaceConfiguration.REBUILD_ON_DEPENDENCY_CHANGE);
isModified |= !myDisabledSettings.contains(Setting.COMPILER_VM_OPTIONS) && ComparingUtils.isModified(myVMOptionsField, workspaceConfiguration.COMPILER_PROCESS_ADDITIONAL_VM_OPTIONS);
final CompilerConfigurationImpl compilerConfiguration = (CompilerConfigurationImpl) CompilerConfiguration.getInstance(myProject);
isModified |= !myDisabledSettings.contains(Setting.HEAP_SIZE) && ComparingUtils.isModified(myHeapSizeField, compilerConfiguration.getBuildProcessHeapSize(0));
isModified |= !myDisabledSettings.contains(Setting.COMPILER_VM_OPTIONS) && ComparingUtils.isModified(mySharedVMOptionsField, compilerConfiguration.getBuildProcessVMOptions());
isModified |= !myDisabledSettings.contains(Setting.ADD_NOT_NULL_ASSERTIONS) && ComparingUtils.isModified(myCbAssertNotNull, compilerConfiguration.isAddNotNullAssertions());
isModified |= !myDisabledSettings.contains(Setting.CLEAR_OUTPUT_DIR_ON_REBUILD) && ComparingUtils.isModified(myCbClearOutputDirectory, workspaceConfiguration.CLEAR_OUTPUT_DIRECTORY);
isModified |= !myDisabledSettings.contains(Setting.RESOURCE_PATTERNS) && ComparingUtils.isModified(myResourcePatternsField, patternsToString(compilerConfiguration.getResourceFilePatterns()));
return isModified;
}
use of com.intellij.compiler.CompilerWorkspaceConfiguration in project intellij-community by JetBrains.
the class CompilerUIConfigurable method apply.
public void apply() throws ConfigurationException {
CompilerConfigurationImpl configuration = (CompilerConfigurationImpl) CompilerConfiguration.getInstance(myProject);
final CompilerWorkspaceConfiguration workspaceConfiguration = CompilerWorkspaceConfiguration.getInstance(myProject);
if (!myDisabledSettings.contains(Setting.AUTO_SHOW_FIRST_ERROR_IN_EDITOR)) {
workspaceConfiguration.AUTO_SHOW_ERRORS_IN_EDITOR = myCbAutoShowFirstError.isSelected();
}
if (!myDisabledSettings.contains(Setting.DISPLAY_NOTIFICATION_POPUP)) {
workspaceConfiguration.DISPLAY_NOTIFICATION_POPUP = myCbDisplayNotificationPopup.isSelected();
}
if (!myDisabledSettings.contains(Setting.CLEAR_OUTPUT_DIR_ON_REBUILD)) {
workspaceConfiguration.CLEAR_OUTPUT_DIRECTORY = myCbClearOutputDirectory.isSelected();
}
if (!myDisabledSettings.contains(Setting.EXTERNAL_BUILD)) {
if (!myDisabledSettings.contains(Setting.AUTO_MAKE)) {
workspaceConfiguration.MAKE_PROJECT_ON_SAVE = myCbEnableAutomake.isSelected();
}
if (!myDisabledSettings.contains(Setting.PARALLEL_COMPILATION)) {
workspaceConfiguration.PARALLEL_COMPILATION = myCbParallelCompilation.isSelected();
}
if (!myDisabledSettings.contains(Setting.REBUILD_MODULE_ON_DEPENDENCY_CHANGE)) {
workspaceConfiguration.REBUILD_ON_DEPENDENCY_CHANGE = myCbRebuildOnDependencyChange.isSelected();
}
if (!myDisabledSettings.contains(Setting.HEAP_SIZE)) {
try {
configuration.setBuildProcessHeapSize(Integer.parseInt(myHeapSizeField.getText().trim()));
} catch (NumberFormatException ignored) {
LOG.info(ignored);
}
}
if (!myDisabledSettings.contains(Setting.COMPILER_VM_OPTIONS)) {
workspaceConfiguration.COMPILER_PROCESS_ADDITIONAL_VM_OPTIONS = myVMOptionsField.getText().trim();
configuration.setBuildProcessVMOptions(mySharedVMOptionsField.getText().trim());
}
}
if (!myDisabledSettings.contains(Setting.ADD_NOT_NULL_ASSERTIONS)) {
configuration.setAddNotNullAssertions(myCbAssertNotNull.isSelected());
}
if (!myDisabledSettings.contains(Setting.RESOURCE_PATTERNS)) {
configuration.removeResourceFilePatterns();
String extensionString = myResourcePatternsField.getText().trim();
applyResourcePatterns(extensionString, (CompilerConfigurationImpl) CompilerConfiguration.getInstance(myProject));
}
BuildManager.getInstance().clearState(myProject);
}
Aggregations