mirror of
https://github.com/xfl03/MCCustomSkinLoader.git
synced 2026-11-12 22:27:37 +00:00
Convert all build scripts to buildSrc. (#216)
This commit is contained in:
1 parent
e1e5319bdb
commit
1b85fa8ff9
22 files changed
+334
-310
No files matched your search
@@ -1,55 +0,0 @@
|
||||
|
||||
buildscript {
|
||||
repositories {
|
||||
maven {
|
||||
url "https://plugins.gradle.org/m2/"
|
||||
}
|
||||
}
|
||||
dependencies {
|
||||
classpath "gradle.plugin.com.matthewprenger:CurseGradle:1.4.0"
|
||||
}
|
||||
}
|
||||
|
||||
import com.matthewprenger.cursegradle.CurseArtifact
|
||||
import com.matthewprenger.cursegradle.CurseGradlePlugin
|
||||
import com.matthewprenger.cursegradle.CurseUploadTask
|
||||
import customskinloader.gradle.util.VersionUtil
|
||||
|
||||
// https://www.curseforge.com/minecraft/mc-mods/customskinloader
|
||||
static void provideCurseForge0(Project proj) {
|
||||
proj.apply plugin: CurseGradlePlugin
|
||||
|
||||
// We don’t use the task provided by the plugin because it adds some dependencies that we don’t need.
|
||||
proj.tasks.create(name: "publishCurseForge", type: CurseUploadTask) { task ->
|
||||
onlyIf {
|
||||
System.getenv("CURSEFORGE_API_KEY") != null
|
||||
}
|
||||
|
||||
apiKey = System.getenv("CURSEFORGE_API_KEY")
|
||||
projectId = "286924"
|
||||
mainArtifact = new CurseArtifact().with {
|
||||
artifact = proj.tasks.jar
|
||||
gameVersionStrings = proj.ext.config.minecraft_full_versions.split(",") // Minecraft Versions
|
||||
proj.ext.config.java_full_versions.split(",").each {
|
||||
gameVersionStrings += "Java ${it}" // Java Versions
|
||||
}
|
||||
gameVersionStrings += proj.name.split("/")[0] // Loader Version
|
||||
changelogType = "text"
|
||||
changelog = System.getenv("GIT_COMMIT_DESC") ?: ""
|
||||
displayName = "${proj.archivesBaseName}-${VersionUtil.getShortVersion(proj.rootProject)}"
|
||||
releaseType = VersionUtil.isSnapshot(proj.rootProject) ? "beta" : "release"
|
||||
it
|
||||
}
|
||||
additionalArtifacts = []
|
||||
|
||||
proj.rootProject.tasks.whenTaskAdded {
|
||||
if (it.name == "upload") {
|
||||
it.finalizedBy task
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ext {
|
||||
provideCurseForge = { Project p -> provideCurseForge0 p }
|
||||
}
|
||||
@@ -1,49 +0,0 @@
|
||||
|
||||
buildscript {
|
||||
repositories {
|
||||
maven {
|
||||
url "https://plugins.gradle.org/m2/"
|
||||
}
|
||||
}
|
||||
dependencies {
|
||||
classpath "gradle.plugin.com.modrinth.minotaur:Minotaur:1.2.1"
|
||||
}
|
||||
}
|
||||
|
||||
import com.modrinth.minotaur.TaskModrinthUpload
|
||||
import com.modrinth.minotaur.request.VersionType
|
||||
import customskinloader.gradle.util.VersionUtil
|
||||
|
||||
// https://modrinth.com/mod/customskinloader
|
||||
static void provideModrinth0(Project proj) {
|
||||
proj.tasks.create(name: "publishModrinth", type: TaskModrinthUpload) { task ->
|
||||
onlyIf {
|
||||
System.getenv("MODRINTH_TOKEN") != null
|
||||
}
|
||||
|
||||
token = System.getenv("MODRINTH_TOKEN")
|
||||
projectId = "idMHQ4n2"
|
||||
versionNumber = "${VersionUtil.getCSLVersion(proj.rootProject)}-${proj.name.replace("/", ".")}"
|
||||
versionName = "${proj.archivesBaseName}-${VersionUtil.getShortVersion(proj.rootProject)}"
|
||||
changelog = System.getenv("GIT_COMMIT_DESC") ?: ""
|
||||
uploadFile = proj.tasks.jar
|
||||
versionType = VersionUtil.isSnapshot(proj.rootProject) ? VersionType.BETA : VersionType.RELEASE
|
||||
failSilently = true
|
||||
detectLoaders = false
|
||||
|
||||
proj.ext.config.minecraft_full_versions.split(",").each {
|
||||
addGameVersion it // Minecraft Versions
|
||||
}
|
||||
addLoader proj.name.split("/")[0].toLowerCase() // Loader Version
|
||||
|
||||
proj.rootProject.tasks.whenTaskAdded {
|
||||
if (it.name == "upload") {
|
||||
it.finalizedBy task
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ext {
|
||||
provideModrinth = { Project p -> provideModrinth0 p }
|
||||
}
|
||||
@@ -1,80 +0,0 @@
|
||||
/**
|
||||
* Gradle Script for Converting Mappings
|
||||
* Designed for Converting Mappings.
|
||||
* Converting Mappings: tsrg->srg
|
||||
*/
|
||||
|
||||
buildscript {
|
||||
repositories {
|
||||
mavenCentral()
|
||||
maven {
|
||||
name = "forge"
|
||||
url = "https://maven.minecraftforge.net/"
|
||||
}
|
||||
}
|
||||
dependencies {
|
||||
classpath 'net.minecraftforge.gradle:ForgeGradle:2.3.+'
|
||||
classpath "org.cadixdev:mercury:0.1.0"
|
||||
}
|
||||
}
|
||||
|
||||
import net.minecraftforge.srg2source.ast.RangeExtractor
|
||||
import net.minecraftforge.srg2source.util.io.InputSupplier
|
||||
import org.cadixdev.lorenz.MappingSet
|
||||
import org.cadixdev.lorenz.io.srg.SrgReader
|
||||
import org.cadixdev.lorenz.io.srg.SrgWriter
|
||||
import org.cadixdev.lorenz.io.srg.tsrg.TSrgReader
|
||||
import org.cadixdev.mercury.Mercury
|
||||
import org.cadixdev.mercury.remapper.MercuryRemapper
|
||||
|
||||
void tsrg2srg(File tsrg, File srg) {
|
||||
if (!tsrg.exists()) return
|
||||
if (!srg.parentFile.exists()) srg.parentFile.mkdirs()
|
||||
MappingSet.create().with { set ->
|
||||
tsrg.withReader "UTF-8", { reader ->
|
||||
new TSrgReader(reader).read(set)
|
||||
}
|
||||
srg.withWriter "UTF-8", { writer ->
|
||||
new SrgWriter(writer).write(set)
|
||||
}
|
||||
}
|
||||
srg.deleteOnExit()
|
||||
}
|
||||
|
||||
void remapSources(Project proj) {
|
||||
proj.tasks.extractRangemapReplacedMain.doFirst {
|
||||
// Because of https://github.com/MinecraftForge/ForgeGradle/blob/62f37569f3afc044489e7606d2eb4c2509a85fb8/build.gradle#L152-L245,
|
||||
// ForgeGradle modified Eclipse JDT and Mercury will call related methods,
|
||||
// so here must be some hacks.
|
||||
RangeExtractor.INSTANCE = new RangeExtractor().with {
|
||||
it.input = new InputSupplier() {
|
||||
@Override String getRoot(String resource) { return null }
|
||||
@Override InputStream getInput(String relPath) { return file(relPath).newInputStream() }
|
||||
@Override List<String> gatherAll(String endFilter) { return null }
|
||||
@Override void close() throws IOException { }
|
||||
}
|
||||
it
|
||||
}
|
||||
|
||||
// We use Mercury to remap source jar because srg2source have a few issues.
|
||||
def mercury = new Mercury()
|
||||
(configurations.compileClasspath + configurations.forgeGradleMc + configurations.forgeGradleMcDeps).getFiles().each { dep ->
|
||||
mercury.classPath << dep.toPath()
|
||||
}
|
||||
file("build/reobf.srg").withReader { reader ->
|
||||
mercury.processors << MercuryRemapper.create(new SrgReader(reader).read(MappingSet.create()))
|
||||
}
|
||||
def source = file("build/sources/main/java"), dest = file("build/sources/main/java_tmp")
|
||||
if (source.renameTo(dest)) {
|
||||
mercury.rewrite(dest.toPath(), source.toPath())
|
||||
dest.deleteDir()
|
||||
}
|
||||
|
||||
RangeExtractor.INSTANCE = null
|
||||
}
|
||||
}
|
||||
|
||||
ext {
|
||||
tsrg2srg = this.&tsrg2srg
|
||||
remapSources = this.&remapSources
|
||||
}
|
||||
@@ -1,46 +0,0 @@
|
||||
|
||||
// If you want to add dependent project sources for annotation processors in current project,
|
||||
// use `projectImplementation project(":xxx")` instead of `dependencies { implementation project(":xxx") }`
|
||||
|
||||
class ProjectContainer {
|
||||
static def implementationProjects = [:]
|
||||
}
|
||||
|
||||
void projectImplementation(Project otherProject) {
|
||||
dependencies {
|
||||
implementation otherProject, {
|
||||
transitive = false
|
||||
}
|
||||
}
|
||||
|
||||
ProjectContainer.implementationProjects.putIfAbsent project, []
|
||||
ProjectContainer.implementationProjects.get project add otherProject
|
||||
}
|
||||
|
||||
ext {
|
||||
projectImplementation = this.&projectImplementation
|
||||
}
|
||||
|
||||
// We need to add sourceSets at compile time to avoid IntelliJ IDEA from removing duplicated source roots and to avoid Eclipse add source dirs twice.
|
||||
// The reason of that we don't just dependent other subprojects is to let Mixin AP work correctly.
|
||||
task setupSourceSets {
|
||||
doLast {
|
||||
sourceSets.main {
|
||||
java {
|
||||
ProjectContainer.implementationProjects.get(project).forEach({
|
||||
it.sourceSets.main.java.srcDirs.forEach({ targetDir ->
|
||||
srcDir targetDir
|
||||
})
|
||||
})
|
||||
}
|
||||
resources {
|
||||
ProjectContainer.implementationProjects.get(project).forEach({
|
||||
it.sourceSets.main.resources.srcDirs.forEach({ targetDir ->
|
||||
srcDir targetDir
|
||||
})
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
deobfCompileDummyTask.dependsOn setupSourceSets
|
||||
+5
-5
@@ -20,18 +20,18 @@ repositories {
|
||||
}
|
||||
}
|
||||
|
||||
projectImplementation project(':Common')
|
||||
projectImplementation project(':Vanilla/Common')
|
||||
|
||||
remapSources project
|
||||
|
||||
dependencies {
|
||||
// This is the minimum version number that the mod should dependent in the development environment.
|
||||
implementation "net.fabricmc:fabric-loader:0.12.0"
|
||||
}
|
||||
|
||||
import customskinloader.gradle.util.RemapUtil
|
||||
import customskinloader.gradle.util.SourceUtil
|
||||
import groovy.json.JsonSlurper
|
||||
|
||||
SourceUtil.addDependencies project, project(":Common"), project(":Vanilla/Common")
|
||||
RemapUtil.remapSources project
|
||||
|
||||
// Resolve snapshot versions
|
||||
tasks.publishModrinth.doFirst {
|
||||
def snapshot = []
|
||||
|
||||
@@ -16,7 +16,12 @@ sourceJar {
|
||||
exclude 'net/**'
|
||||
}
|
||||
|
||||
projectImplementation project(':Common')
|
||||
dependencies.implementation project(':Forge/Common')
|
||||
dependencies {
|
||||
implementation project(":Forge/Common")
|
||||
}
|
||||
|
||||
remapSources project
|
||||
import customskinloader.gradle.util.RemapUtil
|
||||
import customskinloader.gradle.util.SourceUtil
|
||||
|
||||
RemapUtil.remapSources project
|
||||
SourceUtil.addDependencies project, project(":Common")
|
||||
@@ -20,10 +20,14 @@ tasks.signJar {
|
||||
exclude "net/minecraft/client/**"
|
||||
}
|
||||
|
||||
projectImplementation project(':Common')
|
||||
dependencies.implementation project(':Forge/Common')
|
||||
dependencies {
|
||||
implementation project(":Forge/Common")
|
||||
}
|
||||
|
||||
minecraft {
|
||||
clientJvmArgs += "-Dfml.coreMods.load=customskinloader.forge.ForgePlugin"
|
||||
replaceIn 'ForgeMod.java'
|
||||
}
|
||||
|
||||
import customskinloader.gradle.util.SourceUtil
|
||||
|
||||
SourceUtil.addDependencies project, project(":Common")
|
||||
@@ -1,29 +1,12 @@
|
||||
// This subproject is only to provide dependency for other subprojects.
|
||||
|
||||
buildscript {
|
||||
repositories {
|
||||
mavenCentral()
|
||||
maven {
|
||||
name = "sponge"
|
||||
url = "https://repo.spongepowered.org/repository/maven-public/"
|
||||
}
|
||||
}
|
||||
dependencies {
|
||||
classpath 'org.spongepowered:mixin:0.8.5'
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation project(':Common')
|
||||
implementation 'org.spongepowered:mixin:0.8.5'
|
||||
}
|
||||
|
||||
import org.spongepowered.tools.obfuscation.interfaces.IMessagerEx
|
||||
|
||||
compileJava {
|
||||
// Disable all Mixin AP messages
|
||||
// Disable Mixin AP
|
||||
// Since 0.8.4, Mixin no longer provide the jar exclude AP, we should disable them manually
|
||||
IMessagerEx.MessageType.values().each { msg ->
|
||||
options.compilerArgs << "-AMSG_${msg.name()}=note"
|
||||
}
|
||||
options.compilerArgs << "-proc:none"
|
||||
}
|
||||
@@ -14,13 +14,13 @@ jar {
|
||||
exclude 'Profile.json'
|
||||
}
|
||||
|
||||
projectImplementation project(':Common')
|
||||
projectImplementation project(':Vanilla/Common')
|
||||
|
||||
import customskinloader.gradle.util.SourceUtil
|
||||
import groovy.json.JsonOutput
|
||||
import groovy.json.JsonSlurper
|
||||
import java.security.MessageDigest
|
||||
|
||||
SourceUtil.addDependencies project, project(":Common"), project(":Vanilla/Common")
|
||||
|
||||
task afterBuildForVanilla {
|
||||
doLast {
|
||||
def file0 = file("build/libs/${archivesBaseName}-${version}.jar")
|
||||
|
||||
+7
-10
@@ -30,6 +30,9 @@ wrapper {
|
||||
gradleVersion = "4.10.3"
|
||||
}
|
||||
|
||||
import customskinloader.gradle.util.CurseForgeUtil
|
||||
import customskinloader.gradle.util.ModrinthUtil
|
||||
import customskinloader.gradle.util.RemapUtil
|
||||
import customskinloader.gradle.util.VersionUtil
|
||||
|
||||
subprojects {
|
||||
@@ -97,8 +100,6 @@ subprojects {
|
||||
if (!config.is_real_project || Boolean.parseBoolean(config.is_real_project.toString())) {
|
||||
archivesBaseName = "CustomSkinLoader_${-> VersionUtil.getEdition(project)}"
|
||||
|
||||
apply from: rootProject.file("BuildScripts/sources.gradle")
|
||||
|
||||
processResources {
|
||||
filesNotMatching("**/*.js") {
|
||||
expand([
|
||||
@@ -123,13 +124,12 @@ subprojects {
|
||||
implementation 'org.spongepowered:mixin:0.8.5'
|
||||
}
|
||||
|
||||
apply from: rootProject.file("BuildScripts/remap.gradle")
|
||||
task genSrgMap {
|
||||
doLast {
|
||||
if (config.srg_notch_map != null) {
|
||||
// convert mappings
|
||||
tsrg2srg file(config.srg_notch_map), file("build/reobf.srg")
|
||||
tsrg2srg file("mixin.tsrg"), file("build/mixin.srg")
|
||||
RemapUtil.tsrg2srg file(config.srg_notch_map), file("build/reobf.srg")
|
||||
RemapUtil.tsrg2srg file("mixin.tsrg"), file("build/mixin.srg")
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -207,11 +207,8 @@ subprojects {
|
||||
apply from: rootProject.file('Vanilla/common.gradle')
|
||||
} else {
|
||||
// Only Fabric and Forge edition should be uploaded to CurseForge and Modrinth
|
||||
apply from: rootProject.file("BuildScripts/curseforge.gradle")
|
||||
provideCurseForge project
|
||||
|
||||
apply from: rootProject.file("BuildScripts/modrinth.gradle")
|
||||
provideModrinth project
|
||||
CurseForgeUtil.provideCurseForge project
|
||||
ModrinthUtil.provideModrinth project
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
plugins {
|
||||
id("java")
|
||||
}
|
||||
|
||||
group = "customskinloader"
|
||||
version = "1.0.0"
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
maven {
|
||||
url = "https://plugins.gradle.org/m2/"
|
||||
}
|
||||
maven {
|
||||
url = "https://maven.minecraftforge.net/"
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation("com.qcloud:cos_api:5.6.98")
|
||||
implementation("com.google.code.gson:gson:2.9.0")
|
||||
implementation("commons-io:commons-io:2.11.0")
|
||||
implementation("net.minecraftforge.gradle:ForgeGradle:2.3.+")
|
||||
implementation("org.cadixdev:mercury:0.1.0")
|
||||
implementation("gradle.plugin.com.matthewprenger:CurseGradle:1.4.0")
|
||||
implementation("gradle.plugin.com.modrinth.minotaur:Minotaur:1.2.1")
|
||||
}
|
||||
@@ -1,23 +0,0 @@
|
||||
plugins {
|
||||
id("java")
|
||||
}
|
||||
|
||||
group = "customskinloader"
|
||||
version = "1.0.0"
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
dependencies {
|
||||
testImplementation("org.junit.jupiter:junit-jupiter-api:5.8.1")
|
||||
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:5.8.1")
|
||||
implementation("com.qcloud:cos_api:5.6.98")
|
||||
implementation(gradleApi())
|
||||
implementation("com.google.code.gson:gson:2.9.0")
|
||||
implementation("commons-io:commons-io:2.11.0")
|
||||
}
|
||||
|
||||
tasks.getByName<Test>("test") {
|
||||
useJUnitPlatform()
|
||||
}
|
||||
@@ -1,5 +0,0 @@
|
||||
forge_mc_version=1.12.2
|
||||
forge_version=14.23.5.2768
|
||||
mappings_version=stable_39
|
||||
# this subproject is only to provide dependency for other subprojects.
|
||||
is_real_project=false
|
||||
@@ -11,4 +11,4 @@ public class BuildPlugin implements Plugin<Project> {
|
||||
project.getTasks().create("upload", UploadTask.class,
|
||||
task -> task.rootProject = project.getRootProject());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
package customskinloader.gradle.task;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import org.gradle.api.DefaultTask;
|
||||
import org.gradle.api.Project;
|
||||
import org.gradle.api.plugins.JavaPluginConvention;
|
||||
import org.gradle.api.tasks.SourceSet;
|
||||
import org.gradle.api.tasks.TaskAction;
|
||||
|
||||
/**
|
||||
* We need to add sourceSets at compile time to avoid IntelliJ IDEA from removing duplicated source roots and to avoid Eclipse add source dirs twice.
|
||||
* The reason of that we don't just dependent other subprojects is to let Mixin AP work correctly.
|
||||
*/
|
||||
public class SourceSetsSetupTask extends DefaultTask {
|
||||
public Project project;
|
||||
|
||||
public Set<Project> otherProjects = new HashSet<>();
|
||||
|
||||
@TaskAction
|
||||
public void setup() {
|
||||
project.getConvention().getPlugin(JavaPluginConvention.class).getSourceSets().getByName("main", sourceSet ->
|
||||
this.otherProjects.stream()
|
||||
.filter(other -> other.getPlugins().hasPlugin("java"))
|
||||
.forEach(other -> {
|
||||
SourceSet otherMain = other.getConvention().getPlugin(JavaPluginConvention.class).getSourceSets().getByName("main");
|
||||
otherMain.getJava().getSrcDirs().forEach(targetDir ->
|
||||
sourceSet.getJava().srcDir(targetDir)
|
||||
);
|
||||
otherMain.getResources().getSrcDirs().forEach(targetDir ->
|
||||
sourceSet.getResources().srcDir(targetDir)
|
||||
);
|
||||
}));
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,8 @@
|
||||
package customskinloader.gradle.task;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
import customskinloader.gradle.entity.CslDetail;
|
||||
@@ -7,17 +10,10 @@ import customskinloader.gradle.entity.CslLatest;
|
||||
import customskinloader.gradle.util.ConfigUtil;
|
||||
import customskinloader.gradle.util.CosUtil;
|
||||
import customskinloader.gradle.util.VersionUtil;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.gradle.api.DefaultTask;
|
||||
import org.gradle.api.Project;
|
||||
import org.gradle.api.tasks.TaskAction;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Collection;
|
||||
import java.util.LinkedHashMap;
|
||||
|
||||
public class UploadTask extends DefaultTask {
|
||||
public Project rootProject;
|
||||
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
package customskinloader.gradle.util;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
import com.matthewprenger.cursegradle.CurseArtifact;
|
||||
import com.matthewprenger.cursegradle.CurseUploadTask;
|
||||
import org.gradle.api.Project;
|
||||
import org.gradle.api.plugins.BasePluginConvention;
|
||||
|
||||
// https://www.curseforge.com/minecraft/mc-mods/customskinloader
|
||||
public class CurseForgeUtil {
|
||||
public static void provideCurseForge(Project project) {
|
||||
if (!project.getPlugins().hasPlugin("base")) return;
|
||||
|
||||
// We don’t use the task provided by the plugin because it adds some dependencies that we don’t need.
|
||||
project.getTasks().create("publishCurseForge", CurseUploadTask.class, task -> {
|
||||
task.setGroup("publish");
|
||||
task.onlyIf(task0 -> System.getenv("CURSEFORGE_API_KEY") != null);
|
||||
|
||||
task.setApiKey(System.getenv("CURSEFORGE_API_KEY"));
|
||||
task.setProjectId("286924");
|
||||
task.setMainArtifact(new CurseArtifact() {
|
||||
{
|
||||
this.setArtifact(project.getTasks().getByName("jar"));
|
||||
List<Object> gameVersionStrings = new ArrayList<>();
|
||||
Optional.ofNullable(ConfigUtil.getConfigString(project, "minecraft_full_versions"))
|
||||
.ifPresent(versions -> Collections.addAll(gameVersionStrings, versions.split(","))); // Minecraft Versions
|
||||
Optional.ofNullable(ConfigUtil.getConfigString(project, "java_full_versions"))
|
||||
.ifPresent(versions -> {
|
||||
for (String javaVersion : versions.split(",")) {
|
||||
gameVersionStrings.add("Java " + javaVersion); // Java Versions
|
||||
}
|
||||
});
|
||||
gameVersionStrings.add(project.getName().split("/")[0]); // Loader Version
|
||||
this.setGameVersionStrings(gameVersionStrings);
|
||||
this.setChangelogType("text");
|
||||
this.setChangelog(System.getenv("GIT_COMMIT_DESC"));
|
||||
this.setDisplayName(project.getConvention().getPlugin(BasePluginConvention.class).getArchivesBaseName() + "-" + VersionUtil.getShortVersion(project.getRootProject()));
|
||||
this.setReleaseType(VersionUtil.isSnapshot(project.getRootProject()) ? "beta" : "release");
|
||||
}
|
||||
});
|
||||
task.setAdditionalArtifacts(new ArrayList<>());
|
||||
|
||||
TaskUtil.withTask(project.getRootProject(), "upload", task0 -> task0.finalizedBy(task));
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
package customskinloader.gradle.util;
|
||||
|
||||
import java.util.Locale;
|
||||
import java.util.Optional;
|
||||
|
||||
import com.modrinth.minotaur.TaskModrinthUpload;
|
||||
import com.modrinth.minotaur.request.VersionType;
|
||||
import org.gradle.api.Project;
|
||||
import org.gradle.api.plugins.BasePluginConvention;
|
||||
|
||||
// https://modrinth.com/mod/customskinloader
|
||||
public class ModrinthUtil {
|
||||
public static void provideModrinth(Project project) {
|
||||
if (!project.getPlugins().hasPlugin("base")) return;
|
||||
|
||||
project.getTasks().create("publishModrinth", TaskModrinthUpload.class, task -> {
|
||||
task.setGroup("publish");
|
||||
task.onlyIf(task0 -> System.getenv("MODRINTH_TOKEN") != null);
|
||||
|
||||
task.token = System.getenv("MODRINTH_TOKEN");
|
||||
task.projectId = "idMHQ4n2";
|
||||
task.versionNumber = VersionUtil.getCSLVersion(project.getRootProject()) + "-" + project.getName().replace("/", "");
|
||||
task.versionName = project.getConvention().getPlugin(BasePluginConvention.class).getArchivesBaseName() + "-" + VersionUtil.getShortVersion(project.getRootProject());
|
||||
task.changelog = System.getenv("GIT_COMMIT_DESC");
|
||||
task.uploadFile = project.getTasks().getByName("jar");
|
||||
task.versionType = VersionUtil.isSnapshot(project.getRootProject()) ? VersionType.BETA : VersionType.RELEASE;
|
||||
task.failSilently = true;
|
||||
task.detectLoaders = false;
|
||||
|
||||
Optional.ofNullable(ConfigUtil.getConfigString(project, "minecraft_full_versions"))
|
||||
.ifPresent(versions -> {
|
||||
for (String gameVersion : versions.split(",")) {
|
||||
task.addGameVersion(gameVersion); // Minecraft Versions
|
||||
}
|
||||
});
|
||||
task.addLoader(project.getName().split("/")[0].toLowerCase(Locale.ENGLISH)); // Loader Version
|
||||
|
||||
TaskUtil.withTask(project.getRootProject(), "upload", task0 -> task0.finalizedBy(task));
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,92 @@
|
||||
package customskinloader.gradle.util;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.Reader;
|
||||
import java.io.Writer;
|
||||
import java.lang.reflect.Field;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
|
||||
import com.google.common.collect.Sets;
|
||||
import net.minecraftforge.srg2source.ast.RangeExtractor;
|
||||
import net.minecraftforge.srg2source.util.io.InputSupplier;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.cadixdev.lorenz.MappingSet;
|
||||
import org.cadixdev.lorenz.io.srg.SrgReader;
|
||||
import org.cadixdev.lorenz.io.srg.SrgWriter;
|
||||
import org.cadixdev.lorenz.io.srg.tsrg.TSrgReader;
|
||||
import org.cadixdev.mercury.Mercury;
|
||||
import org.cadixdev.mercury.remapper.MercuryRemapper;
|
||||
import org.gradle.api.Project;
|
||||
|
||||
/**
|
||||
* Gradle Utils for Converting Mappings
|
||||
* Designed for Converting Mappings.
|
||||
* Converting Mappings: tsrg->srg
|
||||
*/
|
||||
public class RemapUtil {
|
||||
public static void tsrg2srg(File tsrg, File srg) throws IOException {
|
||||
if (!tsrg.exists()) return;
|
||||
if (!srg.getParentFile().exists()) srg.getParentFile().mkdirs();
|
||||
|
||||
MappingSet set = MappingSet.create();
|
||||
|
||||
try (
|
||||
Reader reader = Files.newBufferedReader(tsrg.toPath(), StandardCharsets.UTF_8);
|
||||
Writer writer = Files.newBufferedWriter(srg.toPath(), StandardCharsets.UTF_8)
|
||||
) {
|
||||
new TSrgReader(reader).read(set);
|
||||
new SrgWriter(writer).write(set);
|
||||
}
|
||||
srg.deleteOnExit();
|
||||
}
|
||||
|
||||
public static void remapSources(Project project) {
|
||||
Optional.ofNullable(project.getTasks().findByName("extractRangemapReplacedMain")).ifPresent(task -> task.doFirst(task0 -> {
|
||||
try {
|
||||
// Because of https://github.com/MinecraftForge/ForgeGradle/blob/62f37569f3afc044489e7606d2eb4c2509a85fb8/build.gradle#L152-L245,
|
||||
// ForgeGradle modified Eclipse JDT and Mercury will call related methods,
|
||||
// so here must use some hacks.
|
||||
RangeExtractor instance = new RangeExtractor();
|
||||
instance.setInput(new InputSupplier() {
|
||||
@Override public String getRoot(String resource) { return null; }
|
||||
@Override public InputStream getInput(String relPath) { try { return Files.newInputStream(Paths.get(relPath)); } catch (IOException e) { throw new RuntimeException(e); } }
|
||||
@Override public List<String> gatherAll(String endFilter) { return null; }
|
||||
@Override public void close() { }
|
||||
});
|
||||
|
||||
Field instanceField = RangeExtractor.class.getDeclaredField("INSTANCE");
|
||||
instanceField.setAccessible(true);
|
||||
instanceField.set(null, instance);
|
||||
|
||||
// We use Mercury to remap source jar because srg2source have a few issues.
|
||||
Mercury mercury = new Mercury();
|
||||
|
||||
Set<File> set = Sets.newHashSet(project.getConfigurations().getByName("compileClasspath").getFiles());
|
||||
set.addAll(project.getConfigurations().getByName("forgeGradleMc").getFiles());
|
||||
set.addAll(project.getConfigurations().getByName("forgeGradleMcDeps").getFiles());
|
||||
for (File dependencies : set) {
|
||||
mercury.getClassPath().add(dependencies.toPath());
|
||||
}
|
||||
|
||||
mercury.getProcessors().add(MercuryRemapper.create(new SrgReader(Files.newBufferedReader(project.file("build/reobf.srg").toPath(), StandardCharsets.UTF_8)).read(MappingSet.create())));
|
||||
|
||||
File source = project.file("build/sources/main/java"), dest = project.file("build/sources/main/java_tmp");
|
||||
if (source.renameTo(dest)) {
|
||||
mercury.rewrite(dest.toPath(), source.toPath());
|
||||
FileUtils.deleteDirectory(dest);
|
||||
}
|
||||
|
||||
instanceField.set(null, null);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package customskinloader.gradle.util;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Optional;
|
||||
|
||||
import customskinloader.gradle.task.SourceSetsSetupTask;
|
||||
import org.gradle.api.Project;
|
||||
import org.gradle.api.artifacts.Dependency;
|
||||
import org.gradle.api.artifacts.ModuleDependency;
|
||||
|
||||
/**
|
||||
* If you want to add dependent project sources for annotation processors in current project,
|
||||
* use `SourceUtil.addDependencies project, project(":xxx")` instead of `dependencies { implementation project(":xxx") }`
|
||||
*/
|
||||
public class SourceUtil {
|
||||
public static void addDependencies(Project project, Project... otherProjects) {
|
||||
if (project.getTasks().findByName("setupSourceSets") == null) {
|
||||
project.getTasks().create("setupSourceSets", SourceSetsSetupTask.class, task -> {
|
||||
task.project = project;
|
||||
Collections.addAll(task.otherProjects, otherProjects);
|
||||
Optional.ofNullable(project.getTasks().findByName("deobfCompileDummyTask")).ifPresent(task0 -> task0.dependsOn(task));
|
||||
});
|
||||
}
|
||||
|
||||
for (Project otherProject : otherProjects) {
|
||||
Dependency dependency = project.getDependencies().add("implementation", otherProject);
|
||||
if (dependency instanceof ModuleDependency) {
|
||||
((ModuleDependency) dependency).setTransitive(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package customskinloader.gradle.util;
|
||||
|
||||
import org.gradle.api.Action;
|
||||
import org.gradle.api.Project;
|
||||
import org.gradle.api.Task;
|
||||
|
||||
public class TaskUtil {
|
||||
public static void withTask(Project project, String taskName, Action<? super Task> action) {
|
||||
Task task = project.getTasks().findByName(taskName);
|
||||
if (task == null) {
|
||||
project.getTasks().whenTaskAdded(task0 -> {
|
||||
if (taskName.equals(task0.getName())) {
|
||||
action.execute(task0);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
action.execute(task);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1 +1 @@
|
||||
implementation-class=customskinloader.gradle.BuildPlugin
|
||||
implementation-class=customskinloader.gradle.BuildPlugin
|
||||
Reference in new issue
Block a user