diff options
Diffstat (limited to 'addon.gradle')
-rw-r--r-- | addon.gradle | 81 |
1 files changed, 81 insertions, 0 deletions
diff --git a/addon.gradle b/addon.gradle new file mode 100644 index 0000000000..f760bb1537 --- /dev/null +++ b/addon.gradle @@ -0,0 +1,81 @@ +compileJava { + options.encoding = "UTF-8" +} +test { + useJUnitPlatform() + testLogging { + events "passed", "skipped", "failed" + } +} + +minecraft { + def vMajor, vMinor, vPatch, logLevel = LogLevel.INFO + try { + String version = project.version + def (five,major,minor,patch)= version.split("[.-]", 5) + + vMajor = 500 + major.toInteger() + vMinor = minor.toInteger() + vPatch = patch.toInteger() + } catch (Exception ex) { + try { + String version = "git describe".execute().text + def (five,major,minor,patch)= version.split("[.-]", 5) + vMajor = 500 + major.toInteger() + vMinor = minor.toInteger() + vPatch = patch.toInteger() + logLevel = LogLevel.LIFECYCLE + } catch (Exception ex2) { + def err = "Cannot automatically determine NBT version. Using defaults hardcoded in buildscript. This could break your world!" + project.logger.error(err) + vMajor = 509 + vMinor = 44 + vPatch = 0 + logLevel = LogLevel.WARN + } + } + injectedTags.put 'VERSION_MAJOR', vMajor + injectedTags.put 'VERSION_MINOR', vMinor + injectedTags.put 'VERSION_PATCH', vPatch + project.logger.log(logLevel, 'Using ({}, {}, {}) as NBT version', vMajor, vMinor, vPatch) +} + +SourceSet functionalTestSet = null + +sourceSets { + functionalTestSet = create("functionalTest") { + java { + srcDir("src/functionalTest/java") + compileClasspath += sourceSets.patchedMc.output + sourceSets.main.output + } + } +} + +configurations { configs -> + // Keep all dependencies from the main mod in the functional test mod + named(functionalTestSet.compileClasspathConfigurationName).configure {it.extendsFrom(named("compileClasspath").get())} + named(functionalTestSet.runtimeClasspathConfigurationName).configure {it.extendsFrom(named("runtimeClasspath").get())} + named(functionalTestSet.annotationProcessorConfigurationName).configure {it.extendsFrom(named("annotationProcessor").get())} +} + +tasks.register(functionalTestSet.jarTaskName, Jar) { + from(functionalTestSet.output) + archiveClassifier.set("functionalTests") + // we don't care about the version number here, keep it stable to avoid polluting the tmp directory + archiveVersion.set("1.0") + destinationDirectory.set(new File(buildDir, "tmp")) +} +tasks.named("assemble").configure { + dependsOn(functionalTestSet.jarTaskName) +} + +// Run tests in the default runServer/runClient configurations +tasks.named("runServer", JavaExec).configure { + dependsOn(functionalTestSet.jarTaskName) + classpath(configurations.named(functionalTestSet.runtimeClasspathConfigurationName), tasks.named(functionalTestSet.jarTaskName)) +} + +tasks.named("runClient", JavaExec).configure { + dependsOn(functionalTestSet.jarTaskName) + classpath(configurations.named(functionalTestSet.runtimeClasspathConfigurationName), tasks.named(functionalTestSet.jarTaskName)) +} |