问题描述
我有一个项目,其中包含大约 50% 的 Java 代码和 50% 的 Groovy,我尝试将其发布到 Sonatype ossrh。发布快照进展顺利,但缺少 docs jar(在本地发布和发布到 Sonatype Nexus 时)。我可以通过定义来创建组合的 groovy/java 文档:
groovydoc {
use = true
groovyClasspath = configurations.compile // http://issues.gradle.org/browse/GRADLE-1391
}
task groovydocJar(type: Jar,dependsOn: groovydoc ) {
classifier 'javadoc' // must use javadoc classifier to be able to deploy to Sonatype
from groovydoc.destinationDir
}
并运行 ./gradlew groovydocJar
可以毫无问题地生成预期的 -javadoc.jar。
我的问题是此文档 jar 未包含在发布任务中。
我尝试了以下
publishing {
publications {
maven(MavenPublication) {
from components.java
artifacts {
archives sourcesJar
archives groovydocJar
}
versionMapping {
usage('java-api') {
fromresolutionOf('runtimeClasspath')
}
usage('java-runtime') {
fromresolutionResult()
}
}
pom {
// omitted for brevity
}
}
}
}
... but e.g. `./gradlew publishToMavenLocal` publishes only the classes jar,the pom,a module and the sources jar.
No sign of a javadoc jar. I thought this was the idea of the artifacts section but maybe something is missing.
How can i tell the publishing task to include publishing of the groovydocs jar?
Gradle version is 6.8.3,jvm version is 1.8 and i depend on `compile 'org.codehaus.groovy:groovy-all:3.0.7'`
The complete build script is available here:
https://github.com/perNyfelt/ProjectDeployer/blob/main/build.gradle
解决方法
我想通了:
artifacts.archives 的方式不起作用。
添加groovy doc的语法是这样的:
@Configuation
@PropertySource({"classpath:application-google-prod.yaml})