用 gradle 发布 groovy 文档
publish groovy doc with gradle
我有一个项目,其中包含大约 50% Java 代码和 50% Groovy 我尝试发布到 Sonatype ossrh。发布快照进展顺利,但缺少文档 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 文档的语法如下:
publishing {
publications {
maven(MavenPublication) {
from components.java
artifact(groovydocJar) {
classifier = 'javadoc'
}
// etc...
}
}
}
我有一个项目,其中包含大约 50% Java 代码和 50% Groovy 我尝试发布到 Sonatype ossrh。发布快照进展顺利,但缺少文档 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 文档的语法如下:
publishing {
publications {
maven(MavenPublication) {
from components.java
artifact(groovydocJar) {
classifier = 'javadoc'
}
// etc...
}
}
}