aboutsummaryrefslogtreecommitdiff
path: root/lwjgl/build.gradle.kts
blob: 925fb4db47bc46efc1913aa1eab80f5558248cd3 (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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
@file:Suppress("GradlePackageUpdate")

plugins {
    kotlin("jvm")
    id("gg.essential.multi-version")
    id("gg.essential.defaults.repo")
    id("gg.essential.defaults.java")
    id("gg.essential.defaults.loom")
    id("com.github.johnrengelman.shadow")
    id("maven-publish")
    id("signing")
    java
}

val mod_name: String by project
val mod_version: String by project
val mod_id: String by project

version = "1.0.0-alpha8"

repositories {
    maven("https://repo.polyfrost.cc/releases")
}
val shadeCompileOnly: Configuration by configurations.creating
val shadeRuntimeOnly: Configuration by configurations.creating

sourceSets {
    main {
        runtimeClasspath += shadeRuntimeOnly
    }
}

dependencies {
    val lwjgl = if (platform.mcVersion >= 11600) {
        "3.2.1"
    } else {
        "3.3.1"
    }
    if (platform.isLegacyForge) {
        shadeCompileOnly("org.lwjgl:lwjgl:$lwjgl")
        shadeCompileOnly("org.lwjgl:lwjgl-stb:$lwjgl")
        shadeCompileOnly("org.lwjgl:lwjgl-tinyfd:$lwjgl")

        shadeRuntimeOnly("org.lwjgl:lwjgl:$lwjgl:natives-windows")
        shadeRuntimeOnly("org.lwjgl:lwjgl-stb:$lwjgl:natives-windows")
        shadeRuntimeOnly("org.lwjgl:lwjgl-tinyfd:$lwjgl:natives-windows")
        shadeRuntimeOnly("org.lwjgl:lwjgl:$lwjgl:natives-linux")
        shadeRuntimeOnly("org.lwjgl:lwjgl-stb:$lwjgl:natives-linux")
        shadeRuntimeOnly("org.lwjgl:lwjgl-tinyfd:$lwjgl:natives-linux")
        shadeRuntimeOnly("org.lwjgl:lwjgl:$lwjgl:natives-macos")
        shadeRuntimeOnly("org.lwjgl:lwjgl-stb:$lwjgl:natives-macos")
        shadeRuntimeOnly("org.lwjgl:lwjgl-tinyfd:$lwjgl:natives-macos")
        shadeRuntimeOnly("org.lwjgl:lwjgl:$lwjgl:natives-macos-arm64")
        shadeRuntimeOnly("org.lwjgl:lwjgl-stb:$lwjgl:natives-macos-arm64")
        shadeRuntimeOnly("org.lwjgl:lwjgl-tinyfd:$lwjgl:natives-macos-arm64")
    }

    shadeCompileOnly("org.lwjgl:lwjgl-nanovg:$lwjgl") {
        isTransitive = false
    }
    shadeRuntimeOnly("org.lwjgl:lwjgl-nanovg:$lwjgl:natives-windows") {
        isTransitive = false
    }
    shadeRuntimeOnly("org.lwjgl:lwjgl-nanovg:$lwjgl:natives-linux") {
        isTransitive = false
    }
    shadeRuntimeOnly("org.lwjgl:lwjgl-nanovg:$lwjgl:natives-macos") {
        isTransitive = false
    }
    // force 3.3.1 for this, because
    // if the user is actually running M1+, LWJGL must be 3.3.0+
    shadeRuntimeOnly("org.lwjgl:lwjgl-nanovg:3.3.1:natives-macos-arm64") {
        isTransitive = false
    }
}

tasks {
    named<com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar>("shadowJar") {
        archiveClassifier.set("")
        configurations = listOf(shadeCompileOnly, shadeRuntimeOnly)
        if (platform.isLegacyForge) {
            exclude("META-INF/versions/**")
            exclude("**/module-info.class")
            exclude("**/package-info.class")
            relocate("org.lwjgl", "org.lwjgl3") {
                include("org.lwjgl.PointerBuffer")
                include("org.lwjgl.BufferUtils")
            }
        }
        duplicatesStrategy = DuplicatesStrategy.EXCLUDE
        dependsOn(jar)
    }
    jar {
        enabled = false
    }
    remapJar {
        enabled = false
    }
}

publishing {
    publications {
        register<MavenPublication>("lwjgl-$platform") {
            groupId = "cc.polyfrost"
            artifactId = "lwjgl-$platform"
            artifact(tasks["shadowJar"])
        }
    }

    repositories {
        maven {
            name = "releases"
            url = uri("https://repo.polyfrost.cc/releases")
            credentials(PasswordCredentials::class)
            authentication {
                create<BasicAuthentication>("basic")
            }
        }
        maven {
            name = "snapshots"
            url = uri("https://repo.polyfrost.cc/snapshots")
            credentials(PasswordCredentials::class)
            authentication {
                create<BasicAuthentication>("basic")
            }
        }
        maven {
            name = "private"
            url = uri("https://repo.polyfrost.cc/private")
            credentials(PasswordCredentials::class)
            authentication {
                create<BasicAuthentication>("basic")
            }
        }
    }
}