【发布时间】:2014-02-08 07:20:06
【问题描述】:
我正在使用 Java、Spring 和 Gradle。我是 gradle 新手,正在尝试理解一些东西。我目前已经 gradle 成功构建了一个 jar 文件。 我想添加一个任务,以便 gradle 运行它构建的 jar。 这样我就可以了
./gradlew clean build run
或者如果可能的话,我可以在一个命令中完成。其伪代码为
task run {
clean
build
java -jar myJar.jar
}
我该怎么做呢?
---信息----
我当前的 build.gradle 文件:
buildscript {
repositories {
maven { url "http://repo.spring.io/libs-snapshot" }
mavenLocal()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:0.5.0.M6")
}
}
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'idea'
apply plugin: 'spring-boot'
jar {
baseName = 'gs-rest-service'
version = '0.1.0'
}
repositories {
mavenCentral()
maven { url "http://repo.spring.io/libs-snapshot" }
}
dependencies {
compile("org.springframework.boot:spring-boot-starter-web:0.5.0.M6")
compile("com.fasterxml.jackson.core:jackson-databind")
testCompile("junit:junit:4.11")
}
task wrapper(type: Wrapper) {
gradleVersion = '1.10'
}
【问题讨论】: