aboutsummaryrefslogtreecommitdiff
path: root/build.gradle.kts
blob: fc7a01897fa28d56357e23bc5e1b237fd1e1a331 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
plugins {
    alias(libs.plugins.architectury.plugin)
    alias(libs.plugins.architectury.loom) apply false

    alias(libs.plugins.minotaur) apply false
    alias(libs.plugins.cursegradle) apply false
    alias(libs.plugins.github.release)
    alias(libs.plugins.grgit)
}

architectury {
    minecraft = libs.versions.minecraft.get()
}

version = "3.0.1+1.20"

val isBeta = "beta" in version.toString()
val changelogText = rootProject.file("changelogs/${project.version}.md").takeIf { it.exists() }?.readText() ?: "No changelog provided."
val snapshotVer = "${grgit.branch.current().name.replace('/', '.')}-SNAPSHOT"

allprojects {
    apply(plugin = "java")
    apply(plugin = "maven-publish")
    apply(plugin = "architectury-plugin")

    version = rootProject.version
    group = "dev.isxander"

    if (System.getenv().containsKey("GITHUB_ACTIONS")) {
        version = "$version+$snapshotVer"
    }

    pluginManager.withPlugin("base") {
        val base = the<BasePluginExtension>()

        base.archivesName.set("yet-another-config-lib-${project.name}")
    }

    ext["changelogText"] = changelogText
    ext["isBeta"] = isBeta

    repositories {
        mavenCentral()
        maven("https://maven.terraformersmc.com/releases")
        maven("https://maven.isxander.dev/releases")
        maven("https://maven.isxander.dev/snapshots")
        maven("https://maven.quiltmc.org/repository/release")
        maven("https://api.modrinth.com/maven") {
            name = "Modrinth"
            content {
                includeGroup("maven.modrinth")
            }
        }
        maven("https://jitpack.io")
    }

    pluginManager.withPlugin("publishing") {
        val publishing = the<PublishingExtension>()

        publishing.repositories {
            val username = "XANDER_MAVEN_USER".let { System.getenv(it) ?: findProperty(it) }?.toString()
            val password = "XANDER_MAVEN_PASS".let { System.getenv(it) ?: findProperty(it) }?.toString()
            if (username != null && password != null) {
                maven(url = "https://maven.isxander.dev/releases") {
                    name = "Releases"
                    credentials {
                        this.username = username
                        this.password = password
                    }
                }
                maven(url = "https://maven.isxander.dev/snapshots") {
                    name = "Snapshots"
                    credentials {
                        this.username = username
                        this.password = password
                    }
                }
            } else {
                println("Xander Maven credentials not satisfied.")
            }
        }
    }
}

githubRelease {
    token(findProperty("GITHUB_TOKEN")?.toString())

    val githubProject: String by rootProject
    val split = githubProject.split("/")
    owner(split[0])
    repo(split[1])
    tagName("${project.version}")
    targetCommitish(grgit.branch.current().name)
    body(changelogText)
    prerelease(isBeta)
    releaseAssets(
        { findProject(":fabric")?.tasks?.get("remapJar")?.outputs?.files },
        { findProject(":fabric")?.tasks?.get("remapSourcesJar")?.outputs?.files },
        { findProject(":forge")?.tasks?.get("remapJar")?.outputs?.files },
        { findProject(":forge")?.tasks?.get("remapSourcesJar")?.outputs?.files },
    )
}

tasks.register("releaseMod") {
    group = "mod"

    dependsOn("githubRelease")
}

tasks.register("buildAll") {
    group = "mod"

    findProject(":fabric")?.let { dependsOn(it.tasks["build"]) }
    findProject(":forge")?.let { dependsOn(it.tasks["build"]) }
}