forked from MinecraftForge/AccessTransformers
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle
222 lines (194 loc) · 7.05 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
220
221
222
plugins {
id 'org.ajoberstar.grgit' version '4.1.0'
id 'com.github.johnrengelman.shadow' version '6.1.0'
id 'com.github.ben-manes.versions' version '0.36.0'
}
apply plugin: 'maven-publish'
apply plugin: 'java-library'
apply plugin: 'eclipse'
group 'net.minecraftforge'
java.toolchain.languageVersion = JavaLanguageVersion.of(8)
version = grgit.describe(longDescr: true).split('-').with { "${it[0]}.${it[1]}" }
def isNonStable = { String version ->
def stableKeyword = ['RELEASE', 'FINAL', 'GA'].any { it -> version.toUpperCase().contains(it) }
def regex = /^[0-9,.v-]+(-r)?$/
return !stableKeyword && !(version ==~ regex)
}
dependencyUpdates {
rejectVersionIf {
isNonStable(it.candidate.version)
}
}
test {
useJUnitPlatform()
}
ext.antlr = [
grammarpackage: 'net.minecraftforge.accesstransformer.generated',
antlrSource: 'src/main/antlr4',
destinationDir: "src/generated-sources/java"
]
configurations {
antlr4 {
description = 'ANTLR4'
}
}
task antlrOutputDir {
mkdir antlr.destinationDir
}
task generateGrammarSource(dependsOn: antlrOutputDir, type: JavaExec)
sourceSets {
testJars
antlr4 {
java {
srcDir {
antlr.destinationDir
}
}
}
}
compileJava {
dependsOn generateGrammarSource
source antlr.destinationDir
}
clean {
delete antlr.destinationDir
}
jar.manifest = manifest {
attributes(['Specification-Title': 'accesstransformers',
'Specification-Vendor': 'forge',
'Specification-Version': '1', // Currently version 1 of the accesstransformer specification
'Implementation-Title': project.name,
'Implementation-Version': "${project.version}+${System.getenv('BUILD_NUMBER')?:0}+${grgit.branch.current().getName()}.${grgit.head().abbreviatedId}",
'Implementation-Vendor': 'forge',
'Implementation-Timestamp': java.time.Instant.now().toString(),
'Git-Commit': grgit.head().abbreviatedId,
'Git-Branch': grgit.branch.current().getName(),
'Build-Number': "${System.getenv('BUILD_NUMBER')?:0}" ],
'net/minecraftforge/accesstransformer/service/')
attributes(['Specification-Title': 'accesstransformers',
'Specification-Vendor': 'Forge',
'Specification-Version': '1', // Currently version 1 of the accesstransformer specification
'Implementation-Title': project.name,
'Implementation-Version': "${project.version}+${System.getenv('BUILD_NUMBER')?:0}+${grgit.branch.current().getName()}.${grgit.head().abbreviatedId}",
'Implementation-Vendor': 'forge',
'Implementation-Timestamp': java.time.Instant.now().toString(),
'Git-Commit': grgit.head().abbreviatedId,
'Git-Branch': grgit.branch.current().getName(),
'Build-Number': "${System.getenv('BUILD_NUMBER')?:0}" ],
'net/minecraftforge/accesstransformer/')
}
task testsJar(type: Jar) {
archiveClassifier = 'testsjar'
from sourceSets.testJars.output
}
task sourcesJar(type: Jar) {
archiveClassifier = 'sources'
from sourceSets.main.allSource
}
build.dependsOn testsJar
repositories {
mavenCentral()
maven {
name = 'forge'
url = 'http://files.minecraftforge.net/maven'
}
}
dependencies {
testImplementation('org.junit.jupiter:junit-jupiter-api:5.7.0')
testImplementation('org.powermock:powermock-core:2.0+')
testImplementation('cpw.mods:modlauncher:6.1.+')
testImplementation('com.google.code.gson:gson:2.8.6')
testRuntimeOnly('org.junit.jupiter:junit-jupiter-engine:5.7.0')
testRuntimeOnly(sourceSets.testJars.runtimeClasspath)
implementation(sourceSets.antlr4.output)
implementation('org.antlr:antlr4-runtime:4.9.1')
implementation('net.sf.jopt-simple:jopt-simple:5.0.4')
implementation('org.ow2.asm:asm:9.0')
implementation('org.ow2.asm:asm-commons:9.0')
implementation('org.ow2.asm:asm-tree:9.0')
implementation('org.apache.logging.log4j:log4j-api:2.11.2')
implementation('org.apache.logging.log4j:log4j-core:2.11.2')
implementation('cpw.mods:modlauncher:6.1.3:api')
implementation('cpw.mods:modlauncher:6.1.3')
antlr4Compile('org.antlr:antlr4:4.9.1')
}
shadowJar {
classifier 'fatjar'
manifest {
inheritFrom jar.manifest
attributes('Main-Class': 'net.minecraftforge.accesstransformer.TransformerProcessor')
attributes('Multi-Release': 'true')
}
dependencies {
exclude(dependency {
it.moduleName == 'antlr4'
})
}
}
artifacts {
archives jar
archives sourcesJar
archives testsJar
archives shadowJar
}
publishing {
publications {
mavenJava(MavenPublication) {
from components.java
artifact sourcesJar
pom {
name = 'Access Transformers'
description = 'Transforms class member access based on specification files'
url = 'https://github.com/MinecraftForge/AccessTransformers'
scm {
url = 'https://github.com/MinecraftForge/AccessTransformers'
connection = 'scm:git:git://github.com/MinecraftForge/AccessTransformers.git'
developerConnection = 'scm:git:[email protected]:MinecraftForge/AccessTransformers.git'
}
issueManagement {
system = 'github'
url = 'https://github.com/MinecraftForge/AccessTransformers/issues'
}
licenses {
license {
name = 'MIT'
url = 'https://opensource.org/licenses/MIT'
}
}
developers {
developer {
id = 'cpw'
name = 'cpw'
}
developer {
id = 'DemonWav'
name = 'DemonWav'
}
}
}
}
}
repositories {
maven {
if (project.hasProperty('forgeMavenPassword')) {
credentials {
username project.properties.forgeMavenUser
password project.properties.forgeMavenPassword
}
url 'https://files.minecraftforge.net/maven/manage/upload'
} else {
url 'file://' + rootProject.file('repo').getAbsolutePath()
}
}
}
}
generateGrammarSource {
description = 'Generates Java sources from ANTLR4 grammars.'
inputs.dir file(antlr.antlrSource)
outputs.dir file(antlr.destinationDir)
def grammars = fileTree(antlr.antlrSource).include('**/*.g4')
main = 'org.antlr.v4.Tool'
classpath = configurations.antlr4Compile
def pkg = antlr.grammarpackage.replaceAll("\\.", "/")
args = ["-o", "${antlr.destinationDir}/${pkg}", '-visitor', '-package', antlr.grammarpackage, grammars.files].flatten()
}