-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
215085a
commit 91e5d3b
Showing
5 changed files
with
116 additions
and
5 deletions.
There are no files selected for viewing
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
111 changes: 111 additions & 0 deletions
111
src/test/groovy/com/mmodding/gradle/test/QuiltModJsonTest.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
package com.mmodding.gradle.test | ||
|
||
import org.gradle.testkit.runner.GradleRunner | ||
import spock.lang.Specification | ||
import spock.lang.TempDir | ||
|
||
import java.nio.file.Files | ||
import java.nio.file.Path; | ||
|
||
class QuiltModJsonTest extends Specification { | ||
|
||
@TempDir | ||
File testProjectDir | ||
|
||
File settingsFile | ||
File buildFile | ||
|
||
def setup() { | ||
settingsFile = new File(this.testProjectDir, "settings.gradle.kts") | ||
settingsFile << """ | ||
pluginManagement { | ||
repositories { | ||
maven { | ||
name = "Fabric" | ||
url = uri("https://maven.fabricmc.net/") | ||
} | ||
maven { | ||
name = "Quilt" | ||
url = uri("https://maven.quiltmc.org/repository/release") | ||
} | ||
gradlePluginPortal() | ||
} | ||
} | ||
""" | ||
buildFile = new File(this.testProjectDir, "build.gradle.kts") | ||
buildFile << """ | ||
plugins { | ||
id("org.quiltmc.loom").version("1.8.+") | ||
id("com.mmodding.gradle").version("0.0.10-alpha") | ||
} | ||
version = "0.0.1-test" | ||
mmodding { | ||
configureQuiltModJson { | ||
name = "Test Mod" | ||
namespace = "test_mod" | ||
group = "com.mmodding.test" | ||
description = "Test Description" | ||
addAuthor("Test Author") | ||
addContributor("Test Contributor") | ||
withContact { | ||
homepage = "https://github.com/MModding/mmodding-gradle" | ||
sources = "https://github.com/MModding/mmodding-gradle" | ||
issues = "https://github.com/MModding/mmodding-gradle/issues" | ||
} | ||
withDependencies { | ||
javaVersion = ">=17" | ||
minecraftVersion = "~1.20.4" | ||
quiltLoaderVersion = ">=0.25.0-" | ||
quiltedFabricApiVersion = ">=1.0.0-" | ||
} | ||
withProvider { | ||
provide("test-mod") | ||
} | ||
withParent("gradle_tests") | ||
withCustom { | ||
withBlock("modmenu") { | ||
withArray("badges") { | ||
addUnique("library") | ||
} | ||
} | ||
} | ||
} | ||
} | ||
dependencies { | ||
minecraft("com.mojang:minecraft:1.20.4") | ||
mappings("org.quiltmc:quilt-mappings:1.20.4+build.3:intermediary-v2") | ||
} | ||
java { | ||
withSourcesJar() | ||
} | ||
""" | ||
} | ||
|
||
def "can successfully gather data and nest it"() { | ||
when: | ||
GradleRunner.create() | ||
.withProjectDir(testProjectDir) | ||
.withPluginClasspath() | ||
.withArguments("generateQMJ") | ||
.build() | ||
|
||
then: | ||
Path generatedQmjPath = testProjectDir.toPath().resolve("build/generated/generated_resources/quilt.mod.json") | ||
if (Files.exists(generatedQmjPath)) { | ||
String generatedQmj = Files.readString(generatedQmjPath); | ||
if (generatedQmj != "") { | ||
println(generatedQmj) | ||
} | ||
else { | ||
throw new IllegalStateException("Generated QMJ is empty") | ||
} | ||
} | ||
else { | ||
throw new IllegalStateException("Generated QMJ does not exist") | ||
} | ||
} | ||
} |