-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
242 lines (215 loc) · 5.78 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
/*
Copyright (c) 2021-2024, Carlos Amengual.
Licensed under a BSD-style License. You can find the license here:
https://raw.githubusercontent.com/css4j/xml-dtd/master/LICENSE.txt
*/
/*
* SPDX-License-Identifier: BSD-3-Clause
*/
plugins {
id 'java-library'
id 'maven-publish'
}
group = 'io.sf.carte'
description = 'xml-dtd'
version = '4.3.1-SNAPSHOT'
sourceSets {
main {
java {
srcDirs = ['src']
includes += ["**/*.java"]
}
resources {
srcDirs = ['src']
excludes += ["**/*.java"]
}
}
test {
java {
srcDirs = ['junit']
includes += ["**/*.java"]
}
resources {
srcDirs = ['junit']
excludes += ["**/*.java"]
}
}
}
java {
sourceCompatibility = JavaVersion.VERSION_1_8
withJavadocJar()
withSourcesJar()
registerFeature('dtdparse') {
usingSourceSet(sourceSets.main)
}
registerFeature('dtdecl') {
usingSourceSet(sourceSets.main)
}
}
dependencies {
api('io.sf.carte:carte-util') {
version {
strictly '[3.4.0,)'
prefer '3.6.0'
}
}
dtdparseImplementation 'io.sf.carte:tokenproducer:[3.0,)'
dtdeclImplementation 'io.sf.jclf:jclf-text:[5.0.0,)'
testImplementation 'org.junit.jupiter:junit-jupiter:5.11.4'
testRuntimeOnly 'org.junit.platform:junit-platform-launcher'
}
repositories {
maven {
url = uri('https://repo.maven.apache.org/maven2/')
}
maven {
url "https://css4j.github.io/maven/"
mavenContent {
releasesOnly()
}
content {
includeGroup 'io.sf.carte'
includeGroup 'io.sf.jclf'
}
}
}
test {
useJUnitPlatform()
}
tasks.compileJava {
excludes += ['module-info.java']
modularity.inferModulePath = false
options.release = 8
}
tasks.register('compileModuleInfo', JavaCompile) {
description = 'Compile module-info to Java 11 bytecode'
dependsOn tasks.compileJava
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
source = sourceSets.main.java
classpath = sourceSets.main.compileClasspath
destinationDirectory = sourceSets.main.java.destinationDirectory
modularity.inferModulePath = true
includes = ['module-info.java']
}
classes.dependsOn compileModuleInfo
// Check bytecode version, in case some other task screws it
tasks.register('checkLegacyJava') {
description = 'Check that classes are Java 8 bytecode (except module-info)'
def classdir = sourceSets.main.output.classesDirs.files.stream().findAny().get()
def classfiles = fileTree(classdir).matching({it.exclude('module-info.class')}).files
doFirst() {
if (!classfiles.isEmpty()) {
def classfile = classfiles.stream().findAny().get()
if (classfile != null) {
def classbytes = classfile.bytes
def bcversion = classbytes[6] * 128 + classbytes[7]
if (bcversion != 52) {
throw new GradleException("Bytecode on " + classfile +
" is not valid Java 8. Version should be 52, instead is " + bcversion)
}
}
}
}
}
classes.finalizedBy checkLegacyJava
tasks.register('lineEndingConversion', CRLFConvert) {
description 'Convert top-level files to Windows line endings'
file "$rootDir/RELEASE_NOTES.md"
}
tasks.register('lineEndingConvCopy', CRLFConvertCopy) {
description 'Convert LICENSE and NOTICE to Windows line endings'
from "$rootDir/LICENSE.txt"
from "$rootDir/NOTICE.txt"
}
tasks.register('cleanBuildSrc') {
description = 'Clean the buildSrc directory'
doLast {
delete("$rootDir/buildSrc/build")
}
}
tasks.named('clean') {
finalizedBy('cleanBuildSrc')
}
tasks.withType(JavaCompile) {
options.encoding = 'UTF-8'
}
tasks.withType(Javadoc) {
options.addStringOption('Xdoclint:none', '-quiet')
options.addStringOption('encoding', 'UTF-8')
options.addStringOption('charset', 'UTF-8')
options.links 'https://docs.oracle.com/en/java/javase/11/docs/api/'
}
tasks.withType(AbstractArchiveTask).configureEach {
// Reproducible build
preserveFileTimestamps = false
reproducibleFileOrder = true
// Copy license file
dependsOn lineEndingConvCopy
from ("$buildDir/tmp/crlf/LICENSE.txt") {
into 'META-INF'
}
from ("$buildDir/tmp/crlf/NOTICE.txt") {
into 'META-INF'
}
}
build.dependsOn lineEndingConversion
publishing {
repositories {
maven {
name = 'mavenRepo'
/*
* The following section applies to the 'publish' task:
*
* If you plan to deploy to a repository, please configure the
* 'mavenReleaseRepoUrl' and/or 'mavenSnapshotRepoUrl' properties
* (for example in GRADLE_USER_HOME/gradle.properties).
*
* Otherwise, Gradle shall create a 'build/repository' subdirectory
* at ${rootDir} and deploy there.
*
* Properties 'mavenRepoUsername' and 'mavenRepoPassword' can also
* be set (generally from command line).
*/
def releasesUrl
def snapshotsUrl
if (project.hasProperty('mavenReleaseRepoUrl') && project.mavenReleaseRepoUrl) {
releasesUrl = mavenReleaseRepoUrl
} else {
releasesUrl = "${rootDir}/build/repository/releases"
}
if (project.hasProperty('mavenSnapshotRepoUrl') && project.mavenSnapshotRepoUrl) {
snapshotsUrl = mavenSnapshotRepoUrl
} else {
snapshotsUrl = "${rootDir}/build/repository/snapshots"
}
url = version.endsWith('-SNAPSHOT') ? snapshotsUrl : releasesUrl
if (project.hasProperty('mavenRepoUsername') &&
project.hasProperty('mavenRepoPassword')) {
credentials.username = mavenRepoUsername
credentials.password = mavenRepoPassword
}
}
}
publications {
maven(MavenPublication) {
from(components.java)
suppressAllPomMetadataWarnings()
pom {
description = "XML DTD utility library"
url = "https://css4j.github.io/resolver.html"
licenses {
license {
name = "BSD 3-clause license"
url = "https://css4j.github.io/LICENSE.txt"
}
}
scm {
connection = "scm:git:https://github.com/css4j/xml-dtd.git"
developerConnection = "scm:git:git://git@github.com:css4j/xml-dtd.git"
url = "https://github.com/css4j/xml-dtd"
}
}
}
}
}