I have a gradle multi-module project and I did realise if I execute gradle javadoc it generates the javadoc individually for each module. Well I don’t want that.
I did a research on Google and I got the following:
[GRADLE-1876: Aggregation of javadocs in muli-project build is cumbersome](https://issues.gradle.org/browse/GRADLE-1876) It does not work for me, nothing is generated
I have tried the third approach with the following (included within subproject {...} and I have the apply plugin: 'java' declared too within subproject {...}):
But when in my STS IDE I do right click in my project and Gradle -> Refresh Gradle Project I always get:
Caused by: groovy.lang.MissingPropertyException: Could not find property 'sourceSets' on project ':web-27-domain'.
at org.gradle.api.internal.AbstractDynamicObject.propertyMissingException(AbstractDynamicObject.java:43)
at org.gradle.api.internal.AbstractDynamicObject.getProperty(AbstractDynamicObject.java:35)
at org.gradle.api.internal.CompositeDynamicObject.getProperty(CompositeDynamicObject.java:97)
at org.gradle.api.internal.project.DefaultProject_Decorated.getProperty(Unknown Source)
....
Therefore:
How I can fix the error thrown above? (What is missing or what is need it?)
Currently for July 2016, what is the best and recommended approach
(from Gradle itself) to accomplish the generation of just one javadoc merging all the sub modules?.
The sourceSets property is contributed to the object model by the java plugin.
I would assume that the domain projects does not have the java plugin applied at the time you are configuring the alljavadoc task. An easy fix is to configure the task in afterEvaluate { ... } block.
Overall looks alright. It would be useful if you could share a complete runnable example. In this case the subprojects { ... } block is not closed, so can’t really figure what follows what.
And always the second item of the collection fails and it does not go forward anymore…
Caused by: groovy.lang.MissingPropertyException: Could not find property 'sourceSets' on project ':web-27-controller'.
at org.gradle.api.internal.AbstractDynamicObject.propertyMissingException(AbstractDynamicObject.java:43)
at org.gradle.api.internal.AbstractDynamicObject.getProperty(AbstractDynamicObject.java:35)
at org.gradle.api.internal.CompositeDynamicObject.getProperty(CompositeDynamicObject.java:97)
at org.gradle.api.internal.project.DefaultProject_Decorated.getProperty(Unknown Source)
You are currently adding an alljavadoc task to every single child project. When you add it to the first project, the second project hasn’t been configured yet, which means that its java plugin has not been applied yet, hence it doesn’t have sourceSets.
The fix would be to take alljavadoc out of the subprojects { ... } block.
Yes, it is my latest resource or option, but I want use something by default or nothing external yet.
It in case that plugin close or something related…
I notice you stopped applying the java plugin to the subprojects. Your original setup was good - the only thing needed was to take the alljavadoc task definition and put it below the subprojects section.
I notice you stopped applying the javadoc plugin to the subprojects.
Yes, I thought was illegal have the apply plugin: 'java' twice
Even when I enable apply plugin: 'java' in subprojects{} all remains the same.
Now according with your suggestion/observation:
the only thing needed was to take the alljavadoc task definition and put it below the subproject section
Yes, now works now… thanks so much! …
Even when I am not an expert with Gradle
(1) Now I am wondered why this change of location was mandatory, I thought that for a task its location does not matter, it for a single module project. I never had some issue about this situation, but now seems that for a multi-module now has consequences.
(2) The code works fine even if I have commented apply plugin: 'java' in subprojects{}, what do you suggest? I don’t know if it has a negative consequence if is declared twice, but apply plugin: 'java' is mandatory in the root level of the build.gradle file. First time I have this situation.
BTW, I have assumed that subprojects{} in some wayinherits the apply plugin: 'java'
I can generate the javadoc for all the modules in one location, but I did realize the javadoc generated has the following format:
public class Persona
extends java.lang.Object
implements java.io.Serializable
or
public class JsonDateSerializer
extends com.fasterxml.jackson.databind.JsonSerializer<java.util.Date>
the extension and implements should be really links, I mean the normal is have something like the following (see each link for a better understanding):
(1) Now I am wondered why this change of location was mandatory, I thought that for a task its location does not matter, it for a single module project. I never had some issue about this situation, but now seems that for a multi-module now has consequences.
Well, in the end Gradle evaluates Groovy scripts that build an object graph. Most of the DSL is designed to be late bound (i.e. you express dependencies by create rules, rather than modifying data).
Because the project structure is frozen the moment settings.gradle is evaluated, the subprojects section merely spins a loop and applies the code within the block to every subproject. For comparison, other sections (in particular all and withType sections) will apply the block to any applicable targets and any future targets that will match that predicate.
In this case though you used plain Groovy to collect the all sourceSets present at the moment you configure the task.
Thet’s why the configuration of alljavadocs has to be in program order after than the application of the java plugin.
Please note that imperative code like this is somewhat poor style, but is acceptable if you know what you are doing and just need to get the job done. I would assume that the plugin suggested by @bmuschko would set proper rules, and then you would be able to reorder without consequences.
(2) The code works fine even if I have commented apply plugin: ‘java’ in subprojects{}, what do you suggest? I don’t know if it has a negative consequence if is declared twice, but apply plugin: ‘java’ is mandatory in the root level of the build.gradle file. First time I have this situation.
In general, a well written plugin is idempotent - that is it can be applied multiple times without changing the build. Also, Gradle encourages plugin composition - i.e. if you use the war plugin, I would expect it to automatically apply java. You need to apply the Java plugin only if you have Java code in that project.
In your Javadoc task, options.memberLevel is an example of configuring one of these options. Another option available is link, which allows you to specify the URLs of external Javadocs to use.
Not necessarily, it just depends on whether you prefer the syntax that calls the links method vs. the setLinks method.
If you want to set options.links using the = operator, which calls the setter, you must use ‘’ because the setter requires a List.
If you call the options.links method (without using the = operator), you’ll call a method that takes a varargs String. This method can be called many times with one or more arguments if desired.