Closed nkoterba closed 9 years ago
So I've figured out a solution. It's definitely an issue with the Gradle JavaDocTask plugin not really providing any means to pass an "array" of values into a JavaDoc options property.
NOTE, sadly, there is no easy options.addXXX(name, array) method on the JavaDocOptions class.
Here is what I tried:
options.addStringsOption("excludeResourcePrefixes").setValue([
"com.me.server.rest.administration",
"com.me.server.rest.workspace"
])
Creates:
-excludeResourcePrefixes 'com.me.server.rest.administration:com.me.server.rest.workspace'
Won't work b/c we need items to be separated and also not wrapped as a single string (e.g. '').
Next:
options.addStringsOption("excludeResourcePrefixes", " ").setValue([
"com.me.server.rest.administration",
"com.me.server.rest.workspace"
])
This produces:
-excludeResourcePrefixes 'com.me.server.rest.administration com.me.server.rest.workspace'
Still not right. What we really need is:
-excludeResourcePrefixes com.me.server.rest.administration com.me.server.rest.workspace
Unfortunately, the only thing I could get to work was:
options.addMultilineStringsOption("excludeResourcePrefixes").setValue([
"com.me.server.rest.administration",
"com.me.server.rest.workspace"
])
This produced:
-excludeResourcePrefixes 'com.me.server.rest.administration'
-excludeResourcePrefixes 'com.me.server.rest.workspace'
While not ideal, it does work because luckily Swagger-Jaxrs-Doclet's DocletOptions.java
class will loop through all the options and will just add any duplicate options to the existing excludes collection versus overwriting it:
} else if (option[0].equals("-excludeResourcePrefixes")) {
parsedOptions.excludeResourcePrefixes.addAll(asList(copyOfRange(option, 1, option.length)));
Really, it would be nice if the Gradle team exposed a method to allow setting or passing an array of values for an option instead of methods that turn the array into a single string, but at least for my current needs the solution posted above works.
I posted this issue/question at the Gradle forums: https://discuss.gradle.org/t/corejavadocoptions-cannot-set-array-of-values-for-option-property/9820
Based on a response from the Gradle team: https://discuss.gradle.org/t/corejavadocoptions-cannot-set-array-of-values-for-option-property/9820
It sounds like one way to accomplish the above is:
options.addStringsOption('excludeResourcePrefixes', "' '").setValue(['com.me.server.rest.administration', 'com.me.server.rest.workspace'])
which produces:
-excludeResourcePrefixes 'com.me.server.rest.administration' 'com.me.server.rest.workspace'
As such, I'm closing this issue...I don't necessarily like the "method" gradle suggests, but it does work. It's just not very intuitive.
I've noticed that in
DocletOptions.java
many of the options accept an array of items, e.g.:However, I'm having difficulty passing a list of resources to exclude. I'm using gradle and trying to do this:
I've spent ~3 hours now trying to figure out the correct syntax (do I use [], do I use spaces, etc.). I've looked at the JavaDocOptions classes and it looks like
addStringOption
is the correct method.According to the documentation on JavaDoc's RootDoc class:
Thus I assumed that just space-separating my list of classes to exclude would work. However, when I put a print statement in the
DocletOptions.java
class, I get the following output: Code in DocletOptions.java:Result is:
Thus, the value is not being turned into an array of String values and the AddAll method below adds an invalid string.
I believe the options object (string[][]) used in DocletOptions is coming directly from JavaDoc source and via the Gradle JavaDocTask so I'm worried this may be an error somewhere other than the swagger-jaxrs-doclet.
Has anybody been able to successfully pass an array of values to any of this Doclet's plugins?
My fallback is to use the @hidden or @exclude JavaDoc annotations but we have lots of classes to exclude and this could get tedious really fast.