我已经使用java-library Gradle插件开发了一个Java库。这个库对protobuf-java有依赖,我需要将它作为传递依赖公开给该库的用户。
我的库的build.gradle中有以下代码片段
plugins {
id 'java-library'
id "maven-publish"
id "com.google.protobuf" version "0.8.16"
}
...
dependencies {
api ("com.google.protobuf:protobuf-java:3.17.3")
testImplementation("com.google.protobuf:protobuf-java-util:3.17.3")
testImplementation("org.junit.jupiter:junit-jupiter-api:5.7.2")
testImplementation("org.junit.jupiter:junit-jupiter-engine:5.7.2")
}运行gradlew dependencies会得到以下预期的结果
api - API dependencies for source set 'main'. (n)
\--- com.google.protobuf:protobuf-java:3.17.3 (n)但是当我将库作为依赖添加到我的主应用程序中时,我没有得到任何可传递的依赖关系。在我的主应用程序中执行gradlew dependencies会给我带来:
compileClasspath - Compile classpath for source set 'main'.
+--- my-library:my-library:1.0.21
+--- javax.jms:javax.jms-api -> 2.0.1
....依赖项没有出现在主应用程序中的原因可能是什么?
发布于 2021-06-21 13:56:49
问题出在maven-publish插件上。
我不得不将以下内容添加到我的publishing部分以使其正常工作。
publications {
mavenJava(MavenPublication) { from project.components.java }
}https://stackoverflow.com/questions/68062875
复制相似问题