Flywheel/common/build.gradle
2024-05-17 08:43:56 -07:00

111 lines
3.5 KiB
Groovy

plugins {
id 'idea'
id 'java'
id 'maven-publish'
id 'dev.architectury.loom'
id 'flywheel.java'
id 'flywheel.package-infos'
id 'flywheel.subproject'
id 'flywheel.outgoing-configuration'
}
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
}
}
jar {
from sourceSets.api.output
from sourceSets.lib.output
from sourceSets.backend.output
archiveClassifier.set('')
}
sourcesJar {
from sourceSets.api.allSource
from sourceSets.lib.allSource
from sourceSets.backend.allSource
}
javadoc {
source sourceSets.api.allJava
source sourceSets.lib.allJava
source sourceSets.backend.allJava
}
// TODO: repackage these for maven publication
outgoing.createJarAndOutgoingConfiguration("apiOnly", sourceSets.api)
outgoing.createJarAndOutgoingConfiguration("lib")
def apiLibJar = outgoing.createJarAndOutgoingConfiguration("api", sourceSets.api, sourceSets.lib)
def backendJar = outgoing.createJarAndOutgoingConfiguration("backend")
def implJar = outgoing.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'])
artifact apiLibJar.remapJar
artifact apiLibJar.remapSources
artifact apiLibJar.javadocJar
artifact backendJar.remapJar
artifact backendJar.remapSources
artifact backendJar.javadocJar
artifact implJar.remapJar
artifact implJar.remapSources
artifact implJar.javadocJar
artifactId = "flywheel-${project.name}-intermediary-${artifact_minecraft_version}"
}
register('mavenMojmap', MavenPublication) {
artifact jar
artifact sourcesJar
artifact javadocJar
artifact apiLibJar.jar
artifact apiLibJar.sources
artifact apiLibJar.javadocJar
artifact backendJar.jar
artifact backendJar.sources
artifact backendJar.javadocJar
artifact implJar.jar
artifact implJar.sources
artifact implJar.javadocJar
artifactId = "flywheel-${project.name}-mojmap-${artifact_minecraft_version}"
}
}
}