-
-
Notifications
You must be signed in to change notification settings - Fork 73
Expand file tree
/
Copy pathbuild.gradle
More file actions
172 lines (143 loc) · 4.67 KB
/
build.gradle
File metadata and controls
172 lines (143 loc) · 4.67 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
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
import com.github.jengelman.gradle.plugins.shadow.transformers.PropertiesFileTransformer
plugins {
id 'java'
id 'eclipse'
id 'maven-publish'
alias libs.plugins.gradleutils
alias libs.plugins.gitversion
alias libs.plugins.changelog
alias libs.plugins.licenser
alias libs.plugins.shadow
}
gradleutils.displayName = 'Installer'
group = 'net.minecraftforge'
version = gitversion.tagOffset
println "Version: $version"
repositories {
mavenCentral()
maven gradleutils.forgeMaven
}
license {
header = file('LICENSE-header.txt')
newLine = false
}
java {
toolchain.languageVersion = JavaLanguageVersion.of(8)
withSourcesJar()
}
configurations {
multirelease {
extendsFrom implementation
canBeConsumed = true
canBeResolved = false
attributes {
attribute(Usage.USAGE_ATTRIBUTE, objects.named(Usage, 'multi-release'))
}
}
}
dependencies {
implementation(libs.jopt.simple)
implementation(libs.gson)
}
// This isn't great, but it alows us to drop a existing jar file into the root folder and do some debugging
def testJars = fileTree(dir: projectDir).matching{ include '*-installer.jar' }
if (testJars.files.size() == 1) {
logger.lifecycle("Detected test installer: ${testJars.singleFile.name}")
def testData = tasks.register('testData', Jar) {
from(zipTree(testJars.singleFile)) {
exclude('**/*.class')
exclude('META-INF/**')
exclude('joptsimple/**')
}
includeEmptyDirs = false
archiveClassifier = 'test-data'
}
dependencies.implementation(files(testData))
}
tasks.named('jar', Jar) {
manifest {
attributes('Main-Class': 'net.minecraftforge.installer.SimpleInstaller')
attributes([
'Specification-Title': 'Installer',
'Specification-Vendor': 'Forge Development LLC',
'Specification-Version': gitversion.info.tag,
'Implementation-Title': 'SimpleInstaller',
'Implementation-Vendor': 'Forge Development LLC',
'Implementation-Version': project.version
] as LinkedHashMap, 'net/minecraftforge/installer/')
}
}
def multiReleaseJar = tasks.register('multiReleaseJar', Jar) {
manifest {
from(tasks.named('jar').get().manifest)
attributes(['Multi-Release': 'true'])
}
archiveClassifier = 'multi-release'
from(zipTree(tasks.named('jar', Jar).flatMap { it.archiveFile }))
}
def addRelease = version -> {
var cfg = configurations.register('java' + version) {
transitive = false
}
dependencies.add('java' + version, project(':installer-java' + version))
multiReleaseJar.configure {
from(cfg.map{ zipTree(it.singleFile) }) {
into('META-INF/versions/' + version)
exclude('META-INF/**')
includeEmptyDirs = false
}
}
}
addRelease(9)
tasks.named('shadowJar', ShadowJar) {
archiveClassifier = 'fatjar'
minimize()
// Add out multi-release elements
from(multiReleaseJar.map{ zipTree(it.archiveFile) }) {
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
}
// Meta stuff we don't need
exclude('com/google/errorprone/**')
exclude('META-INF/maven/**')
exclude('META-INF/proguard/**')
// We shouldn't ever need to care about conflicts as this is an executable jar, but just be safe
relocate('joptsimple', 'net.minecraftforge.installer.shadow.joptsimple')
relocate('com.google.gson', 'net.minecraftforge.installer.shadow.gson')
// Rewrite JOpt's message files, so that help text is displayed nicely.
transform(PropertiesFileTransformer) {
paths = [ 'Messages.properties$' ]
keyTransformer = { key -> 'net.minecraftforge.installer.shadow.' + key }
}
}
tasks.withType(JavaCompile).configureEach {
options.encoding = 'UTF-8'
}
artifacts {
multirelease multiReleaseJar
}
changelog {
fromBase()
}
publishing {
publications.register('mavenJava', MavenPublication) {
changelog.publish(it)
gradleutils.promote(it)
from components.java
artifact multiReleaseJar
artifactId = 'installer'
pom {
name = 'Installer'
description = 'Minecraft Forge Installer'
url = 'https://github.com/MinecraftForge/Installer'
gradleutils.pom.addRemoteDetails(pom)
license gradleutils.pom.licenses.LGPLv2_1
developers {
developer gradleutils.pom.developers.LexManos
}
}
}
repositories {
maven gradleutils.publishingForgeMaven
}
}