gpt4 book ai didi

java - Gradle + Intellij 想法 : run configuration

转载 作者:行者123 更新时间:2023-12-04 13:58:30 27 4
gpt4 key购买 nike

我有多个复杂的 JavaExec 任务的 gradle 项目,为了方便,我想要相应的想法运行配置。

是否可以配置idea run配置?想法插件或其他任何东西?

最佳答案

为此做了一个自定义任务:

// create IDEA run configurations from Gradle JavaExec tasks
task createRunConfigurations {
def runConfigurationsDir = new File(".idea/runConfigurations")
runConfigurationsDir.mkdirs()

tasks.withType(JavaExec).each { task ->
def taskName = task.name
def mainClass = task.main
def props = task.systemProperties.collect { k, v -> "-D$k=$v" }.join(' ')
def args = task.args.join(" ")

def writer = new FileWriter(new File(runConfigurationsDir, "${taskName}.xml"))
def xml = new MarkupBuilder(writer)

xml.component(name: "ProjectRunConfigurationManager") {
configuration(default: 'false', name: taskName, type: "Application", factoryName: "Application", singleton: "true") {
option(name: 'MAIN_CLASS_NAME', value: mainClass)
option(name: 'VM_PARAMETERS', value: props)
option(name: 'PROGRAM_PARAMETERS', value: args)
option(name: 'WORKING_DIRECTORY', value: 'file://$PROJECT_DIR$')
module(name: 'module-name')
}
}
}
}

关于java - Gradle + Intellij 想法 : run configuration,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36947505/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com