Skip to content

Commit

Permalink
Sync with Framework
Browse files Browse the repository at this point in the history
  • Loading branch information
NotRyken committed Nov 4, 2024
1 parent 890298b commit 305b788
Show file tree
Hide file tree
Showing 30 changed files with 492 additions and 261 deletions.
2 changes: 1 addition & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -460,7 +460,7 @@ ij_xml_block_comment_at_first_column = true
ij_xml_keep_indents_on_empty_lines = false
ij_xml_line_comment_at_first_column = true

[{*.yml,*.yaml}]
[{*.yml,*.yaml,*.toml}]
indent_size = 2
ij_yaml_keep_indents_on_empty_lines = false
ij_yaml_keep_line_breaks = true
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/check-build.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Builds the project on Linux and Windows as a partial defence against bad commits
# Builds the project on Linux and Windows as a partial defense against bad commits
name: Check Build

on:
Expand Down
11 changes: 7 additions & 4 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
# Builds the project and publishes the artifacts to GitHub and Modrinth
# Requires GITHUB_TOKEN to have write permissions; if not, replace it with a custom token
# Requires a Modrinth PAT MODRINTH_TOKEN
# Builds the project and publishes the artifacts to GitHub, Modrinth and CurseForge
# Modrinth publishing requires a Modrinth PAT MODRINTH_TOKEN
# Will skip without error if not present
# CurseForge publishing requires a CurseForge API token CURSEFORGE_TOKEN
# Will skip without error if not present
name: Release

on: [workflow_dispatch]
on:
workflow_dispatch:

permissions:
contents: write
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/sync-labels.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Synchronizes the repo's labels with labels.yml
# Synchronizes the repo's labels with a centralized labels.yml
# Requires GITHUB_TOKEN to have write permissions; if not, replace it with a custom token
name: Sync Labels

Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ run/
runs/
out/
classes/
.eclipse/

# IDEA
.idea/
Expand Down
13 changes: 13 additions & 0 deletions NOTICE
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
Copyright ${year} ${owner_name}

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ Copy, insert and erase text from signs using a simple GUI.

<table style="width:100%;">
<tr>
<td style="width:50%;"><img src="https://raw.githubusercontent.com/TerminalMC/SignCopy/HEAD/assets/images/showcase/demo_01.png" style="width:100%;"></td>
<td style="width:50%;"><img src="https://raw.githubusercontent.com/TerminalMC/SignCopy/HEAD/assets/images/showcase/demo_02.png" style="width:100%;"></td>
<td style="width:50%;"><img src="https://raw.githubusercontent.com/TerminalMC/SignCopy/HEAD/assets/images/demo_01.png" style="width:100%;"></td>
<td style="width:50%;"><img src="https://raw.githubusercontent.com/TerminalMC/SignCopy/HEAD/assets/images/demo_02.png" style="width:100%;"></td>
</tr>
</table>

Expand Down
File renamed without changes
File renamed without changes
132 changes: 23 additions & 109 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,121 +1,40 @@
plugins {
id("java")
id("java-library")
id("idea")
id("maven-publish")
id("org.jetbrains.gradle.plugin.idea-ext") version("${ideaext_version}") // Required for NeoGradle
id("fabric-loom") version("${loom_version}") apply(false)
id("net.neoforged.moddev") version("${moddev_version}") apply(false)
id("com.modrinth.minotaur") version("${minotaur_version}")
id("net.darkhax.curseforgegradle") version("${curseforgegradle_version}")
id("com.github.breadmoirai.github-release") version("${githubrelease_version}")
id("org.ajoberstar.grgit.service") version("${grgitservice_version}")
id("org.cadixdev.licenser") version("${licenser_version}")
}

