Skip to content

Commit 58b8ffd

Browse files
committed
add some basic manifold + more java sourcews
1 parent 9d183d2 commit 58b8ffd

File tree

16 files changed

+155
-70
lines changed

16 files changed

+155
-70
lines changed

build-src/build.gradle.kts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ dependencies {
2626
api("org.ow2.asm:asm-analysis:9.7")
2727
api("com.gradleup.shadow:shadow-gradle-plugin:9.0.0-beta12")
2828
api("org.jetbrains.dokka:dokka-gradle-plugin:1.9.20")
29-
val kotlinVersion = "2.0.0"
29+
val kotlinVersion = "2.0.20"
3030
api("org.jetbrains.kotlin.jvm:org.jetbrains.kotlin.jvm.gradle.plugin:$kotlinVersion")
3131
api("org.jetbrains.kotlin.plugin.lombok:org.jetbrains.kotlin.plugin.lombok.gradle.plugin:$kotlinVersion")
32+
api("systems.manifold.manifold-gradle-plugin:systems.manifold.manifold-gradle-plugin.gradle.plugin:0.0.2-alpha")
3233
}

build-src/src/main/kotlin/Dependencies.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
object Dependencies {
22
val LIB_NINE_PATCH = "io.github.juuxel:libninepatch:1.2.0"
33
val JB_ANNOTATIONS = "org.jetbrains:annotations:24.0.1"
4+
val JSPECIFY = "org.jspecify:jspecify:1.0.0"
45

56
/**
67
* Intentionally old version of GSON to properly compile on 1.8.9
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import org.gradle.api.Project
2+
import org.gradle.api.tasks.compile.JavaCompile
3+
import org.gradle.kotlin.dsl.getByName
4+
import javax.inject.Inject
5+
6+
abstract class PreProcessorArgs {
7+
@get:Inject
8+
protected abstract val project: Project
9+
10+
companion object {
11+
val nameRegex = "^[A-Z_][A-Z_0-9]*$".toRegex()
12+
}
13+
14+
class Args(val task: JavaCompile) {
15+
fun define(name: String, value: String) {
16+
require(name.matches(nameRegex))
17+
task.options.compilerArgs.add("-A$name=$value")
18+
}
19+
20+
fun define(name: String, value: Int) {
21+
define(name, value.toString())
22+
}
23+
}
24+
25+
fun forCompilation(task: JavaCompile, init: Args.() -> Unit): Args {
26+
return Args(task).also(init)
27+
}
28+
29+
fun forDefaultCompilation(init: Args.() -> Unit): Args {
30+
return forCompilation(project.tasks.getByName<JavaCompile>("compileJava"), init)
31+
}
32+
}

build-src/src/main/kotlin/moulconfig.leaf.gradle.kts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ dependencies {
1616
shadowInclude(project(":common", configuration = "singleFile"))
1717
"implementation"(Dependencies.LIB_NINE_PATCH)
1818
shadowInclude(Dependencies.LIB_NINE_PATCH)
19+
compileOnly(Dependencies.JB_ANNOTATIONS)
20+
compileOnly(Dependencies.JSPECIFY)
1921
}
2022

2123
val shadowJar by tasks.named("shadowJar", ShadowJar::class) {
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
plugins {
2+
id("systems.manifold.manifold-gradle-plugin")
3+
}
4+
5+
manifold {
6+
manifoldVersion.set("2025.1.25")
7+
}
8+
9+
dependencies {
10+
val manifoldSubSystems = listOf(
11+
"strings" to false,
12+
"preprocessor" to false,
13+
)
14+
manifoldSubSystems.forEach { (name, rt) ->
15+
if (rt)
16+
implementation("systems.manifold:manifold-$name-rt:${manifold.manifoldVersion.get()}")
17+
annotationProcessor("systems.manifold:manifold-$name:${manifold.manifoldVersion.get()}")
18+
}
19+
}
20+
extensions.create<PreProcessorArgs>("preprocessorArgs", PreProcessorArgs::class)

common/build.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ dependencies {
1313
annotationProcessor(Dependencies.LOMBOK)
1414
compileOnly(Dependencies.LOMBOK)
1515
compileOnly(Dependencies.JB_ANNOTATIONS)
16+
compileOnly(Dependencies.JSPECIFY)
1617
implementation(Dependencies.LIB_NINE_PATCH)
1718
compileOnly(Dependencies.LEGACY_GSON)
1819
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
package io.github.notenoughupdates.moulconfig.common;
2+
3+
import io.github.notenoughupdates.moulconfig.common.text.StructuredText;
4+
import org.jspecify.annotations.NullMarked;
5+
6+
import java.util.List;
7+
8+
@NullMarked
9+
public interface IFontRenderer {
10+
int getHeight();
11+
12+
default int getStringWidth(String string) {
13+
return getStringWidth(StructuredText.of(string));
14+
}
15+
16+
int getStringWidth(StructuredText structuredText);
17+
18+
default int getCharWidth(char c) {
19+
return getStringWidth(Character.toString(c));
20+
}
21+
22+
List<StructuredText> splitText(StructuredText structuredText, int width);
23+
24+
default List<StructuredText> splitLines(StructuredText structuredText) {
25+
return splitText(structuredText, Integer.MAX_VALUE);
26+
}
27+
28+
default String trimStringToWidth(String string, int width) {
29+
return trimStringToWidth(string, width, false);
30+
}
31+
32+
String trimStringToWidth(String string, int width, boolean reversed);
33+
}

common/src/main/java/io/github/notenoughupdates/moulconfig/common/IFontRenderer.kt

Lines changed: 0 additions & 21 deletions
This file was deleted.

common/src/main/java/io/github/notenoughupdates/moulconfig/xml/loaders/BasicCollapsibleLoader.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package io.github.notenoughupdates.moulconfig.xml.loaders
22

33
import io.github.notenoughupdates.moulconfig.common.IMinecraft
4+
import io.github.notenoughupdates.moulconfig.common.text.StructuredText
45
import io.github.notenoughupdates.moulconfig.gui.component.CollapsibleComponent
56
import io.github.notenoughupdates.moulconfig.gui.component.TextComponent
67
import io.github.notenoughupdates.moulconfig.observer.GetSetter
@@ -19,7 +20,7 @@ class BasicCollapsibleLoader : XMLGuiLoader.Basic<CollapsibleComponent> {
1920
val title = context.getPropertyFromAttribute(element, QName("title"), String::class.java)!!
2021
val textComponent = TextComponent(
2122
IMinecraft.instance.defaultFontRenderer,
22-
title,
23+
{ StructuredText.of(title.get()) },
2324
IMinecraft.instance.defaultFontRenderer.getStringWidth(title.get()),
2425
TextComponent.TextAlignment.LEFT,
2526
false,

legacy/build.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ dependencies {
4040
annotationProcessor(Dependencies.LOMBOK)
4141
compileOnly(Dependencies.LOMBOK)
4242
compileOnly(Dependencies.JB_ANNOTATIONS)
43+
compileOnly(Dependencies.JSPECIFY)
4344
}
4445

4546
sourceSets.main {

0 commit comments

Comments
 (0)