Adding new run configuration template

已回答

Hi,

I would like to add a couple of new templates to the Run/Debug Configurations section in IntelliJ.
I have been exploring the IntelliJ Community source code and identified the com.intellij.execution.configurations.ConfigurationType interface as common to all elements in the list of run configurations that are showing up in the UI when I click Run->Edit Configurations. However It isn't clear how to add new templates to the list. Please can you advise if/how that can be done and give any guidance on how to do it? For example, is it simply a matter of implementing a class that implements ConfigurationType and including it in a plugin (I tried this and it didn't appear to work)?

Thanks,
Simon

0

If you're not using gradle, perhaps the following will give you some hints.  If you are, it can be done in the build.gradle file like this:

private void generateRunConfigurations() {



createGradleRunConfiguration('Run IDE (default)', 'runIde', '', '-Didea.is.internal=true')
createGradleRunConfiguration('Run IDE (default) - Suppress ProcessCanceledExceptions', 'runIde', '', '-Didea.is.internal=true -Didea.ProcessCanceledException=disabled')
createGradleRunConfiguration('Run Tests (default)', 'test', '', '')
createGradleRunConfiguration('Run Single Test (default)', 'test', '', '--tests "{replace this with FQDN of test suite or single test}"')

createGradleRunConfiguration('Generate Parsers', 'cleanGenerated generateHaxeParser generateHxmlParser', '', '')


createGradleRunConfiguration('Run Tests 2018', 'test', "-PtargetVersion=$latest2018Version", '')
createGradleRunConfiguration('Run Tests 2017', 'test', "-PtargetVersion=$latest2017Version", '')
createGradleRunConfiguration('Run Tests 2016', 'test', "-PtargetVersion=$latest2016Version", '')

createGradleRunConfiguration('Run IDE 2018',
'runIde',
"-PtargetVersion=$latest2018Version",
' -DHAXELIB_LIST_PATH_SUPPORTED=1 -Didea.is.internal=true')
createGradleRunConfiguration('Run IDE 2017',
'runIde',
"-PtargetVersion=$latest2017Version",
'-DHAXELIB_LIST_PATH_SUPPORTED=1 -Didea.is.internal=true')
createGradleRunConfiguration('Run IDE 2016',
'runIde',
"-PtargetVersion=$latest2016Version",
'-Xmx1024m -Xms512m -XX:MaxPermSize=256m -ea -DHAXELIB_LIST_PATH_SUPPORTED=1 -Didea.is.internal=true')



}

// create IDEA run configurations from Gradle JavaExec tasks
private void createGradleRunConfiguration(String configName, String taskList,String scriptParams, String vmOptions) {


def runConfigurationsDir = new File(".idea/runConfigurations")
runConfigurationsDir.mkdirs()

def writer = new FileWriter(new File(runConfigurationsDir, "${configName.replaceAll("\\s", "_")}.xml"))
def xml = new MarkupBuilder(writer)

xml.component(name: "ProjectRunConfigurationManager") {
configuration(default: 'false', name: configName, type: "GradleRunConfiguration", factoryName: "Gradle") {
ExternalSystemSettings() {
option(name: 'executionName')
option(name: 'externalProjectPath', value: '$PROJECT_DIR$')
option(name: 'externalSystemIdString', value: "GRADLE")
option(name: 'scriptParameters', value: scriptParams)
option(name: 'taskNames') {
list() {
for (String task : taskList.split('\\s')) {
option(value: task)
}
}
}
option(name: 'vmOptions', value: vmOptions)
}
}
}
}

Gradle plug-in sources are at https://github.com/JetBrains/gradle-intellij-plugin.

0

Please explain what "add new templates to the list" exactly means? Screenshot?

0

Hi Eric / Yann,

Thanks for the advice about using gradle scripting to generate new run configurations. However it wasn't exactly what I was looking for.

What I mean is how can we add new entries to the list shown here, for example by using a plugin?

Simon

 

 

 

0

Brilliant, thanks Yann, that gives me lots to work on.

Many thanks,

Simon

 

 

 

0

Related to this: I have edited the template of an existing configuration created by the author of the plugin called TeXify. I am hoping, without Java, to ensure that when I create a new project, the configuration template for LaTeX will be exactly as below.

 

0

请先登录再写评论。