mirror of
https://github.com/Jozufozu/Flywheel.git
synced 2024-11-10 12:34:11 +01:00
9ae4065c1c
- Upgrade platform script plugin to pre-compiled groovy plugin - It was getting really difficult to manage all the logic/plugins/types from the basic script, and implementing a real plugin gives us much better type safety and IDE access to upstream plugins - Separate api/lib/backend/impl in platform projects - Add platform module output to main runtime classpath so the fabric loader recognizes our additional modules
90 lines
2.8 KiB
Groovy
90 lines
2.8 KiB
Groovy
plugins {
|
|
id 'idea'
|
|
id 'java'
|
|
id 'maven-publish'
|
|
id 'dev.architectury.loom'
|
|
id 'flywheel.java'
|
|
id 'flywheel.package-infos'
|
|
id 'flywheel.subproject'
|
|
}
|
|
|
|
sourceSets {
|
|
// Loom only populates mc stuff to the main source set,
|
|
// so grab that here and use it for the others.
|
|
// Note that the `+` operator does NOT perform a deep copy
|
|
// of a FileCollection, so this object is shared between
|
|
// the source sets and we should avoid mutating it.
|
|
FileCollection mcCompileClassPath = main.compileClasspath
|
|
|
|
SourceSet api = api {
|
|
compileClasspath = mcCompileClassPath
|
|
}
|
|
SourceSet lib = lib {
|
|
compileClasspath = mcCompileClassPath + api.output
|
|
}
|
|
SourceSet backend = backend {
|
|
compileClasspath = mcCompileClassPath + api.output + lib.output
|
|
}
|
|
|
|
main {
|
|
// Assign here rather than concatenate to avoid modifying the mcCompileClassPath FileCollection
|
|
compileClasspath = mcCompileClassPath + api.output + lib.output + backend.output
|
|
}
|
|
|
|
test {
|
|
// Only test needs runtimeClasspath filled since the game shouldn't run from common alone.
|
|
// Fine to concatenate here.
|
|
compileClasspath += api.output + lib.output + backend.output
|
|
runtimeClasspath += api.output + lib.output + backend.output
|
|
}
|
|
}
|
|
|
|
TaskProvider<Jar> createJarAndOutgoingConfiguration(String name) {
|
|
return createJarAndOutgoingConfiguration(name, sourceSets.named(name).get())
|
|
}
|
|
|
|
TaskProvider<Jar> createJarAndOutgoingConfiguration(String name, SourceSet sourceSet) {
|
|
def config = configurations.register("common${name.capitalize()}") {
|
|
canBeConsumed = true
|
|
canBeResolved = false
|
|
}
|
|
def jarTask = tasks.register("${name}Jar", Jar) {
|
|
archiveClassifier.set(name)
|
|
from sourceSet.output
|
|
}
|
|
|
|
artifacts.add(config.name, jarTask)
|
|
|
|
return jarTask
|
|
}
|
|
|
|
// TODO: repackage these for maven publication
|
|
def apiJar = createJarAndOutgoingConfiguration("api")
|
|
def libJar = createJarAndOutgoingConfiguration("lib")
|
|
def backendJar = createJarAndOutgoingConfiguration("backend")
|
|
def implJar = createJarAndOutgoingConfiguration("impl", sourceSets.main)
|
|
|
|
dependencies {
|
|
modCompileOnly "net.fabricmc:fabric-loader:${fabric_loader_version}"
|
|
|
|
testImplementation 'org.junit.jupiter:junit-jupiter:5.8.1'
|
|
}
|
|
|
|
test {
|
|
useJUnitPlatform()
|
|
}
|
|
|
|
publishing {
|
|
publications {
|
|
register('mavenIntermediary', MavenPublication) {
|
|
from(components['java'])
|
|
artifactId = "flywheel-${project.name}-intermediary-${artifact_minecraft_version}"
|
|
}
|
|
register('mavenMojmap', MavenPublication) {
|
|
artifact jar
|
|
artifact sourcesJar
|
|
artifactId = "flywheel-${project.name}-mojmap-${artifact_minecraft_version}"
|
|
}
|
|
}
|
|
}
|