Excluding aidl generated source in Javadoc

We are using gradle to build javadoc of our project. (Among other things.)
The sources generated by aidl seems to contain javadoc errors, so we tried to exclude them with '**/aidl/**" exclusion. Unfortunately the warnings still remain in the output, which causes build failure.

Shouldn’t those warnings be suppressed by adding the relevant exclude?

Can you give the path of an example file you’d like to exclude?

Perhaps you should be excluding '**/aidl/*'

Thank you for your response, and your suggestion.

An example path would be something like: “./lib/aeroDroid/build/generated/source/aidl/debug/aero/glass/backgroundservice/aidl/IRemote.java”

As per your suggestion, I have tried excluding '/aidl/*’ instead of "/aidl/**" but the warnings were still present. Which is unfortunate, I was really hoping that you will be right, and it’s just that simple. :slight_smile:

I have tried excluding ‘/aidl/*’ instead of “/aidl/**”

I suggested to try '**/aidl/*'

Sorry, yes. The mistake was only when copying the exclude here. The full line we tried is:
excludes = [’/aidl/*’, '/aero/glass/**’]

we added the ‘/aero/glass/’ part so we can verify that the exclude is picked up. And as we expected all the aero.glass.* classes are missing from the generated javadoc, but the aidl warnings are still present.

What we were thinking: Is it possible that somehow the exclusion filter application happens before the aidl file generation? Or that’s not likely?

Thank you for you help.

Please post the relevant section in your build.gradle.

class AeroGlassAggregateJavadocPlugin implements Plugin<Project> {
    static final String AGGREGATE_JAVADOCS_TASK_NAME = 'aggregateJavadocs'

    void apply(Project project) {
        Project rootProject = project.rootProject
        rootProject.gradle.projectsEvaluated {
            Set<Project> subprojectsWithJavadoc = getSubprojectsWithJavadoc(rootProject)
            if (!subprojectsWithJavadoc.isEmpty()) {
                rootProject.task(AGGREGATE_JAVADOCS_TASK_NAME, type: Javadoc) {
                    description = 'Aggregates Javadoc API documentation of all subprojects.'
                    group = JavaBasePlugin.DOCUMENTATION_GROUP
                    dependsOn subprojectsWithJavadoc.javadoc

                    source subprojectsWithJavadoc.javadoc.source
                    destinationDir rootProject.file("$rootProject.buildDir/docs/javadoc")
                    classpath = rootProject.files(subprojectsWithJavadoc.javadoc.classpath)

                    excludes = ['**/aidl/*', '**/aero/glass/**']

    private Set<Project> getSubprojectsWithJavadoc(Project rootProject) {
        rootProject.subprojects.findAll { subproject -> ( subproject.getTasks().findByPath("javadoc")!=null ) }
apply plugin: AeroGlassAggregateJavadocPlugin

It’s a modified version of this plugin: https://github.com/nebula-plugins/gradle-aggregate-javadocs-plugin

Looks like it should work to me. Perhaps try

source subprojectsWithJavadoc.javadoc.source.matching {
   exclude '**/aidl/**' 
   exclude '**/aero/glass/**'

I can’t see it being any different but worth a try

I tried your code. Thank you very much for your suggestion. I substituted the line “source subprojectsWithJavadoc.javadoc.source” in the above code with your suggestion. Is that where I should have put this?

I got this error:

  • Where:
    Script ‘/Users/Shared/Jenkins/Home/workspace/aeroglass-branch-javadoc/gradle/aggregateJavadocs.gradle’ line: 21

  • What went wrong:
    No signature of method: java.util.ArrayList.matching() is applicable for argument types: (AeroGlassAggregateJavadocPlugin$_apply_closure1_closure3_closure4) values: [AeroGlassAggregateJavadocPlugin$_apply_closure1_closure3_closure4@60c69660]

Did I copy something wrong maybe?

Is that where I should have put this?


Try this instead

subprojectsWithJavadoc.each { subproject ->
   source subproject.javadoc.source.matching {
      exclude '**/aidl/**' 
      exclude '**/aero/glass/**'

Thank you. Now this runs, but the warnings are still present. Is that possible?

Sorry… I think I skimmed through the javadoc aggregation implementation and didn’t fully understand how it worked.

Looking at it again it looks like you configure a task named “javadoc” in one or more subprojects. Then you have a task named “aggregateJavadocs” in the root project which generates javadoc for all of the subprojects. Correct?

If you want to avoid warnings in the subtasks, you’ll need to specify an exclude for **/aidl/** in each of the subprojects.

This can either be done in each subproject’s “javadoc” task declaration or can be done once in the root project via a subprojects { ... } closure

Thank you! This did it.

Sorry to bother you.