Skip to content

Commit

Permalink
Add a test task to run the installer with real data from Neoforge. (#5)
Browse files Browse the repository at this point in the history
  • Loading branch information
shartte authored Jan 5, 2024
1 parent b683a74 commit c7a5fb8
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,22 @@ ext {
}
}

configurations {
testInstallerData {
canBeConsumed = false
canBeResolved = true
transitive = false
}
}

dependencies {
implementation 'net.sf.jopt-simple:jopt-simple:5.0.4'
implementation 'com.google.code.gson:gson:2.8.7'
implementation 'net.neoforged.installertools:cli-utils:2.1.0'
testImplementation(platform('org.junit:junit-bom:5.7.2'))
testImplementation('org.junit.jupiter:junit-jupiter')
compileOnly 'org.jetbrains:annotations:24.1.0'
testInstallerData 'net.neoforged:neoforge:20.4.76-beta:installer'
}

test {
Expand Down Expand Up @@ -153,6 +162,28 @@ tasks.register('testJar', Jar) {
manifest.from(MANIFEST)
}

// Combine the shrunk jar with data from the current Neoforge installer
tasks.register('productionTestJar', Jar) {
group = "build"
dependsOn shrinkJar
from zipTree(shrinkJar.archiveFile.get().asFile)
from(zipTree(configurations.testInstallerData.singleFile)) {
exclude '/**/*.class'
}
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
archiveClassifier = 'prodtest'
manifest.from(MANIFEST)
}

/**
* Run this installer that contains the data from a real Neoforge installer.
*/
tasks.register('runProductionTest', JavaExec) {
dependsOn tasks.named("productionTestJar")
mainClass = "-jar";
args productionTestJar.archiveFile.get()
}

publishing {
publications {
mavenJava(MavenPublication) {
Expand Down

0 comments on commit c7a5fb8

Please sign in to comment.