Skip to content

Commit

Permalink
Build: Publish single universal artifact instead of one per platform
Browse files Browse the repository at this point in the history
* Update Gradle, EGT, and Kotlin plugin (to last version before 2.0.0
because that would entail some more changes)
* Replace remaining Platform dependencies with newly introduced UC
methods
* Publish from main `:` project instead of individual platform projects
* Move example into `:example` project and run it via Standalone UC
* Fix Vigilant spawning non-daemon background threads which prevent the
example from exiting cleanly
* Update README

GitHub: #87
  • Loading branch information
Johni0702 authored Aug 12, 2024
1 parent 2b604d3 commit 2e881ee
Show file tree
Hide file tree
Showing 30 changed files with 109 additions and 1,917 deletions.
3 changes: 0 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,3 @@ build
run
.DS_Store
Thumbs.db

versions/*/tmp.srg
versions/*/api/
133 changes: 35 additions & 98 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,108 +5,42 @@ this library provides a simple and clean configuration menu and an easy-to-use s

## Dependency

It's recommended that you include [Essential](link eventually) instead of adding it yourself.

In your repository block, add:

Groovy
```groovy
maven {
url = "https://repo.essential.gg/repository/maven-public"
}
```
Kotlin
```kotlin
maven(url = "https://repo.essential.gg/repository/maven-public")
```

To use the latest builds, use the following dependency:

<details><summary>Forge</summary>

Kotlin
```kotlin
implementation("gg.essential:vigilance-$mcVersion-$mcPlatform:$buildNumber")
```
</details>
<details><summary>Fabric</summary>

Groovy
```groovy
modImplementation(include("gg.essential:vigilance-$mcVersion-$mcPlatform:$buildNumber"))
```
Kotlin
```kotlin
modImplementation(include("gg.essential:vigilance-$mcVersion-$mcPlatform:$buildNumber")!!)
repository {
// All versions of Vigilance and UniversalCraft are published to Essential's public maven repository.
// (if you're still using Groovy build scripts, replace `()` with `{}`)
maven(url = "https://repo.essential.gg/repository/maven-public")
}
dependencies {
// Add Vigilance dependency. For the latest $vigilanceVersion, see the badge below this code snippet.
implementation("gg.essential:vigilance:$vigilanceVersion")

// Vigilance itself is independent of Minecraft versions and mod loaders, instead it depends on UniversalCraft which
// provides bindings to specific Minecraft versions.
// As such, you must include the UniversalCraft version for the Minecraft version + mod loader you're targeting.
// For a list of all available platforms, see https://github.com/EssentialGG/UniversalCraft
// For your convenience, the latest $ucVersion is also included in a badge below this code snippet.
// (Note: if you are not using Loom, replace `modImplementation` with `implementation` or your equivalent)
modImplementation("gg.essential:universalcraft-1.8.9-forge:$ucVersion")

// If you're using Fabric, you may use its jar-in-jar mechanism to bundle Vigilance and UniversalCraft with your
// mod by additionally adding them to the `include` configuration like this (in place of the above):
implementation(include("gg.essential:vigilance:$vigilanceVersion")!!)
modImplementation(include("gg.essential:universalcraft-1.8.9-forge:$ucVersion"))
// If you're using Forge, you must instead include them directly into your jar file and relocate them to your
// own package (this is important! otherwise you will be incompatible with other mods!)
// using e.g. https://gradleup.com/shadow/configuration/relocation/
// For an example, read the IMPORTANT section below.
}
```
</details>

### Build Reference
<details><summary>Build Reference</summary>
<table>
<tbody>
<tr>
<th>mcVersion</th>
<th>mcPlatform</th>
<th>buildNumber</th>
</tr>
<tr>
<td>1.18.1</td>
<td>fabric</td>
<td>
<img alt="1.18.1-fabric" src="https://img.shields.io/badge/dynamic/xml?color=A97BFF&label=%20&query=/metadata/versioning/versions/version[not(contains(text(),'%2B'))][last()]&url=https://repo.sk1er.club/repository/maven-releases/gg/essential/vigilance-1.18.1-fabric/maven-metadata.xml">
</td>
</tr>
<tr>
<td>1.18.1</td>
<td>forge</td>
<td>
<img alt="1.18.1-forge" src="https://img.shields.io/badge/dynamic/xml?color=A97BFF&label=%20&query=/metadata/versioning/versions/version[not(contains(text(),'%2B'))][last()]&url=https://repo.sk1er.club/repository/maven-releases/gg/essential/vigilance-1.18.1-forge/maven-metadata.xml">
</td>
</tr>
<tr>
<td>1.17.1</td>
<td>fabric</td>
<td>
<img alt="1.17.1-fabric" src="https://img.shields.io/badge/dynamic/xml?color=A97BFF&label=%20&query=/metadata/versioning/versions/version[not(contains(text(),'%2B'))][last()]&url=https://repo.sk1er.club/repository/maven-releases/gg/essential/vigilance-1.17.1-fabric/maven-metadata.xml">
</td>
</tr>
<tr>
<td>1.17.1</td>
<td>forge</td>
<td>
<img alt="1.17.1-forge" src="https://img.shields.io/badge/dynamic/xml?color=A97BFF&label=%20&query=/metadata/versioning/versions/version[not(contains(text(),'%2B'))][last()]&url=https://repo.sk1er.club/repository/maven-releases/gg/essential/vigilance-1.17.1-forge/maven-metadata.xml">
</td>
</tr>
<tr>
<td>1.16.2</td>
<td>forge</td>
<td>
<img alt="1.16.2-forge" src="https://img.shields.io/badge/dynamic/xml?color=A97BFF&label=%20&query=/metadata/versioning/versions/version[not(contains(text(),'%2B'))][last()]&url=https://repo.sk1er.club/repository/maven-releases/gg/essential/vigilance-1.16.2-forge/maven-metadata.xml">
</td>
</tr>
<tr>
<td>1.12.2</td>
<td>forge</td>
<td>
<img alt="1.12.2-forge" src="https://img.shields.io/badge/dynamic/xml?color=A97BFF&label=%20&query=/metadata/versioning/versions/version[not(contains(text(),'%2B'))][last()]&url=https://repo.sk1er.club/repository/maven-releases/gg/essential/vigilance-1.12.2-forge/maven-metadata.xml">
</td>
</tr>
<tr>
<td>1.8.9</td>
<td>forge</td>
<td>
<img alt="1.8.9-forge" src="https://img.shields.io/badge/dynamic/xml?color=A97BFF&label=%20&query=/metadata/versioning/versions/version[not(contains(text(),'%2B'))][last()]&url=https://repo.sk1er.club/repository/maven-releases/gg/essential/vigilance-1.8.9-forge/maven-metadata.xml">
</td>
</tr>
</tbody>
</table>

</details>
<img alt="gg.essential:vigilance" src="https://img.shields.io/badge/dynamic/xml?color=A97BFF&label=Latest%20Vigilance&query=/metadata/versioning/versions/version[not(contains(text(),'%2B'))][last()]&url=https://repo.essential.gg/repository/maven-releases/gg/essential/vigilance/maven-metadata.xml">
<img alt="gg.essential:universalcraft-1.8.9-forge" src="https://img.shields.io/badge/dynamic/xml?color=A97BFF&label=Latest%20UniversalCraft&query=/metadata/versioning/versions/version[not(contains(text(),'%2B'))][last()]&url=https://repo.essential.gg/repository/maven-releases/gg/essential/universalcraft-1.8.9-forge/maven-metadata.xml">

<h2><span style="font-size:3em; color:red;">IMPORTANT!</span></h2>

If you are using forge, you must also relocate Vigilance to avoid potential crashes with other mods. To do this, you will need to use the Shadow Gradle plugin.
If you are using Forge, you must also relocate Vigilance to avoid incompatibility with other mods.
To do this, you may use the Shadow Gradle plugin.

<details><summary>Groovy Version</summary>

Expand Down Expand Up @@ -182,5 +116,8 @@ tasks.reobfJar { dependsOn(tasks.shadowJar) }

## Examples

For examples of how to use Vigilance, refer to the example package within Vigilance for [annotation style](https://github.com/Sk1erLLC/Vigilance/blob/master/src/main/kotlin/gg/essential/vigilance/example/ExampleConfig.kt)
and [DSL style](https://github.com/Sk1erLLC/Vigilance/blob/master/src/main/kotlin/gg/essential/vigilance/example/ExampleConfigDSL.kt)
For examples of how to use Vigilance, refer to the `example` sub-project within Vigilance for
[annotation style](https://github.com/Sk1erLLC/Vigilance/blob/master/example/src/main/kotlin/gg/essential/vigilance/example/ExampleConfig.kt)
and [DSL style](https://github.com/Sk1erLLC/Vigilance/blob/master/example/src/main/kotlin/gg/essential/vigilance/example/ExampleConfigDSL.kt)

You can run the examples via `./gradlew :example:run`.
10 changes: 10 additions & 0 deletions api/Vigilance.api
Original file line number Diff line number Diff line change
Expand Up @@ -577,6 +577,11 @@ public final class gg/essential/vigilance/gui/settings/CheckboxComponent : gg/es
public final fun setChecked (Z)V
}

public final class gg/essential/vigilance/gui/settings/CheckboxComponent$inlined$sam$i$java_util_function_Predicate$0 : java/util/function/Predicate {
public fun <init> (Lkotlin/jvm/functions/Function1;)V
public final synthetic fun test (Ljava/lang/Object;)Z
}

public final class gg/essential/vigilance/gui/settings/ColorComponent : gg/essential/vigilance/gui/settings/SettingComponent {
public fun <init> (Ljava/awt/Color;Z)V
public fun closePopups (Z)V
Expand Down Expand Up @@ -619,6 +624,11 @@ public final class gg/essential/vigilance/gui/settings/NumberComponent : gg/esse
public final class gg/essential/vigilance/gui/settings/NumberComponent$Companion {
}

public final class gg/essential/vigilance/gui/settings/NumberComponent$inlined$sam$i$java_util_function_Predicate$0 : java/util/function/Predicate {
public fun <init> (Lkotlin/jvm/functions/Function1;)V
public final synthetic fun test (Ljava/lang/Object;)Z
}

public final class gg/essential/vigilance/gui/settings/PercentSliderComponent : gg/essential/vigilance/gui/settings/AbstractSliderComponent {
public fun <init> (F)V
}
Expand Down
36 changes: 26 additions & 10 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,16 @@ import gg.essential.gradle.util.*
import gg.essential.gradle.util.RelocationTransform.Companion.registerRelocationAttribute

plugins {
kotlin("jvm") version "1.6.10"
kotlin("jvm") version "1.9.23"
id("org.jetbrains.kotlinx.binary-compatibility-validator") version "0.8.0"
id("org.jetbrains.dokka") version "1.6.10" apply false
id("org.jetbrains.dokka") version "1.9.20"
id("gg.essential.defaults")
id("gg.essential.defaults.maven-publish")
}

group = "gg.essential"
version = versionFromBuildIdAndBranch()

kotlin.jvmToolchain {
(this as JavaToolchainSpec).languageVersion.set(JavaLanguageVersion.of(8))
}
Expand All @@ -34,13 +38,10 @@ dependencies {
compileOnly(libs.kotlin.reflect)
compileOnly(libs.jetbrains.annotations)

// Depending on LWJGL3 instead of 2 so we can choose opengl bindings only
compileOnly("org.lwjgl:lwjgl-opengl:3.3.1")
api(libs.elementa)

// Depending on 1.8.9 for all of these because that's the oldest version we support
compileOnly(libs.versions.elementa.map { "gg.essential:elementa-1.8.9-forge:$it" }) {
attributes { attribute(common, true) }
}
compileOnly("gg.essential:universalcraft-1.8.9-forge") {
compileOnly(libs.universalcraft.forge10809) {
attributes { attribute(common, true) }
}

Expand All @@ -52,12 +53,27 @@ dependencies {
testImplementation("io.strikt:strikt-core:0.22.1")
}

tasks.processResources {
inputs.property("project.version", project.version)
filesMatching("fabric.mod.json") {
expand("version" to project.version)
}
}

tasks.jar {
dependsOn(internal)
from({ internal.map { zipTree(it) } })
}

apiValidation {
ignoredProjects.addAll(project("platform").allprojects.map { it.name })
ignoredPackages.add("gg.essential.vigilance.example")
ignoredProjects.addAll(subprojects.map { it.name })
nonPublicMarkers.add("org.jetbrains.annotations.ApiStatus\$Internal")
}

tasks.test {
useJUnitPlatform()
}

publishing.publications.named<MavenPublication>("maven") {
artifactId = "vigilance"
}
1 change: 1 addition & 0 deletions example/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
config/
16 changes: 16 additions & 0 deletions example/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
plugins {
kotlin("jvm")
application
id("gg.essential.defaults.repo")
}

dependencies {
implementation(libs.universalcraft.standalone)
implementation(project(":"))
}

kotlin.jvmToolchain(8)

application {
mainClass.set("gg.essential.vigilance.example.MainKt")
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
@file:Suppress("unused")

package gg.essential.vigilance.example

import gg.essential.universal.UChat
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package gg.essential.vigilance.example

import gg.essential.universal.UScreen
import gg.essential.universal.standalone.runUniversalCraft

fun main() = runUniversalCraft("Vigilance Example", 854, 480) { window ->
UScreen.displayScreen(ExampleConfig.gui())
window.renderScreenUntilClosed()
}
6 changes: 5 additions & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
[versions]
kotlin = "1.5.10"
jetbrains-annotations = "23.0.0"
elementa = "638"
universalcraft = "355"
elementa = "659"
nightconfig = "3.6.0"

[libraries]
kotlin-stdlib-jdk8 = { module = "org.jetbrains.kotlin:kotlin-stdlib-jdk8", version.ref = "kotlin" }
kotlin-reflect = { module = "org.jetbrains.kotlin:kotlin-reflect", version.ref = "kotlin" }
universalcraft-forge10809 = { module = "gg.essential:universalcraft-1.8.9-forge", version.ref = "universalcraft" }
universalcraft-standalone = { module = "gg.essential:universalcraft-standalone", version.ref = "universalcraft" }
elementa = { module = "gg.essential:elementa", version.ref = "elementa" }
jetbrains-annotations = { module = "org.jetbrains:annotations", version.ref = "jetbrains-annotations" }
nightconfig-toml = { module = "com.electronwill.night-config:toml", version.ref = "nightconfig" }
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.2-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
29 changes: 3 additions & 26 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -8,35 +8,12 @@ pluginManagement {
maven("https://repo.essential.gg/repository/maven-public")
}
plugins {
val egtVersion = "0.3.0"
val egtVersion = "0.6.2"
id("gg.essential.defaults") version egtVersion
id("gg.essential.multi-version.root") version egtVersion
id("gg.essential.multi-version.api-validation") version egtVersion
id("gg.essential.defaults.maven-publish") version egtVersion
}
}

rootProject.name = "Vigilance"

include(":platform")
project(":platform").apply {
projectDir = file("versions/")
buildFileName = "root.gradle.kts"
}

listOf(
"1.8.9-forge",
"1.12.2-forge",
"1.15.2-forge",
"1.16.2-forge",
"1.16.2-fabric",
"1.17.1-fabric",
"1.17.1-forge",
"1.18.1-fabric",
"1.18.1-forge",
).forEach { version ->
include(":platform:$version")
project(":platform:$version").apply {
projectDir = file("versions/$version")
buildFileName = "../build.gradle.kts"
}
}
include(":example")
2 changes: 1 addition & 1 deletion src/main/kotlin/gg/essential/vigilance/Vigilant.kt
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ abstract class Vigilant @JvmOverloads constructor(
e.printStackTrace()
}

fixedRateTimer(period = 30 * 1000) { writeData() }
fixedRateTimer(period = 30 * 1000, daemon = true) { writeData() }

Runtime.getRuntime().addShutdownHook(Thread { writeData() })
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import gg.essential.universal.UDesktop
import gg.essential.universal.UKeyboard
import gg.essential.universal.UMatrixStack
import gg.essential.vigilance.gui.VigilancePalette
import gg.essential.vigilance.impl.Platform.Companion.platform
import java.awt.Color
import java.util.*
import kotlin.math.abs
Expand Down
4 changes: 2 additions & 2 deletions src/main/kotlin/gg/essential/vigilance/impl/I18n.kt
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package gg.essential.vigilance.impl

import gg.essential.vigilance.impl.Platform.Companion.platform
import gg.essential.universal.UI18n
import org.jetbrains.annotations.ApiStatus

@ApiStatus.Internal
object I18n {
fun format(key: String): String = platform.i18n(key)
fun format(key: String): String = UI18n.i18n(key)
}
16 changes: 0 additions & 16 deletions src/main/kotlin/gg/essential/vigilance/impl/Platform.kt

This file was deleted.

Loading

0 comments on commit 2e881ee

Please sign in to comment.