Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
287 changes: 83 additions & 204 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,229 +1,108 @@
import com.google.gson.Gson
import com.google.gson.JsonArray
import com.google.gson.JsonElement
import com.google.gson.JsonObject
import net.darkhax.curseforgegradle.TaskPublishCurseForge

import java.nio.file.Files

plugins {
id 'java-library'
id 'maven-publish'
id 'net.neoforged.moddev' version '2.0.124'
id "com.modrinth.minotaur" version "2.8.10"
id 'net.darkhax.curseforgegradle' version '1.1.26'
id 'idea'
buildscript {
repositories {
maven { url = 'https://maven.minecraftforge.net' }
maven { url = 'https://files.minecraftforge.net/maven' }
jcenter()
maven { url = 'https://repo.spongepowered.org/repository/maven-public/' }
mavenCentral()
}
dependencies {
classpath 'net.minecraftforge.gradle:ForgeGradle:2.3-SNAPSHOT'
classpath 'org.spongepowered:mixingradle:0.6-SNAPSHOT'
}
}

tasks.named('wrapper', Wrapper).configure {
// Define wrapper values here so as to not have to always do so when updating gradlew.properties.
// Switching this to Wrapper.DistributionType.ALL will download the full gradle sources that comes with
// documentation attached on cursor hover of gradle classes and methods. However, this comes with increased
// file size for Gradle. If you do switch this to ALL, run the Gradle wrapper task twice afterwards.
// (Verify by checking gradle/wrapper/gradle-wrapper.properties to see if distributionUrl now points to `-all`)
distributionType = Wrapper.DistributionType.BIN
}
apply plugin: 'net.minecraftforge.gradle.forge'
apply plugin: 'org.spongepowered.mixin'
apply plugin: 'java'

version = "${rootProject.mod_version}+${rootProject.mod_version_type}.${System.getenv("GITHUB_RUN_NUMBER") == null ? "dev" : System.getenv("GITHUB_RUN_NUMBER")}"
group = mod_group_id
version = mod_version
archivesBaseName = mod_id

repositories {}
sourceCompatibility = targetCompatibility = '1.8'

base {
archivesName = mod_id
repositories {
maven { url = 'https://maven.minecraftforge.net' }
maven { url = 'https://files.minecraftforge.net/maven' }
jcenter()
maven { url = 'https://repo.spongepowered.org/repository/maven-public/' }
mavenCentral()
}

java.toolchain.languageVersion = JavaLanguageVersion.of(21)

neoForge {
// Specify the version of NeoForge to use.
version = project.neo_version

parchment {
mappingsVersion = project.parchment_mappings_version
minecraftVersion = project.parchment_minecraft_version
}

// This line is optional. Access Transformers are automatically detected
// accessTransformers = project.files('src/main/resources/META-INF/accesstransformer.cfg')

// Default run configurations.
// These can be tweaked, removed, or duplicated as needed.
runs {
client {
client()

// Comma-separated list of namespaces to load gametests from. Empty = all namespaces.
systemProperty 'neoforge.enabledGameTestNamespaces', project.mod_id
}

server {
server()
programArgument '--nogui'
systemProperty 'neoforge.enabledGameTestNamespaces', project.mod_id
}

// This run config launches GameTestServer and runs all registered gametests, then exits.
// By default, the server will crash when no gametests are provided.
// The gametest system is also enabled by default for other run configs under the /test command.
gameTestServer {
type = "gameTestServer"
systemProperty 'neoforge.enabledGameTestNamespaces', project.mod_id
}

data {
clientData()

// example of overriding the workingDirectory set in configureEach above, uncomment if you want to use it
// gameDirectory = project.file('run-data')

// Specify the modid for data generation, where to output the resulting resource, and where to look for existing resources.
programArguments.addAll '--mod', project.mod_id, '--all', '--output', file('src/generated/resources/').getAbsolutePath(), '--existing', file('src/main/resources/').getAbsolutePath()
}

// applies to all the run configs above
configureEach {
// Recommended logging data for a userdev environment
// The markers can be added/remove as needed separated by commas.
// "SCAN": For mods scan.
// "REGISTRIES": For firing of registry events.
// "REGISTRYDUMP": For getting the contents of all registries.
systemProperty 'forge.logging.markers', 'REGISTRIES'

// Recommended logging level for the console
// You can set various levels here.
// Please read: https://stackoverflow.com/questions/2031163/when-to-use-the-different-log-levels
logLevel = org.slf4j.event.Level.DEBUG
}
}

mods {
// define mod <-> source bindings
// these are used to tell the game which sources are for which mod
// multi mod projects should define one per mod
"${mod_id}" {
sourceSet(sourceSets.main)
}
}
dependencies {
compile 'org.spongepowered:mixin:0.8.2'
testCompile 'junit:junit:4.13.2'
}

// Include resources generated by data generators.
sourceSets.main.resources { srcDir 'src/generated/resources' }

// Sets up a dependency configuration called 'localRuntime'.
// This configuration should be used instead of 'runtimeOnly' to declare
// a dependency that will be present for runtime testing but that is
// "optional", meaning it will not be pulled by dependents of this mod.
configurations {
runtimeClasspath.extendsFrom localRuntime
}

dependencies {}

// This block of code expands all declared replace properties in the specified resource targets.
// A missing property will result in an error. Properties are expanded using ${} Groovy notation.
var generateModMetadata = tasks.register("generateModMetadata", ProcessResources) {
var replaceProperties = [
minecraft_version : minecraft_version,
minecraft_version_range: minecraft_version_range,
neo_version : neo_version,
mod_id : mod_id,
mod_name : mod_name,
mod_license : mod_license,
mod_version : mod_version,
mod_authors : mod_authors,
mod_description : mod_description
minecraft {
version = "${minecraft_version}-${forge_version}"
runDir = 'run'
mappings = mcp_mappings
clientJvmArgs += [
'-Dfml.coreMods.load=dev.httxrafa.modflared.mixin.ModflaredMixinLoader',
'-Dmixin.env.disableRefMap=true'
]
inputs.properties replaceProperties
expand replaceProperties
from "src/main/templates"
into "build/generated/sources/modMetadata"
}
// Include the output of "generateModMetadata" as an input directory for the build
// this works with both building through Gradle and the IDE.
sourceSets.main.resources.srcDir generateModMetadata
// To avoid having to run "generateModMetadata" manually, make it run on every project reload
neoForge.ideSyncTask generateModMetadata

// Example configuration to allow publishing using the maven-publish plugin
publishing {
publications {
register('mavenJava', MavenPublication) {
from components.java
}
}
repositories {
maven {
url "file://${project.projectDir}/repo"
}
}
}

tasks.withType(JavaCompile).configureEach {
options.encoding = 'UTF-8' // Use the UTF-8 charset for Java compilation
mixin {
defaultObfuscationEnv searge
}

// IDEA no longer automatically downloads sources/javadoc jars for dependencies, so we need to explicitly enable the behavior.
idea {
module {
downloadSources = true
downloadJavadoc = true
processResources {
inputs.property 'version', project.version
inputs.property 'mcversion', minecraft_version
filesMatching('mcmod.info') {
expand([
version: project.version,
mcversion: minecraft_version,
mod_id: mod_id,
mod_name: mod_name,
mod_description: mod_description,
mod_authors: mod_authors,
mod_license: mod_license
])
}
}

// Configure the modrinth publication
modrinth {
token = System.getenv("MODRINTH_TOKEN")
projectId = "${modrinth_project_id}"
versionNumber = "${version}+${minecraft_version}"
versionName = "${version} for ${minecraft_version}"
versionType = "${mod_version_type}"
changelog = generateChangelog()
uploadFile = jar
gameVersions = ["${minecraft_version}"]

syncBodyFrom = rootProject.file("README.md").text;
tasks.withType(JavaCompile) {
options.encoding = 'UTF-8'
options.compilerArgs += ['-Xlint:unchecked', '-Xlint:deprecation']
}

tasks.modrinth.dependsOn(tasks.modrinthSyncBody)

// Configure the curseforge publication
tasks.register('publishCurseForge', TaskPublishCurseForge) {
apiToken = System.getenv("CURSEFORGE_TOKEN")

// The main file to upload
def mainFile = upload(curseforge_project_id, jar)
mainFile.displayName = "${version} for ${minecraft_version}"
mainFile.releaseType = mod_version_type
mainFile.changelog = generateChangelog()
mainFile.changelogType = 'markdown'
mainFile.addGameVersion(minecraft_version)
mainFile.addModLoader("neoforge")
jar {
manifest {
attributes(
'FMLCorePluginContainsFMLMod': 'true',
'FMLCorePlugin': 'dev.httxrafa.modflared.mixin.ModflaredMixinLoader',
'MixinConfigs': 'modflared.mixins.json'
)
}
rename 'mixin.refmap.json', 'modflared.refmap.json'
}

// Credits: https://github.com/RelativityMC/VMP-fabric
static String generateChangelog() {
final String path = System.getenv("GITHUB_EVENT_RAW_PATH");
if (path == null || path.isBlank()) return "No changelog was specified. ";
final JsonObject jsonObject = new Gson().fromJson(Files.readString(java.nio.file.Path.of(path)), JsonObject.class);
tasks.extractAnnotationsJar.enabled = false

StringBuilder builder = new StringBuilder();
builder.append("This version is uploaded automatically by GitHub Actions. \n\n")
.append("Changelog: \n");
final JsonArray commits = jsonObject.getAsJsonArray("commits");
if (commits.isEmpty()) {
builder.append("No changes detected. \n");
} else {
for (JsonElement commit : commits) {
JsonObject object = commit.getAsJsonObject();
builder.append("- ");
builder.append('[').append(object.get("id").getAsString(), 0, 8).append(']').append('(').append(object.get("url").getAsString()).append(')');
builder.append(' ');
builder.append(object.get("message").getAsString().split("\n")[0]);
builder.append(" - ");
builder.append(object.get("author").getAsJsonObject().get("name").getAsString());
builder.append(" ").append('\n');
}
task shadowJar(type: Jar) {
classifier = 'all'
from zipTree(jar.archivePath)
from {
configurations.compile.filter { dep ->
dep.name.contains('mixin')
}.collect { it.isDirectory() ? it : zipTree(it) }
}
return builder.toString();
exclude 'META-INF/*.SF'
exclude 'META-INF/*.DSA'
exclude 'META-INF/*.RSA'
manifest {
attributes(
'FMLCorePluginContainsFMLMod': 'true',
'FMLCorePlugin': 'dev.httxrafa.modflared.mixin.ModflaredMixinLoader',
'MixinConfigs': 'modflared.mixins.json'
)
}
rename 'mixin.refmap.json', 'modflared.refmap.json'
}

shadowJar.dependsOn reobfJar
build.dependsOn shadowJar
Comment thread
HttpRafa marked this conversation as resolved.
30 changes: 5 additions & 25 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,34 +1,14 @@
# Sets default memory used for gradle commands. Can be overridden by user or command line properties.
org.gradle.jvmargs=-Xmx2G
org.gradle.daemon=true
org.gradle.parallel=true
org.gradle.caching=true
org.gradle.configuration-cache=true

parchment_minecraft_version=1.21.10
parchment_mappings_version=2025.10.12

## Environment Properties

minecraft_version=1.21.11
minecraft_version_range=[1.21.11]
neo_version=21.11.6-beta

## Mod Properties
minecraft_version=1.12.2
forge_version=14.23.5.2847
mcp_mappings=stable_39

mod_id=modflared
mod_name=Modflared
mod_license=MIT
mod_version=1.6.0
mod_version=1.12.2-legacy.1
mod_group_id=dev.httxrafa.modflared
mod_authors=HttpRafa, Contributers
mod_authors=HttpRafa, Contributors
mod_description=Automatically connects you to a Cloudflare tunnel without having to install cloudflared separately.

## Modrinth Properties
modrinth_project_id=modflared

## Curseforge Properties
curseforge_project_id=997330

## Publish Properties
mod_version_type=release
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-9.4.0-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.3-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
11 changes: 2 additions & 9 deletions settings.gradle
Original file line number Diff line number Diff line change
@@ -1,9 +1,2 @@
pluginManagement {
repositories {
gradlePluginPortal()
}
}

plugins {
id 'org.gradle.toolchains.foojay-resolver-convention' version '1.0.0'
}
// ForgeGradle 1.12.2 single-project settings
rootProject.name = 'modflared'
Loading
Loading