subprojects {
version = mod_version
group = mod_group

apply(plugin: "java")
apply(plugin: "java-library")
apply(plugin: "idea")
apply(plugin: "maven-publish")
// License headers
apply(plugin: "org.cadixdev.licenser")
license {
// This can be done in multiloader-common.gradle but only if the
// "matching" method is not used (throws a pile of weird errors).
// Also, NeoForge's update of the plugin can't handle matching at all.
include("**/*.java") // Java files only
header = rootProject.file("NOTICE")
properties {
project_name = mod_name
owner_name = mod_owner
year = java.time.LocalDate.now().getYear().toString()
}
}

if (project.name != "common") {
// Publishing
if (name != "common") {
apply(plugin: "com.modrinth.minotaur")
apply(plugin: "net.darkhax.curseforgegradle")
apply(plugin: "com.github.breadmoirai.github-release")
apply(plugin: "org.ajoberstar.grgit.service")
}

java.toolchain.languageVersion = JavaLanguageVersion.of(Integer.valueOf(java_version))

jar {
from(rootProject.file("LICENSE")) {
rename { "${it}_${mod_name}" }
}
manifest {
attributes([
"Specification-Title" : mod_name,
"Specification-Vendor" : mod_owner,
"Specification-Version" : project.jar.archiveVersion,
"Implementation-Title" : project.name,
"Implementation-Version" : project.jar.archiveVersion,
"Implementation-Vendor" : mod_owner,
"Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ"),
"Timestamp" : System.currentTimeMillis(),
"Built-On-Java" : "${System.getProperty('java.vm.version')} (${System.getProperty('java.vm.vendor')})",
"Built-On-Minecraft" : minecraft_version
])
}
}
java.withSourcesJar()
sourcesJar {
from(rootProject.file("LICENSE")) {
rename { "${it}_${mod_name}" }
}
}

repositories {
maven {
name = "Modrinth"
url = "https://api.modrinth.com/maven"
}
maven {
name = "Shedaniel"
url = "https://maven.shedaniel.me/"
}
}

tasks.withType(JavaCompile).configureEach {
it.options.encoding = "UTF-8"
it.options.getRelease().set(Integer.valueOf(java_version))
}

processResources {
def expandProps = [
"project_group": project.group,
"mod_version": mod_version,
"mod_group": mod_group,
"mod_id": mod_id,
"mod_name": mod_name,
"mod_description": mod_description,
"mod_icon": "assets/" + mod_id + "/icon.png",
"mod_owner": mod_owner,
"mod_authors_list": asJsonList(mod_authors),
"mod_contributors_list": asJsonList(mod_contributors),
"mod_authors_string": mod_authors.replace(",", ", "),
"mod_contributors_string": mod_contributors.replace(",", ", "),
"mod_license": mod_license,
"mod_environment": mod_environment,
"java_version": java_version,
"java_versions_fabric_list": asJsonList(java_versions_fabric),
"java_versions_neoforge": java_versions_neoforge,
"minecraft_version": minecraft_version,
"minecraft_versions_fabric_list": asJsonList(minecraft_versions_fabric),
"minecraft_versions_neoforge": minecraft_versions_neoforge,
"fabric_loader_version": fabric_loader_version,
"fabric_loader_versions_list": asJsonList(fabric_loader_versions),
"fabric_api_version": fabric_api_version,
"fabric_api_versions_list": asJsonList(fabric_api_versions),
"neoforge_loader_versions": neoforge_loader_versions,
"neoforge_version": neoforge_version,
"neoforge_versions": neoforge_versions,
"homepage_url": homepage_url,
"sources_url": sources_url,
"issues_url": issues_url,
"contact_url": contact_url
]

filesMatching(["pack.mcmeta", "*.mod.json", "META-INF/*mods.toml", "*.mixins.json", "assets/"+mod_id+"/lang/*.json"]) {
expand expandProps
}
inputs.properties(expandProps)
}

tasks.withType(GenerateModuleMetadata).configureEach {
enabled = false
}

afterEvaluate {
if (name != "common") {
afterEvaluate {
modrinth {
token = System.getenv().MODRINTH_TOKEN ? System.getenv().MODRINTH_TOKEN : "empty"
projectId = modrinth_id
Expand Down Expand Up @@ -151,8 +70,7 @@ subprojects {
tasks.modrinthSyncBody.onlyIf { System.getenv().MODRINTH_TOKEN }

task curseforge(type: net.darkhax.curseforgegradle.TaskPublishCurseForge) {
apiToken = System.getenv().CURSEFORGE_TOKEN ? System.getenv().CURSEFORGE_TOKEN : ""
if (apiToken.isBlank()) return
apiToken = System.getenv().CURSEFORGE_TOKEN ? System.getenv().CURSEFORGE_TOKEN : "empty"

disableVersionDetection()
String module = project.name
Expand All @@ -161,7 +79,7 @@ subprojects {
file.displayName = "v${mod_version}-${capsLoader(module)}-${minecraft_version}"
file.releaseType = release_type
file.changelog = rootProject.file("changelog.md").text
file.changelogType = 'markdown'
file.changelogType = "markdown"
project.property("release_mod_loaders_${module}").split(",").each { String id ->
file.addModLoader(id)
}
Expand Down Expand Up @@ -207,10 +125,6 @@ subprojects {
}
}

static asJsonList(String versions) {
return versions.split(",").collect { "\"$it\"" }.join(',')
}

static String capsLoader(String loader) {
switch(loader) {
case "fabric": return "Fabric"
Expand Down
3 changes: 3 additions & 0 deletions buildSrc/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
plugins {
id("groovy-gradle-plugin")
}
139 changes: 139 additions & 0 deletions buildSrc/src/main/groovy/multiloader-common.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
plugins {
id("java-library")
id("maven-publish")
}

base {
archivesName = "${mod_id}-${project.name}"
}

java {
toolchain.languageVersion = JavaLanguageVersion.of(java_version)
withSourcesJar()
// withJavadocJar() // Also uncomment javadocElements in capabilities below
}

repositories {
mavenCentral()
// https://docs.gradle.org/current/userguide/declaring_repositories.html#declaring_content_exclusively_found_in_one_repository
exclusiveContent {
forRepository {
maven {
name = "Sponge"
url = "https://repo.spongepowered.org/repository/maven-public"
}
}
filter { includeGroupAndSubgroups("org.spongepowered") }
}
exclusiveContent {
forRepositories(
maven {
name = "ParchmentMC"
url = "https://maven.parchmentmc.org"
},
maven {
name = "NeoForge"
url = "https://maven.neoforged.net/releases"
}
)
filter { includeGroup("org.parchmentmc.data") }
}
}

// Declare capabilities on the outgoing configurations.
// Read more about capabilities here: https://docs.gradle.org/current/userguide/component_capabilities.html#sec:declaring-additional-capabilities-for-a-local-component
["apiElements", "runtimeElements", "sourcesElements", /*"javadocElements"*/].each { variant ->
configurations."$variant".outgoing {
capability("$group:${base.archivesName.get()}:$version")
capability("$group:$mod_id-${project.name}-${minecraft_version}:$version")
capability("$group:$mod_id:$version")
}
publishing.publications.configureEach {
suppressPomMetadataWarningsFor(variant)
}
}

sourcesJar {
from(rootProject.file("LICENSE")) {
rename { "${it}_${mod_name}" }
}
}

jar {
from(rootProject.file("LICENSE")) {
rename { "${it}_${mod_name}" }
}

manifest {
attributes([
"Specification-Title" : mod_name,
"Specification-Vendor" : mod_owner,
"Specification-Version" : project.jar.archiveVersion,
"Implementation-Title" : project.name,
"Implementation-Version" : project.jar.archiveVersion,
"Implementation-Vendor" : mod_owner,
"Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ"),
"Timestamp" : System.currentTimeMillis(),
"Built-On-Java" : "${System.getProperty('java.vm.version')} (${System.getProperty('java.vm.vendor')})",
"Built-On-Minecraft" : minecraft_version
])
}
}

processResources {
def expandProps = [
// Mod info
"mod_version": mod_version,
"mod_group": mod_group,
"mod_id": mod_id,
"mod_name": mod_name,
"mod_description": mod_description,
"mod_icon": "assets/" + mod_id + "/icon.png",
"mod_owner": mod_owner,
"mod_authors_list": asJsonList(mod_authors),
"mod_contributors_list": asJsonList(mod_contributors),
"mod_authors_string": mod_authors.replace(",", ", "),
"mod_contributors_string": mod_contributors.replace(",", ", "),
"mod_license": mod_license,
// Links
"homepage_url": homepage_url,
"sources_url": sources_url,
"issues_url": issues_url,
"contact_url": contact_url,
// Java
"java_version": java_version,
"java_versions_fabric_list": asJsonList(java_versions_fabric),
"java_versions_neoforge": java_versions_neoforge,
// Minecraft
"minecraft_versions_fabric_list": asJsonList(minecraft_versions_fabric),
"minecraft_versions_neoforge": minecraft_versions_neoforge,
// Fabric
"fabric_loader_versions_list": asJsonList(fabric_loader_versions),
"fabric_api_versions_list": asJsonList(fabric_api_versions),
// NeoForge
"neoforge_loader_versions": neoforge_loader_versions,
"neoforge_versions": neoforge_versions,
]
filesMatching(["pack.mcmeta", "*.mod.json", "META-INF/*mods.toml", "*.mixins.json"]) {
expand expandProps
}
inputs.properties(expandProps)
}

publishing {
publications {
register("mavenJava", MavenPublication) {
artifactId base.archivesName.get()
from components.java
}
}
repositories {
maven {
url System.getenv("local_maven_url")
}
}
}

static asJsonList(String versions) {
return versions.split(",").collect { "\"$it\"" }.join(",")
}
Loading

0 comments on commit 305b788

Please sign in to comment.