mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
ability to define output ant build file name (IDEA-39323)
This commit is contained in:
@@ -3,12 +3,12 @@
|
||||
<grid id="3d49c" binding="myPanel" layout-manager="GridLayoutManager" row-count="6" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<margin top="0" left="0" bottom="0" right="0"/>
|
||||
<constraints>
|
||||
<xy x="52" y="58" width="686" height="190"/>
|
||||
<xy x="52" y="58" width="727" height="229"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<grid id="770dc" layout-manager="GridLayoutManager" row-count="2" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<grid id="770dc" layout-manager="GridLayoutManager" row-count="3" column-count="4" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<margin top="0" left="0" bottom="0" right="0"/>
|
||||
<constraints>
|
||||
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
|
||||
@@ -18,7 +18,7 @@
|
||||
<children>
|
||||
<component id="7d65" class="javax.swing.JRadioButton" binding="myRbGenerateMultipleFilesBuild">
|
||||
<constraints>
|
||||
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||
<grid row="0" column="0" row-span="1" col-span="3" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text resource-bundle="messages/CompilerBundle" key="label.generate.ant.script.generate.multiple.files"/>
|
||||
@@ -26,7 +26,7 @@
|
||||
</component>
|
||||
<component id="f1821" class="javax.swing.JRadioButton" binding="myRbGenerateSingleFileBuild">
|
||||
<constraints>
|
||||
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||
<grid row="1" column="0" row-span="1" col-span="3" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text resource-bundle="messages/CompilerBundle" key="label.generate.ant.script.single.file"/>
|
||||
@@ -34,7 +34,7 @@
|
||||
</component>
|
||||
<component id="81381" class="javax.swing.JRadioButton" binding="myRbBackupFiles">
|
||||
<constraints>
|
||||
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||
<grid row="0" column="3" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text resource-bundle="messages/CompilerBundle" key="label.generate.ant.script.backup.files"/>
|
||||
@@ -42,12 +42,28 @@
|
||||
</component>
|
||||
<component id="a019e" class="javax.swing.JRadioButton" binding="myRbOverwriteFiles">
|
||||
<constraints>
|
||||
<grid row="1" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||
<grid row="1" column="3" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text resource-bundle="messages/CompilerBundle" key="label.generate.ant.script.overwrite.files"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="cd13a" class="javax.swing.JTextField" binding="myOutputFileNameField">
|
||||
<constraints>
|
||||
<grid row="2" column="2" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
|
||||
<preferred-size width="150" height="-1"/>
|
||||
</grid>
|
||||
</constraints>
|
||||
<properties/>
|
||||
</component>
|
||||
<component id="3a774" class="javax.swing.JLabel">
|
||||
<constraints>
|
||||
<grid row="2" column="0" row-span="1" col-span="2" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text resource-bundle="messages/CompilerBundle" key="label.generate.ant.script.filename"/>
|
||||
</properties>
|
||||
</component>
|
||||
</children>
|
||||
</grid>
|
||||
<component id="ec5e9" class="javax.swing.JCheckBox" binding="myCbEnableUIFormsCompilation">
|
||||
|
||||
@@ -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<File> allFiles = new ArrayList<File>();
|
||||
|
||||
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<File> 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<File> generated = new ArrayList<File>();
|
||||
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];
|
||||
|
||||
+170
-150
@@ -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<Chunk<Module>> getCycleChunks() {
|
||||
List<Chunk<Module>> chunks =
|
||||
ModuleCompilerUtil.getSortedModuleChunks(myProject, Arrays.asList(ModuleManager.getInstance(myProject).getModules()));
|
||||
for (Iterator<Chunk<Module>> it = chunks.iterator(); it.hasNext();) {
|
||||
final Chunk<Module> chunk = it.next();
|
||||
if (chunk.getNodes().size() == 1) {
|
||||
it.remove();
|
||||
}
|
||||
private List<Chunk<Module>> getCycleChunks() {
|
||||
List<Chunk<Module>> chunks =
|
||||
ModuleCompilerUtil.getSortedModuleChunks(myProject, Arrays.asList(ModuleManager.getInstance(myProject).getModules()));
|
||||
for (Iterator<Chunk<Module>> it = chunks.iterator(); it.hasNext();) {
|
||||
final Chunk<Module> 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<Chunk<Module>> 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<Chunk<Module>> 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;
|
||||
|
||||
@@ -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"),
|
||||
|
||||
@@ -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<String, String> myOutputUrlToPropertyRefMap;
|
||||
/**
|
||||
* module chunks
|
||||
*/
|
||||
private final ModuleChunk[] myModuleChunks;
|
||||
/**
|
||||
* the project to be converted
|
||||
*/
|
||||
private final Project myProject;
|
||||
private final boolean myGenerateIdeaHomeProperty;
|
||||
private Set<String> myJdkUrls;
|
||||
/**
|
||||
* Custom compilers used in the ant build.
|
||||
*/
|
||||
private final Set<ChunkCustomCompilerExtension> myCustomCompilers = new HashSet<ChunkCustomCompilerExtension>();
|
||||
/**
|
||||
* map from modules to chunks
|
||||
*/
|
||||
private final Map<Module, ModuleChunk> myModuleToChunkMap = new HashMap<Module, ModuleChunk>();
|
||||
|
||||
/**
|
||||
* 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<String, String> 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<String> myJdkUrls;
|
||||
/**
|
||||
* Custom compilers used in the ant build.
|
||||
*/
|
||||
private final Set<ChunkCustomCompilerExtension> myCustomCompilers = new HashSet<ChunkCustomCompilerExtension>();
|
||||
/**
|
||||
* map from modules to chunks
|
||||
*/
|
||||
private final Map<Module, ModuleChunk> myModuleToChunkMap = new HashMap<Module, ModuleChunk>();
|
||||
|
||||
/**
|
||||
* 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<String> 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<String, String> createOutputUrlToPropertyRefMap(ModuleChunk[] chunks) {
|
||||
final Map<String, String> map = new HashMap<String, String>();
|
||||
|
||||
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<String> 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<String, String> createOutputUrlToPropertyRefMap(ModuleChunk[] chunks) {
|
||||
final Map<String, String> map = new HashMap<String, String>();
|
||||
|
||||
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<String> mainModuleNames = new HashSet<String>(Arrays.asList(representativeModuleNames));
|
||||
final Graph<Chunk<Module>> chunkGraph = ModuleCompilerUtil.toChunkGraph(ModuleManager.getInstance(myProject).moduleGraph());
|
||||
final Map<Chunk<Module>, ModuleChunk> map = new HashMap<Chunk<Module>, ModuleChunk>();
|
||||
final Map<ModuleChunk, Chunk<Module>> reverseMap = new HashMap<ModuleChunk, Chunk<Module>>();
|
||||
for (final Chunk<Module> chunk : chunkGraph.getNodes()) {
|
||||
final Set<Module> 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<ModuleChunk> moduleChunkGraph =
|
||||
GraphGenerator.create(CachingSemiGraph.create(new GraphGenerator.SemiGraph<ModuleChunk>() {
|
||||
public Collection<ModuleChunk> getNodes() {
|
||||
return map.values();
|
||||
}
|
||||
|
||||
public Iterator<ModuleChunk> getIn(ModuleChunk n) {
|
||||
final Chunk<Module> chunk = reverseMap.get(n);
|
||||
final Iterator<Chunk<Module>> in = chunkGraph.getIn(chunk);
|
||||
return new Iterator<ModuleChunk>() {
|
||||
public boolean hasNext() {
|
||||
return in.hasNext();
|
||||
}
|
||||
|
||||
public ModuleChunk next() {
|
||||
return map.get(in.next());
|
||||
}
|
||||
|
||||
public void remove() {
|
||||
new OperationNotSupportedException();
|
||||
}
|
||||
};
|
||||
}
|
||||
}));
|
||||
final Collection<ModuleChunk> nodes = moduleChunkGraph.getNodes();
|
||||
final ModuleChunk[] moduleChunks = nodes.toArray(new ModuleChunk[nodes.size()]);
|
||||
for (ModuleChunk moduleChunk : moduleChunks) {
|
||||
final Iterator<ModuleChunk> depsIterator = moduleChunkGraph.getIn(moduleChunk);
|
||||
List<ModuleChunk> deps = new ArrayList<ModuleChunk>();
|
||||
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<String> mainModuleNames = new HashSet<String>(Arrays.asList(representativeModuleNames));
|
||||
final Graph<Chunk<Module>> chunkGraph = ModuleCompilerUtil.toChunkGraph(ModuleManager.getInstance(myProject).moduleGraph());
|
||||
final Map<Chunk<Module>, ModuleChunk> map = new HashMap<Chunk<Module>, ModuleChunk>();
|
||||
final Map<ModuleChunk, Chunk<Module>> reverseMap = new HashMap<ModuleChunk, Chunk<Module>>();
|
||||
for (final Chunk<Module> chunk : chunkGraph.getNodes()) {
|
||||
final Set<Module> 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<ModuleChunk> moduleChunkGraph =
|
||||
GraphGenerator.create(CachingSemiGraph.create(new GraphGenerator.SemiGraph<ModuleChunk>() {
|
||||
public Collection<ModuleChunk> getNodes() {
|
||||
return map.values();
|
||||
}
|
||||
|
||||
public Iterator<ModuleChunk> getIn(ModuleChunk n) {
|
||||
final Chunk<Module> chunk = reverseMap.get(n);
|
||||
final Iterator<Chunk<Module>> in = chunkGraph.getIn(chunk);
|
||||
return new Iterator<ModuleChunk>() {
|
||||
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<String> getAllJdkUrls() {
|
||||
if (myJdkUrls != null) {
|
||||
return myJdkUrls;
|
||||
}
|
||||
final Sdk[] projectJdks = ProjectJdkTable.getInstance().getAllJdks();
|
||||
myJdkUrls = new HashSet<String>();
|
||||
for (Sdk jdk : projectJdks) {
|
||||
ContainerUtil.addAll(myJdkUrls, jdk.getRootProvider().getUrls(OrderRootType.CLASSES));
|
||||
}
|
||||
return myJdkUrls;
|
||||
}
|
||||
|
||||
private static class ChunksComparator implements Comparator<ModuleChunk> {
|
||||
final Map<ModuleChunk, Integer> myCachedLevels = new HashMap<ModuleChunk, Integer>();
|
||||
|
||||
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<ModuleChunk> nodes = moduleChunkGraph.getNodes();
|
||||
final ModuleChunk[] moduleChunks = nodes.toArray(new ModuleChunk[nodes.size()]);
|
||||
for (ModuleChunk moduleChunk : moduleChunks) {
|
||||
final Iterator<ModuleChunk> depsIterator = moduleChunkGraph.getIn(moduleChunk);
|
||||
List<ModuleChunk> deps = new ArrayList<ModuleChunk>();
|
||||
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<String> getAllJdkUrls() {
|
||||
if (myJdkUrls != null) {
|
||||
return myJdkUrls;
|
||||
}
|
||||
final Sdk[] projectJdks = ProjectJdkTable.getInstance().getAllJdks();
|
||||
myJdkUrls = new HashSet<String>();
|
||||
for (Sdk jdk : projectJdks) {
|
||||
ContainerUtil.addAll(myJdkUrls, jdk.getRootProvider().getUrls(OrderRootType.CLASSES));
|
||||
}
|
||||
return myJdkUrls;
|
||||
}
|
||||
|
||||
private static class ChunksComparator implements Comparator<ModuleChunk> {
|
||||
final Map<ModuleChunk, Integer> myCachedLevels = new HashMap<ModuleChunk, Integer>();
|
||||
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
@@ -212,3 +212,4 @@ label.resource.patterns.legend=<html>\
|
||||
Accepted wildcards: <b>?</b> - exactly one symbol; <b>*</b> - zero or more symbols; <b>/</b> - path separator; <b>/**/</b> - any number of directories<br>\
|
||||
</html>
|
||||
label.option.autoshow.first.error=Automatically show first &error in editor
|
||||
label.generate.ant.script.filename=Output file name:
|
||||
|
||||
Reference in New Issue
Block a user