Closed aschrijver closed 8 years ago
Hi, docgen in fact is an annotation processor so you can use it in Gradle by providing processor compilerArgs
. An example build.gradle
for the given test_proj example in the project:
plugins {
id 'java'
}
version '1.0-SNAPSHOT'
ext {
vertxVersion = "3.3.2"
}
repositories {
jcenter()
}
task docProcessing(type: JavaCompile, group: 'build') {
source = sourceSets.main.java
classpath = configurations.compile
destinationDir = project.file('src/main/asciidoc')
options.compilerArgs = [
"-proc:only",
"-processor", "io.vertx.docgen.JavaDocGenProcessor",
"-Adocgen.output=${project.buildDir}/asciidoc",
"-Adocgen.source=${project.projectDir}/src/main/asciidoc/doc.adoc"
]
}
compileJava {
targetCompatibility = 1.8
sourceCompatibility = 1.8
dependsOn docProcessing
}
dependencies {
compile("io.vertx:vertx-docgen:${vertxVersion}")
}
The task docProcessing
is responsible for generating docs.
Thanks a bunch! Exactly what I was looking for :+1:
Would be nice to add this piece of information to the README. Could you PR (I can too, if you lack the time)?
One more thing: Presumably this can be improved by adding docgen dependency to provided
scope, so the docgen does not end up in your shipped runtime.
I will try with compile-only and let you know:
dependencies {
compileOnly "io.vertx:vertx-docgen:$vertxVersion"
}
Yes, I'll make a PR to add examples about Gradle.
Using provided
scope is a good idea and Gradle start supporting compile time only dependencies (compileOnly
) from Gradle 2.12 (see here) so I think we can use the original compileOnly
scope here :-)
Cross-post, sorry.
Just changing to compileOnly
does not seem to work out of the box:
error: Annotation processor 'io.vertx.docgen.JavaDocGenProcessor' not found
warning: Annotation processing without compilation requested but no processors were found.
Will check later, going for compile
for now.
The classpath
in task docProcessing
should also be changed:
classpath = configurations.compile + configurations.compileOnly
Ah, you're right. Thanks again!!
Still get warning: The following options were not recognized by any processor: '[docgen.source]'
.
fancy doing a PR for the example with gradle in test-proj
?
never mind there is one
@sczyh30 Do you get aforementioned warning, or did I overlook something?
@aschrijver Yes, I've also got the same warning... What's wrong with it?
Seems like something doesn't work as it should..
can you provide a reproducer @aschrijver ?
Yes, ./gradlew clean build
this project and you should see it: https://github.com/engagingspaces/vertx-dataloader/commit/92249437eb5db4bb562c54fd7d1a35398be60914
Nice project, this one! I would like to use it with Gradle. Are you aware of any versions doing that? For
javadoc to asciidoc
I found this as well https://github.com/asciidoctor/asciidoclet