Skip to content

Commit

Permalink
Release v1.2.1 for MC 1.20.1 Forge
Browse files Browse the repository at this point in the history
  • Loading branch information
cpburnz committed Nov 3, 2024
1 parent 60d5030 commit 4123071
Show file tree
Hide file tree
Showing 21 changed files with 798 additions and 293 deletions.
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
.gradle
/bin/
/build/
/run/

# Eclipse
.classpath
Expand All @@ -11,9 +12,15 @@

# IntelliJ
.idea
*.iml
*.ipr
*.iws

# Avoid ignoring Gradle wrapper jar file (.jar files are usually ignored)
!gradle-wrapper.jar

# Cache of project
.gradletasknamecache

# Development
.env
55 changes: 55 additions & 0 deletions HACKING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
These instructions are written with Linux in mind because that is my development environment.


Java Environment
----------------

Create a ".env" file, and assign the `JAVA_HOME` variable to the path of the
Java 17 JDK. E.g.,

```shell
# Define the version of Java to use with Gradle (i.e., "./gradlew").
JAVA_HOME=/usr/lib/jvm/java-17-openjdk
```

The "env-gradlew" script is a wrapper around "gradlew", and loads the ".env" file to ensure Gradle is run with the proper version of Java.


IDE Projects
------------

Project files for IntelliJ IDEA and Eclipse can be generated by running the "idea" and "eclipse" tasks, respectively:

```shell
./env-gradlew idea
# OR
./env-gradlew eclipse
```


Playtesting
-----------

The Minecraft client can be run directly with the mod by running the "runClient" task:

```shell
./env-gradlew runClient
```

Once a world has been launched within Minecraft, the metrics can be inspected by running:

```shell
curl -Ss 'http://localhost:19565/metrics'
```


Compiling
---------

The release JAR can be compiled by running the "assemble" task:

```shell
./env-gradlew assemble
```

The release JAR will be located at "build/libs/Prometheus-Exporter-{MC Version}-{Mod Loader}-{Mod Version}.jar".
33 changes: 14 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,11 @@
This mod provides a Prometheus exporter for Minecraft. It exports metrics
related to the Minecraft server and the JVM for consumption by the open-source
systems monitoring toolkit, [Prometheus]. The mod is intended for server-side
use, and does not need to be installed client-side. This currently has builds
for the following versions:
use, and does not need to be installed client-side. You can find the latest
builds for various versions of Minecraft and mod loaders in [Releases].

- Minecraft 1.20.1 with Forge 47.1.0.
- Minecraft 1.19.3 with Forge 44.1.0.
- Minecraft 1.19.2 with Forge 43.0.0.
- Minecraft 1.18.1 with Forge 39.0.0.
- Minecraft 1.16.5 with Forge 36.2.0.
- Minecraft 1.15.2 with Forge 21.2.0.
- Minecraft 1.14.4 with Forge 28.1.0.
- Minecraft 1.12.2 with Forge 14.23.0.

Is there a newer version of Minecraft not listed? Let me know by opening an
[issue on GitHub].
Is there a newer version of Minecraft not listed? Is the mod outdated for one of
the listed Minecraft versions? Let me know by opening an [issue on GitHub].


