vert-x3 / vertx-docgen

Documentation generation
Apache License 2.0
23 stars 11 forks source link

Is there a version for Gradle around? #15

Closed aschrijver closed 8 years ago

aschrijver commented 8 years ago

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

sczyh30 commented 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.

aschrijver commented 8 years ago

Thanks a bunch! Exactly what I was looking for :+1:

aschrijver commented 8 years ago

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"
}
sczyh30 commented 8 years ago

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 :-)

aschrijver commented 8 years ago

Cross-post, sorry.

aschrijver commented 8 years ago

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.

sczyh30 commented 8 years ago

The classpath in task docProcessing should also be changed:

classpath = configurations.compile + configurations.compileOnly
aschrijver commented 8 years ago

Ah, you're right. Thanks again!!

aschrijver commented 8 years ago

Still get warning: The following options were not recognized by any processor: '[docgen.source]'.

vietj commented 8 years ago

fancy doing a PR for the example with gradle in test-proj ?

vietj commented 8 years ago

never mind there is one

aschrijver commented 8 years ago

@sczyh30 Do you get aforementioned warning, or did I overlook something?

sczyh30 commented 8 years ago

@aschrijver Yes, I've also got the same warning... What's wrong with it?

aschrijver commented 8 years ago

Seems like something doesn't work as it should..

vietj commented 8 years ago

can you provide a reproducer @aschrijver ?

aschrijver commented 8 years ago

Yes, ./gradlew clean build this project and you should see it: https://github.com/engagingspaces/vertx-dataloader/commit/92249437eb5db4bb562c54fd7d1a35398be60914