Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using with gradle #8

Open
laxika opened this issue May 28, 2018 · 8 comments
Open

Using with gradle #8

laxika opened this issue May 28, 2018 · 8 comments
Labels
bug Something isn't working help wanted Extra attention is needed

Comments

@laxika
Copy link

laxika commented May 28, 2018

Hello guys,

Can I use this plugin with Gradle? If yes then how?

Thanks!

@rahuljain1804
Copy link

+1

@anesterkina
Copy link

anesterkina commented Jun 28, 2018

Hi guys,

There's an issue with gradle. The default javadoc task always sets the -d option (output directory for the standard javadoc doclet). However, the custom springfox-javadoc doclet does not recognize that option and instead uses the -classdir option to set the output directory. So your task will always pass the -d option to the custom doclet, but the doclet won't work because of the unrecognized option.

A managed to write a task whith a workaround that works whith gradle 3.3, but it results in error in gradle 4.8.

task javadoc2swagger(type: Javadoc , dependsOn: compileJava ) {
    source = sourceSets.main.allJava
    classpath = sourceSets.main.compileClasspath
    options.doclet = "springfox.javadoc.doclet.SwaggerPropertiesDoclet"
    options.addStringOption("classdir", "${sourceSets.main.output.resourcesDir}")
    options.addStringOption("exceptionRef", "true")
    options.encoding("UTF8")

    //workaround not to pass default options
    title = null
    options.addStringOption("d", null)

    doFirst {
        options.docletpath = configurations.springfoxJavadoc.files.asList()
    }
}

jar.dependsOn(javadoc2swagger)

For newer versions of gradle I guess you'll need to use an ant task to get the doclet to work.

To get the doclet to work properly with newer versions of gradle, it would be better to use the -d option instead of -classdir or at least to recognize the -d option and simply ignore it.

@dilipkrish
Copy link
Member

Thanks for the hint @AnnaNesterkina. Ill try to update the readme with instructions.

@anesterkina
Copy link

@dilipkrish as I mentioned, this code doesn't work with newer versions of gradle. What do you think about making it possible to pass the output dir via -d option (it's set via destinationDir in gradle and destDir in maven). Spring Auto Rest Docs does so, you can view their documentation ( https://htmlpreview.github.io/?https://github.com/ScaCap/spring-auto-restdocs/blob/v2.0.1/docs/index.html ). We can leave the classDir option for backwards compatibility. I am willing to submit a pull request for this.

@rahuljain1804
Copy link

rahuljain1804 commented Jun 29, 2018

@AnnaNesterkina, @dilipkrish - I also made changes for the same. I think we should just created a PR and release a new version for the same. If you can give me permissions to create a PR, I can submit that

@dilipkrish
Copy link
Member

@AnnaNesterkina @rahuljain1804 would be great if either of you have a fix in mind for this.

@dilipkrish dilipkrish added bug Something isn't working help wanted Extra attention is needed labels Aug 12, 2018
@rahuljain1804
Copy link

@dilipkrish - Missed the notification. Saw this just now. I guess there is already one PR open for the issue which should fix it (however, it is not backward compatible). For now, I was using it by adding additional parameters for the newer versions of gradle. Let me know if that works. I can submit a PR for the same.

@dilipkrish
Copy link
Member

@rahuljain1804 thank for helping out, will definitely reach out if I have questions

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

4 participants