这是我的 Groovy 应用程序的驱动程序类:
package org.me.myapp
class MyDriver {
static void main(String[] args) {
// The p flag was passed in and had a value of 50!
println String.format("The %s flag was passed in and had a value of %s!", args[0], args[1])
}
}
我正在尝试增强我的 Gradle 构建,以便我可以:
- 让 Gradle 打包我的可执行 JAR;和
- 运行我的可执行 JAR,将命令行参数传递给它的 main 方法
理想情况下,我可以通过以下方式简单地运行我的应用程序:
gradle run -p 50
并查看以下控制台输出:
The p flag was passed in and had a value of 50!
这是我的build.gradle
:
apply plugin: 'groovy'
apply plugin: 'eclipse'
sourceCompatibility = '1.7'
targetCompatibility = '1.7'
repositories {
mavenCentral()
}
dependencies {
compile (
'org.codehaus.groovy:groovy-all:2.3.9',
'com.google.guava:guava:18.0',
'com.google.inject:guice:3.0'
)
}
task sourcesJar(type: Jar, dependsOn: classes) {
classifier = 'sources'
from sourceSets.main.allSource
}
task wrapper(type: Wrapper) {
gradleVersion = '1.11'
}
我需要做什么才能让 Gradle 包 + 像这样运行我的应用程序?