Skip to content

Commit 144bb1d

Browse files
committed
javadoc things
1 parent 4e7dca9 commit 144bb1d

24 files changed

+128
-15
lines changed

buildSrc/src/main/kotlin/hypo-java.gradle.kts

Lines changed: 55 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
import java.net.URI
2+
import java.net.http.HttpClient
3+
import java.net.http.HttpRequest
4+
import java.net.http.HttpResponse
5+
import kotlin.io.path.absolutePathString
6+
import kotlin.io.path.createDirectories
7+
import kotlin.io.path.deleteIfExists
8+
import kotlin.io.path.notExists
9+
110
plugins {
211
`java-library`
312
}
@@ -33,7 +42,45 @@ afterEvaluate {
3342
}
3443
}
3544

45+
// javadoc doesn't like that static.javadoc.io redirects, so we'll manually copy the
46+
// package-list for it so it doesn't complain
47+
val elementLists = layout.buildDirectory.dir("javadocElementLists")
48+
val javadocElementList by tasks.registering {
49+
inputs.property("libs", hypoJava.javadocLibs)
50+
outputs.dir(elementLists)
51+
52+
doLast {
53+
val client = HttpClient.newBuilder().followRedirects(HttpClient.Redirect.ALWAYS).build()
54+
55+
val outDir = elementLists.get().asFile.toPath()
56+
val base = "https://static.javadoc.io"
57+
hypoJava.javadocLibs.get().forEach { m ->
58+
val types = listOf("element", "package")
59+
var response: HttpResponse<*>? = null
60+
for (type in types) {
61+
val filePath = "${m.module.group}/${m.module.name}/${m.versionConstraint}/$type-list"
62+
val url = "$base/$filePath"
63+
val outFile = outDir.resolve(filePath)
64+
outFile.parent.createDirectories()
65+
66+
val request = HttpRequest.newBuilder().GET().uri(URI.create(url)).build()
67+
response = client.send(request, HttpResponse.BodyHandlers.ofFile(outFile))
68+
if (response.statusCode() == 200) {
69+
break
70+
}
71+
72+
outFile.deleteIfExists()
73+
}
74+
if (response == null || response.statusCode() != 200) {
75+
throw Exception("Failed: $response")
76+
}
77+
}
78+
}
79+
}
80+
3681
tasks.javadoc {
82+
dependsOn(javadocElementList)
83+
3784
for (projDep in hypoJava.jdkVersionProjects.get()) {
3885
val proj = project(projDep.path)
3986

@@ -42,11 +89,16 @@ afterEvaluate {
4289
classpath += sources
4390
}
4491

45-
val base = "https://static.javadoc.io/"
92+
val packageListDir = elementLists.get().asFile.toPath()
4693
hypoJava.javadocLibs.get().forEach { m ->
47-
val url = "$base/${m.module.group}/${m.module.name}/${m.versionConstraint}"
48-
opt.links(url)
94+
val base = "https://static.javadoc.io"
95+
val artifact = "${m.module.group}/${m.module.name}/${m.versionConstraint}"
96+
val packageDir = packageListDir.resolve(artifact)
97+
val url = "$base/$artifact"
98+
99+
opt.linksOffline(url, packageDir.absolutePathString())
49100
}
101+
50102
hypoJava.javadocProjects.get().forEach { p ->
51103
val javadocTask = project(p.path).tasks.javadoc
52104
dependsOn(javadocTask)

hypo-asm/build.gradle.kts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,13 @@ repositories {
1616
}
1717

1818
dependencies {
19-
api(projects.hypoCore)
19+
compileOnlyApi(libs.annotations)
2020
api(libs.bundles.asm)
21+
api(libs.slf4j.api)
22+
23+
api(projects.hypoCore)
24+
api(projects.hypoModel)
25+
api(projects.hypoTypes)
2126

2227
testImplementation(projects.hypoTest)
2328
}
@@ -36,9 +41,9 @@ tasks.jar {
3641

3742
hypoJava {
3843
javadocLibs.add(libs.annotations)
39-
javadocLibs.add(libs.errorprone.annotations)
4044
javadocLibs.addAll(libs.bundles.asm)
41-
javadocProjects.addAll(projects.hypoCore, projects.hypoModel)
45+
javadocLibs.add(libs.slf4j.api)
46+
javadocProjects.addAll(projects.hypoCore, projects.hypoModel, projects.hypoTypes)
4247
}
4348

4449
hypoPublish {

hypo-asm/hypo-asm-hydrate/build.gradle.kts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ plugins {
66
}
77

88
dependencies {
9+
compileOnlyApi(libs.annotations)
10+
11+
api(projects.hypoTypes)
12+
api(projects.hypoModel)
913
api(projects.hypoCore)
1014
api(projects.hypoAsm)
1115
api(projects.hypoHydrate)
@@ -21,10 +25,7 @@ tasks.jar {
2125

2226
hypoJava {
2327
javadocLibs.add(libs.annotations)
24-
javadocLibs.add(libs.errorprone.annotations)
25-
javadocLibs.add(libs.jgrapht)
26-
javadocLibs.addAll(libs.bundles.asm)
27-
javadocProjects.addAll(projects.hypoAsm, projects.hypoHydrate, projects.hypoCore, projects.hypoModel)
28+
javadocProjects.addAll(projects.hypoAsm, projects.hypoHydrate, projects.hypoCore, projects.hypoModel, projects.hypoTypes)
2829
}
2930

3031
hypoPublish {

hypo-core/build.gradle.kts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ plugins {
66
}
77

88
dependencies {
9+
compileOnlyApi(libs.annotations)
10+
911
api(projects.hypoModel)
1012
}
1113

@@ -19,7 +21,6 @@ tasks.jar {
1921

2022
hypoJava {
2123
javadocLibs.add(libs.annotations)
22-
javadocLibs.add(libs.errorprone.annotations)
2324
javadocProjects.add(projects.hypoModel)
2425
}
2526

hypo-hydrate/build.gradle.kts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,15 @@ repositories {
1616
}
1717

1818
dependencies {
19-
implementation(projects.hypoCore)
19+
compileOnlyApi(libs.annotations)
20+
compileOnlyApi(libs.errorprone.annotations)
21+
2022
implementation(libs.jgrapht)
2123

24+
implementation(projects.hypoCore)
25+
implementation(projects.hypoModel)
26+
implementation(projects.hypoTypes)
27+
2228
testImplementation(projects.hypoTest)
2329
}
2430

@@ -38,7 +44,7 @@ hypoJava {
3844
javadocLibs.add(libs.annotations)
3945
javadocLibs.add(libs.errorprone.annotations)
4046
javadocLibs.add(libs.jgrapht)
41-
javadocProjects.addAll(projects.hypoCore, projects.hypoModel)
47+
javadocProjects.addAll(projects.hypoCore, projects.hypoModel, projects.hypoTypes)
4248
}
4349

4450
hypoPublish {

hypo-mappings/build.gradle.kts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@ plugins {
66
}
77

88
dependencies {
9+
compileOnlyApi(libs.annotations)
10+
compileOnlyApi(libs.errorprone.annotations)
11+
12+
api(projects.hypoTypes)
13+
api(projects.hypoModel)
914
api(projects.hypoCore)
1015
api(projects.hypoHydrate)
1116

@@ -24,8 +29,10 @@ tasks.jar {
2429
hypoJava {
2530
javadocLibs.add(libs.annotations)
2631
javadocLibs.add(libs.errorprone.annotations)
32+
2733
javadocLibs.add(libs.lorenz)
2834
javadocLibs.add(libs.bombe)
35+
2936
javadocProjects.addAll(projects.hypoHydrate, projects.hypoCore, projects.hypoModel, projects.hypoTypes)
3037
}
3138

hypo-model/build.gradle.kts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ plugins {
88

99
dependencies {
1010
compileOnlyApi(libs.annotations)
11-
api(libs.slf4j.api)
1211

1312
api(projects.hypoTypes)
1413
}
@@ -23,7 +22,8 @@ tasks.jar {
2322

2423
hypoJava {
2524
javadocLibs.add(libs.annotations)
26-
javadocLibs.add(libs.errorprone.annotations)
25+
26+
javadocProjects.add(projects.hypoTypes)
2727
}
2828

2929
hypoPublish {

hypo-types/build.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ plugins {
88

99
dependencies {
1010
compileOnlyApi(libs.annotations)
11+
compileOnlyApi(libs.errorprone.annotations)
1112
}
1213

1314
tasks.jar {

hypo-types/src/main/java/dev/denwav/hypo/types/TypeRepresentable.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
package dev.denwav.hypo.types;
2020

21+
import com.google.errorprone.annotations.Immutable;
2122
import org.jetbrains.annotations.NotNull;
2223

2324
/**
@@ -38,6 +39,7 @@
3839
* {@link #asReadable()} to assist with debugging. {@link #asInternal()} should be used for serialization, as it matches
3940
* 1:1 with corresponding {@code parse()} methods for each type.
4041
*/
42+
@Immutable
4143
public interface TypeRepresentable {
4244

4345
/**

hypo-types/src/main/java/dev/denwav/hypo/types/desc/ArrayTypeDescriptor.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
package dev.denwav.hypo.types.desc;
2020

21+
import com.google.errorprone.annotations.Immutable;
2122
import dev.denwav.hypo.types.Intern;
2223
import dev.denwav.hypo.types.sig.ArrayTypeSignature;
2324
import java.lang.ref.WeakReference;
@@ -34,6 +35,7 @@
3435
* <p>Array type descriptors have the internal format of {@code [<base_type>}. The leading {@code [} is repeated to
3536
* denote the dimensionality of the array, so a 3-dimension array type would start with {@code [[[}.
3637
*/
38+
@Immutable
3739
public final class ArrayTypeDescriptor extends Intern<ArrayTypeDescriptor> implements TypeDescriptor {
3840

3941
private final int dimension;

0 commit comments

Comments
 (0)