aboutsummaryrefslogtreecommitdiff
path: root/fabric/build.gradle
blob: 1dc8b1523d928c733457532d655b01abdb8094f7 (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
137
138
139
140
141
142
143
144
plugins {
    id "com.github.johnrengelman.shadow" version "7.0.0"
}

architectury {
    platformSetupLoomIde()
    fabric()
}

configurations {
    common
    shadowCommon // Don't use shadow from the shadow plugin because we don't want IDEA to index this.
    compileClasspath.extendsFrom common
    runtimeClasspath.extendsFrom common
}

processResources {
    filesMatching("fabric.mod.json") {
        expand "version": project.version
    }
    inputs.property "version", project.version
}

loom {
    accessWidenerPath = file("src/main/resources/roughlyenoughitems.accessWidener")
}

dependencies {
    modApi("net.fabricmc:fabric-loader:${project.fabricloader_version}")
    modApi("net.fabricmc.fabric-api:fabric-api:${project.fabric_api}")
    modApi("me.shedaniel.cloth:cloth-config-fabric:${cloth_config_version}") {
        exclude(module: "fabric-api")
    }
    //modRuntime("com.terraformersmc:modmenu:${modmenu_version}") { transitive false }
    modApi("dev.architectury:architectury-fabric:${architectury_version}")
    modApi("me.shedaniel:error-notifier-fabric:1.0.9")
    include("me.shedaniel:error-notifier-fabric:1.0.9")

    depProjects.forEach {
        common(project(path: it, configuration: "namedElements")) { transitive false }
        shadowCommon(project(path: it, configuration: "transformProductionFabric")) { transitive false }
    }
}

shadowJar {
    configurations = [project.configurations.shadowCommon]
    classifier "dev-shadow"
}

remapJar {
    input.set shadowJar.archiveFile
    dependsOn shadowJar
    classifier null
}

jar {
    classifier "dev"
}

java {
    withSourcesJar()
}

sourcesJar {
    afterEvaluate {
        depProjects.forEach {
            def depSources = project(it).sourcesJar
            dependsOn depSources
            from depSources.archiveFile.map { zipTree(it) }
        }
    }
}

components.java {
    withVariantsFromConfiguration(project.configurations.shadowRuntimeElements) {
        skip()
    }
}

publishing {
    publications {
        mavenFabric(MavenPublication) {
            artifactId = rootProject.name + "-" + project.name
            from components.java
        }
        ["api", "default-plugin", "runtime"].forEach { projectName ->
            create(projectName + "Fabric", MavenPublication.class) { publication ->
                publication.artifactId = rootProject.name + "-" + projectName + "-fabric"
                project.afterEvaluate {
                    def project = project(":" + projectName)
                    publication.artifact(project.fakeJar) { classifier null }
                    def remapSourcesJarTask = project.remapSourcesJar
                    publication.artifact(remapSourcesJarTask) {
                        builtBy remapSourcesJarTask
                        classifier "sources"
                    }
                }
            }
        }
    }
}

unifiedPublishing {
    project {
        displayName = "[Fabric $rootProject.supported_version] v$project.version"
        releaseType = "release"
        gameVersions = ["1.18.2"]
        gameLoaders = ["fabric"]
        changelog = rootProject.releaseChangelog

        mainPublication remapJar
        
        relations {
            depends {
                curseforge = "architectury-api"
                modrinth = "architectury-api"
            }
            depends {
                curseforge = "cloth-config"
                modrinth = "cloth-config"
            }
            depends {
                curseforge = "fabric-api"
                modrinth = "fabric-api"
            }
        }

        if (project.hasProperty("danielshe_curse_api_key") || System.getenv("danielshe_curse_api_key") != null) {
            curseforge {
                token = project.hasProperty("danielshe_curse_api_key") ? project.property("danielshe_curse_api_key") : System.getenv("danielshe_curse_api_key")
                id = "310111"
                gameVersions.addAll "Java 17", "1.18-Snapshot"
            }
        }

        if (project.hasProperty("modrinth_key") || System.getenv("modrinth_key") != null) {
            modrinth {
                token = project.hasProperty("modrinth_key") ? project.property("modrinth_key") : System.getenv("modrinth_key")
                id = "nfn13YXA"
                version = "$project.version+$project.name"
            }
        }
    }
}