如何执行Gradle Kotlin DSL构建文件中的构建JAR
文件 ?也就是说,使其成为一项任务。
thufir@dur:~/NetBeansProjects/HelloKotlinWorld$
thufir@dur:~/NetBeansProjects/HelloKotlinWorld$ gradle clean ShadowJar;java -jar build/libs/app-9-inajar.jar
Deprecated Gradle features were used in this build, making it incompatible with Gradle 6.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/5.0/userguide/command_line_interface.html#sec:command_line_warnings
BUILD SUCCESSFUL in 1s
5 actionable tasks: 5 executed
Hello world.
thufir@dur:~/NetBeansProjects/HelloKotlinWorld$
版本file:
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
plugins {
kotlin("jvm") version "1.3.11"
id("com.github.johnrengelman.shadow") version "2.0.4"
}
group = "xxx.yyy"
version = "1.0-SNAPSHOT"
repositories {
mavenCentral()
}
dependencies {
implementation(kotlin("stdlib-jdk8"))
}
tasks.withType<KotlinCompile> {
kotlinOptions.jvmTarget = "1.8"
}
tasks.withType<ShadowJar> {
baseName = "app"
classifier = "inajar"
version = "9"
manifest.attributes.apply {
put("Implementation-Title", "Gradle Jar File Example")
//put("Implementation-Version" version)
put("Main-Class", "HelloKotlinWorld.App")
}
}
直接在构建文件中移至TestNG
。