207 lines
7.1 KiB
Groovy
207 lines
7.1 KiB
Groovy
plugins {
|
|
id 'multiloader-loader'
|
|
id 'net.minecraftforge.gradle' version '[6.0.24,6.2)'
|
|
id 'org.spongepowered.mixin' version '0.7-SNAPSHOT'
|
|
}
|
|
base {
|
|
archivesName = "${mod_name}-forge-${minecraft_version}"
|
|
}
|
|
mixin {
|
|
config("${mod_id}.mixins.json")
|
|
config("${mod_id}.forge.mixins.json")
|
|
}
|
|
jar {
|
|
manifest {
|
|
attributes["MixinConfigs"] = "${mod_id}.mixins.json,${mod_id}.forge.mixins.json"
|
|
}
|
|
}
|
|
|
|
minecraft {
|
|
def commonResources = project(':common').file('src/main/resources/').getAbsolutePath()
|
|
def forgeResources = file('src/main/resources/').getAbsolutePath()
|
|
def forgeBuildResources = file('build/resources/main/').getAbsolutePath()
|
|
def commonBuildResources = project(':common').file('build/resources/main/').getAbsolutePath()
|
|
def generatedOutput = project(':common').file('src/generated/resources/').getAbsolutePath()
|
|
|
|
mappings channel: 'official', version: minecraft_version
|
|
|
|
copyIdeResources = true //Calls processResources when in dev
|
|
|
|
reobf = false // Forge 1.20.6+ uses official mappings at runtime, so we shouldn't reobf from official to SRG
|
|
|
|
// Automatically enable forge AccessTransformers if the file exists
|
|
// This location is hardcoded in Forge and can not be changed.
|
|
// https://github.com/MinecraftForge/MinecraftForge/blob/be1698bb1554f9c8fa2f58e32b9ab70bc4385e60/fmlloader/src/main/java/net/minecraftforge/fml/loading/moddiscovery/ModFile.java#L123
|
|
// Forge still uses SRG names during compile time, so we cannot use the common AT's
|
|
def at = project(':common').file('src/main/resources/META-INF/accesstransformer.cfg')
|
|
if (at.exists()) {
|
|
accessTransformers = ["src/main/resources/META-INF/accesstransformer.cfg"]
|
|
}
|
|
|
|
runs {
|
|
client {
|
|
workingDirectory file('runs/client')
|
|
ideaModule "${rootProject.name}.${project.name}.main"
|
|
taskName 'Client'
|
|
mods {
|
|
modClientRun {
|
|
source sourceSets.main
|
|
}
|
|
}
|
|
args '--mod', project.mod_id,
|
|
'--all',
|
|
'--existing', forgeResources,
|
|
'--existing', commonResources,
|
|
'--existing', forgeBuildResources,
|
|
'--existing', commonBuildResources
|
|
}
|
|
|
|
server {
|
|
workingDirectory file('runs/server')
|
|
ideaModule "${rootProject.name}.${project.name}.main"
|
|
taskName 'Server'
|
|
mods {
|
|
modServerRun {
|
|
source sourceSets.main
|
|
}
|
|
}
|
|
args '--mod', project.mod_id,
|
|
'--all',
|
|
'--existing', forgeResources,
|
|
'--existing', commonResources,
|
|
'--existing', forgeBuildResources,
|
|
'--existing', commonBuildResources
|
|
}
|
|
|
|
data {
|
|
workingDirectory file('runs/data')
|
|
ideaModule "${rootProject.name}.${project.name}.main"
|
|
args '--mod', mod_id, '--all', '--output', file('src/generated/resources/'), '--existing', file('src/main/resources/')
|
|
taskName 'Data'
|
|
mods {
|
|
modDataRun {
|
|
source sourceSets.main
|
|
}
|
|
}
|
|
args '--mod', mod_id,
|
|
'--all',
|
|
'--output', generatedOutput,
|
|
'--existing', forgeResources,
|
|
'--existing', commonResources,
|
|
'--existing', forgeBuildResources,
|
|
'--existing', commonBuildResources
|
|
}
|
|
}
|
|
}
|
|
|
|
sourceSets.main.resources.srcDir project(':common').file('src/generated/resources')
|
|
|
|
dependencies {
|
|
minecraft "net.minecraftforge:forge:${minecraft_version}-${forge_version}"
|
|
annotationProcessor("org.spongepowered:mixin:0.8.5-SNAPSHOT:processor")
|
|
|
|
// Forge's hack fix
|
|
implementation('net.sf.jopt-simple:jopt-simple:5.0.4') { version { strictly '5.0.4' } }
|
|
}
|
|
|
|
publishing {
|
|
publications {
|
|
mavenJava(MavenPublication) {
|
|
artifactId = "${mod_id}-forge-${minecraft_version}"
|
|
artifacts.clear()
|
|
artifact(jar) {
|
|
builtBy jar
|
|
}
|
|
artifact(sourcesJar) {
|
|
builtBy sourcesJar
|
|
classifier = 'sources'
|
|
}
|
|
artifact(javadocJar) {
|
|
builtBy javadocJar
|
|
classifier = 'javadoc'
|
|
}
|
|
pom {
|
|
name = mod_name
|
|
description = project.description ?: "default"
|
|
developers {
|
|
developer {
|
|
id = mod_author
|
|
name = mod_author
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
// 配置sourceJar任务
|
|
tasks.named('sourcesJar', Jar) {
|
|
dependsOn classes
|
|
dependsOn project(':common').tasks.named('sourcesJar') // 显式依赖common的source
|
|
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
|
|
archiveClassifier.set('sources')
|
|
from sourceSets.main.allSource
|
|
from project(':common').sourceSets.main.allSource
|
|
}
|
|
|
|
// 配置javadoc任务
|
|
tasks.named('javadoc', Javadoc) {
|
|
source project(':common').sourceSets.main.allJava
|
|
source sourceSets.main.allJava
|
|
classpath = configurations.compileClasspath
|
|
classpath += project(':common').sourceSets.main.compileClasspath
|
|
options.encoding = 'UTF-8'
|
|
options.charSet = 'UTF-8'
|
|
options.links("https://docs.oracle.com/en/java/javase/17/docs/api/")
|
|
options.memberLevel = JavadocMemberLevel.PUBLIC
|
|
options.addBooleanOption('Xdoclint:none', true)
|
|
options.addStringOption('doctitle', "${mod_id} ${minecraft_version} ${version} Javadoc")
|
|
}
|
|
|
|
// 配置javadocJar任务
|
|
tasks.named('javadocJar', Jar) {
|
|
dependsOn javadoc
|
|
dependsOn project(':common').tasks.named('javadoc') // 显式依赖common的javadoc
|
|
|
|
archiveClassifier.set('javadoc')
|
|
from javadoc.destinationDir
|
|
from project(':common').javadoc.destinationDir
|
|
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
|
|
}
|
|
|
|
// 确保build任务包含所有需要的jar
|
|
tasks.named('build') {
|
|
dependsOn tasks.named('sourcesJar')
|
|
dependsOn tasks.named('javadocJar')
|
|
}
|
|
|
|
|
|
sourceSets.each {
|
|
def dir = layout.buildDirectory.dir("sourcesSets/$it.name")
|
|
it.output.resourcesDir = dir
|
|
it.java.destinationDirectory = dir
|
|
}
|
|
|
|
processResources {
|
|
from project(':common').sourceSets.main.resources
|
|
inputs.property "version", project.version
|
|
inputs.property "minecraft_version", minecraft_version
|
|
inputs.property "forge_version", forge_version
|
|
inputs.property "mod_id", mod_id
|
|
inputs.property "mod_name", mod_name
|
|
inputs.property "description", description
|
|
inputs.property "mod_author", mod_author
|
|
|
|
filesMatching(['META-INF/mods.toml', 'pack.mcmeta']) {
|
|
expand([
|
|
version: project.version,
|
|
minecraft_version: minecraft_version,
|
|
forge_version: forge_version,
|
|
mod_id: mod_id,
|
|
mod_name: mod_name,
|
|
description: description,
|
|
mod_author: mod_author
|
|
])
|
|
}
|
|
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
|
|
} |