Update Loom to prepare for unit tests

This commit is contained in:
embeddedt 2023-07-06 14:42:51 -04:00
parent 5ca9485f0b
commit 582f17c0e7
No known key found for this signature in database
GPG Key ID: A69433EC199B5613
7 changed files with 55 additions and 9 deletions

1
.gitignore vendored
View File

@ -4,6 +4,7 @@ libs
media media
classes/ classes/
.architectury-transformer/ .architectury-transformer/
fabric/fabricloader.log
# Changelog # Changelog
CHANGELOG.md CHANGELOG.md

View File

@ -1,6 +1,6 @@
plugins { plugins {
id "architectury-plugin" version "3.4-SNAPSHOT" id "architectury-plugin" version "3.4-SNAPSHOT"
id "dev.architectury.loom" version "1.1-SNAPSHOT" apply false id "dev.architectury.loom" version "1.2-SNAPSHOT" apply false
id "maven-publish" id "maven-publish"
id 'com.matthewprenger.cursegradle' version '1.4.0' apply false id 'com.matthewprenger.cursegradle' version '1.4.0' apply false
id 'com.palantir.git-version' version '1.0.0' id 'com.palantir.git-version' version '1.0.0'

View File

@ -26,6 +26,8 @@ configurations {
dependencies { dependencies {
modImplementation "net.fabricmc:fabric-loader:${rootProject.fabric_loader_version}" modImplementation "net.fabricmc:fabric-loader:${rootProject.fabric_loader_version}"
testImplementation "net.fabricmc:fabric-loader-junit:${rootProject.fabric_loader_version}"
modIncludeImplementation(fabricApi.module("fabric-api-base", rootProject.fabric_api_version)) { exclude group: 'net.fabricmc', module: 'fabric-loader' } modIncludeImplementation(fabricApi.module("fabric-api-base", rootProject.fabric_api_version)) { exclude group: 'net.fabricmc', module: 'fabric-loader' }
modIncludeImplementation(fabricApi.module("fabric-lifecycle-events-v1", rootProject.fabric_api_version)) { exclude group: 'net.fabricmc', module: 'fabric-loader' } modIncludeImplementation(fabricApi.module("fabric-lifecycle-events-v1", rootProject.fabric_api_version)) { exclude group: 'net.fabricmc', module: 'fabric-loader' }
modIncludeImplementation(fabricApi.module("fabric-screen-api-v1", rootProject.fabric_api_version)) { exclude group: 'net.fabricmc', module: 'fabric-loader' } modIncludeImplementation(fabricApi.module("fabric-screen-api-v1", rootProject.fabric_api_version)) { exclude group: 'net.fabricmc', module: 'fabric-loader' }
@ -38,8 +40,21 @@ dependencies {
// Remove the next line if you don't want to depend on the API // Remove the next line if you don't want to depend on the API
// modApi "me.shedaniel:architectury-fabric:${rootProject.architectury_version}" // modApi "me.shedaniel:architectury-fabric:${rootProject.architectury_version}"
common(project(path: ":common", configuration: "namedElements")) { transitive false } testImplementation(common(project(path: ":common", configuration: "namedElements"))) { transitive false }
shadowCommon(project(path: ":common", configuration: "transformProductionFabric")) { transitive false } shadowCommon(project(path: ":common", configuration: "transformProductionFabric")) { transitive false }
testImplementation(platform("org.junit:junit-bom:${project.junit_version}"))
testImplementation("org.junit.jupiter:junit-jupiter-api")
testImplementation("org.junit.jupiter:junit-jupiter-params")
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine")
testImplementation("org.junit.platform:junit-platform-launcher")
testImplementation("org.assertj:assertj-core:3.19.0")
testImplementation("com.google.guava:guava-testlib:21.0")
testImplementation("org.mockito:mockito-junit-jupiter:5.3.1")
}
test {
useJUnitPlatform()
} }
processResources { processResources {
@ -54,18 +69,18 @@ shadowJar {
exclude "architectury.common.json" exclude "architectury.common.json"
configurations = [project.configurations.shadowCommon] configurations = [project.configurations.shadowCommon]
classifier "dev-shadow" archiveClassifier.set("dev-shadow")
} }
remapJar { remapJar {
injectAccessWidener = true injectAccessWidener = true
input.set shadowJar.archiveFile input.set shadowJar.archiveFile
dependsOn shadowJar dependsOn shadowJar
classifier null archiveClassifier.set(null)
} }
jar { jar {
classifier "dev" archiveClassifier.set("dev")
} }
components.java { components.java {

View File

@ -0,0 +1,28 @@
/*
package org.embeddedt.modernfix.blocks;
import net.minecraft.DetectedVersion;
import net.minecraft.core.Registry;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.Bootstrap;
import net.minecraft.world.item.Items;
import org.junit.Test;
import org.junit.jupiter.api.BeforeAll;
import static org.junit.jupiter.api.Assertions.*;
public class BlockStateCacheTest {
@BeforeAll
public static void setup() {
DetectedVersion.tryDetectVersion();
Bootstrap.bootStrap();
}
@Test
public void testItemRegistry() {
ResourceLocation location = Registry.ITEM.getKey(Items.DIAMOND);
assertEquals(location.toString(), "minecraft:diamond");
}
}
*/

View File

@ -69,17 +69,17 @@ shadowJar {
exclude "architectury.common.json" exclude "architectury.common.json"
configurations = [project.configurations.shadowCommon] configurations = [project.configurations.shadowCommon]
classifier "dev-shadow" archiveClassifier.set("dev-shadow")
} }
remapJar { remapJar {
input.set shadowJar.archiveFile input.set shadowJar.archiveFile
dependsOn shadowJar dependsOn shadowJar
classifier null archiveClassifier.set(null)
} }
jar { jar {
classifier "dev" archiveClassifier.set("dev")
manifest { manifest {
attributes([ attributes([
"Specification-Title" : "modernfix", "Specification-Title" : "modernfix",

View File

@ -1,6 +1,8 @@
# Done to increase the memory available to gradle. # Done to increase the memory available to gradle.
org.gradle.jvmargs=-Xmx2G org.gradle.jvmargs=-Xmx2G
junit_version=5.10.0-M1
mod_id=modernfix mod_id=modernfix
minecraft_version=1.16.5 minecraft_version=1.16.5
enabled_platforms=fabric,forge enabled_platforms=fabric,forge

View File

@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.2-bin.zip distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-bin.zip
zipStoreBase=GRADLE_USER_HOME zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists zipStorePath=wrapper/dists