I'm following the tutorial in Run Configuration section of IntelliJ IDEA SDK.
Following the tutorial, I will get a new configuration panel with an empty "Before launch" section. That section is added by default.
I would like to specify some targets by default, i.e. at least the Build target as done in several plugins (see next picture)
I'm trying to understand how, but I cannot find any example nor documentation on this.
build
task?Your run configuration (DemoRunConfiguration
in the example) should implement RunProfileWithCompileBeforeLaunchOption
. This interface doesn't provide any methods to implement, so this is a kind of mark. build
task will be added automatically, no additional steps are required.
before launch
section?Your plugin.xml
should contain a line with stepsBeforeRunProvider
<stepsBeforeRunProvider implementation="com.MyBeforeRunProvider" id="myBeforeRun"/>
For that you should create "before run provider" with "before run task".
public class BeforeRunProvider extends BeforeRunTaskProvider<MyBeforeRunTask> {
@Override
public Key<MyBeforeRunTask> getId() {
return Key.create("ThisIsId");
}
@Override
public String getName() {
return "Nice name";
}
@Override
public String getDescription(MyBeforeRunTask task) {
return "Description";
}
@Nullable
@Override
public Icon getIcon() {
return AllIcons.Actions.Compile;
}
@Nullable
@Override
public MyBeforeRunTask createTask(@NotNull RunConfiguration runConfiguration) {
return new MyBeforeRunTask(getId());
}
@Override
public boolean executeTask(@NotNull DataContext dataContext, @NotNull RunConfiguration runConfiguration, @NotNull ExecutionEnvironment executionEnvironment, @NotNull MyBeforeRunTask myBeforeRunTask) {
return true;
}
}
And the task:
public class MyBeforeRunTask extends BeforeRunTask<MyBeforeRunTask> {
protected MyBeforeRunTask(@NotNull Key<MyBeforeRunTask> providerId) {
super(providerId);
setEnabled(true);
}
}