ore*_*tis 4 java gradle shadowjar
我正在使用 Gradle 构建一个 java 应用程序,我想将最终的 jar 文件传输到另一个文件夹中。我想复制每个上的文件build并删除每个上的文件clean。
不幸的是,我只能完成其中一项任务,而不能同时完成两项任务。当我激活任务时copyJar,它成功复制了 JAR。当我包含该clean任务时,不会复制 JAR,如果其中有文件,则会将其删除。就好像有某个任务调用clean.
有什么解决办法吗?
plugins {
id 'java'
id 'base'
id 'com.github.johnrengelman.shadow' version '2.0.2'
}
dependencies {
compile project(":core")
compile project("fs-api-reader")
compile project(":common")
}
task copyJar(type: Copy) {
copy {
from "build/libs/${rootProject.name}.jar"
into "myApp-app"
}
}
clean {
file("myApp-app/${rootProject.name}.jar").delete()
}
copyJar.dependsOn(build)
allprojects {
apply plugin: 'java'
apply plugin: 'base'
repositories {
mavenCentral()
}
dependencies {
testCompile 'junit:junit:4.12'
compile 'org.slf4j:slf4j-api:1.7.12'
testCompile group: 'ch.qos.logback', name: 'logback-classic', version: '0.9.26'
}
sourceSets {
test {
java.srcDir 'src/test/java'
}
integration {
java.srcDir 'src/test/integration/java'
resources.srcDir 'src/test/resources'
compileClasspath += main.output + test.output
runtimeClasspath += main.output + test.output
}
}
configurations {
integrationCompile.extendsFrom testCompile
integrationRuntime.extendsFrom testRuntime
}
task integration(type: Test, description: 'Runs the integration tests.', group: 'Verification') {
testClassesDirs = sourceSets.integration.output.classesDirs
classpath = sourceSets.integration.runtimeClasspath
}
test {
reports.html.enabled = true
}
clean {
file('out').deleteDir()
}
}
Run Code Online (Sandbox Code Playgroud)
clean {
file("myApp-app/${rootProject.name}.jar").delete()
}
Run Code Online (Sandbox Code Playgroud)
这将在每次评估时删除文件,这不是您想要的。将其更改为:
clean {
delete "myApp-app/${rootProject.name}.jar"
}
Run Code Online (Sandbox Code Playgroud)
这将配置 clean 任务并添加要在执行时删除的 JAR。
| 归档时间: |
|
| 查看次数: |
6087 次 |
| 最近记录: |