MultiLoader-Template/neoforge/build.gradle
2023-11-11 11:43:09 -07:00

79 lines
2.3 KiB
Groovy

plugins {
id 'idea'
id 'maven-publish'
id 'net.neoforged.gradle.userdev' version '7.0.41'
id 'java-library'
}
base {
archivesName = "${mod_name}-neoforge-${minecraft_version}"
}
// Automatically enable neoforge AccessTransformers if the file exists
// This location is hardcoded in FML and can not be changed.
// https://github.com/neoforged/FancyModLoader/blob/a952595eaaddd571fbc53f43847680b00894e0c1/loader/src/main/java/net/neoforged/fml/loading/moddiscovery/ModFile.java#L118
if (file('src/main/resources/META-INF/accesstransformer.cfg').exists()) {
minecraft.accessTransformers.file file('src/main/resources/META-INF/accesstransformer.cfg')
}
runs {
configureEach {
modSource project.sourceSets.main
}
client {
systemProperty 'neoforge.enabledGameTestNamespaces', project.mod_id
}
server {
systemProperty 'neoforge.enabledGameTestNamespaces', project.mod_id
programArgument '--nogui'
}
gameTestServer {
systemProperty 'neoforge.enabledGameTestNamespaces', project.mod_id
}
data {
programArguments.addAll '--mod', project.mod_id, '--all', '--output', file('src/generated/resources/').getAbsolutePath(), '--existing', file('src/main/resources/').getAbsolutePath()
}
}
sourceSets.main.resources { srcDir 'src/generated/resources' }
dependencies {
implementation "net.neoforged:neoforge:${neoforge_version}"
compileOnly project(":common")
}
// NeoGradle compiles the game, but we don't want to add our common code to the game's code
TaskCollection.metaClass.excludingNeoTasks = { ->
delegate.matching { !it.name.startsWith("neo") }
}
tasks.withType(JavaCompile).excludingNeoTasks().configureEach {
source(project(":common").sourceSets.main.allSource)
}
tasks.withType(Javadoc).excludingNeoTasks().configureEach {
source(project(":common").sourceSets.main.allJava)
}
tasks.named("sourcesJar", Jar) {
from(project(":common").sourceSets.main.allSource)
}
tasks.withType(ProcessResources).excludingNeoTasks().configureEach {
from project(":common").sourceSets.main.resources
}
publishing {
publications {
mavenJava(MavenPublication) {
artifactId base.archivesName.get()
from components.java
}
}
repositories {
maven {
url "file://" + System.getenv("local_maven")
}
}
}