diff --git a/java/compiler/impl/src/com/intellij/compiler/actions/AntBuildForm.form b/java/compiler/impl/src/com/intellij/compiler/actions/AntBuildForm.form index 44abfab964b8..da9463433bbe 100644 --- a/java/compiler/impl/src/com/intellij/compiler/actions/AntBuildForm.form +++ b/java/compiler/impl/src/com/intellij/compiler/actions/AntBuildForm.form @@ -3,12 +3,12 @@ - + - + @@ -18,7 +18,7 @@ - + @@ -26,7 +26,7 @@ - + @@ -34,7 +34,7 @@ - + @@ -42,12 +42,28 @@ - + + + + + + + + + + + + + + + + + diff --git a/java/compiler/impl/src/com/intellij/compiler/actions/GenerateAntBuildAction.java b/java/compiler/impl/src/com/intellij/compiler/actions/GenerateAntBuildAction.java index 291e06e25725..8af49a55007e 100644 --- a/java/compiler/impl/src/com/intellij/compiler/actions/GenerateAntBuildAction.java +++ b/java/compiler/impl/src/com/intellij/compiler/actions/GenerateAntBuildAction.java @@ -56,7 +56,7 @@ public class GenerateAntBuildAction extends CompileActionBase { public void run() { genOptions[0] = new GenerationOptionsImpl(project, dialog.isGenerateSingleFileBuild(), dialog.isFormsCompilationEnabled(), dialog.isBackupFiles(), dialog.isForceTargetJdk(), dialog.isRuntimeClasspathInlined(), - dialog.isIdeaHomeGenerated(), names); + dialog.isIdeaHomeGenerated(), names, dialog.getOutputFileName()); } }; if (!ProgressManager.getInstance().runProcessWithProgressSynchronously(runnable, "Analyzing project structure...", true, project)) { @@ -118,8 +118,8 @@ public class GenerateAntBuildAction extends CompileActionBase { try { if (genOptions.generateSingleFile) { final File projectBuildFileDestDir = VfsUtil.virtualToIoFile(project.getBaseDir()); - final File destFile = new File(projectBuildFileDestDir, BuildProperties.getProjectBuildFileName(project) + XML_EXTENSION); - final File propertiesFile = new File(projectBuildFileDestDir, BuildProperties.getPropertyFileName(project)); + final File destFile = new File(projectBuildFileDestDir, genOptions.getBuildFileName()); + final File propertiesFile = new File(projectBuildFileDestDir, genOptions.getPropertiesFileName()); ensureFilesWritable(project, new File[]{destFile, propertiesFile}); } @@ -127,8 +127,8 @@ public class GenerateAntBuildAction extends CompileActionBase { final List allFiles = new ArrayList(); final File projectBuildFileDestDir = VfsUtil.virtualToIoFile(project.getBaseDir()); - allFiles.add(new File(projectBuildFileDestDir, BuildProperties.getProjectBuildFileName(project) + XML_EXTENSION)); - allFiles.add(new File(projectBuildFileDestDir, BuildProperties.getPropertyFileName(project))); + allFiles.add(new File(projectBuildFileDestDir, genOptions.getBuildFileName())); + allFiles.add(new File(projectBuildFileDestDir, genOptions.getPropertiesFileName())); final ModuleChunk[] chunks = genOptions.getModuleChunks(); for (final ModuleChunk chunk : chunks) { @@ -218,8 +218,8 @@ public class GenerateAntBuildAction extends CompileActionBase { private File[] generateSingleFileBuild(Project project, GenerationOptions genOptions, List filesToRefresh) throws IOException { final File projectBuildFileDestDir = VfsUtil.virtualToIoFile(project.getBaseDir()); projectBuildFileDestDir.mkdirs(); - final File destFile = new File(projectBuildFileDestDir, BuildProperties.getProjectBuildFileName(project) + XML_EXTENSION); - final File propertiesFile = new File(projectBuildFileDestDir, BuildProperties.getPropertyFileName(project)); + final File destFile = new File(projectBuildFileDestDir, genOptions.getBuildFileName()); + final File propertiesFile = new File(projectBuildFileDestDir, genOptions.getPropertiesFileName()); if (!backup(destFile, project, genOptions, filesToRefresh)) { return null; @@ -289,8 +289,8 @@ public class GenerateAntBuildAction extends CompileActionBase { final File projectBuildFileDestDir = VfsUtil.virtualToIoFile(project.getBaseDir()); projectBuildFileDestDir.mkdirs(); final List generated = new ArrayList(); - final File projectBuildFile = new File(projectBuildFileDestDir, BuildProperties.getProjectBuildFileName(project) + XML_EXTENSION); - final File propertiesFile = new File(projectBuildFileDestDir, BuildProperties.getPropertyFileName(project)); + final File projectBuildFile = new File(projectBuildFileDestDir, genOptions.getBuildFileName()); + final File propertiesFile = new File(projectBuildFileDestDir, genOptions.getPropertiesFileName()); final ModuleChunk[] chunks = genOptions.getModuleChunks(); final File[] chunkFiles = new File[chunks.length]; diff --git a/java/compiler/impl/src/com/intellij/compiler/actions/GenerateAntBuildDialog.java b/java/compiler/impl/src/com/intellij/compiler/actions/GenerateAntBuildDialog.java index c121779066ba..ae81d85668be 100644 --- a/java/compiler/impl/src/com/intellij/compiler/actions/GenerateAntBuildDialog.java +++ b/java/compiler/impl/src/com/intellij/compiler/actions/GenerateAntBuildDialog.java @@ -17,6 +17,7 @@ package com.intellij.compiler.actions; import com.intellij.compiler.HelpID; import com.intellij.compiler.ModuleCompilerUtil; +import com.intellij.compiler.ant.BuildProperties; import com.intellij.ide.util.PropertiesComponent; import com.intellij.openapi.compiler.CompilerBundle; import com.intellij.openapi.help.HelpManager; @@ -51,178 +52,197 @@ import java.util.List; * Date: Mar 29, 2004 */ public class GenerateAntBuildDialog extends DialogWrapper { - private JPanel myPanel; - private JRadioButton myRbGenerateSingleFileBuild; - private JRadioButton myRbGenerateMultipleFilesBuild; - private JCheckBox myCbEnableUIFormsCompilation; - private JRadioButton myRbBackupFiles; - private JRadioButton myRbOverwriteFiles; - private JCheckBox myCbForceTargetJdk; - private JCheckBox myCbInlineRuntimeClasspath; - private JPanel myChunksPanel; - private JCheckBox myGenerateIdeaHomeProperty; - private final Project myProject; - @NonNls private static final String SINGLE_FILE_PROPERTY = "GenerateAntBuildDialog.generateSingleFile"; - @NonNls private static final String UI_FORM_PROPERTY = "GenerateAntBuildDialog.enableUiFormCompile"; - @NonNls private static final String FORCE_TARGET_JDK_PROPERTY = "GenerateAntBuildDialog.forceTargetJdk"; - @NonNls private static final String BACKUP_FILES_PROPERTY = "GenerateAntBuildDialog.backupFiles"; - @NonNls private static final String INLINE_RUNTIME_CLASSPATH_PROPERTY = "GenerateAntBuildDialog.inclineRuntiemClasspath"; - @NonNls private static final String GENERATE_IDEA_HOME_PROPERTY = "GenerateAntBuildDialog.generateIdeaHomeProperty"; - private MyTableModel myTableModel; - private Table myTable; + private JPanel myPanel; + private JRadioButton myRbGenerateSingleFileBuild; + private JRadioButton myRbGenerateMultipleFilesBuild; + private JCheckBox myCbEnableUIFormsCompilation; + private JRadioButton myRbBackupFiles; + private JRadioButton myRbOverwriteFiles; + private JCheckBox myCbForceTargetJdk; + private JCheckBox myCbInlineRuntimeClasspath; + private JPanel myChunksPanel; + private JCheckBox myGenerateIdeaHomeProperty; + private JTextField myOutputFileNameField; + private final Project myProject; + @NonNls private static final String SINGLE_FILE_PROPERTY = "GenerateAntBuildDialog.generateSingleFile"; + @NonNls private static final String UI_FORM_PROPERTY = "GenerateAntBuildDialog.enableUiFormCompile"; + @NonNls private static final String FORCE_TARGET_JDK_PROPERTY = "GenerateAntBuildDialog.forceTargetJdk"; + @NonNls private static final String BACKUP_FILES_PROPERTY = "GenerateAntBuildDialog.backupFiles"; + @NonNls private static final String INLINE_RUNTIME_CLASSPATH_PROPERTY = "GenerateAntBuildDialog.inclineRuntiemClasspath"; + @NonNls private static final String GENERATE_IDEA_HOME_PROPERTY = "GenerateAntBuildDialog.generateIdeaHomeProperty"; + @NonNls private static final String OUTPUT_FILE_NAME_PROPERTY = "GenerateAntBuildDialog.outputFileNameProperty"; + private MyTableModel myTableModel; + private Table myTable; - public GenerateAntBuildDialog(Project project) { - super(project, false); - myProject = project; - setTitle(CompilerBundle.message("generate.ant.build.title")); - init(); - loadSettings(); - } + public GenerateAntBuildDialog(Project project) { + super(project, false); + myProject = project; + setTitle(CompilerBundle.message("generate.ant.build.title")); + init(); + loadSettings(); + } - private List> getCycleChunks() { - List> chunks = - ModuleCompilerUtil.getSortedModuleChunks(myProject, Arrays.asList(ModuleManager.getInstance(myProject).getModules())); - for (Iterator> it = chunks.iterator(); it.hasNext();) { - final Chunk chunk = it.next(); - if (chunk.getNodes().size() == 1) { - it.remove(); - } + private List> getCycleChunks() { + List> chunks = + ModuleCompilerUtil.getSortedModuleChunks(myProject, Arrays.asList(ModuleManager.getInstance(myProject).getModules())); + for (Iterator> it = chunks.iterator(); it.hasNext();) { + final Chunk chunk = it.next(); + if (chunk.getNodes().size() == 1) { + it.remove(); } - return chunks; } + return chunks; + } - private void loadSettings() { - final PropertiesComponent properties = PropertiesComponent.getInstance(myProject); - if (properties.isValueSet(SINGLE_FILE_PROPERTY)) { - final boolean singleFile = properties.isTrueValue(SINGLE_FILE_PROPERTY); - myRbGenerateSingleFileBuild.setSelected(singleFile); - myRbGenerateMultipleFilesBuild.setSelected(!singleFile); - } - if (properties.isValueSet(UI_FORM_PROPERTY)) { - myCbEnableUIFormsCompilation.setSelected(properties.isTrueValue(UI_FORM_PROPERTY)); - } - if (properties.isValueSet(FORCE_TARGET_JDK_PROPERTY)) { - myCbForceTargetJdk.setSelected(properties.isTrueValue(FORCE_TARGET_JDK_PROPERTY)); - } - if (properties.isValueSet(BACKUP_FILES_PROPERTY)) { - final boolean backup = properties.isTrueValue(BACKUP_FILES_PROPERTY); - myRbBackupFiles.setSelected(backup); - myRbOverwriteFiles.setSelected(!backup); - } - if (properties.isValueSet(INLINE_RUNTIME_CLASSPATH_PROPERTY)) { - myCbInlineRuntimeClasspath.setSelected(properties.isTrueValue(INLINE_RUNTIME_CLASSPATH_PROPERTY)); - } - if (properties.isValueSet(GENERATE_IDEA_HOME_PROPERTY)) { - myGenerateIdeaHomeProperty.setSelected(properties.isTrueValue(GENERATE_IDEA_HOME_PROPERTY)); - } + private void loadSettings() { + final PropertiesComponent properties = PropertiesComponent.getInstance(myProject); + if (properties.isValueSet(SINGLE_FILE_PROPERTY)) { + final boolean singleFile = properties.isTrueValue(SINGLE_FILE_PROPERTY); + myRbGenerateSingleFileBuild.setSelected(singleFile); + myRbGenerateMultipleFilesBuild.setSelected(!singleFile); } - - private void saveSettings() { - final PropertiesComponent properties = PropertiesComponent.getInstance(myProject); - properties.setValue(SINGLE_FILE_PROPERTY, Boolean.toString(myRbGenerateSingleFileBuild.isSelected())); - properties.setValue(UI_FORM_PROPERTY, Boolean.toString(myCbEnableUIFormsCompilation.isSelected())); - properties.setValue(FORCE_TARGET_JDK_PROPERTY, Boolean.toString(myCbForceTargetJdk.isSelected())); - properties.setValue(BACKUP_FILES_PROPERTY, Boolean.toString(myRbBackupFiles.isSelected())); - properties.setValue(INLINE_RUNTIME_CLASSPATH_PROPERTY, Boolean.toString(myCbInlineRuntimeClasspath.isSelected())); - properties.setValue(GENERATE_IDEA_HOME_PROPERTY, Boolean.toString(myGenerateIdeaHomeProperty.isSelected())); + if (properties.isValueSet(UI_FORM_PROPERTY)) { + myCbEnableUIFormsCompilation.setSelected(properties.isTrueValue(UI_FORM_PROPERTY)); } - - public void dispose() { - saveSettings(); - super.dispose(); + if (properties.isValueSet(FORCE_TARGET_JDK_PROPERTY)) { + myCbForceTargetJdk.setSelected(properties.isTrueValue(FORCE_TARGET_JDK_PROPERTY)); } - - protected JComponent createCenterPanel() { - final ButtonGroup group = new ButtonGroup(); - group.add(myRbGenerateMultipleFilesBuild); - group.add(myRbGenerateSingleFileBuild); - - final ButtonGroup group1 = new ButtonGroup(); - group1.add(myRbBackupFiles); - group1.add(myRbOverwriteFiles); - - myRbGenerateMultipleFilesBuild.setSelected(true); - myRbBackupFiles.setSelected(true); - myCbEnableUIFormsCompilation.setSelected(true); - myCbForceTargetJdk.setSelected(true); - myCbInlineRuntimeClasspath.setSelected(false); - - initChunksPanel(); - - return myPanel; + if (properties.isValueSet(BACKUP_FILES_PROPERTY)) { + final boolean backup = properties.isTrueValue(BACKUP_FILES_PROPERTY); + myRbBackupFiles.setSelected(backup); + myRbOverwriteFiles.setSelected(!backup); } - - private void initChunksPanel() { - List> chunks = getCycleChunks(); - if (chunks.isEmpty()) { - return; - } - myChunksPanel.setLayout(new BorderLayout()); - myChunksPanel.setBorder( - IdeBorderFactory.createTitledBorder(CompilerBundle.message("generate.ant.build.dialog.cyclic.modules.table.title"))); - JLabel textLabel = new JLabel(CompilerBundle.message("generate.ant.build.dialog.cyclic.modules.table.description")); - textLabel.setUI(new MultiLineLabelUI()); - textLabel.setBorder(IdeBorderFactory.createEmptyBorder(4, 4, 6, 4)); - myChunksPanel.add(textLabel, BorderLayout.NORTH); - - myTableModel = new MyTableModel(chunks); - myTable = new Table(myTableModel); - final MyTableCellRenderer cellRenderer = new MyTableCellRenderer(); - final TableColumn nameColumn = myTable.getColumnModel().getColumn(MyTableModel.NAME_COLUMN); - nameColumn.setCellEditor(ComboBoxTableCellEditor.INSTANCE); - nameColumn.setCellRenderer(cellRenderer); - final TableColumn labelColumn = myTable.getColumnModel().getColumn(MyTableModel.NUMBER_COLUMN); - labelColumn.setCellRenderer(cellRenderer); - - final Dimension preferredSize = new Dimension(myTable.getPreferredSize()); - preferredSize.height = (myTableModel.getRowCount() + 2) * myTable.getRowHeight() + myTable.getTableHeader().getHeight(); - - final JScrollPane scrollPane = ScrollPaneFactory.createScrollPane(myTable); - scrollPane.setPreferredSize(preferredSize); - myChunksPanel.add(scrollPane, BorderLayout.CENTER); + if (properties.isValueSet(INLINE_RUNTIME_CLASSPATH_PROPERTY)) { + myCbInlineRuntimeClasspath.setSelected(properties.isTrueValue(INLINE_RUNTIME_CLASSPATH_PROPERTY)); } - - protected void doOKAction() { - if (myTable != null) { - TableCellEditor cellEditor = myTable.getCellEditor(); - if (cellEditor != null) { - cellEditor.stopCellEditing(); - } - } - super.doOKAction(); + if (properties.isValueSet(GENERATE_IDEA_HOME_PROPERTY)) { + myGenerateIdeaHomeProperty.setSelected(properties.isTrueValue(GENERATE_IDEA_HOME_PROPERTY)); } - - public boolean isGenerateSingleFileBuild() { - return myRbGenerateSingleFileBuild.isSelected(); + if (properties.isValueSet(OUTPUT_FILE_NAME_PROPERTY)) { + myOutputFileNameField.setText(properties.getValue(OUTPUT_FILE_NAME_PROPERTY)); } - - public boolean isFormsCompilationEnabled() { - return myCbEnableUIFormsCompilation.isSelected(); + else { + myOutputFileNameField.setText(BuildProperties.getProjectBuildFileName(myProject)); } + } - public boolean isForceTargetJdk() { - return myCbForceTargetJdk.isSelected(); + private void saveSettings() { + final PropertiesComponent properties = PropertiesComponent.getInstance(myProject); + properties.setValue(SINGLE_FILE_PROPERTY, Boolean.toString(myRbGenerateSingleFileBuild.isSelected())); + properties.setValue(UI_FORM_PROPERTY, Boolean.toString(myCbEnableUIFormsCompilation.isSelected())); + properties.setValue(FORCE_TARGET_JDK_PROPERTY, Boolean.toString(myCbForceTargetJdk.isSelected())); + properties.setValue(BACKUP_FILES_PROPERTY, Boolean.toString(myRbBackupFiles.isSelected())); + properties.setValue(INLINE_RUNTIME_CLASSPATH_PROPERTY, Boolean.toString(myCbInlineRuntimeClasspath.isSelected())); + properties.setValue(GENERATE_IDEA_HOME_PROPERTY, Boolean.toString(myGenerateIdeaHomeProperty.isSelected())); + final String outputFileName = getOutputFileName(); + if (outputFileName.length() > 0) { + properties.setValue(OUTPUT_FILE_NAME_PROPERTY, outputFileName); } - - public boolean isBackupFiles() { - return myRbBackupFiles.isSelected(); + else { + properties.unsetValue(OUTPUT_FILE_NAME_PROPERTY); } + } - public boolean isRuntimeClasspathInlined() { - return myCbInlineRuntimeClasspath.isSelected(); + public void dispose() { + saveSettings(); + super.dispose(); + } + + protected JComponent createCenterPanel() { + final ButtonGroup group = new ButtonGroup(); + group.add(myRbGenerateMultipleFilesBuild); + group.add(myRbGenerateSingleFileBuild); + + final ButtonGroup group1 = new ButtonGroup(); + group1.add(myRbBackupFiles); + group1.add(myRbOverwriteFiles); + + myRbGenerateMultipleFilesBuild.setSelected(true); + myRbBackupFiles.setSelected(true); + myCbEnableUIFormsCompilation.setSelected(true); + myCbForceTargetJdk.setSelected(true); + myCbInlineRuntimeClasspath.setSelected(false); + + initChunksPanel(); + + return myPanel; + } + + private void initChunksPanel() { + List> chunks = getCycleChunks(); + if (chunks.isEmpty()) { + return; } + myChunksPanel.setLayout(new BorderLayout()); + myChunksPanel.setBorder( + IdeBorderFactory.createTitledBorder(CompilerBundle.message("generate.ant.build.dialog.cyclic.modules.table.title"))); + JLabel textLabel = new JLabel(CompilerBundle.message("generate.ant.build.dialog.cyclic.modules.table.description")); + textLabel.setUI(new MultiLineLabelUI()); + textLabel.setBorder(IdeBorderFactory.createEmptyBorder(4, 4, 6, 4)); + myChunksPanel.add(textLabel, BorderLayout.NORTH); - public String[] getRepresentativeModuleNames() { - return myTableModel != null ? myTableModel.getModuleRepresentatives() : ArrayUtil.EMPTY_STRING_ARRAY; + myTableModel = new MyTableModel(chunks); + myTable = new Table(myTableModel); + final MyTableCellRenderer cellRenderer = new MyTableCellRenderer(); + final TableColumn nameColumn = myTable.getColumnModel().getColumn(MyTableModel.NAME_COLUMN); + nameColumn.setCellEditor(ComboBoxTableCellEditor.INSTANCE); + nameColumn.setCellRenderer(cellRenderer); + final TableColumn labelColumn = myTable.getColumnModel().getColumn(MyTableModel.NUMBER_COLUMN); + labelColumn.setCellRenderer(cellRenderer); + + final Dimension preferredSize = new Dimension(myTable.getPreferredSize()); + preferredSize.height = (myTableModel.getRowCount() + 2) * myTable.getRowHeight() + myTable.getTableHeader().getHeight(); + + final JScrollPane scrollPane = ScrollPaneFactory.createScrollPane(myTable); + scrollPane.setPreferredSize(preferredSize); + myChunksPanel.add(scrollPane, BorderLayout.CENTER); + } + + protected void doOKAction() { + if (myTable != null) { + TableCellEditor cellEditor = myTable.getCellEditor(); + if (cellEditor != null) { + cellEditor.stopCellEditing(); + } } + super.doOKAction(); + } - /** - * @return true if user has selected to generate IDEA_HOME property - */ - public boolean isIdeaHomeGenerated() { - return myGenerateIdeaHomeProperty.isSelected(); - } + public boolean isGenerateSingleFileBuild() { + return myRbGenerateSingleFileBuild.isSelected(); + } + public boolean isFormsCompilationEnabled() { + return myCbEnableUIFormsCompilation.isSelected(); + } + + public boolean isForceTargetJdk() { + return myCbForceTargetJdk.isSelected(); + } + + public boolean isBackupFiles() { + return myRbBackupFiles.isSelected(); + } + + public boolean isRuntimeClasspathInlined() { + return myCbInlineRuntimeClasspath.isSelected(); + } + + public String[] getRepresentativeModuleNames() { + return myTableModel != null ? myTableModel.getModuleRepresentatives() : ArrayUtil.EMPTY_STRING_ARRAY; + } + + /** + * @return true if user has selected to generate IDEA_HOME property + */ + public boolean isIdeaHomeGenerated() { + return myGenerateIdeaHomeProperty.isSelected(); + } + + public String getOutputFileName() { + return myOutputFileNameField.getText().trim(); + } + private static class MyTableModel extends AbstractTableModel { private static final int NUMBER_COLUMN = 0; private static final int NAME_COLUMN = 1; diff --git a/java/compiler/impl/src/com/intellij/compiler/ant/BuildPropertiesImpl.java b/java/compiler/impl/src/com/intellij/compiler/ant/BuildPropertiesImpl.java index c7e1a8d20a50..5b77864f6e1a 100644 --- a/java/compiler/impl/src/com/intellij/compiler/ant/BuildPropertiesImpl.java +++ b/java/compiler/impl/src/com/intellij/compiler/ant/BuildPropertiesImpl.java @@ -43,7 +43,7 @@ import java.io.IOException; public class BuildPropertiesImpl extends BuildProperties { public BuildPropertiesImpl(Project project, final GenerationOptions genOptions) { - add(new Property(getPropertyFileName(project))); + add(new Property(genOptions.getPropertiesFileName())); //noinspection HardCodedStringLiteral add(new Comment(CompilerBundle.message("generated.ant.build.disable.tests.property.comment"), diff --git a/java/compiler/impl/src/com/intellij/compiler/ant/GenerationOptionsImpl.java b/java/compiler/impl/src/com/intellij/compiler/ant/GenerationOptionsImpl.java index bfa9141e1ced..0bfe80e303b6 100644 --- a/java/compiler/impl/src/com/intellij/compiler/ant/GenerationOptionsImpl.java +++ b/java/compiler/impl/src/com/intellij/compiler/ant/GenerationOptionsImpl.java @@ -44,267 +44,286 @@ import java.util.*; * Date: Mar 25, 2004 */ public class GenerationOptionsImpl extends GenerationOptions { - /** - * from absolute path to macro substitutions - */ - private final ReplacePathToMacroMap myMacroReplacementMap; - /** - * from absolute path to macro substitutions - */ - private final Map myOutputUrlToPropertyRefMap; - /** - * module chunks - */ - private final ModuleChunk[] myModuleChunks; - /** - * the project to be converted - */ - private final Project myProject; - private final boolean myGenerateIdeaHomeProperty; - private Set myJdkUrls; - /** - * Custom compilers used in the ant build. - */ - private final Set myCustomCompilers = new HashSet(); - /** - * map from modules to chunks - */ - private final Map myModuleToChunkMap = new HashMap(); - /** - * A constructor - * - * @param project a project to generate - * @param forceTargetJdk a value of corresponding option - * @param generateSingleFile a value of corresponding option - * @param enableFormCompiler a value of corresponding option - * @param backupPreviouslyGeneratedFiles a value of corresponding option - * @param inlineRuntimeClasspath if true a runtiem classpaths are inlined - * @param representativeModuleNames a module name that represents module chunks. - */ - public GenerationOptionsImpl(Project project, - boolean generateSingleFile, - boolean enableFormCompiler, - boolean backupPreviouslyGeneratedFiles, - boolean forceTargetJdk, - boolean inlineRuntimeClasspath, - boolean generateIdeaHomeProperty, - String[] representativeModuleNames) { - super(forceTargetJdk, generateSingleFile, enableFormCompiler, backupPreviouslyGeneratedFiles, inlineRuntimeClasspath); - myProject = project; - myGenerateIdeaHomeProperty = generateIdeaHomeProperty; - myMacroReplacementMap = createReplacementMap(); - myModuleChunks = createModuleChunks(representativeModuleNames); - myOutputUrlToPropertyRefMap = createOutputUrlToPropertyRefMap(myModuleChunks); + /** + * from absolute path to macro substitutions + */ + private final ReplacePathToMacroMap myMacroReplacementMap; + /** + * from absolute path to macro substitutions + */ + private final Map myOutputUrlToPropertyRefMap; + /** + * module chunks + */ + private final ModuleChunk[] myModuleChunks; + /** + * the project to be converted + */ + private final Project myProject; + private final boolean myGenerateIdeaHomeProperty; + private final String myOutputFileName; + private Set myJdkUrls; + /** + * Custom compilers used in the ant build. + */ + private final Set myCustomCompilers = new HashSet(); + /** + * map from modules to chunks + */ + private final Map myModuleToChunkMap = new HashMap(); + + /** + * A constructor + * + * @param project a project to generate + * @param generateSingleFile a value of corresponding option + * @param enableFormCompiler a value of corresponding option + * @param backupPreviouslyGeneratedFiles a value of corresponding option + * @param forceTargetJdk a value of corresponding option + * @param inlineRuntimeClasspath if true a runtiem classpaths are inlined + * @param representativeModuleNames a module name that represents module chunks. + * @param outputFileName a name for the output file + */ + public GenerationOptionsImpl(Project project, + boolean generateSingleFile, + boolean enableFormCompiler, + boolean backupPreviouslyGeneratedFiles, + boolean forceTargetJdk, + boolean inlineRuntimeClasspath, + boolean generateIdeaHomeProperty, + String[] representativeModuleNames, String outputFileName) { + super(forceTargetJdk, generateSingleFile, enableFormCompiler, backupPreviouslyGeneratedFiles, inlineRuntimeClasspath); + myProject = project; + myGenerateIdeaHomeProperty = generateIdeaHomeProperty; + myOutputFileName = outputFileName; + myMacroReplacementMap = createReplacementMap(); + myModuleChunks = createModuleChunks(representativeModuleNames); + myOutputUrlToPropertyRefMap = createOutputUrlToPropertyRefMap(myModuleChunks); + } + + /** + * A constructor + * + * @param project a project to generate + * @param forceTargetJdk a value of corresponding option + * @param generateSingleFile a value of corresponding option + * @param enableFormCompiler a value of corresponding option + * @param backupPreviouslyGeneratedFiles a value of corresponding option + * @param representativeModuleNames a module name that represents module chunks. + */ + @Deprecated + public GenerationOptionsImpl(Project project, + boolean generateSingleFile, + boolean enableFormCompiler, + boolean backupPreviouslyGeneratedFiles, + boolean forceTargetJdk, + String[] representativeModuleNames) { + this(project, forceTargetJdk, generateSingleFile, enableFormCompiler, backupPreviouslyGeneratedFiles, false, false, + representativeModuleNames, null); + } + + /** + * {@inheritDoc} + */ + @Override + public boolean isIdeaHomeGenerated() { + return myGenerateIdeaHomeProperty; + } + + public String getBuildFileName() { + return getOutputFileName() + ".xml"; + } + + public String getPropertiesFileName() { + return getOutputFileName() + ".properties"; + } + + private String getOutputFileName() { + if (myOutputFileName == null || myOutputFileName.length() == 0) { + return BuildProperties.getProjectBuildFileName(myProject); } + return myOutputFileName; + } - /** - * A constructor - * - * @param project a project to generate - * @param forceTargetJdk a value of corresponding option - * @param generateSingleFile a value of corresponding option - * @param enableFormCompiler a value of corresponding option - * @param backupPreviouslyGeneratedFiles a value of corresponding option - * @param representativeModuleNames a module name that represents module chunks. - */ - @Deprecated - public GenerationOptionsImpl(Project project, - boolean generateSingleFile, - boolean enableFormCompiler, - boolean backupPreviouslyGeneratedFiles, - boolean forceTargetJdk, - String[] representativeModuleNames) { - this(project, forceTargetJdk, generateSingleFile, enableFormCompiler, backupPreviouslyGeneratedFiles, false, false, - representativeModuleNames); - } - - /** - * {@inheritDoc} - */ - @Override - public boolean isIdeaHomeGenerated() { - return myGenerateIdeaHomeProperty; - } - - /** - * {@inheritDoc} - */ - @Override - public ModuleChunk getChunkByModule(final Module module) { - if (myModuleToChunkMap.isEmpty()) { - for (ModuleChunk c : myModuleChunks) { - for (Module m : c.getModules()) { - myModuleToChunkMap.put(m, c); - } - } + /** + * {@inheritDoc} + */ + @Override + public ModuleChunk getChunkByModule(final Module module) { + if (myModuleToChunkMap.isEmpty()) { + for (ModuleChunk c : myModuleChunks) { + for (Module m : c.getModules()) { + myModuleToChunkMap.put(m, c); } - return myModuleToChunkMap.get(module); + } } + return myModuleToChunkMap.get(module); + } - @Override - public String subsitutePathWithMacros(String path) { - if (myMacroReplacementMap.size() == 0) { - return path; // optimization + @Override + public String subsitutePathWithMacros(String path) { + if (myMacroReplacementMap.size() == 0) { + return path; // optimization + } + return myMacroReplacementMap.substitute(path, SystemInfo.isFileSystemCaseSensitive); + } + + public String getPropertyRefForUrl(String url) { + return myOutputUrlToPropertyRefMap.get(url); + } + + private static ReplacePathToMacroMap createReplacementMap() { + final PathMacros pathMacros = PathMacros.getInstance(); + final Set macroNames = pathMacros.getUserMacroNames(); + final ReplacePathToMacroMap map = new ReplacePathToMacroMap(); + for (final String macroName : macroNames) { + map.put(GenerationUtils.normalizePath(pathMacros.getValue(macroName)), + BuildProperties.propertyRef(BuildProperties.getPathMacroProperty(macroName))); + } + map.put(GenerationUtils.normalizePath(PathManager.getHomePath()), BuildProperties.propertyRef(BuildProperties.PROPERTY_IDEA_HOME)); + return map; + } + + private static Map createOutputUrlToPropertyRefMap(ModuleChunk[] chunks) { + final Map map = new HashMap(); + + for (final ModuleChunk chunk : chunks) { + final String outputPathRef = BuildProperties.propertyRef(BuildProperties.getOutputPathProperty(chunk.getName())); + final String testsOutputPathRef = BuildProperties.propertyRef(BuildProperties.getOutputPathForTestsProperty(chunk.getName())); + + final Module[] modules = chunk.getModules(); + for (final Module module : modules) { + final String outputPathUrl = CompilerModuleExtension.getInstance(module).getCompilerOutputUrl(); + if (outputPathUrl != null) { + map.put(outputPathUrl, outputPathRef); } - return myMacroReplacementMap.substitute(path, SystemInfo.isFileSystemCaseSensitive); - } - - public String getPropertyRefForUrl(String url) { - return myOutputUrlToPropertyRefMap.get(url); - } - - private static ReplacePathToMacroMap createReplacementMap() { - final PathMacros pathMacros = PathMacros.getInstance(); - final Set macroNames = pathMacros.getUserMacroNames(); - final ReplacePathToMacroMap map = new ReplacePathToMacroMap(); - for (final String macroName : macroNames) { - map.put(GenerationUtils.normalizePath(pathMacros.getValue(macroName)), - BuildProperties.propertyRef(BuildProperties.getPathMacroProperty(macroName))); - } - map.put(GenerationUtils.normalizePath(PathManager.getHomePath()), BuildProperties.propertyRef(BuildProperties.PROPERTY_IDEA_HOME)); - return map; - } - - private static Map createOutputUrlToPropertyRefMap(ModuleChunk[] chunks) { - final Map map = new HashMap(); - - for (final ModuleChunk chunk : chunks) { - final String outputPathRef = BuildProperties.propertyRef(BuildProperties.getOutputPathProperty(chunk.getName())); - final String testsOutputPathRef = BuildProperties.propertyRef(BuildProperties.getOutputPathForTestsProperty(chunk.getName())); - - final Module[] modules = chunk.getModules(); - for (final Module module : modules) { - final String outputPathUrl = CompilerModuleExtension.getInstance(module).getCompilerOutputUrl(); - if (outputPathUrl != null) { - map.put(outputPathUrl, outputPathRef); - } - final String outputPathForTestsUrl = CompilerModuleExtension.getInstance(module).getCompilerOutputUrlForTests(); - if (outputPathForTestsUrl != null) { - if (outputPathUrl == null || !outputPathForTestsUrl.equals(outputPathUrl)) { - map.put(outputPathForTestsUrl, testsOutputPathRef); - } - } - } - } - return map; - } - - @Override - public ModuleChunk[] getModuleChunks() { - return myModuleChunks; - } - - private ModuleChunk[] createModuleChunks(String[] representativeModuleNames) { - final Set mainModuleNames = new HashSet(Arrays.asList(representativeModuleNames)); - final Graph> chunkGraph = ModuleCompilerUtil.toChunkGraph(ModuleManager.getInstance(myProject).moduleGraph()); - final Map, ModuleChunk> map = new HashMap, ModuleChunk>(); - final Map> reverseMap = new HashMap>(); - for (final Chunk chunk : chunkGraph.getNodes()) { - final Set modules = chunk.getNodes(); - final ModuleChunk moduleChunk = new ModuleChunk(modules.toArray(new Module[modules.size()])); - for (final Module module : modules) { - if (mainModuleNames.contains(module.getName())) { - moduleChunk.setMainModule(module); - break; - } - } - map.put(chunk, moduleChunk); - reverseMap.put(moduleChunk, chunk); - } - - final Graph moduleChunkGraph = - GraphGenerator.create(CachingSemiGraph.create(new GraphGenerator.SemiGraph() { - public Collection getNodes() { - return map.values(); - } - - public Iterator getIn(ModuleChunk n) { - final Chunk chunk = reverseMap.get(n); - final Iterator> in = chunkGraph.getIn(chunk); - return new Iterator() { - public boolean hasNext() { - return in.hasNext(); - } - - public ModuleChunk next() { - return map.get(in.next()); - } - - public void remove() { - new OperationNotSupportedException(); - } - }; - } - })); - final Collection nodes = moduleChunkGraph.getNodes(); - final ModuleChunk[] moduleChunks = nodes.toArray(new ModuleChunk[nodes.size()]); - for (ModuleChunk moduleChunk : moduleChunks) { - final Iterator depsIterator = moduleChunkGraph.getIn(moduleChunk); - List deps = new ArrayList(); - while (depsIterator.hasNext()) { - deps.add(depsIterator.next()); + final String outputPathForTestsUrl = CompilerModuleExtension.getInstance(module).getCompilerOutputUrlForTests(); + if (outputPathForTestsUrl != null) { + if (outputPathUrl == null || !outputPathForTestsUrl.equals(outputPathUrl)) { + map.put(outputPathForTestsUrl, testsOutputPathRef); } - moduleChunk.setDependentChunks(deps.toArray(new ModuleChunk[deps.size()])); - ContainerUtil.addAll(myCustomCompilers, moduleChunk.getCustomCompilers()); } - Arrays.sort(moduleChunks, new ChunksComparator()); - if (generateSingleFile) { - final File baseDir = BuildProperties.getProjectBaseDir(myProject); - for (ModuleChunk chunk : moduleChunks) { - chunk.setBaseDir(baseDir); + } + } + return map; + } + + @Override + public ModuleChunk[] getModuleChunks() { + return myModuleChunks; + } + + private ModuleChunk[] createModuleChunks(String[] representativeModuleNames) { + final Set mainModuleNames = new HashSet(Arrays.asList(representativeModuleNames)); + final Graph> chunkGraph = ModuleCompilerUtil.toChunkGraph(ModuleManager.getInstance(myProject).moduleGraph()); + final Map, ModuleChunk> map = new HashMap, ModuleChunk>(); + final Map> reverseMap = new HashMap>(); + for (final Chunk chunk : chunkGraph.getNodes()) { + final Set modules = chunk.getNodes(); + final ModuleChunk moduleChunk = new ModuleChunk(modules.toArray(new Module[modules.size()])); + for (final Module module : modules) { + if (mainModuleNames.contains(module.getName())) { + moduleChunk.setMainModule(module); + break; + } + } + map.put(chunk, moduleChunk); + reverseMap.put(moduleChunk, chunk); + } + + final Graph moduleChunkGraph = + GraphGenerator.create(CachingSemiGraph.create(new GraphGenerator.SemiGraph() { + public Collection getNodes() { + return map.values(); + } + + public Iterator getIn(ModuleChunk n) { + final Chunk chunk = reverseMap.get(n); + final Iterator> in = chunkGraph.getIn(chunk); + return new Iterator() { + public boolean hasNext() { + return in.hasNext(); } - } - return moduleChunks; - } - /** - * {@inheritDoc} - */ - public ChunkCustomCompilerExtension[] getCustomCompilers() { - ChunkCustomCompilerExtension[] sorted = myCustomCompilers.toArray(new ChunkCustomCompilerExtension[myCustomCompilers.size()]); - Arrays.sort(sorted, ChunkCustomCompilerExtension.COMPARATOR); - return sorted; - } - - Set getAllJdkUrls() { - if (myJdkUrls != null) { - return myJdkUrls; - } - final Sdk[] projectJdks = ProjectJdkTable.getInstance().getAllJdks(); - myJdkUrls = new HashSet(); - for (Sdk jdk : projectJdks) { - ContainerUtil.addAll(myJdkUrls, jdk.getRootProvider().getUrls(OrderRootType.CLASSES)); - } - return myJdkUrls; - } - - private static class ChunksComparator implements Comparator { - final Map myCachedLevels = new HashMap(); - - public int compare(final ModuleChunk o1, final ModuleChunk o2) { - final int level1 = getChunkLevel(o1); - final int level2 = getChunkLevel(o2); - return (level1 == level2) ? o1.getName().compareToIgnoreCase(o2.getName()) : (level1 - level2); - } - - private int getChunkLevel(ModuleChunk chunk) { - Integer level = myCachedLevels.get(chunk); - if (level == null) { - final ModuleChunk[] chunks = chunk.getDependentChunks(); - if (chunks.length > 0) { - int maxLevel = 0; - for (ModuleChunk dependent : chunks) { - maxLevel = Math.max(maxLevel, getChunkLevel(dependent)); - } - level = 1 + maxLevel; - } - else { - level = 0; - } - myCachedLevels.put(chunk, level); + public ModuleChunk next() { + return map.get(in.next()); } - return level.intValue(); + + public void remove() { + new OperationNotSupportedException(); + } + }; } + })); + final Collection nodes = moduleChunkGraph.getNodes(); + final ModuleChunk[] moduleChunks = nodes.toArray(new ModuleChunk[nodes.size()]); + for (ModuleChunk moduleChunk : moduleChunks) { + final Iterator depsIterator = moduleChunkGraph.getIn(moduleChunk); + List deps = new ArrayList(); + while (depsIterator.hasNext()) { + deps.add(depsIterator.next()); + } + moduleChunk.setDependentChunks(deps.toArray(new ModuleChunk[deps.size()])); + ContainerUtil.addAll(myCustomCompilers, moduleChunk.getCustomCompilers()); } + Arrays.sort(moduleChunks, new ChunksComparator()); + if (generateSingleFile) { + final File baseDir = BuildProperties.getProjectBaseDir(myProject); + for (ModuleChunk chunk : moduleChunks) { + chunk.setBaseDir(baseDir); + } + } + return moduleChunks; + } + + /** + * {@inheritDoc} + */ + public ChunkCustomCompilerExtension[] getCustomCompilers() { + ChunkCustomCompilerExtension[] sorted = myCustomCompilers.toArray(new ChunkCustomCompilerExtension[myCustomCompilers.size()]); + Arrays.sort(sorted, ChunkCustomCompilerExtension.COMPARATOR); + return sorted; + } + + Set getAllJdkUrls() { + if (myJdkUrls != null) { + return myJdkUrls; + } + final Sdk[] projectJdks = ProjectJdkTable.getInstance().getAllJdks(); + myJdkUrls = new HashSet(); + for (Sdk jdk : projectJdks) { + ContainerUtil.addAll(myJdkUrls, jdk.getRootProvider().getUrls(OrderRootType.CLASSES)); + } + return myJdkUrls; + } + + private static class ChunksComparator implements Comparator { + final Map myCachedLevels = new HashMap(); + + public int compare(final ModuleChunk o1, final ModuleChunk o2) { + final int level1 = getChunkLevel(o1); + final int level2 = getChunkLevel(o2); + return (level1 == level2) ? o1.getName().compareToIgnoreCase(o2.getName()) : (level1 - level2); + } + + private int getChunkLevel(ModuleChunk chunk) { + Integer level = myCachedLevels.get(chunk); + if (level == null) { + final ModuleChunk[] chunks = chunk.getDependentChunks(); + if (chunks.length > 0) { + int maxLevel = 0; + for (ModuleChunk dependent : chunks) { + maxLevel = Math.max(maxLevel, getChunkLevel(dependent)); + } + level = 1 + maxLevel; + } + else { + level = 0; + } + myCachedLevels.put(chunk, level); + } + return level.intValue(); + } + } } diff --git a/java/compiler/openapi/src/com/intellij/compiler/ant/BuildProperties.java b/java/compiler/openapi/src/com/intellij/compiler/ant/BuildProperties.java index 0eb86f056305..51ee7d10e320 100644 --- a/java/compiler/openapi/src/com/intellij/compiler/ant/BuildProperties.java +++ b/java/compiler/openapi/src/com/intellij/compiler/ant/BuildProperties.java @@ -72,11 +72,6 @@ public abstract class BuildProperties extends CompositeGenerator { return jdks.toArray(new Sdk[jdks.size()]); } - @NonNls - public static String getPropertyFileName(Project project) { - return getProjectBuildFileName(project) + ".properties"; - } - @NonNls public static String getJdkPathId(@NonNls final String jdkName) { return "jdk.classpath." + convertName(jdkName); diff --git a/java/compiler/openapi/src/com/intellij/compiler/ant/GenerationOptions.java b/java/compiler/openapi/src/com/intellij/compiler/ant/GenerationOptions.java index bd6a0ec9751a..fc286ee7db52 100644 --- a/java/compiler/openapi/src/com/intellij/compiler/ant/GenerationOptions.java +++ b/java/compiler/openapi/src/com/intellij/compiler/ant/GenerationOptions.java @@ -23,7 +23,7 @@ import com.intellij.openapi.module.Module; * @author anna */ public abstract class GenerationOptions { - /** + /** * This option specifies whether mulitfile or single file ant script is created. */ public final boolean generateSingleFile; @@ -146,4 +146,7 @@ public abstract class GenerationOptions { public abstract boolean isIdeaHomeGenerated(); + public abstract String getBuildFileName(); + + public abstract String getPropertiesFileName(); } \ No newline at end of file diff --git a/resources-en/src/messages/CompilerBundle.properties b/resources-en/src/messages/CompilerBundle.properties index 4e747c04f0fb..b7ab2a5bfca9 100644 --- a/resources-en/src/messages/CompilerBundle.properties +++ b/resources-en/src/messages/CompilerBundle.properties @@ -212,3 +212,4 @@ label.resource.patterns.legend=\ Accepted wildcards: ? - exactly one symbol; * - zero or more symbols; / - path separator; /**/ - any number of directories
\ label.option.autoshow.first.error=Automatically show first &error in editor +label.generate.ant.script.filename=Output file name: