Skip to content

Commit

Permalink
Merge pull request #148 from EssentialGG/feature/universal-version
Browse files Browse the repository at this point in the history
Build: Publish single universal artifact instead of one per platform
  • Loading branch information
Johni0702 committed Aug 9, 2024
2 parents b194e7f + 78ad29f commit 56abfcf
Show file tree
Hide file tree
Showing 45 changed files with 171 additions and 299 deletions.
3 changes: 0 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,3 @@ options.txt
usercache.json
usernamecache.json
*.txt

versions/*/tmp.srg
versions/*/api/
139 changes: 40 additions & 99 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,110 +11,46 @@ instead you simply have to describe _what_ you want.

## 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
implementation("gg.essential:elementa-$mcVersion-$mcPlatform:$buildNumber")
```
</details>
<details><summary>Fabric</summary>

Groovy
```groovy
modImplementation(include("gg.essential:elementa-$mcVersion-$mcPlatform:$buildNumber"))
```
Kotlin
```kotlin
modImplementation(include("gg.essential:elementa-$mcVersion-$mcPlatform:$buildNumber")!!)
repository {
// All versions of Elementa 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 Elementa dependency. For the latest $elementaVersion, see the badge below this code snippet.
implementation("gg.essential:elementa:$elementaVersion")

// Optionally, add some of the unstable Elementa features.
// Note that these MUST be relocated to your own package because future versions may contain breaking changes
// and therefore MUST NOT be simply included via Fabric's jar-in-jar mechanism.
implementation("gg.essential:elementa-unstable-layoutdsl:$elementaVersion")

// Elementa 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 Elementa and UniversalCraft with your
// mod by additionally adding them to the `include` configuration like this (in place of the above):
implementation(include("gg.essential:elementa:$elementaVersion")!!)
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.essential.gg/repository/maven-releases/gg/essential/elementa-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.essential.gg/repository/maven-releases/gg/essential/elementa-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.essential.gg/repository/maven-releases/gg/essential/elementa-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.essential.gg/repository/maven-releases/gg/essential/elementa-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.essential.gg/repository/maven-releases/gg/essential/elementa-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.essential.gg/repository/maven-releases/gg/essential/elementa-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.essential.gg/repository/maven-releases/gg/essential/elementa-1.8.9-forge/maven-metadata.xml"></td>
</tr>
</tbody>
</table>

</details>

If you were previously using v1.7.1 of Elementa and are now on the v2.0.0 builds, please refer to the
[migration](docs/migration.md) document to know what has changed.

To learn about all the new features in v2.0.0, please read the [what's new](docs/whatsnew.md) document.
<img alt="gg.essential:elementa" src="https://img.shields.io/badge/dynamic/xml?color=A97BFF&label=Latest%20Elementa&query=/metadata/versioning/versions/version[not(contains(text(),'%2B'))][last()]&url=https://repo.essential.gg/repository/maven-releases/gg/essential/elementa/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 Elementa 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 Elementa 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 @@ -191,6 +127,11 @@ In your dependencies block, add:
implementation "club.sk1er:Elementa:1.7.1-$mcVersion"
```

If you were previously using v1.7.1 of Elementa and are now on the v2.0.0 builds, please refer to the
[migration](docs/migration.md) document to know what has changed.

To learn about all the new features in v2.0.0, please read the [what's new](docs/whatsnew.md) document.

## Components

All the drawing in Elementa is done via UIComponents. There is a root component named `Window`
Expand Down
8 changes: 8 additions & 0 deletions api/Elementa.api
Original file line number Diff line number Diff line change
Expand Up @@ -2565,8 +2565,16 @@ public final class gg/essential/elementa/dsl/UtilitiesKt {
public static final fun toConstraint (Ljava/awt/Color;)Lgg/essential/elementa/constraints/ConstantColorConstraint;
public static final fun width (CF)F
public static final fun width (Ljava/lang/String;FLgg/essential/elementa/font/FontProvider;)F
public static final synthetic fun width (Lnet/minecraft/class_2561;FLgg/essential/elementa/font/FontProvider;)F
public static final synthetic fun width (Lnet/minecraft/network/chat/Component;FLgg/essential/elementa/font/FontProvider;)F
public static final synthetic fun width (Lnet/minecraft/util/IChatComponent;FLgg/essential/elementa/font/FontProvider;)F
public static final synthetic fun width (Lnet/minecraft/util/text/ITextComponent;FLgg/essential/elementa/font/FontProvider;)F
public static synthetic fun width$default (CFILjava/lang/Object;)F
public static synthetic fun width$default (Ljava/lang/String;FLgg/essential/elementa/font/FontProvider;ILjava/lang/Object;)F
public static synthetic fun width$default (Lnet/minecraft/class_2561;FLgg/essential/elementa/font/FontProvider;ILjava/lang/Object;)F
public static synthetic fun width$default (Lnet/minecraft/network/chat/Component;FLgg/essential/elementa/font/FontProvider;ILjava/lang/Object;)F
public static synthetic fun width$default (Lnet/minecraft/util/IChatComponent;FLgg/essential/elementa/font/FontProvider;ILjava/lang/Object;)F
public static synthetic fun width$default (Lnet/minecraft/util/text/ITextComponent;FLgg/essential/elementa/font/FontProvider;ILjava/lang/Object;)F
}

public abstract class gg/essential/elementa/effects/Effect {
Expand Down
26 changes: 23 additions & 3 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,14 @@ import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
plugins {
kotlin("jvm") version "1.9.23"
id("org.jetbrains.kotlinx.binary-compatibility-validator") version "0.8.0"
id("org.jetbrains.dokka") version "1.9.20" 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 Down Expand Up @@ -47,6 +51,7 @@ dependencies {
internal(libs.dom4j)
implementation(prebundle(internal))

compileOnly(project(":mc-stubs"))
// Depending on LWJGL3 instead of 2 so we can choose opengl bindings only
compileOnly("org.lwjgl:lwjgl-opengl:3.3.1")
// Depending on 1.8.9 for all of these because that's the oldest version we support
Expand All @@ -56,8 +61,23 @@ dependencies {
compileOnly("com.google.code.gson:gson:2.2.4")
}

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(listOf("platform", "statev2", "layoutdsl"))
ignoredPackages.add("com.example")
ignoredProjects.addAll(subprojects.map { it.name })
nonPublicMarkers.add("org.jetbrains.annotations.ApiStatus\$Internal")
}

publishing.publications.named<MavenPublication>("maven") {
artifactId = "elementa"
}
File renamed without changes.
File renamed without changes.
44 changes: 1 addition & 43 deletions versions/build.gradle.kts → example/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,25 +1,14 @@
import gg.essential.gradle.multiversion.excludeKotlinDefaultImpls
import gg.essential.gradle.multiversion.mergePlatformSpecifics
import gg.essential.gradle.util.*

plugins {
kotlin("jvm")
id("org.jetbrains.dokka")
id("gg.essential.multi-version")
id("gg.essential.defaults")
id("gg.essential.defaults.maven-publish")
}

group = "gg.essential"

java.withSourcesJar()
tasks.compileKotlin.setJvmDefault(if (platform.mcVersion >= 11400) "all" else "all-compatibility")
loom.noServerRunConfigs()

val common by configurations.creating
configurations.compileClasspath { extendsFrom(common) }
configurations.runtimeClasspath { extendsFrom(common) }

dependencies {
implementation(libs.kotlin.stdlib.jdk8)
implementation(libs.kotlin.reflect)
Expand All @@ -29,7 +18,7 @@ dependencies {
exclude(group = "org.jetbrains.kotlin")
}

common(project(":"))
implementation(project(":example:common"))

if (platform.isFabric) {
val fabricApiVersion = when(platform.mcVersion) {
Expand Down Expand Up @@ -57,34 +46,3 @@ dependencies {
}
}
}

tasks.processResources {
filesMatching(listOf("fabric.mod.json")) {
filter { it.replace("\"com.example.examplemod.ExampleMod\"", "") }
}
}

tasks.dokkaHtml {
moduleName.set("Elementa $name")
}

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

// We build the common module with legacy default impl for backwards compatibility, but we only need those for
// 1.12.2 and older. Newer versions have never shipped with legacy default impl.
if (platform.mcVersion >= 11400) {
excludeKotlinDefaultImpls()
}

exclude("com/example/examplemod/**")
exclude("META-INF/mods.toml")
exclude("mcmod.info")
exclude("kotlin/**")
}

tasks.named<Jar>("sourcesJar") {
from(project(":").sourceSets.main.map { it.allSource })
}
23 changes: 23 additions & 0 deletions example/common/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import gg.essential.gradle.multiversion.StripReferencesTransform.Companion.registerStripReferencesAttribute

plugins {
kotlin("jvm")
id("gg.essential.defaults")
}
repositories.mavenLocal()

kotlin.jvmToolchain(8)

val common = registerStripReferencesAttribute("common") {
excludes.add("net.minecraft")
}

dependencies {
api(libs.kotlin.stdlib.jdk8)

compileOnly(libs.versions.universalcraft.map { "gg.essential:universalcraft-1.8.9-forge:$it" }) {
attributes { attribute(common, true) }
}

api(project(":"))
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import gg.essential.elementa.components.*
import gg.essential.elementa.constraints.*
import gg.essential.elementa.constraints.animation.Animations
import gg.essential.elementa.dsl.*
import gg.essential.elementa.impl.Platform.Companion.platform
import gg.essential.universal.UMinecraft
import gg.essential.universal.UScreen
import java.awt.Color

Expand Down Expand Up @@ -39,7 +39,7 @@ class ExamplesGui : WindowScreen(ElementaVersion.V2) {
}
}.onMouseClick {
try {
platform.currentScreen = action()
UMinecraft.currentScreenObj = action()
} catch (e: Exception) {
e.printStackTrace()
}
Expand Down
File renamed without changes.
13 changes: 1 addition & 12 deletions versions/root.gradle.kts → example/root.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,15 @@ import gg.essential.gradle.util.*

plugins {
id("gg.essential.multi-version.root")
id("gg.essential.multi-version.api-validation")
}

version = versionFromBuildIdAndBranch()

preprocess {
val forge11801 = createNode("1.18.1-forge", 11801, "srg")
val fabric11801 = createNode("1.18.1-fabric", 11801, "yarn")
val forge11701 = createNode("1.17.1-forge", 11701, "srg")
val fabric11701 = createNode("1.17.1-fabric", 11701, "yarn")
val fabric11602 = createNode("1.16.2-fabric", 11602, "yarn")
val forge11602 = createNode("1.16.2-forge", 11602, "srg")
val forge11502 = createNode("1.15.2-forge", 11502, "srg")
val forge11202 = createNode("1.12.2-forge", 11202, "srg")
val forge10809 = createNode("1.8.9-forge", 10809, "srg")

Expand All @@ -23,13 +19,6 @@ preprocess {
forge11701.link(fabric11701)
fabric11701.link(fabric11602)
fabric11602.link(forge11602)
forge11602.link(forge11502)
forge11502.link(forge11202, file("1.15.2-1.12.2.txt"))
forge11602.link(forge11202, file("1.15.2-1.12.2.txt"))
forge11202.link(forge10809, file("1.12.2-1.8.9.txt"))
}

apiValidation {
ignoredProjects.addAll(subprojects.map { it.name })
ignoredPackages.add("com.example")
nonPublicMarkers.add("org.jetbrains.annotations.ApiStatus\$Internal")
}
10 changes: 10 additions & 0 deletions example/src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"schemaVersion": 1,
"id": "examplemod",
"name": "Example Mod",
"version": "0",
"environment": "client",
"entrypoints": {
"client": ["com.example.examplemod.ExampleMod"]
}
}
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
kotlin = "1.5.10"
kotlinx-coroutines = "1.5.2"
jetbrains-annotations = "23.0.0"
universalcraft = "211"
universalcraft = "349"
commonmark = "0.17.1"
dom4j = "2.1.1"

Expand Down
Loading

0 comments on commit 56abfcf

Please sign in to comment.