From 11a39428c323dc24bbeb9da6faf2b6e9b3391398 Mon Sep 17 00:00:00 2001 From: shedaniel Date: Sun, 7 Mar 2021 20:59:13 +0800 Subject: [PATCH] Fix build script --- build.gradle | 15 ++++++++---- .../launch/LaunchProviderSettings.java | 24 +++++++++++++++++++ .../minecraft/MinecraftNativesProvider.java | 1 - .../net/fabricmc/loom/util/Constants.java | 2 +- .../net/fabricmc/loom/BuildUtils.groovy | 6 +++-- 5 files changed, 39 insertions(+), 9 deletions(-) diff --git a/build.gradle b/build.gradle index 45daaeb4..49a0f48e 100644 --- a/build.gradle +++ b/build.gradle @@ -16,11 +16,11 @@ targetCompatibility = 1.8 group = 'me.shedaniel' archivesBaseName = project.name def baseVersion = '0.6' -def runNumber = (System.getenv("GITHUB_RUN_NUMBER") == null ? (((short) new Random().nextInt()).abs() + 1000).toString() : System.getenv("GITHUB_RUN_NUMBER")) +def runNumber = (System.getenv("GITHUB_RUN_NUMBER") == null ? "9999" : System.getenv("GITHUB_RUN_NUMBER")) def isSnapshot = System.getenv("PR_NUM") != null -def build = "release #$runNumber" +def buildNum = "release #$runNumber" if (!isSnapshot) { version = baseVersion + "." + runNumber @@ -31,6 +31,7 @@ if (!isSnapshot) { logger.lifecycle(":building plugin v${version}") configurations { + shadowArchitectury forgeInjectShadow forgeInjectCompileClasspath.extendsFrom(forgeInjectShadow) forgeInjectRuntimeClasspath.extendsFrom(forgeInjectShadow) @@ -70,7 +71,9 @@ dependencies { // tinyfile management compileOnly ('net.fabricmc:tiny-remapper:0.3.2-architectury.6') - shadow ('net.fabricmc:tiny-remapper:0.3.2-architectury.6') + shadowArchitectury ('net.fabricmc:tiny-remapper:0.3.2-architectury.6') { + transitive = false + } implementation ('net.fabricmc:tiny-mappings-parser:0.3.0+build.17') implementation 'net.fabricmc:access-widener:1.0.0' @@ -132,7 +135,7 @@ jar { } manifest { - attributes 'Implementation-Version': project.version + ' Build(' + build + ')' + attributes 'Implementation-Version': project.version + ' Build(' + buildNum + ')' } classifier 'jar' @@ -140,7 +143,7 @@ jar { shadowJar { relocate "net.fabricmc.tinyremapper", "me.shedaniel.architectury.loom.shadowed.impl.net.fabricmc.tinyremapper" - configurations = [project.configurations.shadow] + configurations = [project.configurations.shadowArchitectury] classifier null } @@ -176,6 +179,8 @@ gradlePlugin { } } +build.dependsOn shadowJar + publishing { publications { plugin(MavenPublication) { diff --git a/src/main/java/net/fabricmc/loom/configuration/launch/LaunchProviderSettings.java b/src/main/java/net/fabricmc/loom/configuration/launch/LaunchProviderSettings.java index 9211607e..985a9db3 100644 --- a/src/main/java/net/fabricmc/loom/configuration/launch/LaunchProviderSettings.java +++ b/src/main/java/net/fabricmc/loom/configuration/launch/LaunchProviderSettings.java @@ -1,3 +1,27 @@ +/* + * This file is part of fabric-loom, licensed under the MIT License (MIT). + * + * Copyright (c) 2016, 2017, 2018 FabricMC + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + package net.fabricmc.loom.configuration.launch; import java.util.AbstractMap; diff --git a/src/main/java/net/fabricmc/loom/configuration/providers/minecraft/MinecraftNativesProvider.java b/src/main/java/net/fabricmc/loom/configuration/providers/minecraft/MinecraftNativesProvider.java index 59c626d8..08c4c6d4 100644 --- a/src/main/java/net/fabricmc/loom/configuration/providers/minecraft/MinecraftNativesProvider.java +++ b/src/main/java/net/fabricmc/loom/configuration/providers/minecraft/MinecraftNativesProvider.java @@ -40,7 +40,6 @@ import org.zeroturnaround.zip.ZipUtil; import net.fabricmc.loom.LoomGradleExtension; import net.fabricmc.loom.LoomGradlePlugin; import net.fabricmc.loom.util.HashedDownloadUtil; -import net.fabricmc.loom.util.ThreadingUtils; public class MinecraftNativesProvider { private final Project project; diff --git a/src/main/java/net/fabricmc/loom/util/Constants.java b/src/main/java/net/fabricmc/loom/util/Constants.java index 175cbdb3..2e124766 100644 --- a/src/main/java/net/fabricmc/loom/util/Constants.java +++ b/src/main/java/net/fabricmc/loom/util/Constants.java @@ -145,7 +145,7 @@ public class Constants { private Knot() { } } - + public static final class ForgeUserDev { public static final String LAUNCH_TESTING = "net.minecraftforge.userdev.LaunchTesting"; diff --git a/src/test/groovy/net/fabricmc/loom/BuildUtils.groovy b/src/test/groovy/net/fabricmc/loom/BuildUtils.groovy index 58fe3cfd..e7ac743e 100644 --- a/src/test/groovy/net/fabricmc/loom/BuildUtils.groovy +++ b/src/test/groovy/net/fabricmc/loom/BuildUtils.groovy @@ -1,12 +1,14 @@ package net.fabricmc.loom +import net.fabricmc.loom.util.Constants + /** * Created by Mitchell Skaggs on 6/12/2019. */ -static String genBuildFile(String mappingsDep = "\"net.fabricmc:yarn:\${project.yarn_mappings}\"") { +static String genBuildFile(String mappingsDep = "\"net.fabricmc:yarn:\${project.yarn_mappings}\"", String pluginId = Constants.PLUGIN_ID) { """ plugins { - id 'fabric-loom' + id '${pluginId}' id 'maven-publish' } sourceCompatibility = JavaVersion.VERSION_1_8