-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.gradle
More file actions
204 lines (179 loc) · 6.32 KB
/
Copy pathbuild.gradle
File metadata and controls
204 lines (179 loc) · 6.32 KB
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
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
plugins {
id 'net.fabricmc.fabric-loom' version '1.17.11'
id 'maven-publish'
id 'signing'
id 'io.github.gradle-nexus.publish-plugin' version '2.0.0'
id 'checkstyle'
id 'pmd'
id 'com.modrinth.minotaur' version '2.9.0'
}
ext {
checkstyleVersion = '13.6.0'
pmdVersion = '7.25.0'
}
version = project.mod_version
group = project.maven_group
base {
archivesName = project.archivesBaseName
}
loom {
accessWidenerPath = file("src/main/resources/zpral.classtweaker")
log4jConfigs.from(file("src/dev/log4j2.xml"))
}
// https://github.com/gradle/gradle/issues/27035
configurations.checkstyle {
resolutionStrategy.capabilitiesResolution.withCapability("com.google.collections:google-collections") {
select("com.google.guava:guava:0")
}
}
dependencies {
checkstyle "com.puppycrawl.tools:checkstyle:${checkstyleVersion}"
pmd "net.sourceforge.pmd:pmd-ant:${pmdVersion}",
"net.sourceforge.pmd:pmd-java:${pmdVersion}"
minecraft "com.mojang:minecraft:${project.minecraft_version}"
implementation "net.fabricmc:fabric-loader:${project.loader_version}"
// Required for unfrozen registry
implementation fabricApi.module("fabric-registry-sync-v0", project.fabric_api_version)
// Only needed during development
localRuntime "net.fabricmc.fabric-api:fabric-api:${project.fabric_api_version}"
}
processResources {
filesMatching("fabric.mod.json") {
expand "version": project.version,
"id": project.archivesBaseName,
"name": project.mod_name,
"desc": project.mod_desc,
"license_spdx_id": project.mod_license_spdx_id,
"minecraft_version": project.minecraft_version,
"loader_version": project.loader_version,
"fabric_api_version": project.fabric_api_version
}
}
checkstyle {
configDirectory = file("$rootProject.projectDir/.config/checkstyle")
ignoreFailures = false
showViolations = true
toolVersion = checkstyleVersion
}
pmd {
consoleOutput = true
incrementalAnalysis = true
ruleSetFiles = files(".config/pmd/java/ruleset.xml")
toolVersion = pmdVersion
}
tasks.withType(Checkstyle).configureEach {
enabled = project.hasProperty("checkstyleEnabled");
}
tasks.withType(Pmd).configureEach {
enabled = project.hasProperty("pmdEnabled")
}
tasks.withType(JavaCompile).configureEach {
it.options.release = 25
}
java {
// Loom will automatically attach sourcesJar to a RemapSourcesJar task and to the "build" task
// if it is present.
withSourcesJar()
withJavadocJar()
sourceCompatibility = JavaVersion.VERSION_25
targetCompatibility = JavaVersion.VERSION_25
}
javadoc {
def opts = (options as StandardJavadocDocletOptions)
opts.addBooleanOption('html5', true)
opts.addBooleanOption('Xdoclint:none', true)
opts.addBooleanOption('quiet', true)
opts.tags(
"apiNote:a:API Note:",
"implSpec:a:Implementation Requirements:",
"implNote:a:Implementation Note:"
)
}
jar {
from("LICENSE") {
rename { "${it}_${project.archivesBaseName}"}
}
}
// configure the maven publication
publishing {
publications {
create("mavenJava", MavenPublication) {
artifactId = project.archivesBaseName
from components.java
pom {
name = project.mod_name
description = project.mod_desc
url = 'https://github.com/litetex-oss/mcm-' + artifactId
licenses {
license {
name = project.mod_license_spdx_id
url = project.mod_license_url
distribution = 'repo'
}
}
developers {
developer {
name = 'litetex'
url = 'https://github.com/litetex'
}
}
scm {
connection = 'scm:git:https://github.com/litetex-oss/' + artifactId + '.git'
url = 'https://github.com/litetex-oss/mcm-' + artifactId
}
}
}
}
// Docs: https://docs.gradle.org/current/userguide/publishing_maven.html
// repositories.mavenLocal() // uncomment to publish locally
if (providers.environmentVariable("MAVEN_PUBLISH_URL").present) {
repositories.maven {
url = providers.environmentVariable("MAVEN_PUBLISH_URL")
credentials {
username = providers.environmentVariable("MAVEN_PUBLISH_USERNAME").get()
password = providers.environmentVariable("MAVEN_PUBLISH_PASSWORD").get()
}
}
}
}
tasks.modrinth.dependsOn(tasks.modrinthSyncBody)
// https://github.com/modrinth/minotaur/blob/master/README.md#available-properties
modrinth {
// token defaults to "MODRINTH_TOKEN" environment variable
projectId = project.archivesBaseName
// Default/empty value is release
versionType = System.getenv("MODRINTH_VERSION_TYPE")
uploadFile = jar
additionalFiles = [sourcesJar]
syncBodyFrom = provider {
rootProject.file("README.md").text
}
changelog = provider {
def changelogFile = System.getenv("MODRINTH_CHANGELOG_FILE")
return changelogFile != null
? rootProject.file(changelogFile).text
: System.getenv("MODRINTH_CHANGELOG_TEXT")
}
dependencies {
required.project 'fabric-api'
}
}
signing {
required { System.getenv("MAVEN_GPG_PRIVATE_KEY") != null }
def signingKey = System.getenv("MAVEN_GPG_PRIVATE_KEY")
def signingPassword = System.getenv("MAVEN_GPG_PASSPHRASE")
useInMemoryPgpKeys(signingKey, signingPassword)
sign publishing.publications.mavenJava
}
// Docs: https://github.com/gradle-nexus/publish-plugin
// Publish using publishToSonatype closeAndReleaseSonatypeStagingRepository
nexusPublishing {
repositories {
sonatype {
nexusUrl.set(uri("https://ossrh-staging-api.central.sonatype.com/service/local/"))
snapshotRepositoryUrl.set(uri("https://central.sonatype.com/repository/maven-snapshots/"))
username = System.getenv("SONATYPE_MAVEN_CENTRAL_PORTAL_USERNAME")
password = System.getenv("SONATYPE_MAVEN_CENTRAL_PORTAL_TOKEN")
}
}
}