我正在尝试创建具有自定义主要工件的Java库。 我遵循了这个https://otmgtm-test-ejzc.otm.em2.oraclecloud.com/GC3/glog.webserver.rate.RateOfferingManagementServlet,但是问题是当我运行“发布”任务时,出现此错误。
Could not determine the dependencies of task ':publishMavenPublicationToMyRepoRepository'.
> Task with path 'rpm' not found in root project 'commons'.
这是我的gradle文件:
import com.netflix.gradle.plugins.rpm.Rpm
plugins {
`java-library`
`maven-publish`
id("nebula.ospackage") version "7.4.1"
kotlin("jvm") version "1.3.50"
}
group = "com.test"
version = "1.0.0"
java.sourceCompatibility = JavaVersion.VERSION_1_8
repositories {
mavenCentral()
}
dependencies {
implementation("javax.xml.bind:jaxb-api:2.3.1")
implementation("io.jsonwebtoken:jjwt:0.9.1")
implementation("com.googlecode.libphonenumber:libphonenumber:8.10.14")
implementation("com.fasterxml.jackson.module:jackson-module-kotlin:2.9.9")
}
tasks.withType<Rpm> {
version = "1.0.0"
release = "1"
packageName = "com.test.commons"
into("$buildDir/rpms/com.test.commons.rpm")
}
val rpmFile = file("$buildDir/rpms/com.test.commons.rpm")
val rpmArtifact = artifacts.add("archives", rpmFile) {
type = "rpm"
builtBy("rpm")
}
publishing {
publications {
create<MavenPublication>("maven") {
artifact(rpmArtifact)
}
}
repositories {
maven {
name = "myRepo"
url = uri("file://${buildDir}/repo")
}
}
}
我认为问题出在rpm任务中,我该如何解决?
答案 0 :(得分:0)
rpm
任务类型可与nebula.rpm
插件一起使用,如Wiki here
plugins {
id("nebula.ospackage") version "7.4.1"
id("nebula.rpm") version "7.4.1"
}
不熟悉此插件,但是应用nebula.ospackage
看起来并不足够。
答案 1 :(得分:0)
nebula.ospackage
插件将创建类型为buildRpm
的名为com.netflix.gradle.plugins.rpm.Rpm
的任务。
在脚本中,您使用名称rpm
引用了一个任务,该任务不存在:这说明了您遇到的错误(> Task with path 'rpm' not found in root project 'commons'.
)
只需更新脚本以使用正确的任务名称即可:
val rpmArtifact = artifacts.add("archives", rpmFile) {
type = "rpm"
builtBy("buildRpm") // <=== instead of "rpm"
}
注意:您不必应用插件nebula.rpm
,nebula.ospackage
就足够了。