IDEA: add facet option to skip TeaVM compilation

This commit is contained in:
Alexey Andreev 2018-09-04 18:30:15 +03:00
parent 0473020bc8
commit 55e0905518
3 changed files with 25 additions and 0 deletions

View File

@ -39,12 +39,21 @@ public class TeaVMJpsConfiguration extends JpsElementBase<TeaVMJpsConfiguration>
@Transient @Transient
private TeaVMTargetType targetType; private TeaVMTargetType targetType;
private boolean skipped;
private String mainClass; private String mainClass;
private String targetDirectory; private String targetDirectory;
private boolean sourceMapsFileGenerated = true; private boolean sourceMapsFileGenerated = true;
private boolean sourceFilesCopied = true; private boolean sourceFilesCopied = true;
private List<TeaVMProperty> properties = new ArrayList<>(); private List<TeaVMProperty> properties = new ArrayList<>();
public boolean isSkipped() {
return skipped;
}
public void setSkipped(boolean skipped) {
this.skipped = skipped;
}
public TeaVMTargetType getTargetType() { public TeaVMTargetType getTargetType() {
return targetType; return targetType;
} }

View File

@ -96,6 +96,11 @@ class TeaVMBuild {
storage = context.getProjectDescriptor().dataManager.getStorage(target, storageProvider); storage = context.getProjectDescriptor().dataManager.getStorage(target, storageProvider);
TeaVMJpsConfiguration config = target.getConfiguration(); TeaVMJpsConfiguration config = target.getConfiguration();
if (config.isSkipped()) {
context.processMessage(new CompilerMessage("TeaVM", BuildMessage.Kind.INFO,
"TeaVM skipped due to facet configuration"));
return false;
}
classPathEntries.clear(); classPathEntries.clear();
buildStrategy.init(); buildStrategy.init();

View File

@ -52,6 +52,7 @@ import org.teavm.idea.jps.model.TeaVMJpsConfiguration;
import org.teavm.idea.jps.model.TeaVMProperty; import org.teavm.idea.jps.model.TeaVMProperty;
class TeaVMConfigurationPanel extends JPanel { class TeaVMConfigurationPanel extends JPanel {
private final JComboBox<ComboBoxItem<Boolean>> skipField = new JComboBox<>(new DefaultComboBoxModel<>());
private final TextFieldWithBrowseButton mainClassField = new TextFieldWithBrowseButton(event -> chooseMainClass()); private final TextFieldWithBrowseButton mainClassField = new TextFieldWithBrowseButton(event -> chooseMainClass());
private final TextFieldWithBrowseButton targetDirectoryField = new TextFieldWithBrowseButton(); private final TextFieldWithBrowseButton targetDirectoryField = new TextFieldWithBrowseButton();
private final JComboBox<ComboBoxItem<Boolean>> sourceMapsField = new JComboBox<>(new DefaultComboBoxModel<>()); private final JComboBox<ComboBoxItem<Boolean>> sourceMapsField = new JComboBox<>(new DefaultComboBoxModel<>());
@ -67,7 +68,13 @@ class TeaVMConfigurationPanel extends JPanel {
private final List<ComboBoxItem<Boolean>> copySourcesOptions = Arrays.asList(new ComboBoxItem<>(true, "Copy"), private final List<ComboBoxItem<Boolean>> copySourcesOptions = Arrays.asList(new ComboBoxItem<>(true, "Copy"),
new ComboBoxItem<>(false, "Skip")); new ComboBoxItem<>(false, "Skip"));
private final List<ComboBoxItem<Boolean>> skipOptions = Arrays.asList(new ComboBoxItem<>(true, "Skip"),
new ComboBoxItem<>(false, "Don't skip"));
private final List<Field<?>> fields = Arrays.asList( private final List<Field<?>> fields = Arrays.asList(
new Field<>(TeaVMJpsConfiguration::setSkipped, TeaVMJpsConfiguration::isSkipped,
value -> skipField.setSelectedIndex(value ? 0 : 1),
() -> skipOptions.get(skipField.getSelectedIndex()).value),
new Field<>(TeaVMJpsConfiguration::setMainClass, TeaVMJpsConfiguration::getMainClass, new Field<>(TeaVMJpsConfiguration::setMainClass, TeaVMJpsConfiguration::getMainClass,
mainClassField::setText, mainClassField::getText), mainClassField::setText, mainClassField::getText),
new Field<>(TeaVMJpsConfiguration::setTargetDirectory, TeaVMJpsConfiguration::getTargetDirectory, new Field<>(TeaVMJpsConfiguration::setTargetDirectory, TeaVMJpsConfiguration::getTargetDirectory,
@ -94,6 +101,7 @@ class TeaVMConfigurationPanel extends JPanel {
sourceMapsOptions.forEach(sourceMapsField::addItem); sourceMapsOptions.forEach(sourceMapsField::addItem);
copySourcesOptions.forEach(copySourcesField::addItem); copySourcesOptions.forEach(copySourcesField::addItem);
skipOptions.forEach(skipField::addItem);
} }
private void setupLayout() { private void setupLayout() {
@ -123,6 +131,9 @@ class TeaVMConfigurationPanel extends JPanel {
fieldConstraints.insets.left = 10; fieldConstraints.insets.left = 10;
fieldConstraints.insets.right = 10; fieldConstraints.insets.right = 10;
add(bold(new JBLabel("Skip TeaVM compilation")), labelConstraints);
add(skipField, fieldConstraints);
add(bold(new JBLabel("Main class")), labelConstraints); add(bold(new JBLabel("Main class")), labelConstraints);
add(mainClassField, fieldConstraints); add(mainClassField, fieldConstraints);