验证中...
Languages: Groovy
Categories: 软件配置
Latest update 2018-12-09 09:59
gradleRunMainMethod.md
Raw Copy

build.gradle

apply plugin: 'java'
repositories {
    mavenLocal()
    mavenCentral()
}
dependencies {
}
jar {
    baseName = 'hello'
    version =  '0.1.0'
}
task run(type: JavaExec, dependsOn: 'classes') {
    description '运行指定main函数的java'
    classpath = sourceSets.main.runtimeClasspath
    if(project.hasProperty('main')){
       main = "${project.getProperty('main')}"
    }
}

Then run

$gradle run -Pmain=HelloWorld

Comment list( 0 )

You need to Sign in for post a comment

Help Search

Gitee_sixth 5th_float_left_close