Javadoc task in 0.8

View: New views
4 Messages — Rating Filter:   Alert me  

Javadoc task in 0.8

by levi_h :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I'm trying to upgrade one of my projects from Gradle 0.7 to Gradle 0.8. The project has a number of subprojects, for which I'd like to generate combined Javadocs. At the moment, I have the following in my root build.gradle:

task apidocs(type: Javadoc, visible: false)  {
    destinationDir = new File(project.buildDir, 'docs/api')

    srcDirs = []
    options.links = ['http://java.sun.com/javase/6/docs/api/']

    subprojects.each {subproject ->
        subproject.sourceSets.each {sourceSet ->
            sourceSet.java.srcDirs.each {srcDir ->
                srcDirs << srcDir
            }
        }

        if (classpath) {
            classpath += subproject.configurations.apidocs
        } else {
            classpath = subproject.configurations.apidocs
        }

        if (subproject.hasProperty('apidocUrls')) {
            options.links += subproject.property('apidocUrls')
        }
    }
}


I have a couple of questions:

- in the 0.7 version, I used the options' classpath property, but that seems to be removed. My current approach seems a bit clumsy - is there a more elegant way?
- the build fails with the message No value has been specified for property 'optionsFile'. Is optionsFile intended to be required?

Thanks in advance,
  Levi

Re: Javadoc task in 0.8

by Adam Murdoch-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message



Levi Hoogenberg wrote:
I'm trying to upgrade one of my projects from Gradle 0.7 to Gradle 0.8. The project has a number of subprojects, for which I'd like to generate combined Javadocs. At the moment, I have the following in my root build.gradle:

task apidocs(type: Javadoc, visible: false)  {
    destinationDir = new File(project.buildDir, 'docs/api')

    srcDirs = []
    options.links = ['http://java.sun.com/javase/6/docs/api/']

    subprojects.each {subproject ->
        subproject.sourceSets.each {sourceSet ->
            sourceSet.java.srcDirs.each {srcDir ->
                srcDirs << srcDir
            }
        }

        if (classpath) {
            classpath += subproject.configurations.apidocs
        } else {
            classpath = subproject.configurations.apidocs
        }

        if (subproject.hasProperty('apidocUrls')) {
            options.links += subproject.property('apidocUrls')
        }
    }
}



The srcDirs property was replaced with the source property in 0.8. You could do something like:

subprojects.each {subproject ->
    subproject.sourceSets.each {sourceSet ->
        source sourceSet.allJava
    }
}

or, more concisely

source subprojects*.sourceSets*.allJava

I have a couple of questions:

- in the 0.7 version, I used the options' classpath property, but that seems to be removed. My current approach seems a bit clumsy - is there a more elegant way?

It was removed from the options. It was on the task and the options. Now it's just on the task.

To assemble the classpath, you could do something like:

classpath = files(subprojects*.configurations*.apidocs)

Another option would be to use a configuration to declare the classpath:

dependencies {
     subprojects.each {
         apidocs project(path: it.path, configuration: apidocs)
    }
}

javadoc {
    classpath = configurations.apidocs
}

- the build fails with the message No value has been specified for property 'optionsFile'. Is optionsFile intended to be required?


It shouldn't be - could you add a JIRA issue for this?


-- 
Adam Murdoch
Gradle Developer
http://www.gradle.org

Re: Javadoc task in 0.8

by levi_h :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Thanks for your help and suggestions.

The source subprojects*.sourceSets*.allJava form does not work - it causes the message Could not find property 'allJava' on SourceSet container. The foreach does work, so I'm fine with using that.

I created http://jira.codehaus.org/browse/GRADLE-686 for the options file issue.

Thanks again,
  Levi

On Wed, Oct 7, 2009 at 10:43 PM, Adam Murdoch <a@...> wrote:


Levi Hoogenberg wrote:
I'm trying to upgrade one of my projects from Gradle 0.7 to Gradle 0.8. The project has a number of subprojects, for which I'd like to generate combined Javadocs. At the moment, I have the following in my root build.gradle:

task apidocs(type: Javadoc, visible: false)  {
    destinationDir = new File(project.buildDir, 'docs/api')

    srcDirs = []
    options.links = ['http://java.sun.com/javase/6/docs/api/']

    subprojects.each {subproject ->
        subproject.sourceSets.each {sourceSet ->
            sourceSet.java.srcDirs.each {srcDir ->
                srcDirs << srcDir
            }
        }

        if (classpath) {
            classpath += subproject.configurations.apidocs
        } else {
            classpath = subproject.configurations.apidocs
        }

        if (subproject.hasProperty('apidocUrls')) {
            options.links += subproject.property('apidocUrls')
        }
    }
}



The srcDirs property was replaced with the source property in 0.8. You could do something like:


subprojects.each {subproject ->
    subproject.sourceSets.each {sourceSet ->
        source sourceSet.allJava
    }
}

or, more concisely

source subprojects*.sourceSets*.allJava


I have a couple of questions:

- in the 0.7 version, I used the options' classpath property, but that seems to be removed. My current approach seems a bit clumsy - is there a more elegant way?

It was removed from the options. It was on the task and the options. Now it's just on the task.

To assemble the classpath, you could do something like:

classpath = files(subprojects*.configurations*.apidocs)

Another option would be to use a configuration to declare the classpath:

dependencies {
     subprojects.each {
         apidocs project(path: it.path, configuration: apidocs)
    }
}

javadoc {
    classpath = configurations.apidocs

}

- the build fails with the message No value has been specified for property 'optionsFile'. Is optionsFile intended to be required?


It shouldn't be - could you add a JIRA issue for this?


-- 
Adam Murdoch
Gradle Developer
http://www.gradle.org


Re: Javadoc task in 0.8

by levi_h :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Apologies, the sourceSets*.allJava does work, I made a typo.

On Thu, Oct 8, 2009 at 9:55 PM, Levi Hoogenberg <levihoogenberg@...> wrote:
The source subprojects*.sourceSets*.allJava form does not work - it causes the message Could not find property 'allJava' on SourceSet container. The foreach does work, so I'm fine with using that.