171 lines
5.5 KiB
Groovy
171 lines
5.5 KiB
Groovy
import net.fabricmc.loom.task.RemapJarTask
|
|
|
|
plugins {
|
|
id 'multiloader-loader'
|
|
id 'fabric-loom'
|
|
}
|
|
dependencies {
|
|
minecraft "com.mojang:minecraft:${minecraft_version}"
|
|
mappings loom.layered {
|
|
officialMojangMappings()
|
|
parchment("org.parchmentmc.data:parchment-${parchment_minecraft}:${parchment_version}@zip")
|
|
}
|
|
modImplementation "net.fabricmc:fabric-loader:${fabric_loader_version}"
|
|
modImplementation "net.fabricmc.fabric-api:fabric-api:${fabric_version}"
|
|
implementation group: 'com.google.code.findbugs', name: 'jsr305', version: '3.0.1'
|
|
implementation project(":common")
|
|
}
|
|
|
|
loom {
|
|
if (project(":common").file("src/main/resources/${mod_id}.accesswidener").exists()) {
|
|
accessWidenerPath.set(project(":common").file("src/main/resources/${mod_id}.accesswidener"))
|
|
}
|
|
mixin {
|
|
defaultRefmapName.set("${mod_id}.refmap.json")
|
|
}
|
|
runs {
|
|
client {
|
|
client()
|
|
setConfigName("Fabric Client")
|
|
ideConfigGenerated(true)
|
|
runDir("run")
|
|
}
|
|
server {
|
|
server()
|
|
setConfigName("Fabric Server")
|
|
ideConfigGenerated(true)
|
|
runDir("run")
|
|
}
|
|
}
|
|
}
|
|
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
|
|
dependsOn project(':common').tasks.named('javadoc') // 显式依赖common的javadoc
|
|
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
|
|
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
|
|
archiveClassifier.set('javadoc')
|
|
from javadoc.destinationDir
|
|
from project(':common').javadoc.destinationDir
|
|
}
|
|
|
|
// 确保build任务包含所有需要的jar
|
|
tasks.named('build') {
|
|
dependsOn tasks.named('sourcesJar')
|
|
dependsOn tasks.named('javadocJar')
|
|
}
|
|
|
|
// 配置remap任务以包含sources和javadoc
|
|
remapJar {
|
|
dependsOn tasks.named('sourcesJar')
|
|
dependsOn tasks.named('javadocJar')
|
|
inputFile.set(tasks.named('jar').get().archiveFile)
|
|
addNestedDependencies = false
|
|
}
|
|
|
|
remapSourcesJar {
|
|
dependsOn tasks.named('sourcesJar')
|
|
inputFile.set(tasks.named('sourcesJar').get().archiveFile)
|
|
}
|
|
|
|
// 为javadocJar创建remap任务
|
|
tasks.register('remapJavadocJar', RemapJarTask) {
|
|
dependsOn tasks.named('javadocJar')
|
|
inputFile.set(tasks.named('javadocJar').get().archiveFile)
|
|
archiveClassifier.set('javadoc')
|
|
addNestedDependencies = false
|
|
}
|
|
|
|
// 将remapped artifacts添加到发布配置
|
|
publishing {
|
|
publications {
|
|
mavenJava(MavenPublication) {
|
|
// 重置artifactsId
|
|
artifactId = "${mod_id}-fabric-${minecraft_version}"
|
|
artifacts.clear()
|
|
// 手动添加需要的artifacts
|
|
artifact(remapJar) {
|
|
builtBy remapJar
|
|
}
|
|
artifact(remapSourcesJar) {
|
|
builtBy remapSourcesJar
|
|
classifier = 'sources'
|
|
}
|
|
artifact(remapJavadocJar) {
|
|
builtBy remapJavadocJar
|
|
classifier = 'javadoc'
|
|
}
|
|
pom {
|
|
name = 'Lib39'
|
|
description = 'Lib39 is a general-purpose dependency library for Minecraft mods.'
|
|
url = 'https://github.com/3944Realms/lib39'
|
|
|
|
properties = [
|
|
'minecraft.version': project.minecraft_version,
|
|
'mod.version': project.version,
|
|
'fabric.version': project.fabric_version,
|
|
'java.version': '17'
|
|
]
|
|
|
|
licenses {
|
|
license {
|
|
name = 'MIT'
|
|
url = 'https://raw.githubusercontent.com/3944Realms/lib39/refs/heads/main/LICENSE'
|
|
distribution = 'repo'
|
|
}
|
|
}
|
|
|
|
developers {
|
|
developer {
|
|
id = 'R3944Realms'
|
|
name = "${mod_author}"
|
|
email = 'f256198830@hotmail.com'
|
|
}
|
|
}
|
|
|
|
scm {
|
|
connection = 'scm:git:https://github.com/3944Realms/lib39.git'
|
|
developerConnection = 'scm:git:ssh://git@github.com:3944Realms/lib39.git'
|
|
url = 'https://github.com/3944Realms/lib39'
|
|
tag = 'main'
|
|
}
|
|
|
|
issueManagement {
|
|
system = 'GitHub'
|
|
url = 'https://github.com/3944Realms/lib39/issues'
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|
|
}
|
|
|
|
tasks.named('generateMetadataFileForMavenJavaPublication') {
|
|
dependsOn tasks.named('remapJavadocJar')
|
|
dependsOn tasks.named('remapJar')
|
|
dependsOn tasks.named('remapSourcesJar')
|
|
}
|
|
|