-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathbuild.gradle
210 lines (174 loc) · 5.73 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
buildscript {
repositories {
jcenter()
maven { url = 'http://files.minecraftforge.net/maven' }
}
dependencies {
classpath 'net.minecraftforge.gradle:ForgeGradle:2.3-SNAPSHOT'
}
}
plugins {
id 'com.matthewprenger.cursegradle' version '1.1.0'
}
apply plugin: 'net.minecraftforge.gradle.forge'
apply plugin: 'jacoco'
apply plugin: 'maven'
apply plugin: 'signing'
version = '1.12.2-0.0.3.0'
group = 'com.jamieswhiteshirt'
archivesBaseName = 'clothesline'
sourceCompatibility = targetCompatibility = JavaVersion.VERSION_1_8
minecraft {
version = '1.12.2-14.23.5.2768'
runDir = 'run'
mappings = 'stable_39'
}
repositories {
jcenter()
maven {
url 'https://oss.sonatype.org/content/repositories/snapshots'
}
maven {
url 'http://maven.jamieswhiteshirt.com/libs-snapshot/'
}
maven {
url 'http://maven.jamieswhiteshirt.com/libs-release/'
}
}
configurations {
contained {
transitive = false
}
}
dependencies {
contained 'com.jamieswhiteshirt:rtree-3i-lite:0.3.0'
compile 'com.jamieswhiteshirt:rtree-3i-lite:0.3.0'
contained 'com.jamieswhiteshirt:clothesline-hooks:1.12.2-0.0.1.2'
deobfCompile 'com.jamieswhiteshirt:clothesline-hooks:1.12.2-0.0.1.2'
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.2.+'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.2.+'
testCompile 'org.mockito:mockito-core:2.+'
}
test {
useJUnitPlatform()
}
jacocoTestReport {
sourceSets sourceSets.api
}
processResources {
inputs.property 'version', project.version
inputs.property 'mcversion', project.minecraft.version
from(sourceSets.main.resources.srcDirs) {
include 'mcmod.info'
expand 'version':project.version, 'mcversion':project.minecraft.version
}
from(sourceSets.main.resources.srcDirs) {
exclude 'mcmod.info'
}
exclude '**/*.psd'
}
// We need two jars with slightly different dependency management.
// Let build systems handle the transitive dependencies of the jar
// The jar must not include contained dependencies
jar {
from sourceSets.api.output
from sourceSets.main.output
manifest {
attributes([
'Maven-Artifact': "${project.group}:${project.archivesBaseName}:${project.version}",
'Timestamp': System.currentTimeMillis()
])
}
}
// The bundle jar is ready to be dropped in the mods folder and must contain its dependencies
// The bundle jar must include contained dependencies
task bundleJar(type: Jar) {
classifier 'bundle'
from sourceSets.api.output
from sourceSets.main.output
from(configurations.contained.files) {
include '*'
into 'META-INF/libraries'
}
manifest {
attributes([
'ContainedDeps': configurations.contained.files.collect { it.name }.join(' '),
'Maven-Artifact': "${project.group}:${project.archivesBaseName}:${project.version}",
'Timestamp': System.currentTimeMillis()
])
}
}
task sourcesJar(type: Jar) {
from sourceSets.api.allSource
from sourceSets.main.allSource
classifier = 'sources'
}
// The jar is reobfuscated with the default reobfJar task
// Create reobfBundleJar task
reobf.create('bundleJar')
task signJar(type: SignJar, dependsOn: reobfJar) {
onlyIf {
project.hasProperty('keyStore')
}
inputFile = jar.archivePath
outputFile = jar.archivePath
keyStore = project.properties.keyStore
alias = project.properties.keyStoreAlias
storePass = project.properties.keyStorePass
keyPass = project.properties.keyStoreKeyPass
}
task signBundleJar(type: SignJar, dependsOn: reobfBundleJar) {
onlyIf {
project.hasProperty('keyStore')
}
inputFile = bundleJar.archivePath
outputFile = bundleJar.archivePath
keyStore = project.properties.keyStore
alias = project.properties.keyStoreAlias
storePass = project.properties.keyStorePass
keyPass = project.properties.keyStoreKeyPass
}
artifacts {
archives(signJar.outputFile) {
builtBy signJar
}
archives(signBundleJar.outputFile) {
builtBy signBundleJar
}
archives sourceJar
}
project.ext.isReleaseVersion = !version.endsWith("-SNAPSHOT")
signing {
required { isReleaseVersion && gradle.taskGraph.hasTask("uploadArchives") }
sign configurations.archives
}
uploadArchives {
repositories.mavenDeployer {
repository(url: 'https://maven.jamieswhiteshirt.com/libs-release/') {
authentication(userName: project.properties.mavenUser, password: project.properties.mavenPassword)
}
snapshotRepository(url: 'https://maven.jamieswhiteshirt.com/libs-snapshot/') {
authentication(userName: project.properties.mavenUser, password: project.properties.mavenPassword)
}
beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) }
}
}
curseforge {
if (project.hasProperty('curseForgeApiKey')) {
apiKey = project.properties.curseForgeApiKey
}
project {
id = '300262'
changelogType = 'markdown'
changelog = file('CHANGELOG.md')
releaseType = 'beta'
mainArtifact(signBundleJar.outputFile) {
displayName = "Clothesline $project.version"
}
}
}
afterEvaluate {
// CurseGradle has ForgeGradle integration, but it falls short for signed jars
// CurseGradle generates tasks in afterEvaluate for each project as such
tasks.curseforge300262.dependsOn signBundleJar
}