ZmtJavadocPlugin.groovy 1.65 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
package de.zmt.gradle;

import org.gradle.api.*
import org.gradle.external.javadoc.JavadocOfflineLink
import org.gradle.plugins.ide.eclipse.model.ProjectDependency

/*
 * Plugin for adding links to dependency projects to javadoc task
 * <p>
 * Also adds a task to deploy javadoc files.
 */
class ZmtJavadocPlugin implements Plugin<Project> {
    private static final def CONFIGURE = {
        apply plugin: be.jlrhome.gradle.plantuml.PlantumlPlugin
        // use svg instead of the default (png)
        plantuml.fileFormat = net.sourceforge.plantuml.FileFormat.SVG

18 19 20
        javadoc {
            ext.targetPath = 'javadoc/' + project.name
            options.links << 'http://docs.oracle.com/javase/8/docs/api/'
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
        }

        task('deployJavadoc') {
            dependsOn 'javadoc', 'determineCredentials'
            group = 'Upload'
            description = 'Uploads javadoc files to dochost.'
        }

        deployJavadoc.doLast {
            println "\nConnecting to ${remotes.dochost.host}..."
            ssh.run {
                session(remotes.dochost) {
                    def remoteTargetDir = determineCredentials.wwwPath + javadoc.targetPath
                    
                    // create and clean target directory on remote
                    execute "mkdir -p ${remoteTargetDir}"
                    execute "rm -rf ${remoteTargetDir}/*"
                    
                    javadoc.destinationDir.eachFile {
                        put from: it, into: remoteTargetDir
                    }
                }
            }
        }
    }

    @Override
    void apply(Project project) {
        project.configure(project, CONFIGURE)
    }
}