Skip to content

Commit

Permalink
javadoc things
Browse files Browse the repository at this point in the history
  • Loading branch information
DenWav committed Dec 19, 2024
1 parent 4e7dca9 commit 144bb1d
Show file tree
Hide file tree
Showing 24 changed files with 128 additions and 15 deletions.
58 changes: 55 additions & 3 deletions buildSrc/src/main/kotlin/hypo-java.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
import java.net.URI
import java.net.http.HttpClient
import java.net.http.HttpRequest
import java.net.http.HttpResponse
import kotlin.io.path.absolutePathString
import kotlin.io.path.createDirectories
import kotlin.io.path.deleteIfExists
import kotlin.io.path.notExists

plugins {
`java-library`
}
Expand Down Expand Up @@ -33,7 +42,45 @@ afterEvaluate {
}
}

// javadoc doesn't like that static.javadoc.io redirects, so we'll manually copy the
// package-list for it so it doesn't complain
val elementLists = layout.buildDirectory.dir("javadocElementLists")
val javadocElementList by tasks.registering {
inputs.property("libs", hypoJava.javadocLibs)
outputs.dir(elementLists)

doLast {
val client = HttpClient.newBuilder().followRedirects(HttpClient.Redirect.ALWAYS).build()

val outDir = elementLists.get().asFile.toPath()
val base = "https://static.javadoc.io"
hypoJava.javadocLibs.get().forEach { m ->
val types = listOf("element", "package")
var response: HttpResponse<*>? = null
for (type in types) {
val filePath = "${m.module.group}/${m.module.name}/${m.versionConstraint}/$type-list"
val url = "$base/$filePath"
val outFile = outDir.resolve(filePath)
outFile.parent.createDirectories()

val request = HttpRequest.newBuilder().GET().uri(URI.create(url)).build()
response = client.send(request, HttpResponse.BodyHandlers.ofFile(outFile))
if (response.statusCode() == 200) {
break
}

outFile.deleteIfExists()
}
if (response == null || response.statusCode() != 200) {
throw Exception("Failed: $response")
}
}
}
}

