Flywheel/common/build.gradle

92 lines
2.9 KiB
Groovy
Raw Normal View History

plugins {
id 'idea'
id 'java'
id 'maven-publish'
id 'dev.architectury.loom'
}
apply from: rootProject.file('buildSrc/simple-java.gradle')
apply from: rootProject.file('buildSrc/subprojects.gradle')
// TODO: package-infos specifically targets the main source set
// apply from: rootProject.file('buildSrc/package-infos.gradle')
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)
2024-04-17 21:05:04 +02:00
dependencies {
2024-04-22 02:15:21 +02:00
modCompileOnly "net.fabricmc:fabric-loader:${fabric_loader_version}"
2024-04-17 21:59:44 +02:00
testImplementation 'org.junit.jupiter:junit-jupiter:5.8.1'
2024-04-17 21:05:04 +02:00
}
test {
2024-04-17 21:05:04 +02:00
useJUnitPlatform()
}
publishing {
publications {
2024-04-23 09:14:19 +02:00
register('mavenIntermediary', MavenPublication) {
2024-04-22 02:15:21 +02:00
from(components['java'])
2024-04-17 21:05:04 +02:00
artifactId = "flywheel-${project.name}-intermediary-${artifact_minecraft_version}"
}
2024-04-23 09:14:19 +02:00
register('mavenMojmap', MavenPublication) {
2024-04-17 21:05:04 +02:00
artifact jar
artifact sourcesJar
artifactId = "flywheel-${project.name}-mojmap-${artifact_minecraft_version}"
}
}
}