Skip to content

Commit e33cc22

Browse files
Add packageJavadocForWeb task.
Note that javadoc for web only works using JDK 10+.
1 parent 91c5a31 commit e33cc22

File tree

3 files changed

+45
-19
lines changed

3 files changed

+45
-19
lines changed

objectbox-java-api/build.gradle

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,6 @@ version= rootProject.version
55

66
sourceCompatibility = 1.7
77

8-
javadoc {
9-
failOnError = false
10-
title = "ObjectBox API ${version} API"
11-
options.bottom = 'Available under the Apache License, Version 2.0 - <i>Copyright &#169; 2017-2020 <a href="http://objectbox.io/">ObjectBox Ltd</a>. All Rights Reserved.</i>'
12-
}
13-
148
task javadocJar(type: Jar, dependsOn: javadoc) {
159
classifier = 'javadoc'
1610
from 'build/docs/javadoc'

objectbox-java/build.gradle

Lines changed: 45 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,7 @@ dependencies {
2323
}
2424

2525
javadoc {
26-
failOnError = false
27-
title = "ObjectBox Java ${version} API"
28-
options.bottom = 'Available under the Apache License, Version 2.0 - <i>Copyright &#169; 2017-2020 <a href="http://objectbox.io/">ObjectBox Ltd</a>. All Rights Reserved.</i>'
29-
exclude("**/com/google/**")
26+
// Hide internal API from javadoc artifact.
3027
exclude("**/io/objectbox/Cursor.java")
3128
exclude("**/io/objectbox/KeyValueCursor.java")
3229
exclude("**/io/objectbox/ModelBuilder.java")
@@ -37,12 +34,40 @@ javadoc {
3734
exclude("**/io/objectbox/internal/**")
3835
exclude("**/io/objectbox/reactive/DataPublisherUtils.java")
3936
exclude("**/io/objectbox/reactive/WeakDataObserver.java")
37+
}
38+
39+
// Note: use packageJavadocForWeb to get as ZIP.
40+
// Note: the style changes only work if using JDK 10+.
41+
task javadocForWeb(type: Javadoc) {
42+
group = 'documentation'
43+
description = 'Builds Javadoc incl. objectbox-java-api classes with web tweaks.'
44+
4045
def srcApi = project(':objectbox-java-api').file('src/main/java/')
4146
if (!srcApi.directory) throw new GradleScriptException("Not a directory: ${srcApi}", null)
42-
source += srcApi
47+
// Hide internal API from javadoc artifact.
48+
def filteredSources = sourceSets.main.allJava.matching {
49+
exclude("**/io/objectbox/Cursor.java")
50+
exclude("**/io/objectbox/KeyValueCursor.java")
51+
exclude("**/io/objectbox/ModelBuilder.java")
52+
exclude("**/io/objectbox/Properties.java")
53+
exclude("**/io/objectbox/Transaction.java")
54+
exclude("**/io/objectbox/model/**")
55+
exclude("**/io/objectbox/ideasonly/**")
56+
exclude("**/io/objectbox/internal/**")
57+
exclude("**/io/objectbox/reactive/DataPublisherUtils.java")
58+
exclude("**/io/objectbox/reactive/WeakDataObserver.java")
59+
}
60+
source = filteredSources + srcApi
61+
62+
classpath = sourceSets.main.output + sourceSets.main.compileClasspath
63+
destinationDir = reporting.file("web-api-docs")
64+
65+
title = "ObjectBox Java ${version} API"
66+
options.bottom = 'Available under the Apache License, Version 2.0 - <i>Copyright &#169; 2017-2020 <a href="http://objectbox.io/">ObjectBox Ltd</a>. All Rights Reserved.</i>'
67+
4368
doLast {
4469
// Note: frequently check the vanilla stylesheet.css if values still match.
45-
def stylesheetPath = "$buildDir/docs/javadoc/stylesheet.css"
70+
def stylesheetPath = "$destinationDir/stylesheet.css"
4671

4772
// Primary background
4873
ant.replace(file: stylesheetPath, token: "#4D7A97", value: "#17A6A6")
@@ -68,6 +93,20 @@ javadoc {
6893
}
6994
}
7095

96+
task packageJavadocForWeb(type: Zip, dependsOn: javadocForWeb) {
97+
group = 'documentation'
98+
description = 'Packages Javadoc incl. objectbox-java-api classes with web tweaks as ZIP.'
99+
100+
archiveFileName = "objectbox-java-web-api-docs.zip"
101+
destinationDirectory = file("$buildDir/dist")
102+
103+
from reporting.file("web-api-docs")
104+
105+
doLast {
106+
println "Javadoc for web packaged to ${file("$buildDir/dist/objectbox-java-web-api-docs.zip")}"
107+
}
108+
}
109+
71110
task javadocJar(type: Jar, dependsOn: javadoc) {
72111
classifier = 'javadoc'
73112
from 'build/docs/javadoc'

objectbox-rxjava/build.gradle

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,6 @@ dependencies {
1313
testCompile 'org.mockito:mockito-core:2.25.1'
1414
}
1515

16-
javadoc {
17-
failOnError = false
18-
title = "ObjectBox RxJava2 ${version} API"
19-
excludes = [] // Unfinished APIs if any
20-
options.bottom = 'Available under the Apache License, Version 2.0 - <i>Copyright &#169; 2018-2020 <a href="http://objectbox.io/">ObjectBox Ltd</a>. All Rights Reserved.</i>'
21-
}
22-
2316
task javadocJar(type: Jar, dependsOn: javadoc) {
2417
classifier = 'javadoc'
2518
from 'build/docs/javadoc'

0 commit comments

Comments
 (0)