-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild.gradle
273 lines (219 loc) · 8.3 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
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
buildscript {
repositories {
jcenter()
mavenCentral()
//maven { url "http://oss.sonatype.org/content/repositories/snapshots/" }
}
}
plugins {
id 'java-library'
id 'maven'
id 'signing'
id 'io.codearte.nexus-staging' version "0.9.0"
id 'net.researchgate.release' version '2.6.0'
//id 'eclipse'
id 'me.champeau.gradle.jmh' version "0.4.4"
id 'jacoco'
id 'antlr'
id 'build-dashboard'
id 'nebula.gradle-git-scm' version '3.0.1'
}
repositories {
jcenter()
mavenCentral()
}
//plugins.withType(EclipsePlugin) {
// project.eclipse.classpath.plusConfigurations += [ configurations.jmh ]
//}
group = 'com.github.protobufel'
archivesBaseName = 'protobufel-grammar'
sourceCompatibility = 1.8
targetCompatibility = 1.8
def testGrammarProtobuf = "$buildDir/resources/test/com/github/protobufel/grammar"
def testOriginalProtobuf = "$testGrammarProtobuf/protobuf-original"
configurations {
shared
}
sourceSets {
test {
resources {
// output.dir(testOriginalProtobuf, finalizedBy: ['copyOriginalProtobuf'])
// output.dir(testGrammarProtobuf, finalizedBy: ['copyGrammarProtobuf'])
output.dir(testOriginalProtobuf)
output.dir(testGrammarProtobuf)
}
}
}
dependencies {
//api '...'
api 'org.eclipse.jdt:org.eclipse.jdt.annotation:2.1.0'
antlr group: 'org.antlr', name: 'antlr4', version: '4.7', classifier: 'complete'
shared 'com.github.protobufel:protobufel-protobuf-test-protos:0.7.1@jar'
shared 'com.github.protobufel:protobufel-test-protos2:0.7.1@jar'
implementation group: 'org.antlr', name: 'antlr4-runtime', version: '4.7'
implementation group: 'com.google.protobuf', name: 'protobuf-java', version: '2.6.1'
implementation 'com.github.protobufel:common-verifications:0.6'
implementation group: 'org.slf4j', name: 'slf4j-api', version: '1.7.25'
//testImplementation group: 'org.antlr', name: 'antlr4', version:'4.7', classifier:'complete'
// testRuntime 'com.github.protobufel:protobufel-protobuf-test-protos:0.7.0'
// testRuntime 'com.github.protobufel:protobufel-test-protos2:0.7.0'
testImplementation 'com.github.protobufel:protobufel-test-util:0.7.0'
testImplementation group: 'ch.qos.logback', name: 'logback-classic', version: '1.2.3'
testImplementation group: 'com.google.guava', name: 'guava', version: '22.0'
testImplementation 'com.google.guava:guava-testlib:22.0'
testImplementation group: 'junit', name: 'junit', version: '4.12'
testImplementation 'org.hamcrest:hamcrest-junit:2.0.0.0'
testImplementation 'org.mockito:mockito-core:2.8.47'
testImplementation 'org.powermock:powermock-module-junit4:1.7.0'
testImplementation 'org.powermock:powermock-api-mockito2:1.7.0'
testImplementation group: 'org.assertj', name: 'assertj-core', version: '3.8.0'
testImplementation group: 'com.googlecode.java-diff-utils', name: 'diffutils', version: '1.3.0'
}
task copyOriginalProtobuf(type: Sync, group: 'runtime-resource') {
println "hi:" + configurations.shared.files.find({ file -> file.name.contains('protobufel-protobuf-test-protos') }).name
from zipTree(configurations.shared.files.find { file -> file.name.matches('.*protobufel-protobuf-test-protos.*\\.jar') })
include '**/*'
exclude '**/META-INF/**/*'
exclude '/META-INF'
into testOriginalProtobuf
}
task copyGrammarProtobuf(type: Sync, group: 'runtime-resource') {
println "hi:" + configurations.shared.files.find({ file -> file.name.contains('protobufel-test-protos2') }).name
from zipTree(configurations.shared.files.find { file -> file.name.matches('.*protobufel-test-protos2.*\\.jar') })
include '**/*'
exclude '**/META-INF/**/*'
exclude '/META-INF'
into testGrammarProtobuf
}
processTestResources.dependsOn copyGrammarProtobuf, copyOriginalProtobuf
if (project.hasProperty('ossrhUsername')) {
uploadArchives {
repositories {
mavenDeployer {
beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) }
repository(url: "https://oss.sonatype.org/service/local/staging/deploy/maven2/") {
authentication(userName: ossrhUsername, password: ossrhPassword)
}
snapshotRepository(url: "https://oss.sonatype.org/content/repositories/snapshots/") {
authentication(userName: ossrhUsername, password: ossrhPassword)
}
pom.project {
name 'protobufel-grammar'
packaging 'jar'
description 'ProtoBuf Java Parser and FileDescriptor Builder'
url 'https://github.com/protobufel/protobufel-grammar'
scm {
connection 'scm:git:https://github.com/protobufel/protobufel-grammar.git'
developerConnection 'scm:[email protected]:protobufel/protobufel-grammar.git'
url 'https://github.com/protobufel/protobufel-grammar'
}
licenses {
license {
name 'The BSD 3-Clause License'
url 'http://opensource.org/licenses/BSD-3-Clause'
}
}
developers {
developer {
id 'protobufel'
name 'David Tesler'
email '[email protected]'
}
}
}
}
}
}
nexusStaging {
//packageGroup = "com.github.protobufel.multikeymapjava" //optional if packageGroup == project.getGroup()
stagingProfileId = "com.github.protobufel" //when not defined will be got from server using "packageGroup"
}
task sourcesJar(type: Jar) {
classifier = 'sources'
from sourceSets.main.allSource
}
signing {
sign configurations.archives
}
task javadocJar(type: Jar) {
classifier = 'javadoc'
from javadoc
}
task copyJavadocToDoc(type: Sync, group: 'documentation') {
from javadoc
into("docs/javadoc")
doLast {
scmFactory.create().commit('added auto generated JavaDocs', "docs/javadoc")
}
}
copyJavadocToDoc.dependsOn 'javadoc'
artifacts {
archives javadocJar, sourcesJar
}
release {
preCommitText = ''
preTagCommitMessage = 'pre tag commit: '
tagCommitMessage = 'bumped to '
newVersionCommitMessage = 'new version commit: '
// tagTemplate = "${version}"
}
uploadArchives.finalizedBy 'copyJavadocToDoc'
afterReleaseBuild.dependsOn uploadArchives
} else {
test {
testLogging {
events "PASSED", "FAILED", "SKIPPED"
exceptionFormat "short"
debug {
events "skipped", "failed"
exceptionFormat "full"
}
info.events = ["failed", "skipped"]
}
}
}
jar {
manifest {
attributes('Implementation-Title': project.name,
'Implementation-Version': project.version)
}
}
jmh {
jmhVersion = '1.19' // Specifies JMH version
includeTests = false
// Allows to include test sources into generate JMH jar, i.e. use it when benchmarks depend on the test classes.
duplicateClassesStrategy = 'FAIL'
// Strategy to apply when encountring duplicate classes during creation of the fat jar (i.e. while executing jmhJar task)
}
jacocoTestCoverageVerification {
violationRules {
rule {
limit {
minimum = 0.5
}
}
rule {
enabled = false
element = 'CLASS'
includes = ['com.github.protobufel.*']
limit {
counter = 'LINE'
value = 'TOTALCOUNT'
maximum = 0.3
}
}
}
}
jacocoTestReport {
reports {
xml.enabled true
html.enabled false
}
}
check.dependsOn jacocoTestReport
generateGrammarSource {
maxHeapSize = "64m"
arguments += ["-visitor", "-long-messages",
"-package", "com.github.protobufel.grammar",
"-lib", "src/main/antlr/com/github/protobufel/grammar"]
}