-
Notifications
You must be signed in to change notification settings - Fork 2
/
build.gradle
230 lines (189 loc) · 8.07 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
import io.github.gradlenexus.publishplugin.NexusPublishExtension
import io.github.gradlenexus.publishplugin.NexusRepository
import io.github.gradlenexus.publishplugin.NexusRepositoryContainer
import java.util.regex.Pattern
plugins {
id 'java-library'
id 'signing'
id 'maven-publish'
alias(libs.plugins.axion)
alias(libs.plugins.nexus.publish)
}
repositories {
mavenCentral()
}
extensions.configure(NexusPublishExtension) { NexusPublishExtension extension ->
extension.repositories { NexusRepositoryContainer container ->
container.sonatype { NexusRepository sonatypeRepository ->
sonatypeRepository.username.set project.findProperty(Constants.OSSRH_USER_NAME_PROPERTY_KEY_PREFIX).toString()
sonatypeRepository.password.set project.findProperty(Constants.OSSRH_PASSWORD_PROPERTY_KEY_PREFIX).toString()
}
}
}
project.group = 'info.fingo.xactus'
extensions.configure(JavaPluginExtension) {
it.toolchain { toolchain ->
toolchain.languageVersion.set(JavaLanguageVersion.of(8))
}
}
interface Constants {
def CODE_GENERATION_TASK_GROUP = 'code generation'
// this is to improve code searching
def CODE_GENERATION_TARGET_DIRECTORY =
'info.fingo.xactus.processor.internal'.replaceAll(Pattern.quote('.'), '/')
def PGP_SECRET_KEY_PROPERTY_KEY = "pgpSecretKey"
def PGP_SECRET_KEY_PASSWORD_PROPERTY_KEY = "pgpSecretKeyPassword"
def PGP_KEY_ID_PROPERTY_KEY = "pgpKeyId"
def OSSRH_USER_NAME_PROPERTY_KEY_PREFIX = "ossrhUserName"
def OSSRH_PASSWORD_PROPERTY_KEY_PREFIX = "ossrhPassword"
def PUBLICATION_NAME = 'mavenJava'
}
def generateJFlexTaskProvider = tasks.register('generateJFlex', JavaExec) {
jFlexExec ->
def outputDirectory = "${project.layout.buildDirectory.get()}/jflex-generated"
def classesDestinationDirectory = file("$outputDirectory/$Constants.CODE_GENERATION_TARGET_DIRECTORY")
def inputFile = file('src/main/jflex/xpath.lex')
jFlexExec.group Constants.CODE_GENERATION_TASK_GROUP
jFlexExec.classpath(configurations.named('jflex'))
jFlexExec.inputs.file(inputFile)
jFlexExec.outputs.dir("$outputDirectory")
jFlexExec.outputs.cacheIf { true }
jFlexExec.workingDir = classesDestinationDirectory
jFlexExec.args '-d', classesDestinationDirectory.absolutePath, inputFile.absolutePath
jFlexExec.mainClass.set 'jflex.Main'
jFlexExec.doFirst {
classesDestinationDirectory.mkdirs()
}
}
def generateJCupTaskProvider = tasks.register('generateJCup', JavaExec) {
jCupExec ->
def outputDirectory = "${project.layout.buildDirectory.get()}/jcup-generated"
def classesDestinationDirectory = file("$outputDirectory/$Constants.CODE_GENERATION_TARGET_DIRECTORY")
def inputFile = file('src/main/jcup/xpath.cup')
jCupExec.group Constants.CODE_GENERATION_TASK_GROUP
jCupExec.classpath(configurations.named('jcup'))
jCupExec.mainClass.set 'java_cup.Main'
jCupExec.workingDir = classesDestinationDirectory
jCupExec.inputs.file(inputFile)
jCupExec.outputs.dir("$outputDirectory")
jCupExec.outputs.cacheIf { true }
jCupExec.args '-symbols', 'XpathSym', '-parser', 'XPathCup', inputFile.absolutePath
jCupExec.doFirst {
classesDestinationDirectory.mkdirs()
}
}
sourceSets.main.java {
SourceDirectorySet sourceDirectorySet ->
sourceDirectorySet.srcDir(generateJCupTaskProvider)
sourceDirectorySet.srcDir(generateJFlexTaskProvider)
}
configurations {
jflex
jcup
implementation.extendsFrom jcup
}
tasks.named('test', Test).configure {
it.filter {
// exclude test suites
it.excludeTestsMatching('*.All*Tests')
it.excludeTestsMatching('info.fingo.xactus.processor.testutil.legacytestsuiteadapter.PsychopathTestContext')
}
}
tasks.register('testSuite', Test).configure {
it.filter {
it.includeTestsMatching('*.All*Tests')
}
}
tasks.withType(Test).configureEach {
it.filter {
// exclude disabled junit 3 tests
it.excludeTestsMatching('*.disabled_*')
}
it.outputs.cacheIf { false }
it.outputs.upToDateWhen { false }
it.useJUnitPlatform()
it.systemProperty 'junit.jupiter.execution.parallel.enabled', 'true'
it.systemProperty 'junit.jupiter.execution.parallel.mode.default', 'same_thread'
it.systemProperty 'junit.jupiter.execution.parallel.mode.classes.default', 'concurrent'
it.systemProperty 'junit.jupiter.execution.parallel.config.strategy', 'dynamic'
}
extensions.configure(JavaPluginExtension) {
it.withJavadocJar()
it.withSourcesJar()
}
extensions.configure(PublishingExtension) { publishingExtension ->
publishingExtension.repositories.maven { MavenArtifactRepository repo ->
repo.name = 'local'
repo.url = uri(isSnapshot() ? "${project.layout.buildDirectory.get()}/repos/snapshots" : "${project.layout.buildDirectory.get()}/repos/releases")
}
publishingExtension.publications.register(Constants.PUBLICATION_NAME, MavenPublication) {
mavenPublication ->
mavenPublication.from(project.components.getByName('java'))
mavenPublication.pom { mavenPom ->
mavenPom.name = 'Xactus'
mavenPom.url = 'https://github.com/fingo/xactus'
mavenPom.description = 'Open-source XPath 2.0 processing library based on Eclipse\'s implementation from the Eclipse Web Tools Platform project.'
mavenPom.developers { mavenPomDeveloperSpec ->
mavenPomDeveloperSpec.developer { mavenPomDeveloper ->
mavenPomDeveloper.name = 'Janusz Wiśniowski'
mavenPomDeveloper.email = 'janusz@januszwisniowski.it'
}
}
mavenPom.licenses { licenseSpec ->
licenseSpec.license { license ->
license.name = 'Eclipse Public License - v 2.0'
license.url = 'https://www.eclipse.org/legal/epl-2.0/'
}
}
mavenPom.scm { mavenPomScm ->
mavenPomScm.url = 'https://github.com/fingo/xactus'
mavenPomScm.connection = 'scm:git:git://github.com/fingo/xactus'
}
}
}
}
if (!isSnapshot()) {
extensions.configure(SigningExtension) {
if (project.hasProperty(Constants.PGP_SECRET_KEY_PROPERTY_KEY) &&
project.hasProperty(Constants.PGP_SECRET_KEY_PASSWORD_PROPERTY_KEY)) {
def pgpSecretKey = project.property(Constants.PGP_SECRET_KEY_PROPERTY_KEY).toString()
def pgpKeyPassword = project.property(Constants.PGP_SECRET_KEY_PASSWORD_PROPERTY_KEY).toString()
if (project.hasProperty(Constants.PGP_KEY_ID_PROPERTY_KEY)) {
it.useInMemoryPgpKeys(project.property(Constants.PGP_KEY_ID_PROPERTY_KEY).toString(), pgpSecretKey, pgpKeyPassword)
} else {
it.useInMemoryPgpKeys(pgpSecretKey, pgpKeyPassword)
}
}
it.sign(extensions.findByType(PublishingExtension).publications.getByName(Constants.PUBLICATION_NAME))
}
}
tasks.named('javadoc', Javadoc).configure {
it.failOnError = false
it.options.encoding = 'UTF-8'
}
tasks.withType(JavaCompile).configureEach {
it.options.with {
it.encoding = 'UTF-8'
it.compilerArgs << '-Xlint'
it.deprecation = true
}
}
dependencies {
implementation libs.xerces
implementation libs.icu4j
jcup libs.jcup
jflex libs.jflex
testImplementation testLibs.bundles.jupiter
testImplementation testLibs.bundles.xmlunit
testImplementation testLibs.bundles.mockito
testImplementation testLibs.bundles.assertj
// LSSerializerImpl used to serialize ResultSequence to XML - see AbstractPsychoPathTest#buildXMLResultString
testImplementation libs.xalan.serializer
}
@SuppressWarnings('GrMethodMayBeStatic')
def getDeploymentVersion() {
scmVersion.version
}
def isSnapshot() {
deploymentVersion.toString().endsWith("-SNAPSHOT")
}