tasks.javadoc {
dependsOn(javadocElementList)

for (projDep in hypoJava.jdkVersionProjects.get()) {
val proj = project(projDep.path)

Expand All @@ -42,11 +89,16 @@ afterEvaluate {
classpath += sources
}

val base = "https://static.javadoc.io/"
val packageListDir = elementLists.get().asFile.toPath()
hypoJava.javadocLibs.get().forEach { m ->
val url = "$base/${m.module.group}/${m.module.name}/${m.versionConstraint}"
opt.links(url)
val base = "https://static.javadoc.io"
val artifact = "${m.module.group}/${m.module.name}/${m.versionConstraint}"
val packageDir = packageListDir.resolve(artifact)
val url = "$base/$artifact"

opt.linksOffline(url, packageDir.absolutePathString())
}

hypoJava.javadocProjects.get().forEach { p ->
val javadocTask = project(p.path).tasks.javadoc
dependsOn(javadocTask)
Expand Down
11 changes: 8 additions & 3 deletions hypo-asm/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,13 @@ repositories {
}

dependencies {
api(projects.hypoCore)
compileOnlyApi(libs.annotations)
api(libs.bundles.asm)
api(libs.slf4j.api)

api(projects.hypoCore)
api(projects.hypoModel)
api(projects.hypoTypes)

testImplementation(projects.hypoTest)
}
Expand All @@ -36,9 +41,9 @@ tasks.jar {

hypoJava {
javadocLibs.add(libs.annotations)
javadocLibs.add(libs.errorprone.annotations)
javadocLibs.addAll(libs.bundles.asm)
javadocProjects.addAll(projects.hypoCore, projects.hypoModel)
javadocLibs.add(libs.slf4j.api)
javadocProjects.addAll(projects.hypoCore, projects.hypoModel, projects.hypoTypes)
}

hypoPublish {
Expand Down
9 changes: 5 additions & 4 deletions hypo-asm/hypo-asm-hydrate/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ plugins {
}

dependencies {
compileOnlyApi(libs.annotations)

api(projects.hypoTypes)
api(projects.hypoModel)
api(projects.hypoCore)
api(projects.hypoAsm)
api(projects.hypoHydrate)
Expand All @@ -21,10 +25,7 @@ tasks.jar {

hypoJava {
javadocLibs.add(libs.annotations)
javadocLibs.add(libs.errorprone.annotations)
javadocLibs.add(libs.jgrapht)
javadocLibs.addAll(libs.bundles.asm)
javadocProjects.addAll(projects.hypoAsm, projects.hypoHydrate, projects.hypoCore, projects.hypoModel)
javadocProjects.addAll(projects.hypoAsm, projects.hypoHydrate, projects.hypoCore, projects.hypoModel, projects.hypoTypes)
}

hypoPublish {
Expand Down
3 changes: 2 additions & 1 deletion hypo-core/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ plugins {
}

dependencies {
compileOnlyApi(libs.annotations)

api(projects.hypoModel)
}

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

hypoJava {
javadocLibs.add(libs.annotations)
javadocLibs.add(libs.errorprone.annotations)
javadocProjects.add(projects.hypoModel)
}

Expand Down
10 changes: 8 additions & 2 deletions hypo-hydrate/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,15 @@ repositories {
}

dependencies {
implementation(projects.hypoCore)
compileOnlyApi(libs.annotations)
compileOnlyApi(libs.errorprone.annotations)

implementation(libs.jgrapht)

implementation(projects.hypoCore)
implementation(projects.hypoModel)
implementation(projects.hypoTypes)

testImplementation(projects.hypoTest)
}

Expand All @@ -38,7 +44,7 @@ hypoJava {
javadocLibs.add(libs.annotations)
javadocLibs.add(libs.errorprone.annotations)
javadocLibs.add(libs.jgrapht)
javadocProjects.addAll(projects.hypoCore, projects.hypoModel)
javadocProjects.addAll(projects.hypoCore, projects.hypoModel, projects.hypoTypes)
}

hypoPublish {
Expand Down
7 changes: 7 additions & 0 deletions hypo-mappings/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ plugins {
}

dependencies {
compileOnlyApi(libs.annotations)
compileOnlyApi(libs.errorprone.annotations)

api(projects.hypoTypes)
api(projects.hypoModel)
api(projects.hypoCore)
api(projects.hypoHydrate)

Expand All @@ -24,8 +29,10 @@ tasks.jar {
hypoJava {
javadocLibs.add(libs.annotations)
javadocLibs.add(libs.errorprone.annotations)

javadocLibs.add(libs.lorenz)
javadocLibs.add(libs.bombe)

javadocProjects.addAll(projects.hypoHydrate, projects.hypoCore, projects.hypoModel, projects.hypoTypes)
}

Expand Down
4 changes: 2 additions & 2 deletions hypo-model/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ plugins {

dependencies {
compileOnlyApi(libs.annotations)
api(libs.slf4j.api)

api(projects.hypoTypes)
}
Expand All @@ -23,7 +22,8 @@ tasks.jar {

hypoJava {
javadocLibs.add(libs.annotations)
javadocLibs.add(libs.errorprone.annotations)

javadocProjects.add(projects.hypoTypes)
}

hypoPublish {
Expand Down
1 change: 1 addition & 0 deletions hypo-types/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ plugins {

dependencies {
compileOnlyApi(libs.annotations)
compileOnlyApi(libs.errorprone.annotations)
}

tasks.jar {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

package dev.denwav.hypo.types;

import com.google.errorprone.annotations.Immutable;
import org.jetbrains.annotations.NotNull;

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

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

package dev.denwav.hypo.types.desc;

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

private final int dimension;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

package dev.denwav.hypo.types.desc;

import com.google.errorprone.annotations.Immutable;
import dev.denwav.hypo.types.HypoTypesUtil;
import dev.denwav.hypo.types.Intern;
import dev.denwav.hypo.types.sig.ClassTypeSignature;
Expand All @@ -31,6 +32,7 @@
* A {@link TypeDescriptor} representing a class type. Class (or reference) types follow the internal format of
* {@code L<class_name>;}.
*/
@Immutable
public final class ClassTypeDescriptor extends Intern<ClassTypeDescriptor> implements TypeDescriptor {

private final @NotNull String name;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

package dev.denwav.hypo.types.desc;

import com.google.errorprone.annotations.Immutable;
import dev.denwav.hypo.types.Intern;
import dev.denwav.hypo.types.TypeRepresentable;
import dev.denwav.hypo.types.parsing.JvmTypeParseFailureException;
Expand Down Expand Up @@ -48,8 +49,10 @@
* @see TypeDescriptor
* @see MethodSignature
*/
@Immutable
public final class MethodDescriptor extends Intern<MethodDescriptor> implements TypeRepresentable {

@SuppressWarnings("Immutable")
final @NotNull List<? extends TypeDescriptor> parameters;
final @NotNull TypeDescriptor returnType;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

package dev.denwav.hypo.types.desc;

import com.google.errorprone.annotations.Immutable;
import dev.denwav.hypo.types.Intern;
import dev.denwav.hypo.types.TypeRepresentable;
import dev.denwav.hypo.types.parsing.JvmTypeParseFailureException;
Expand All @@ -44,6 +45,7 @@
* @see MethodDescriptor
* @see TypeSignature
*/
@Immutable
public interface TypeDescriptor extends TypeRepresentable {

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

package dev.denwav.hypo.types.sig;

import com.google.errorprone.annotations.Immutable;
import dev.denwav.hypo.types.Intern;
import dev.denwav.hypo.types.TypeVariableBinder;
import dev.denwav.hypo.types.desc.ArrayTypeDescriptor;
Expand All @@ -27,6 +28,7 @@
import java.util.concurrent.ConcurrentHashMap;
import org.jetbrains.annotations.NotNull;

@Immutable
public final class ArrayTypeSignature
extends Intern<ArrayTypeSignature>
implements ReferenceTypeSignature {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

package dev.denwav.hypo.types.sig;

import com.google.errorprone.annotations.Immutable;
import dev.denwav.hypo.types.Intern;
import dev.denwav.hypo.types.TypeRepresentable;
import dev.denwav.hypo.types.TypeVariableBinder;
Expand All @@ -32,10 +33,13 @@
import java.util.stream.Collectors;
import org.jetbrains.annotations.NotNull;

@Immutable
public final class ClassSignature extends Intern<ClassSignature> implements TypeRepresentable {

@SuppressWarnings("Immutable")
private final @NotNull List<? extends TypeParameter> typeParameters;
private final @NotNull ClassTypeSignature superClass;
@SuppressWarnings("Immutable")
private final @NotNull List<? extends ClassTypeSignature> superInterfaces;

public static @NotNull ClassSignature of(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

package dev.denwav.hypo.types.sig;

import com.google.errorprone.annotations.Immutable;
import dev.denwav.hypo.types.Intern;
import dev.denwav.hypo.types.TypeVariableBinder;
import dev.denwav.hypo.types.desc.ClassTypeDescriptor;
Expand All @@ -33,12 +34,14 @@
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

@Immutable
public final class ClassTypeSignature
extends Intern<ClassTypeSignature>
implements ReferenceTypeSignature, ThrowsSignature {

private final @Nullable ClassTypeSignature parentClass;
private final @NotNull String name;
@SuppressWarnings("Immutable")
private final @NotNull List<? extends TypeArgument> typeArguments;

public static @NotNull ClassTypeSignature of(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

package dev.denwav.hypo.types.sig;

import com.google.errorprone.annotations.Immutable;
import dev.denwav.hypo.types.Intern;
import dev.denwav.hypo.types.TypeRepresentable;
import dev.denwav.hypo.types.TypeVariableBinder;
Expand All @@ -34,11 +35,15 @@
import java.util.stream.Collectors;
import org.jetbrains.annotations.NotNull;

@Immutable
public final class MethodSignature extends Intern<MethodSignature> implements TypeRepresentable {

@SuppressWarnings("Immutable")
private final @NotNull List<? extends TypeParameter> typeParameters;
@SuppressWarnings("Immutable")
private final @NotNull List<? extends TypeSignature> parameters;
private final @NotNull TypeSignature returnType;
@SuppressWarnings("Immutable")
private final @NotNull List<? extends ThrowsSignature> throwsSignatures;

public static @NotNull MethodSignature of(
Expand Down
Loading

0 comments on commit 144bb1d

Please sign in to comment.