public void generateBuildConfiguration(@NotNull final CompileContext context) { if (shouldBeBuiltByExternalSystem(myProject)) return; if (!hasGradleModules(context)) return; final BuildManager buildManager = BuildManager.getInstance(); final File projectSystemDir = buildManager.getProjectSystemDirectory(myProject); if (projectSystemDir == null) return; final File gradleConfigFile = new File(projectSystemDir, GradleProjectConfiguration.CONFIGURATION_FILE_RELATIVE_PATH); final Map<String, GradleModuleResourceConfiguration> affectedGradleModuleConfigurations = generateAffectedGradleModulesConfiguration(context); if (affectedGradleModuleConfigurations.isEmpty()) return; boolean configurationUpdateRequired = context.isRebuild() || !gradleConfigFile.exists(); final Map<String, Integer> affectedConfigurationHash = new THashMap<String, Integer>(); for (Map.Entry<String, GradleModuleResourceConfiguration> entry : affectedGradleModuleConfigurations.entrySet()) { Integer moduleLastConfigurationHash = myModulesConfigurationHash.get(entry.getKey()); int moduleCurrentConfigurationHash = entry.getValue().computeConfigurationHash(); if (moduleLastConfigurationHash == null || moduleLastConfigurationHash.intValue() != moduleCurrentConfigurationHash) { configurationUpdateRequired = true; } affectedConfigurationHash.put(entry.getKey(), moduleCurrentConfigurationHash); } final GradleProjectConfiguration projectConfig = loadLastConfiguration(gradleConfigFile); // update with newly generated configuration projectConfig.moduleConfigurations.putAll(affectedGradleModuleConfigurations); final Document document = new Document(new Element("gradle-project-configuration")); XmlSerializer.serializeInto(projectConfig, document.getRootElement()); final boolean finalConfigurationUpdateRequired = configurationUpdateRequired; buildManager.runCommand( new Runnable() { @Override public void run() { if (finalConfigurationUpdateRequired) { buildManager.clearState(myProject); } FileUtil.createIfDoesntExist(gradleConfigFile); try { JDOMUtil.writeDocument(document, gradleConfigFile, "\n"); myModulesConfigurationHash.putAll(affectedConfigurationHash); } catch (IOException e) { throw new RuntimeException(e); } } }); }
// in case of external build this path is returned by // FlexCommonUtils.getPathToFlexUnitTempDirectory() public static String getPathToFlexUnitTempDirectory(final Project project) { final BuildManager buildManager = BuildManager.getInstance(); final File projectSystemDir = buildManager.getProjectSystemDirectory(project); if (projectSystemDir == null) { Logger.getInstance(FlexUnitPrecompileTask.class.getName()).error(project); return ""; } return FileUtil.toSystemIndependentName(projectSystemDir.getPath()) + "/tmp"; }
@Override public void apply() throws ConfigurationException { commonCompilerArguments.suppressWarnings = generateNoWarningsCheckBox.isSelected(); compilerSettings.setAdditionalArguments(additionalArgsOptionsField.getText()); compilerSettings.setScriptTemplates(scriptTemplatesField.getText()); compilerSettings.setScriptTemplatesClasspath(scriptTemplatesClasspathField.getText()); compilerSettings.setCopyJsLibraryFiles(copyRuntimeFilesCheckBox.isSelected()); compilerSettings.setOutputDirectoryForJsLibraryFiles(outputDirectory.getText()); if (compilerWorkspaceSettings != null) { compilerWorkspaceSettings.setPreciseIncrementalEnabled( enablePreciseIncrementalCheckBox.isSelected()); boolean oldEnableDaemon = compilerWorkspaceSettings.getEnableDaemon(); compilerWorkspaceSettings.setEnableDaemon(keepAliveCheckBox.isSelected()); if (keepAliveCheckBox.isSelected() != oldEnableDaemon) { PluginStartupComponent.getInstance().resetAliveFlag(); } } k2jsCompilerArguments.sourceMap = generateSourceMapsCheckBox.isSelected(); k2jsCompilerArguments.outputPrefix = StringUtil.nullize(outputPrefixFile.getText(), true); k2jsCompilerArguments.outputPostfix = StringUtil.nullize(outputPostfixFile.getText(), true); k2jsCompilerArguments.moduleKind = getSelectedModuleKind(); BuildManager.getInstance().clearState(project); }
@Override protected void tearDown() throws Exception { Messages.setTestDialog(TestDialog.DEFAULT); myProjectsManager.projectClosed(); removeFromLocalRepository("test"); if (useJps()) { CompilerTestUtil.disableExternalCompiler(myProject); FileUtil.delete(BuildManager.getInstance().getBuildSystemDirectory()); } super.tearDown(); }
private void doCommit(ArtifactModelImpl artifactModel) { boolean hasChanges; LOG.assertTrue(!myInsideCommit, "Recursive commit"); myInsideCommit = true; try { final List<ArtifactImpl> allArtifacts = artifactModel.getOriginalArtifacts(); final Set<ArtifactImpl> removed = new THashSet<ArtifactImpl>(myModel.myArtifactsList); final List<ArtifactImpl> added = new ArrayList<ArtifactImpl>(); final List<Pair<ArtifactImpl, String>> changed = new ArrayList<Pair<ArtifactImpl, String>>(); for (ArtifactImpl artifact : allArtifacts) { final boolean isAdded = !removed.remove(artifact); final ArtifactImpl modifiableCopy = artifactModel.getModifiableCopy(artifact); if (isAdded) { added.add(artifact); } else if (modifiableCopy != null && !modifiableCopy.equals(artifact)) { final String oldName = artifact.getName(); artifact.copyFrom(modifiableCopy); changed.add(Pair.create(artifact, oldName)); } } myModel.setArtifactsList(allArtifacts); myModificationTracker.incModificationCount(); final ArtifactListener publisher = myProject.getMessageBus().syncPublisher(TOPIC); hasChanges = !removed.isEmpty() || !added.isEmpty() || !changed.isEmpty(); ProjectRootManagerEx.getInstanceEx(myProject) .mergeRootsChangesDuring( new Runnable() { @Override public void run() { for (ArtifactImpl artifact : removed) { publisher.artifactRemoved(artifact); } // it's important to send 'removed' events before 'added'. Otherwise when // artifacts are reloaded from xml artifact pointers will be damaged for (ArtifactImpl artifact : added) { publisher.artifactAdded(artifact); } for (Pair<ArtifactImpl, String> pair : changed) { publisher.artifactChanged(pair.getFirst(), pair.getSecond()); } } }); } finally { myInsideCommit = false; } updateWatchedRoots(); if (hasChanges) { BuildManager.getInstance().clearState(myProject); } }