diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..a891362 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,64 @@ +# Builds and tests the project + +name: Build + +# On pull requests +on: + push: + paths: + - '**/src/**' + - '**/build.gradle' + - '**/gradle.properties' + - '**/settings.gradle' + - .github/workflows/build.yml + - LICENCE + pull_request: + paths: + - '**/src/**' + - '**/build.gradle' + - '**/gradle.properties' + - '**/settings.gradle' + - .github/workflows/build.yml + - LICENCE + +jobs: + build: + name: Build + + runs-on: ubuntu-latest + + steps: + - name: โœจ Checkout repository + uses: actions/checkout@v2 + + - name: ๐Ÿ›‚ Validate Gradle wrapper + uses: gradle/wrapper-validation-action@v1 + + - name: ๐Ÿ— Set up JDK 16 + uses: actions/setup-java@v2 + with: + java-version: 16 + distribution: adopt + + - name: ๐Ÿ“ท Begin Gradle cache + uses: actions/cache@v2 + with: + path: | + ~/.gradle/caches + ~/.gradle/wrapper + key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} + restore-keys: | + ${{ runner.os }}-gradle- + - name: ๐Ÿ”จ Build artifacts + run: ./gradlew clean build + + - name: ๐Ÿ“ฆ Upload artifacts + uses: actions/upload-artifact@v2 + with: + name: artifacts + path: '**/build/libs/' + + - name: ๐Ÿงจ Cleanup Gradle cache + run: | + rm -f ~/.gradle/caches/modules-2/modules-2.lock + rm -f ~/.gradle/caches/modules-2/gc.properties diff --git a/build.gradle b/build.gradle index 65822e2..5ea6c0d 100644 --- a/build.gradle +++ b/build.gradle @@ -1,5 +1,5 @@ plugins { - id 'fabric-loom' version '0.7-SNAPSHOT' + id 'fabric-loom' version '0.9-SNAPSHOT' id 'maven-publish' } @@ -13,8 +13,8 @@ group = project.maven_group dependencies { //to change the versions see the gradle.properties file minecraft "com.mojang:minecraft:${project.minecraft_version}" - mappings "net.fabricmc:yarn:${project.yarn_mappings}+build.+:v2" - modImplementation "net.fabricmc:fabric-loader:${project.loader_version}+build.+" + mappings "net.fabricmc:yarn:${project.minecraft_version}+${project.yarn_build}:v2" + modImplementation "net.fabricmc:fabric-loader:${project.loader_version}" // PSA: Some older mods, compiled on Loom 0.2.1, might have outdated Maven POMs. // You may need to force-disable transitiveness on them. @@ -23,14 +23,9 @@ dependencies { processResources { inputs.property "version", project.version - from(sourceSets.main.resources.srcDirs) { - include "fabric.mod.json" + filesMatching("fabric.mod.json") { expand "version": project.version } - - from(sourceSets.main.resources.srcDirs) { - exclude "fabric.mod.json" - } } // ensure that the encoding is set to UTF-8, no matter what the system default is @@ -40,12 +35,11 @@ tasks.withType(JavaCompile) { options.encoding = "UTF-8" } -// Loom will automatically attach sourcesJar to a RemapSourcesJar task and to the "build" task -// if it is present. -// If you remove this task, sources will not be generated. -task sourcesJar(type: Jar, dependsOn: classes) { - classifier = "sources" - from sourceSets.main.allSource +java { + // Loom will automatically attach sourcesJar to a RemapSourcesJar task and to the "build" task + // if it is present. + // If you remove this line, sources will not be generated. + withSourcesJar() } jar { diff --git a/gradle.properties b/gradle.properties index 88d1689..033d585 100644 --- a/gradle.properties +++ b/gradle.properties @@ -4,8 +4,8 @@ org.gradle.jvmargs=-Xmx1G # Fabric Properties # check these on https://fabricmc.net/use minecraft_version=1.15.2 - yarn_mappings=1.15.2 - loader_version=0.8.2 + yarn_build=build.17 + loader_version=0.11.6 # Mod Properties mod_version = 1.2.0 diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index f3d88b1..490fda8 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index a4b4429..ffed3a2 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-6.3-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/src/main/java/com/halotroop/arrchecker/ARRChecker.java b/src/main/java/com/halotroop/arrchecker/ARRChecker.java index e57e34a..1b95800 100644 --- a/src/main/java/com/halotroop/arrchecker/ARRChecker.java +++ b/src/main/java/com/halotroop/arrchecker/ARRChecker.java @@ -1,8 +1,5 @@ package com.halotroop.arrchecker; -import java.util.ArrayList; -import java.util.List; - import net.fabricmc.api.ModInitializer; import net.fabricmc.loader.api.FabricLoader; import net.fabricmc.loader.api.ModContainer; @@ -10,6 +7,9 @@ import net.fabricmc.loader.api.metadata.ModMetadata; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; +import java.util.ArrayList; +import java.util.List; + public class ARRChecker implements ModInitializer { private static final List arrMods = new ArrayList<>(); private static final Logger LOGGER = LogManager.getLogger("arrchecker"); @@ -20,11 +20,12 @@ public class ARRChecker implements ModInitializer { for (ModContainer mod : FabricLoader.getInstance().getAllMods()) { ModMetadata modMeta = mod.getMetadata(); // Assume all authors don't know how capitalization works, and don't use an array for the string! - String modLicense = modMeta.getLicense().toString().toLowerCase().replace('[', ' ').replace(']', ' ').trim(); + // '-' is being replaced with ' ' due to some mod authors having specified their creative commons license without '-' but with spaces instead + final String modLicense = modMeta.getLicense().toString().toLowerCase().replaceAll("[\\[\\]-]", " ").trim(); // Create a constant of the mod name and ID to be used multiple times: Don't use an array for the string! - String modNameAndID = (modMeta.getName() + " (" + modMeta.getId() + ")").replace('[', ' ').replace(']', ' ').trim(); - // Give a different warning for Minecraft itself. - if (!modMeta.getId().equals("minecraft") && !modMeta.getId().equals("java")) { + final String modNameAndID = (modMeta.getName() + " (" + modMeta.getId() + ")").replaceAll("[\\[\\]]", " ").trim(); + // Ignore built in mods + if (!modMeta.getType().equals("builtin")) { if (modLicense.isEmpty()) { // If no license is found, assume mod is not correctly licensed, and therefore, not modpack-friendly. LOGGER.warn(modNameAndID + " has no license! It may be ARR!"); @@ -37,7 +38,7 @@ public class ARRChecker implements ModInitializer { String[] validLicenses = { "gpl", "mit", "cc0", "apache", "unlicense", "mpl", // Short form names - "gnu public license", "mozilla public license", "creative commons" // Long form (incorrect, but check anyway) + "gnu lesser general public license", "gnu general public license", "mozilla public license", "creative commons", "cc by nc" // Long form (incorrect, but check anyway) }; boolean modLicenseInvalid = true; for (String validLicense : validLicenses) {