[英]How to copy mutliple jars with gradle?
I want to execute a custom task, which should build some jars and copy these to a different directory. 我要执行一个自定义任务,该任务应该构建一些jar并将其复制到其他目录。
This is my build.gradle
file: 这是我的build.gradle
文件:
allprojects {
apply plugin: 'java'
apply plugin: 'eclipse'
task hello << { task -> println "I'm project $task.project.name" }
}
subprojects {
repositories {
maven {
url "http://repo1.maven.org/maven2"
}
}
task allDependencies(type: DependencyReportTask) {}
task allDependenciesInsight(type: DependencyInsightReportTask) << {}
dependencies {
compile 'log4j:log4j:1.2.14'
compile 'org.eclipse.jdt:org.eclipse.jdt.annotation:2.0.+'
testCompile "junit:junit:4.+"
testCompile 'org.mockito:mockito-all:1.10.+'
}
task copyJars(type: Copy) << {
println "Copies artifacts from " + project.libsDir + " to " + project.rootDir + "."
from('$project.libsDir')
into('$project.rootDir')
}
}
task bamm(type: Copy) << {
description "Creates BAMM plugin."
println "Creates BAMM plugin."
println "Copies artifacts from " + project.libsDir + " to " + gradle.bammDir
from(project.libsDir)
into(gradle.bammDir)
}
bamm.dependsOn ':camm-server:jar', ':camm-server:copyJars'
project(':camm-shared') {
dependencies {
compile 'joda-time:joda-time:1.5.2'
compile 'org.springframework:spring:2.5.6.+'
compile files ('../lib/MarketInterface.jar')
}
}
project(':camm-client') {
dependencies {
compile 'org.jfree:jfreechart:1.0.+'
compile project(':camm-shared')
}
}
project(':camm-server') {
dependencies {
compile 'org.jibx:jibx-run:1.2.+'
compile project(':camm-client')
compile project(':camm-shared')
testCompile files ('../lib/MarketInterface.jar')
testCompile project(':camm-shared').sourceSets.test.output
}
}
task wrapper(type: Wrapper) {
gradleVersion = '2.8'
}
I can run the bamm task but it never copies anything. 我可以运行bamm任务,但是它从不复制任何内容。
My goal is to build all necessary jars (which works) and to copy all of the jars created from my projects to the gradle.bammDir
. 我的目标是构建所有必需的jar(起作用)并将从我的项目创建的所有jar复制到gradle.bammDir
。
from
and into
does not work when added in an action ( <<
). 当添加到动作 ( <<
)中时, from
和into
不起作用。 It should be: 它应该是:
task bamm(type: Copy) {
description "Creates BAMM plugin."
println "Creates BAMM plugin."
println "Copies artifacts from " + project.libsDir + " to " + gradle.bammDir
from(project.libsDir)
into(gradle.bammDir)
}
or: 要么:
task bamm << {
description "Creates BAMM plugin."
println "Creates BAMM plugin."
println "Copies artifacts from " + project.libsDir + " to " + gradle.bammDir
copy {
from(project.libsDir)
into(gradle.bammDir)
}
}
Please read about configuration and execution phase - it's crucial to understand how gradle works. 请阅读有关配置和执行阶段的信息-了解gradle的工作方式至关重要。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.