This repository was archived by the owner on Oct 20, 2024. It is now read-only.
forked from vini2003/Linkart
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathbuild.gradle
179 lines (153 loc) · 4.98 KB
/
build.gradle
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
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
import com.github.spotbugs.snom.SpotBugsTask
import me.modmuss50.mpp.ReleaseType
plugins {
alias libs.plugins.fabric.loom
id 'maven-publish'
alias libs.plugins.lombok
alias libs.plugins.spotbugs.base
alias libs.plugins.spotless
alias libs.plugins.modmuss50.publish
}
def local = !System.getenv().containsKey("GITHUB_RUN_NUMBER")
version = "${project.mod_version}-${project.minecraft_version}-${local ? 'local' : "build.${System.getenv("GITHUB_RUN_NUMBER")}"}"
group = project.maven_group
apply from: "https://raw.githubusercontent.com/constellation-mc/artifacts/main/artifacts.groovy"
constellationRepo(project, "dark-matter")
repositories {
mavenCentral()
}
dependencies {
// To change the versions see the gradle.properties file
minecraft "com.mojang:minecraft:${project.minecraft_version}"
mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2"
modImplementation libs.fabric.loader
// Fabric API. This is technically optional, but you probably want it anyway.
modImplementation libs.fabric.api
modApi libs.dark.matter.base
include libs.dark.matter.base
}
tasks.register("spotbugs", SpotBugsTask) { task ->
sourceSets.each {
task.sourceDirs.from(task.sourceDirs.files, it.allSource.sourceDirectories)
task.classDirs.from(task.classDirs.files, it.output)
task.auxClassPaths.from(task.auxClassPaths.files, it.compileClasspath)
}
excludeFilter = file("spotbugs.xml")
ignoreFailures = true
reports {
if (local) {
html {
required = true
outputLocation = file("$buildDir/reports/spotbugs/main/spotbugs.html")
stylesheet = 'fancy-hist.xsl'
}
} else {
sarif {
required = true
outputLocation = file("$buildDir/reports/spotbugs/main/spotbugs.sarif")
}
}
}
}
spotless {
java {
removeUnusedImports()
trimTrailingWhitespace()
formatAnnotations()
importOrder('', 'java|javax', '\\#')
}
}
processResources {
def map = [
"version": project.version,
"loader_version": libs.fabric.loader.get().version
]
inputs.properties(map)
filteringCharset "UTF-8"
filesMatching("fabric.mod.json") {
expand map
}
}
def targetJavaVersion = 17
tasks.withType(JavaCompile).configureEach {
// ensure that the encoding is set to UTF-8, no matter what the system default is
// this fixes some edge cases with special characters not displaying correctly
// see http://yodaconditions.net/blog/fix-for-java-file-encoding-problems-with-gradle.html
// If Javadoc is generated, this must be specified in that task too.
it.options.encoding = "UTF-8"
if (targetJavaVersion >= 10 || JavaVersion.current().isJava10Compatible()) {
it.options.release = targetJavaVersion
}
}
java {
def javaVersion = JavaVersion.toVersion(targetJavaVersion)
if (JavaVersion.current() < javaVersion) {
toolchain.languageVersion = JavaLanguageVersion.of(targetJavaVersion)
}
withSourcesJar()
}
jar {
from("LICENSE") {
rename { "${it}_${project.archivesBaseName}" }
}
}
sourcesJar {
exclude {
sourceSets.main.allSource.contains it.file
}
from delombok
}
// configure the maven publication
publishing {
publications {
mavenJava(MavenPublication) {
artifactId 'linkart'
from components.java
}
}
repositories {
maven {
name = "GitHubPackages"
url = "https://maven.pkg.github.com/constellation-mc/Linkart"
credentials {
username = System.getenv("GITHUB_ACTOR")
password = System.getenv("GITHUB_TOKEN")
}
}
}
}
publishMods {
file = remapJar.archiveFile
additionalFiles.from(remapSourcesJar.archiveFile)
changelog = file("CHANGELOG.md").text
type = ReleaseType.valueOf(providers.environmentVariable("VERSION_TYPE").getOrElse("BETA"))
modLoaders.add("fabric")
displayName = "${project.mod_version} (${project.minecraft_version})"
["1.19.2", "1.19.3", "1.19.4", "1.20", "1.20.1", "1.20.2", "1.20.3", "1.20.4"].each {
modrinth {
minecraftVersions.add(it)
}
curseforge {
minecraftVersions.add(it)
}
}
modrinth {
projectId = "sc4Mu9Zu"
accessToken = providers.environmentVariable("MODRINTH_TOKEN")
requires("fabric-api")
embeds("dark-matter")
}
curseforge {
projectId = "622736"
accessToken = providers.environmentVariable("CURSEFORGE_TOKEN")
requires("fabric-api")
embeds("dark-matter")
}
github {
repository = "constellation-mc/Linkart"
accessToken = providers.environmentVariable("GITHUB_TOKEN")
commitish = providers.environmentVariable("GITHUB_SHA").getOrElse("${project.minecraft_version}-fabric")
type = STABLE
}
dryRun = local
}