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
private TeaVMTargetType targetType;
private boolean skipped;
private String mainClass;
private String targetDirectory;
private boolean sourceMapsFileGenerated = true;
private boolean sourceFilesCopied = true;
private List<TeaVMProperty> properties = new ArrayList<>();
public boolean isSkipped() {
return skipped;
}
public void setSkipped(boolean skipped) {
this.skipped = skipped;
}
public TeaVMTargetType getTargetType() {
return targetType;
}

View File

@ -96,6 +96,11 @@ class TeaVMBuild {
storage = context.getProjectDescriptor().dataManager.getStorage(target, storageProvider);
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();
buildStrategy.init();

View File

@ -52,6 +52,7 @@ import org.teavm.idea.jps.model.TeaVMJpsConfiguration;
import org.teavm.idea.jps.model.TeaVMProperty;
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 targetDirectoryField = new TextFieldWithBrowseButton();
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"),
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(
new Field<>(TeaVMJpsConfiguration::setSkipped, TeaVMJpsConfiguration::isSkipped,
value -> skipField.setSelectedIndex(value ? 0 : 1),
() -> skipOptions.get(skipField.getSelectedIndex()).value),
new Field<>(TeaVMJpsConfiguration::setMainClass, TeaVMJpsConfiguration::getMainClass,
mainClassField::setText, mainClassField::getText),
new Field<>(TeaVMJpsConfiguration::setTargetDirectory, TeaVMJpsConfiguration::getTargetDirectory,
@ -94,6 +101,7 @@ class TeaVMConfigurationPanel extends JPanel {
sourceMapsOptions.forEach(sourceMapsField::addItem);
copySourcesOptions.forEach(copySourcesField::addItem);
skipOptions.forEach(skipField::addItem);
}
private void setupLayout() {
@ -123,6 +131,9 @@ class TeaVMConfigurationPanel extends JPanel {
fieldConstraints.insets.left = 10;
fieldConstraints.insets.right = 10;
add(bold(new JBLabel("Skip TeaVM compilation")), labelConstraints);
add(skipField, fieldConstraints);
add(bold(new JBLabel("Main class")), labelConstraints);
add(mainClassField, fieldConstraints);