我有以下自定义配置和工件出版物,我希望将其包括进来,因为它是一个单独的项目。我该怎么办?
(当前使用gradle 5.3)
这是我对tlib的自定义配置
sourceSets {
val main by getting
val tlib by creating {
compileClasspath += main.output
runtimeClasspath += main.output
}
val test by getting {
compileClasspath += tlib.output
runtimeClasspath += tlib.output
}
}
configurations {
val tlibCompile by getting {
extendsFrom(configurations["implementation"])
}
}
publishing {
publications {
val tlibJar by tasks.registering(Jar::class) {
from(sourceSets["tlib"].output)
}
val tlibSourcesJar by tasks.registering(Jar::class) {
archiveClassifier.set("sources")
from(sourceSets["tlib"].allSource)
}
register("mavenTLib", MavenPublication::class) {
artifactId = "phg-entity-tlib"
artifact(tlibJar.get())
artifact(tlibSourcesJar.get())
}
}
}
目前,这是我在组合中导入子项目的方式
import org.slf4j.LoggerFactory
rootProject.name = "predictive-health-service-app"
val cwd = file(".")
var modules = file("./modules")
modules.mkdirs()
val log = LoggerFactory.getLogger("settings.gradle")!!
modules.listFiles { file ->
log.debug("dir: {}", file)
val match = file.isDirectory && file.listFiles { _, n ->
log.debug("{}/{}", file.name, n)
n.startsWith("settings.gradle")
}.isNotEmpty()
if (match) {
log.info("found module :{}", file.name)
}
match
}.forEach {
includeBuild("modules/" + it.name)
}
我的某些模块就这样依赖它
testImplementation("${project.group}:phg-entity-tlib:[0.8.5,0.9)")
所以我需要替换它,但是如何将其作为自定义配置/独立工件呢?