Skip to content

Commit 6c86d4f

Browse files
author
Mark Perry
committed
Got Java 8 Javadoc working
1 parent 33af643 commit 6c86d4f

File tree

5 files changed

+83
-5
lines changed

5 files changed

+83
-5
lines changed

build.gradle

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11

2+
import org.apache.tools.ant.taskdefs.condition.Os
3+
24
defaultTasks 'build'
35

46
ext {
@@ -12,7 +14,10 @@ if (JavaVersion.current().isJava8Compatible()) {
1214
}
1315
}
1416

17+
1518
allprojects {
19+
20+
1621
ext {
1722
isSnapshot = true
1823
fjBaseVersion = "4.2"
@@ -43,4 +48,7 @@ allprojects {
4348

4449
subprojects {
4550

51+
52+
53+
4654
}

core/build.gradle

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ apply plugin: 'maven'
1515
//apply plugin: 'signing'
1616
apply plugin: 'retrolambda'
1717

18+
apply from: "$rootDir/lib.gradle"
19+
1820
defaultTasks 'build'
1921

2022
jar {
@@ -34,17 +36,19 @@ dependencies {
3436
testCompile "junit:junit:4.11"
3537
}
3638

39+
task javadoc(type: Javadoc, overwrite: true, dependsOn: "java8Javadoc") {
40+
}
3741

3842
retrolambda {
3943
jdk System.getenv("JAVA8_HOME")
4044
oldJdk System.getenv("JAVA7_HOME")
4145
javaVersion JavaVersion.VERSION_1_7
4246
}
4347

44-
//task javadocJar(type: Jar, dependsOn: javadoc) {
45-
// classifier = 'javadoc'
46-
// from "build/docs/javadoc"
47-
//}
48+
task javadocJar(type: Jar, dependsOn: java8Javadoc) {
49+
classifier = 'javadoc'
50+
from "build/docs/javadoc"
51+
}
4852

4953
task sourcesJar(type: Jar) {
5054
from sourceSets.main.allSource
@@ -53,7 +57,7 @@ task sourcesJar(type: Jar) {
5357

5458
artifacts {
5559
archives jar
56-
// archives javadocJar
60+
archives javadocJar
5761
archives sourcesJar
5862
}
5963

demo/build.gradle

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ buildscript {
1313
apply plugin: 'java'
1414
apply plugin: 'application'
1515
apply plugin: 'retrolambda'
16+
apply from: "$rootDir/lib.gradle"
1617

1718
defaultTasks 'build'
1819

@@ -27,6 +28,11 @@ repositories {
2728
mavenCentral()
2829
}
2930

31+
//task javadoc(type: Javadoc, overwrite: true, dependsOn: "java8Javadoc") {
32+
task javadoc(type: Javadoc, overwrite: true) {
33+
def t = createDynamicJavadoc("$projectDir", ["core"])
34+
dependsOn(t)
35+
}
3036

3137
retrolambda {
3238
jdk System.getenv("JAVA8_HOME")

java8/build.gradle

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,23 @@ buildscript {
1212
apply plugin: 'java'
1313
apply plugin: 'retrolambda'
1414

15+
apply from: "$rootDir/lib.gradle"
16+
1517
defaultTasks 'build'
1618

1719
repositories {
1820
mavenCentral()
1921
}
2022

23+
//task javadoc(type: Javadoc, overwrite: true, dependsOn: "java8Javadoc") {
24+
//}
25+
26+
task javadoc(type: Javadoc, overwrite: true) {
27+
def t = createDynamicJavadoc("$projectDir", ["core"])
28+
// dependsOn(":$t.name")
29+
dependsOn(t)
30+
}
31+
2132
retrolambda {
2233
jdk System.getenv("JAVA8_HOME")
2334
oldJdk System.getenv("JAVA7_HOME")

lib.gradle

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
2+
import org.apache.tools.ant.taskdefs.condition.Os
3+
4+
5+
String findCommand(String dir, String command) {
6+
def extension = Os.isFamily(Os.FAMILY_WINDOWS) ? ".exe" : ""
7+
def cmd = "$dir/$command$extension"
8+
if (! new File(cmd).exists()) {
9+
throw new Exception("Command $command not found in dir $dir")
10+
}
11+
cmd
12+
13+
}
14+
15+
String findJavaCommand(String s) {
16+
def jh = System.getenv("JAVA8_HOME")
17+
if (jh == null) {
18+
throw new Exception("Environment variable JAVA8_HOME not set")
19+
}
20+
findCommand("$jh/bin", "javadoc")
21+
}
22+
23+
List<String> projectClasses(List<String> list) {
24+
list.collect {
25+
// "$projectDir/../$it/src/main/java"
26+
"$projectDir/../$it/build/classes/main"
27+
}
28+
29+
}
30+
31+
def createDynamicJavadoc(String mainPath, List<String> paths) {
32+
def taskName = "dynamicJava8Javadoc"
33+
task "$taskName"(type: Exec) {
34+
def cp = projectClasses(paths).join(";")
35+
def c = findJavaCommand("javadoc")
36+
commandLine c, "-sourcepath", "$mainPath/src/main/java", "-d", "$mainPath/build/docs/javadoc", "-subpackages", "fj", "-Xdoclint:none", "-quiet", "-classpath", cp
37+
}
38+
project.tasks[taskName]
39+
}
40+
41+
ext {
42+
createDynamicJavadoc = this.&createDynamicJavadoc
43+
}
44+
45+
task java8Javadoc(type: Exec) {
46+
def c = findJavaCommand("javadoc")
47+
commandLine c, "-sourcepath", "$projectDir/src/main/java", "-d", "$buildDir/docs/javadoc", "-subpackages", "fj", "-Xdoclint:none", "-quiet"
48+
}
49+

0 commit comments

Comments
 (0)