Skip to content

Commit 832eb53

Browse files
author
Justin Ryan
committed
Automatically aggregate and publish docs (java,groovy,scala)
1 parent 498c25f commit 832eb53

File tree

2 files changed

+29
-5
lines changed

2 files changed

+29
-5
lines changed

gradle/buildscript.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,5 @@ dependencies {
77
classpath 'nl.javadude.gradle.plugins:license-gradle-plugin:0.6.1'
88
classpath 'com.mapvine:gradle-cobertura-plugin:0.1'
99
classpath 'gradle-release:gradle-release:1.1.4'
10+
classpath 'org.ajoberstar:gradle-git:0.5.0'
1011
}

gradle/convention.gradle

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -63,11 +63,34 @@ subprojects { project ->
6363
}
6464
}
6565

66-
task aggregateJavadoc(type: Javadoc) {
67-
description = 'Aggregate all subproject docs into a single docs directory'
68-
source subprojects.collect {project -> project.sourceSets.main.allJava }
69-
classpath = files(subprojects.collect {project -> project.sourceSets.main.compileClasspath})
70-
destinationDir = new File(projectDir, 'doc')
66+
apply plugin: 'github-pages' // Used to create publishGhPages task
67+
68+
def docTasks = [:]
69+
[Javadoc,ScalaDoc,Groovydoc].each{ Class docClass ->
70+
def allSources = allprojects.tasks*.withType(docClass).flatten()*.source
71+
if (allSources) {
72+
def shortName = docClass.simpleName.toLowerCase()
73+
def docTask = task "aggregate${shortName.capitalize()}"(type: docClass, description: "Aggregate subproject ${shortName}s") {
74+
source = allSources
75+
doFirst {
76+
def classpaths = allprojects.findAll { it.plugins.hasPlugin(JavaPlugin) }.collect { it.sourceSets.main.compileClasspath }
77+
classpath = files(classpaths)
78+
}
79+
}
80+
docTasks[shortName] = docTask
81+
processGhPages.dependsOn(docTask)
82+
}
83+
}
84+
85+
githubPages {
86+
repoUri = "[email protected]:quidryan/${rootProject.githubProjectName}.git"
87+
pages {
88+
docTasks.each { shortName, docTask ->
89+
from(docTask.outputs.files) {
90+
into "docs/${shortName}"
91+
}
92+
}
93+
}
7194
}
7295

7396
// Generate wrapper, which is distributed as part of source to alleviate the need of installing gradle

0 commit comments

Comments
 (0)