所以我解决了这个问题,在这个过程中,终于学会了一些 gradle 基础知识(来自 maven 背景)。毫无疑问,以下内容是不雅的,可以更好地概括 - 但它有效!
TLDR:shadowJar
假设
解决方案
1。添加shadowJar 参考
在根build.gradle 文件中添加以下内容
classpath 'com.github.jengelman.gradle.plugins:shadow:2.0.2'
到buildscriptdependencies:
buildscript {
// ...
dependencies {
// ...
classpath 'com.github.jengelman.gradle.plugins:shadow:2.0.2'
}
}
2。将shadowJar 任务添加到cordapp
在cordapp 项目中,应用shadowJar 插件。
请注意:我需要把它放在所有现有插件之前才能工作。
apply plugin: 'com.github.johnrengelman.shadow'
apply plugin: 'kotlin'
// ... etc
然后添加调用参数化:
tasks {
shadowJar {
mergeServiceFiles()
// Place your shaded packages here!
relocate 'io.netty', 'shadow.io.netty'
relocate 'com.fasterxml', 'shadow.com.fasterxml'
configurations = [project.configurations.compile]
baseName = jar.baseName + "-" + jar.version
classifier = null
version = null
dependencies {
include(dependency(".*:.*:.*"))
exclude(dependency('org.jetbrains.kotlin:.*:.*'))
exclude(dependency('net.corda:.*:.*'))
exclude(dependency('org.apache.logging.*:.*:.*'))
exclude(dependency('org.apache.activemq:.*:.*'))
exclude(dependency('com.google.*:.*:.*'))
exclude(dependency('io.reactivex:.*:.*'))
exclude(dependency('org.bouncycastle.*:.*:.*'))
exclude(dependency('org.glassfish.*:.*:.*'))
exclude(dependency('co.paralleluniverse.*:.*:.*'))
exclude(dependency('co.paralleluniverse.*:.*:.*'))
exclude(dependency('com.typesafe.*:.*:.*'))
exclude(dependency('com.esotericsoftware.*:.*:.*'))
exclude(dependency('org.qpid.*:.*:.*'))
}
}
}
3。更改构建依赖项
现在将deployNodes 的定义更改为不依赖于jar 任务,而是依赖于每个模块的构建:
task deployNodes(type: net.corda.plugins.Cordform, dependsOn: [':cordapp-contracts-states:jar', ':cordapp:shadowJar']) {
// ... etc
}