Installation
Expand All @@ -39,24 +30,28 @@ exist. The default configuration can be seen in the example [prometheus_exporter
Exporter Output
---------------

The metrics are documented in [metrics.md].

A sample output from the exporter can be seen in the example [output.txt].
Please note as of version 1.0.0 the "mc_world_tick_seconds" metric has been
renamed to "mc_dimension_tick_seconds".


Dashboards
----------

Known compatible Grafana dashboards are listed in [dashboards.md].


Known compatible Grafana dashboards:

- [Minecraft Server Stats] built by [randombk].


[Curse Forge]: https://www.curseforge.com/minecraft/mc-mods/prometheus-exporter
[GitHub]: https://github.com/cpburnz/minecraft-prometheus-exporter/releases
[Minecraft Server Stats]: https://grafana.com/grafana/dashboards/16508-minecraft-server-stats/
[Prometheus]: https://prometheus.io/
[Releases]: https://github.com/cpburnz/minecraft-prometheus-exporter/wiki/Releases
[dashboards.md]: https://github.com/cpburnz/minecraft-prometheus-exporter/blob/mc1.20.1-forge/dashboards.md
[issue on GitHub]: https://github.com/cpburnz/minecraft-prometheus-exporter/issues
[output.txt]: https://github.com/cpburnz/minecraft-prometheus-exporter/blob/mc1.20.1/examples/output.txt
[prometheus_exporter-server.toml]: https://github.com/cpburnz/minecraft-prometheus-exporter/blob/mc1.20.1/examples/prometheus_exporter-server.toml
[randombk]: https://github.com/randombk
[metrics.md]: https://github.com/cpburnz/minecraft-prometheus-exporter/blob/mc1.20.1-forge/metrics.md
[output.txt]: https://github.com/cpburnz/minecraft-prometheus-exporter/blob/mc1.20.1-forge/examples/output.txt
[prometheus_exporter-server.toml]: https://github.com/cpburnz/minecraft-prometheus-exporter/blob/mc1.20.1-forge/examples/prometheus_exporter-server.toml
92 changes: 62 additions & 30 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
plugins {
// IntelliJ IDEA plugin (makes life easier).
// Java Library plugin.
id 'java-library'

// Eclipse plugin (makes life easier using Eclipse).
id 'eclipse'

// IDEA plugin (makes life easier using IntelliJ IDEA).
id 'idea'

// Forge Gradle plugin (required).
Expand All @@ -8,8 +14,11 @@ plugins {
// Shadow Jar plugin: bundle dependencies.
id 'com.github.johnrengelman.shadow' version '7.1.2'

// Curse Gradle (publishing)
//id 'com.matthewprenger.cursegradle' version '1.4.0'
// CurseForge plugin.
id 'net.darkhax.curseforgegradle' version '1.1.25'

// GitHub plugin.
id 'com.github.breadmoirai.github-release' version '2.4.1'
}

// Project settings.
Expand Down Expand Up @@ -125,6 +134,7 @@ configurations {
compileAndShadow
compile.extendsFrom compileAndShadow
shadow.extendsFrom compileAndShadow
minecraftLibrary.extendsFrom compileAndShadow
}

repositories {
Expand Down Expand Up @@ -173,19 +183,14 @@ dependencies {
// A missing property will result in an error. Properties are expanded using ${} Groovy notation.
// When "copyIdeResources" is enabled, this will also run before the game launches in IDE environments.
// See https://docs.gradle.org/current/dsl/org.gradle.language.jvm.tasks.ProcessResources.html
tasks.named('processResources', ProcessResources).configure {
def replaceProperties = [
processResources {
var replaceProperties = [
'forge_version_range': forge_version_range,
'loader_version_range': loader_version_range,
'minecraft_version_range': minecraft_version_range,
'mod_authors': mod_authors,
'mod_description': mod_description,
'mod_id': mod_id,
'mod_license': mod_license,
'mod_logo_file': mod_logo_file,
'mod_name': mod_name,
'mod_tracker_url': mod_tracker_url,
'mod_url': mod_url,
'mod_version': mod_version,
]

Expand All @@ -198,25 +203,28 @@ tasks.named('processResources', ProcessResources).configure {
}

// Project JAR settings.
tasks.named('jar', Jar).configure {
jar {
// Include the Minecraft version in the JAR name.
archiveAppendix = "${minecraft_version}-forge"

manifest {
attributes([
'Specification-Title': mod_id,
'Specification-Vendor': mod_authors,
'Specification-Version': '1', // We are version 1 of ourselves
'Specification-Version': mod_version,
'Implementation-Title': mod_name,
'Implementation-Version': mod_version,
'Implementation-Vendor': mod_authors,
'Implementation-Timestamp': new Date().format("yyyy-MM-dd'T'HH:mm:ssZ")
])
}

// This is the preferred method to reobfuscate your jar file.
finalizedBy 'reobfShadowJar'
}

// Configure Shadow Jar.
tasks.named('shadowJar').configure {
shadowJar {
// Remove JAR suffix.
archiveAppendix = tasks.jar.archiveAppendix
archiveClassifier = tasks.jar.archiveClassifier
Expand All @@ -230,10 +238,9 @@ tasks.named('shadowJar').configure {

// Vendor dependencies with Shadow Jar.
import com.github.jengelman.gradle.plugins.shadow.tasks.ConfigureShadowRelocation

task vendorShadowJarDeps(type: ConfigureShadowRelocation) {
tasks.register('vendorShadowJarDeps', ConfigureShadowRelocation) {
target = tasks.shadowJar
prefix = "${project.group}.minecraft_prometheus_exporter.vendors"
prefix = "${mod_package}.vendor"
}

tasks.shadowJar.dependsOn tasks.vendorShadowJarDeps
Expand All @@ -252,24 +259,49 @@ reobf {
tasks.reobfShadowJar.dependsOn tasks.jar
tasks.assemble.dependsOn tasks.reobfShadowJar

// Configure Curse Gradle for publishing to Curse Forge.
/*
curseforge {
apiKey = "test"
tasks.withType(JavaCompile).configureEach {
options.encoding = 'UTF-8' // Use the UTF-8 charset for Java compilation
}

project {
id = '351938'
changelog = 'CHANGES.md'
// Publish release to CurseForge.
import net.darkhax.curseforgegradle.TaskPublishCurseForge
tasks.register('publishCurseForge', TaskPublishCurseForge) {
var curseforge_token = System.env.CURSEFORGE_TOKEN
var project_id = 351938

apiToken = curseforge_token

upload(project_id, remapJar.archiveFile) {
changelog = file('CHANGES.md').filterLine {
!it.startsWith('Change History') && !it.startsWith('====')
}.toString()
changelogType = 'markdown'
releaseType = 'beta'
releaseType = 'release'

mainArtifact shadowJar
addEnvironment 'Server'
}
}

tasks.curseforge.dependsOn tasks.build
*/

tasks.withType(JavaCompile).configureEach {
options.encoding = 'UTF-8' // Use the UTF-8 charset for Java compilation
// Publish release to GitHub.
githubRelease {
var branch = "mc${minecraft_version}-forge"
var changes_url = "https://github.com/cpburnz/minecraft-prometheus-exporter/blob/${branch}/CHANGES.md"
var github_token = System.env.GITHUB_TOKEN

body = "Release v${mod_version} for Minecraft ${minecraft_version} with Forge ${forge_version_min}. See [CHANGES.md](${changes_url})."
draft = false
//dryRun = true
releaseAssets = jar.archiveFile
releaseName = "Minecraft ${minecraft_version} (Forge) / v${mod_version}"
repo = 'minecraft-prometheus-exporter'
tagName = "${minecraft_version}-forge-${mod_version}"
targetCommitish = branch
token = github_token ?: ""
}

tasks.githubRelease.dependsOn tasks.jar
tasks.githubRelease.dependsOn tasks.shadowJar

// Alias for publishing to GitHub.
tasks.register('publishGithub')
tasks.publishGithub.dependsOn tasks.githubRelease
10 changes: 10 additions & 0 deletions dashboards.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
Grafana
-------

Known compatible Grafana (v9) dashboards:

- [Minecraft Server Stats] built by [randombk].


[Minecraft Server Stats]: https://grafana.com/grafana/dashboards/16508-minecraft-server-stats/
[randombk]: https://github.com/randombk
23 changes: 23 additions & 0 deletions env-gradlew
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/bin/bash
#
# This is a tiny wrapper to load the environment variables from ".env" before
# running "gradlew". This makes using the correct version of Java easier.
#

# Exit on error.
set -e

# Get project directory.
home_dir="$(cd "$(dirname "$0")" && pwd)"

# Load ".env".
set -a
. "$home_dir/.env"
set +a

# Verify Gradle wrapper JAR.
# - See <https://gradle.org/release-checksums/>.
sha256sum --quiet -c "$home_dir/gradle-wrapper-v8.1.sha256"

# Run Gradle.
"$home_dir/gradlew" "$@"
Loading

0 comments on commit 4123071

Please sign in to comment.