-
Notifications
You must be signed in to change notification settings - Fork 160
/
build.gradle
216 lines (176 loc) · 5.37 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
plugins {
id 'java-library'
id 'wrapper'
id 'maven-publish'
id 'io.github.gradle-nexus.publish-plugin' version '1.1.0'
id 'com.github.sherter.google-java-format' version '0.3.2'
id 'net.ltgt.errorprone' version '2.0.2'
id 'idea'
id 'signing'
// code coverage support
id 'net.saliman.cobertura' version '2.5.4'
// Add license plugin. By default, this plugin only applies to the root
// project. Since we need license enforcement for benchmarks and the
// Unicode table generator, "apply false" specifies that the plugin should
// be downloaded and made available to Gradle, but not applied yet. See the
// allprojects section below for where this plugin is actually applied.
id 'com.github.hierynomus.license' version '0.15.0' apply false
}
cobertura.coverageFormats = ['html', 'xml']
// The name of the release we're working on. See RELEASING.md for details.
group = "com.google.re2j"
version = "1.7"
wrapper {
gradleVersion '5.2'
}
sourceCompatibility = 1.6
targetCompatibility = 1.6
repositories {
mavenCentral()
}
sourceSets {
main {
java {
srcDir 'java'
exclude 'com/google/re2j/super/**'
}
}
gwt {
java {
srcDir 'java'
include 'com/google/re2j/super/**'
}
resources {
srcDir 'java'
include 'com/google/re2j/RE2J.gwt.xml'
}
}
test {
java {
srcDir 'javatests'
}
resources {
srcDir 'testdata'
}
}
}
idea {
module {
// Unfortunately, IntelliJ ignores the `exclude` directive in the sourceSet declaration
// above. Without this, it complains about duplicated classes that exist both in GWT and non-
// GWT sources.
excludeDirs += file('java/com/google/re2j/super')
}
}
test {
// Allow parallel test execution.
maxParallelForks = Runtime.runtime.availableProcessors().intdiv(2) ?: 1
}
dependencies {
errorproneJavac 'com.google.errorprone:javac:9+181-r4173-1'
errorprone 'com.google.errorprone:error_prone_core:2.10.0'
testCompile 'junit:junit:4.12'
testCompile 'com.google.gwt:gwt-dev:2.9.0'
testCompile 'com.google.gwt:gwt-user:2.9.0'
testCompile 'com.google.truth:truth:0.36'
// Cobertura requires slf4j at runtime
testRuntime "org.slf4j:slf4j-api:1.7.10"
}
task sourceJar(type: Jar) {
baseName 'sources'
from sourceSets.main.allJava
from sourceSets.gwt.allSource
}
task javadocJar(type: Jar, dependsOn: javadoc) {
baseName 'javadoc'
from javadoc.destinationDir
}
def appendMavenCentralMetadata(Node node) {
node.appendNode('name', 'RE2/J')
node.appendNode('description', 'Linear time regular expressions for Java')
node.appendNode('url', 'https://github.com/google/re2j')
def license = node.appendNode('licenses').appendNode('license')
license.appendNode('name', 'Go License')
license.appendNode('url', 'https://golang.org/LICENSE')
license.appendNode('distribution', 'repo')
node.appendNode('scm').appendNode('url', 'https://github.com/google/re2j.git')
def developerInfo = node.appendNode('developers').appendNode('developer')
developerInfo.appendNode('id', 'dev')
developerInfo.appendNode('name', 'The RE2/J Contributors')
developerInfo.appendNode('email', '[email protected]')
}
publishing {
publications {
mavenJava(MavenPublication) {
from components.java
artifact sourceJar {
classifier 'sources'
}
artifact javadocJar {
classifier 'javadoc'
}
groupId 'com.google.re2j'
artifactId 're2j'
version project.version
pom.withXml {
appendMavenCentralMetadata(asNode())
}
}
}
}
signing {
useGpgCmd()
sign publishing.publications.mavenJava
}
nexusPublishing {
repositories {
sonatype {
username = findProperty('sonatype.username')
password = findProperty('sonatype.password')
}
}
}
// If Java formatter checks fail, tell the user how to fix them.
task printFormatHelperMessage {
doLast {
throw new GradleException('google-java-format is required.\n' +
'Use ./gradlew googleJavaFormat to reformat the broken files')
}
}
verifyGoogleJavaFormat.finalizedBy printFormatHelperMessage
printFormatHelperMessage.onlyIf { verifyGoogleJavaFormat.state.failure != null }
import com.hierynomus.gradle.license.tasks.LicenseCheck
// By default, this plugin only applies to the root project. We apply it here
// manually to all projects so that even the subprojects receive license
// enforcement.
allprojects {
apply plugin: "license"
license {
header rootProject.file('LICENSE.header')
ext.year = Calendar.getInstance().get(Calendar.YEAR)
strictCheck true
skipExistingHeaders true
mapping {
// Without this, the plugin adds javadoc-style comments to the top
// of each Java source file.
java = 'SLASHSTAR_STYLE'
}
include '**/*.gradle'
include '**/*.java'
include '**/*.xml'
include '**/*.pl'
}
// Each license check task gets a new "help message" task to tell the
// user how to fix license violations.
tasks.withType(LicenseCheck) { checkTask ->
def helpMessageTask = task "${checkTask.name}HelpMessage" {
doLast {
throw new GradleException(
'Some files lack an appropriate license header.\n' +
'Run ./gradlew licenseFormat to add one.')
}
}
checkTask.finalizedBy helpMessageTask
helpMessageTask.onlyIf { checkTask.state.failure != null }
}
}