我的build.gradle当前是:
project(':rss-middletier') {
apply plugin: 'java'
dependencies {
compile project(':rss-core')
compile 'asm:asm-all:3.2'
compile 'com.sun.jersey:jersey-server:1.9.1'
compile group: 'org.javalite', name: 'activejdbc', version: '1.4.9'
}
jar {
from(configurations.compile.collect { it.isDirectory() ? it : zipTree(it) }) {
exclude "META-INF/*.SF"
exclude "META-INF/*.DSA"
exclude "META-INF/*.RSA"
}
manifest { attributes 'Main-Class':
'com.netflix.recipes.rss.server.MiddleTierServer' }
}
}
但是,与其将这些编译后的类直接包装到jar中,不如通过运行以下任务首先对其进行检测:
task instrument(dependsOn: 'build', type: JavaExec) {
main = 'org.javalite.instrumentation.Main'
classpath = buildscript.configurations.classpath
classpath += project(':rss-middletier').sourceSets.main.runtimeClasspath
jvmArgs '-DoutputDirectory=' + project(':rss-middletier').sourceSets
.main.output.classesDir.getPath()
}
只有在我检测了这些类之后,我才想将它们打包到一个JAR文件中。有没有一种方法可以使我在包装之前进行此检测?
非常感谢!!!
终于想出了办法!
task instrument(type: JavaExec) {
//your instrumentation task steps here
}
compileJava.doLast {
tasks.instrument.execute()
}
jar {
//whatever jar actions you need to do
}
希望这可以防止其他人在几天内陷入这个问题:)
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句