2021-10-09 12:44:01 +02:00
|
|
|
import com.modrinth.minotaur.TaskModrinthUpload
|
2021-11-24 13:35:57 +01:00
|
|
|
import com.modrinth.minotaur.request.VersionType
|
2021-10-09 12:44:01 +02:00
|
|
|
|
2021-09-27 20:55:48 +02:00
|
|
|
plugins {
|
2021-09-28 20:21:29 +02:00
|
|
|
id "java"
|
2021-09-27 20:55:48 +02:00
|
|
|
id "idea"
|
2021-09-28 20:21:29 +02:00
|
|
|
id "eclipse"
|
|
|
|
id "java-library"
|
2021-09-27 20:55:48 +02:00
|
|
|
id "maven-publish"
|
2021-10-03 13:50:26 +02:00
|
|
|
id "fabric-loom" version "0.10-SNAPSHOT" apply false
|
2021-09-27 20:55:48 +02:00
|
|
|
id "com.matthewprenger.cursegradle" version "1.4.0"
|
2021-11-24 13:35:57 +01:00
|
|
|
id "com.modrinth.minotaur" version "1.2.1"
|
2021-10-16 17:00:24 +02:00
|
|
|
id "org.ajoberstar.grgit" version "3.1.0"
|
2021-09-27 20:55:48 +02:00
|
|
|
}
|
|
|
|
|
2021-09-28 20:41:17 +02:00
|
|
|
def ENV = System.getenv()
|
2021-10-03 12:58:01 +02:00
|
|
|
ext.isPublicMaven = project.hasProperty('publicMaven')
|
2021-04-11 16:00:37 +02:00
|
|
|
|
2021-10-16 17:00:24 +02:00
|
|
|
// Fetch changelog
|
|
|
|
grgit.open(dir: project.projectDir.toString())
|
|
|
|
def tagList = grgit.tag.list()
|
2021-11-24 13:35:57 +01:00
|
|
|
def currentTag = tagList.get(tagList.size() - 1)
|
|
|
|
ext.currentVer = currentTag.getName()
|
|
|
|
ext.currentType = VersionType.RELEASE
|
|
|
|
switch (ext.currentVer[0]) {
|
|
|
|
case 'v':
|
|
|
|
ext.currentVer = ext.currentVer.substring(1)
|
|
|
|
break
|
|
|
|
case 'b':
|
|
|
|
ext.currentVer = ext.currentVer.substring(1)
|
|
|
|
ext.currentType = VersionType.BETA
|
|
|
|
break
|
|
|
|
case 'a':
|
|
|
|
ext.currentVer = ext.currentVer.substring(1)
|
|
|
|
ext.currentType = VersionType.ALPHA
|
|
|
|
break
|
|
|
|
}
|
|
|
|
def changelogStr = "Commits in " + ext.currentType.toString().toLowerCase() + " " + ext.currentVer + ":"
|
|
|
|
for (def commit : grgit.log{range(tagList.get(tagList.size() - 2).fullName, currentTag.fullName)}) {
|
2021-10-16 17:00:24 +02:00
|
|
|
changelogStr += "\n- " + commit.shortMessage
|
|
|
|
}
|
|
|
|
println(changelogStr)
|
|
|
|
|
2021-09-28 20:21:29 +02:00
|
|
|
static Node getOrCreateNode(Node node, String name) {
|
|
|
|
Node dependencies = null
|
|
|
|
for(Node n : node) {
|
|
|
|
if(name == n.name()) {
|
|
|
|
dependencies = n
|
|
|
|
break
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(dependencies == null) {
|
|
|
|
dependencies = node.appendNode(name)
|
|
|
|
}
|
|
|
|
return dependencies
|
|
|
|
}
|
|
|
|
|
2021-09-27 20:55:48 +02:00
|
|
|
def moduleDependencies(project, List<String> depNames) {
|
|
|
|
def deps = depNames.iterator().collect { project.dependencies.project(path: ":$it", configuration: 'dev') }
|
|
|
|
project.dependencies {
|
|
|
|
deps.each {
|
|
|
|
api it
|
|
|
|
}
|
|
|
|
}
|
2021-09-28 20:21:29 +02:00
|
|
|
project.publishing {
|
2021-09-27 20:55:48 +02:00
|
|
|
publications {
|
|
|
|
mavenJava(MavenPublication) {
|
|
|
|
pom.withXml {
|
2021-09-28 20:21:29 +02:00
|
|
|
def depsNode = getOrCreateNode(asNode(), "dependencies")
|
2021-09-27 20:55:48 +02:00
|
|
|
deps.each {
|
|
|
|
def depNode = depsNode.appendNode("dependency")
|
|
|
|
depNode.appendNode("groupId", it.group)
|
|
|
|
depNode.appendNode("artifactId", it.name)
|
|
|
|
depNode.appendNode("version", it.version)
|
|
|
|
depNode.appendNode("scope", "compile")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2021-09-28 20:21:29 +02:00
|
|
|
}
|
2021-04-11 20:23:52 +02:00
|
|
|
}
|
|
|
|
|
2021-09-27 20:55:48 +02:00
|
|
|
allprojects {
|
|
|
|
apply plugin: "java-library"
|
2021-09-28 20:21:29 +02:00
|
|
|
apply plugin: "maven-publish"
|
2021-09-27 20:55:48 +02:00
|
|
|
apply plugin: "fabric-loom"
|
|
|
|
|
|
|
|
tasks.withType(JavaCompile).configureEach {
|
2021-11-17 12:38:17 +01:00
|
|
|
it.options.release = 17
|
2021-09-27 20:55:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
group = "io.gitlab.jfronny.libjf"
|
2021-11-24 13:35:57 +01:00
|
|
|
version = "$rootProject.ext.currentVer" + (project.hasProperty('pipeline') ? "-" + project.getProperty('pipeline') : "")
|
2021-09-27 20:55:48 +02:00
|
|
|
|
|
|
|
sourceSets {
|
|
|
|
testmod {
|
|
|
|
compileClasspath += main.compileClasspath
|
|
|
|
runtimeClasspath += main.runtimeClasspath
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
loom {
|
|
|
|
runs {
|
|
|
|
testmodClient {
|
|
|
|
client()
|
|
|
|
ideConfigGenerated project.rootProject == project
|
|
|
|
name = "Testmod Client"
|
|
|
|
source sourceSets.testmod
|
|
|
|
}
|
|
|
|
testmodServer {
|
|
|
|
server()
|
|
|
|
ideConfigGenerated project.rootProject == project
|
|
|
|
name = "Testmod Server"
|
|
|
|
source sourceSets.testmod
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
dependencies {
|
|
|
|
minecraft "com.mojang:minecraft:${project.minecraft_version}"
|
|
|
|
mappings "net.fabricmc:yarn:${project.minecraft_version}+${project.yarn_mappings}:v2"
|
|
|
|
modImplementation "net.fabricmc:fabric-loader:${project.loader_version}"
|
|
|
|
|
2021-10-09 12:51:40 +02:00
|
|
|
modRuntimeOnly modCompileOnly("com.terraformersmc:modmenu:2.0.14")
|
2021-11-19 15:23:07 +01:00
|
|
|
modRuntimeOnly("net.fabricmc.fabric-api:fabric-api:${project.fabric_version}")
|
2021-09-27 20:55:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
configurations {
|
|
|
|
dev
|
|
|
|
}
|
|
|
|
|
|
|
|
loom {
|
|
|
|
shareRemapCaches = true
|
|
|
|
}
|
|
|
|
|
|
|
|
repositories {
|
|
|
|
maven {
|
|
|
|
name = 'TerraformersMC'
|
|
|
|
url = 'https://maven.terraformersmc.com/'
|
|
|
|
}
|
2021-09-28 20:21:29 +02:00
|
|
|
mavenLocal()
|
2021-09-27 20:55:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
jar {
|
|
|
|
archiveClassifier = "dev"
|
|
|
|
}
|
|
|
|
|
|
|
|
afterEvaluate {
|
|
|
|
remapJar {
|
|
|
|
input = file("${project.buildDir}/libs/$archivesBaseName-${project.version}-dev.jar")
|
|
|
|
archiveFileName = "${archivesBaseName}-${project.version}.jar"
|
|
|
|
}
|
|
|
|
|
|
|
|
artifacts {
|
|
|
|
dev file: file("${project.buildDir}/libs/$archivesBaseName-${project.version}-dev.jar"), type: "jar", builtBy: jar
|
|
|
|
}
|
|
|
|
|
|
|
|
processResources {
|
|
|
|
inputs.property "version", project.version
|
|
|
|
|
|
|
|
filesMatching("fabric.mod.json") {
|
|
|
|
expand "version": project.version
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
task sourcesJar(type: Jar, dependsOn: classes) {
|
|
|
|
archiveClassifier = "sources"
|
|
|
|
from sourceSets.main.allSource
|
|
|
|
}
|
|
|
|
|
|
|
|
tasks.withType(AbstractArchiveTask) {
|
|
|
|
preserveFileTimestamps = false
|
|
|
|
reproducibleFileOrder = true
|
2021-04-11 20:23:52 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-09-27 20:55:48 +02:00
|
|
|
subprojects {
|
|
|
|
dependencies {
|
|
|
|
testmodImplementation sourceSets.main.output
|
|
|
|
}
|
2021-04-11 16:00:37 +02:00
|
|
|
|
2021-09-27 20:55:48 +02:00
|
|
|
publishing {
|
|
|
|
publications {
|
|
|
|
mavenJava(MavenPublication) {
|
|
|
|
afterEvaluate {
|
|
|
|
artifact(remapJar) {
|
|
|
|
builtBy remapJar
|
|
|
|
}
|
|
|
|
|
|
|
|
artifact(sourcesJar) {
|
|
|
|
builtBy remapSourcesJar
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2021-09-28 20:21:29 +02:00
|
|
|
|
2021-10-03 12:58:01 +02:00
|
|
|
setupRepositories(repositories)
|
2021-09-28 20:21:29 +02:00
|
|
|
}
|
2021-10-09 12:44:01 +02:00
|
|
|
|
|
|
|
loom.disableDeprecatedPomGeneration(publishing.publications.mavenJava)
|
|
|
|
|
|
|
|
javadoc.enabled = false
|
|
|
|
|
|
|
|
afterEvaluate {
|
|
|
|
genSources.enabled = false
|
|
|
|
unpickJar.enabled = false
|
|
|
|
}
|
2021-09-28 20:21:29 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
task remapMavenJar(type: net.fabricmc.loom.task.RemapJarTask, dependsOn: jar) {
|
|
|
|
input = jar.archiveFile
|
|
|
|
archiveFileName = "${archivesBaseName}-${project.version}-maven.jar"
|
|
|
|
addNestedDependencies = false
|
|
|
|
}
|
|
|
|
build.dependsOn remapMavenJar
|
|
|
|
|
|
|
|
publishing {
|
|
|
|
publications {
|
|
|
|
mavenJava(MavenPublication) {
|
|
|
|
artifact(remapMavenJar) {
|
|
|
|
builtBy remapMavenJar
|
|
|
|
}
|
|
|
|
|
|
|
|
artifact(sourcesJar) {
|
|
|
|
builtBy remapSourcesJar
|
|
|
|
}
|
|
|
|
|
|
|
|
pom.withXml {
|
|
|
|
def depsNode = getOrCreateNode(asNode(), "dependencies")
|
|
|
|
subprojects.each {
|
|
|
|
def depNode = depsNode.appendNode("dependency")
|
|
|
|
depNode.appendNode("groupId", it.group)
|
|
|
|
depNode.appendNode("artifactId", it.name)
|
|
|
|
depNode.appendNode("version", it.version)
|
|
|
|
depNode.appendNode("scope", "compile")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-10-03 12:58:01 +02:00
|
|
|
setupRepositories(repositories)
|
|
|
|
}
|
|
|
|
|
2021-10-09 12:44:01 +02:00
|
|
|
loom.disableDeprecatedPomGeneration(publishing.publications.mavenJava)
|
|
|
|
|
2021-10-03 12:58:01 +02:00
|
|
|
void setupRepositories(RepositoryHandler repositories) {
|
|
|
|
//repositories.mavenLocal() // uncomment for testing
|
|
|
|
def ENV = System.getenv()
|
|
|
|
if (ext.isPublicMaven) {
|
|
|
|
repositories.maven {
|
2021-10-03 12:16:38 +02:00
|
|
|
url = "https://gitlab.com/api/v4/projects/25805200/packages/maven"
|
2021-09-28 20:21:29 +02:00
|
|
|
name = "gitlab"
|
|
|
|
|
|
|
|
credentials(HttpHeaderCredentials) {
|
|
|
|
name = "Job-Token"
|
2021-09-28 20:41:17 +02:00
|
|
|
value = ENV.CI_JOB_TOKEN
|
2021-09-28 20:21:29 +02:00
|
|
|
}
|
|
|
|
authentication {
|
|
|
|
header(HttpHeaderAuthentication)
|
|
|
|
}
|
|
|
|
}
|
2021-09-27 20:55:48 +02:00
|
|
|
}
|
2021-10-03 12:58:01 +02:00
|
|
|
repositories.mavenLocal()
|
2021-04-11 16:00:37 +02:00
|
|
|
}
|
|
|
|
|
2021-09-27 20:55:48 +02:00
|
|
|
subprojects.each { remapJar.dependsOn("${it.path}:remapJar") }
|
|
|
|
|
2021-09-28 20:21:29 +02:00
|
|
|
sourceSets {
|
|
|
|
testmod
|
|
|
|
}
|
|
|
|
|
|
|
|
def devOnlyModules = [
|
|
|
|
"libjf-devutil-v0"
|
|
|
|
]
|
|
|
|
|
2021-09-27 20:55:48 +02:00
|
|
|
dependencies {
|
|
|
|
afterEvaluate {
|
|
|
|
subprojects.each {
|
|
|
|
api project(path: ":${it.name}", configuration: "dev")
|
|
|
|
|
2021-09-28 20:21:29 +02:00
|
|
|
if (!(it.name in devOnlyModules)) {
|
2021-10-09 12:44:01 +02:00
|
|
|
include it
|
2021-09-28 20:21:29 +02:00
|
|
|
}
|
2021-09-27 20:55:48 +02:00
|
|
|
|
2021-10-09 12:44:01 +02:00
|
|
|
testmodImplementation it.sourceSets.testmod.output
|
2021-07-18 10:36:51 +02:00
|
|
|
}
|
2021-09-27 20:55:48 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-10-09 13:31:50 +02:00
|
|
|
task modrinth(type: TaskModrinthUpload, dependsOn: build) {
|
2021-09-27 20:55:48 +02:00
|
|
|
onlyIf {
|
2021-09-28 20:41:17 +02:00
|
|
|
ENV.MODRINTH_API_TOKEN
|
2021-09-27 20:55:48 +02:00
|
|
|
}
|
|
|
|
|
2021-09-28 20:41:17 +02:00
|
|
|
token = ENV.MODRINTH_API_TOKEN
|
2021-09-27 20:55:48 +02:00
|
|
|
projectId = "WKwQAwke"
|
|
|
|
versionNumber = version
|
2021-11-24 13:35:57 +01:00
|
|
|
versionName = "[${project.minecraft_version}] ${version}"
|
2021-10-09 13:29:46 +02:00
|
|
|
uploadFile = file("${project.buildDir}/libs/${archivesBaseName}-${version}.jar")
|
2021-11-24 13:35:57 +01:00
|
|
|
versionType = rootProject.ext.currentType
|
2021-10-16 17:00:24 +02:00
|
|
|
changelog = changelogStr
|
2021-09-27 20:55:48 +02:00
|
|
|
addGameVersion("${project.minecraft_version}")
|
|
|
|
addLoader('fabric')
|
|
|
|
}
|
|
|
|
|
|
|
|
curseforge {
|
2021-09-28 20:41:17 +02:00
|
|
|
if (ENV.CURSEFORGE_API_TOKEN) {
|
|
|
|
apiKey = ENV.CURSEFORGE_API_TOKEN
|
2021-09-27 20:55:48 +02:00
|
|
|
} else {
|
|
|
|
println "No CURSEFORGE_API_TOKEN specified"
|
|
|
|
}
|
|
|
|
project {
|
|
|
|
id = "482600"
|
|
|
|
releaseType = 'release'
|
|
|
|
addGameVersion "Fabric"
|
|
|
|
addGameVersion "${project.minecraft_version}"
|
2021-10-16 17:00:24 +02:00
|
|
|
changelog = changelogStr
|
2021-09-27 20:55:48 +02:00
|
|
|
mainArtifact(file("${project.buildDir}/libs/${archivesBaseName}-${version}.jar"))
|
2021-11-24 13:35:57 +01:00
|
|
|
mainArtifact.displayName = "[${project.minecraft_version}] ${version}"
|
|
|
|
releaseType = rootProject.ext.currentType.toString().toLowerCase()
|
2021-09-27 20:55:48 +02:00
|
|
|
afterEvaluate {
|
2021-10-09 13:31:50 +02:00
|
|
|
uploadTask.dependsOn(build)
|
2021-07-18 10:36:51 +02:00
|
|
|
}
|
|
|
|
}
|
2021-09-27 20:55:48 +02:00
|
|
|
options {
|
|
|
|
forgeGradleIntegration = false
|
|
|
|
}
|
|
|
|
}
|