-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild.gradle
219 lines (189 loc) · 5.92 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
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
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
plugins {
id 'groovy'
id 'maven-publish'
id 'signing'
alias libs.plugins.fabric.loom
alias libs.plugins.quilt.licenser
alias libs.plugins.mdg.plugin
alias libs.plugins.simpleci
alias libs.plugins.nexuspublish
}
tasks.changelog {
gitDir = project.file('./')
start = '2.1.13'
}
import org.eclipse.jgit.api.Git
versioning {
fromTag.set('2.1.13')
}
final calculatedVersion = Git.open(project.file("./")).withCloseable {
versioning.calculateVersion(it) { cm, info -> }
}
println("${project.name} version: ${project.version = calculatedVersion.toString()}")
license {
rule project.file('header.txt')
exclude '**/*.mcmeta'
exclude '**/package-info.java'
}
afterEvaluate {
tasks.withType(AbstractArchiveTask).configureEach {
preserveFileTimestamps = false
reproducibleFileOrder = true
fileMode = dirMode = 0664
}
}
static String getGitCommit() {
def proc = 'git rev-parse --short HEAD'.execute()
proc.waitFor()
if (proc.exitValue()) {
throw new RuntimeException("Failed to get git commit: ERROR(${proc.exitValue()})")
}
return proc.text.trim()
}
static String getGitCommitDate() {
def procDate = 'git log -1 --format=%at'.execute()
procDate.waitFor()
if (procDate.exitValue()) {
throw new RuntimeException("Failed to get git commit time: ERROR(${procDate.exitValue()})")
}
long timestamp = procDate.text.trim() as long * 1000
return new Date(timestamp).format(/yyyy-MM-dd HH:mm:ssZ/, TimeZone.getTimeZone("UTC"))
}
configurations {
includeCompileOnlyApi
compileOnlyApi.extendsFrom includeCompileOnlyApi
include.extendsFrom includeCompileOnlyApi
includeBundle
compileOnly.extendsFrom includeBundle
include.extendsFrom includeBundle
}
repositories {
maven {
name = 'ParchmentMC'
url = 'https://maven.parchmentmc.org'
}
mavenCentral()
}
modsDotGroovy {
dslVersion = libs.mdg.dsl.get().version
platform 'fabric'
}
dependencies {
minecraft libs.minecraft
mappings loom.layered() {
officialMojangMappings()
parchment("org.parchmentmc.data:parchment-${libs.versions.parchment.minecraft.get()}:${libs.versions.parchment.mappings.get()}@zip")
}
modImplementation libs.fabric.loader
annotationProcessor libs.autoextension
annotationProcessor libs.autoservice
compileOnly libs.autoextension
compileOnly libs.autoservice
includeBundle libs.srgutils
includeCompileOnlyApi libs.groovybundler
}
tasks.named('jar', Jar) {
from(project.file("LICENSE")) {
rename { "${it}-${archivesBaseName}" }
}
}
tasks.withType(JavaCompile).configureEach {
it.options.encoding = "UTF-8"
it.options.release = 17
}
java {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
withSourcesJar()
}
groovydoc {
use = true
exclude 'mods.groovy'
}
tasks.register('groovydocJar', Jar) {
dependsOn groovydoc
archiveClassifier.set 'javadoc'
from groovydoc.destinationDir
}
tasks.withType(GroovyCompile) {
groovyOptions.optimizationOptions.indy = true
groovyOptions.optimizationOptions.groovydoc = true
it.groovyOptions.javaAnnotationProcessing = true
it.exclude('mods.groovy')
}
tasks.compileGroovy { t ->
t.options.compilerArgs += [
"-Aautoextension.name=${project.name}",
"-Aautoextension.version=${project.version}"
]
}
jar {
manifest.attributes([
'Specification-Title': 'GroovyDuvet',
'Specification-Vendor': 'Luke Bemish',
'Specification-Version': 1,
'Implementation-Title':"${archivesBaseName}",
'Implementation-Version': project.version,
'Implementation-Vendor' : 'Luke Bemish',
'Implementation-Commit-Time': getGitCommitDate(),
'Implementation-Commit': getGitCommit()
])
}
publishing {
publications {
mavenJava(MavenPublication) {
groupId project.group
artifactId project.archivesBaseName
version project.version
from components.java
artifact tasks.groovydocJar
artifact(changelog.output.get().asFile) {
it.builtBy changelog
it.extension = 'txt'
it.classifier = 'changelog'
}
pom {
name = "GroovyDuvetCore"
packaging = 'jar'
description = 'Core language provider allowing mods written in groovy to run on the quilt loader'
url = 'https://github.com/GroovyMC/GroovyDuvetCore'
inceptionYear = '2023'
licenses {
license {
name = 'LGPL 3.0 or later'
url = 'https://opensource.org/license/lgpl-3-0/'
}
}
developers {
developer {
id = 'groovymc'
name = 'GroovyMC'
email = '[email protected]'
url = 'https://github.com/GroovyMC/'
}
}
scm {
connection='scm:git:git://github.com/GroovyMC/GroovyDuvetCore.git'
url='https://github.com/GroovyMC/GroovyDuvetCore'
}
}
}
}
}
nexusPublishing {
repositories {
sonatype {
username.set(System.getenv('SONATYPE_USER') ?: '')
password.set(System.getenv('SONATYPE_PASSWORD') ?: '')
nexusUrl.set(uri("https://s01.oss.sonatype.org/service/local/"))
}
}
}
if (System.getenv('SONATYPE_USER')) {
signing {
final signingKey = System.getenv('SIGNING_KEY') ?: ''
final signingPassword = System.getenv('SIGNING_PASSWORD') ?: ''
useInMemoryPgpKeys(signingKey, signingPassword)
sign publishing.publications.mavenJava
}
}