-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
235 lines (212 loc) · 5.86 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
plugins {
id 'java-library'
id 'maven-publish'
id 'org.gradlex.extra-java-module-info' version '1.9'
}
group = 'io.sf.carte'
version = '5.1-SNAPSHOT'
description = 'css4j-awt'
dependencies {
api('io.sf.carte:css4j') {
version {
strictly '[4.0,)'
prefer '5.0'
}
}
testImplementation group: 'io.sf.carte', name: 'css4j', classifier: 'tests', version: '5.0'
testImplementation 'io.sf.carte:xml-dtd:4.3'
testImplementation 'nu.validator:htmlparser:1.4.16'
testImplementation 'org.slf4j:slf4j-api:2.0.16'
testImplementation 'org.junit.jupiter:junit-jupiter:5.11.3'
testRuntimeOnly 'org.junit.platform:junit-platform-launcher'
}
extraJavaModuleInfo {
failOnMissingModuleInfo.set(false)
automaticModule('htmlparser-1.4.16.jar', 'htmlparser')
}
java {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
withJavadocJar()
withSourcesJar()
}
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'
}
}
}
sourceSets {
main {
java {
srcDirs = ['src']
includes += ["**/*.java"]
}
resources {
srcDirs = ['src']
excludes += ["**/*.java"]
}
}
test {
java {
srcDirs = ['junit']
includes += ["**/*.java"]
}
resources {
srcDirs = ['junit']
excludes += ["**/*.java"]
}
}
}
test {
useJUnitPlatform()
}
tasks.compileJava {
excludes += ['module-info.java']
modularity.inferModulePath = false
}
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.txt to Windows line endings'
from "$rootDir/LICENSE.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/'
options.links 'https://css4j.github.io/api/latest/'
}
tasks.withType(AbstractArchiveTask).configureEach {
// Reproducible build
preserveFileTimestamps = false
reproducibleFileOrder = true
// Copy license file
dependsOn lineEndingConvCopy
from ("$buildDir/tmp/crlf/LICENSE.txt") {
into 'META-INF'
}
}
build.dependsOn lineEndingConversion
tasks.withType(PublishToMavenRepository) { task ->
doFirst {
if (repository == publishing.repositories.getByName('mavenRepo')) {
logger.lifecycle "Deploying artifacts to \"${it.repository.url}\""
}
}
}
publishing {
publications {
maven(MavenPublication) {
description = 'css4j AWT module'
from(components.java)
pom {
description = 'css4j AWT module'
url = "https://css4j.github.io/"
licenses {
license {
name = "BSD 3-clause license"
url = "https://css4j.github.io/LICENSE.txt"
}
}
scm {
connection = "scm:git:https://github.com/css4j/css4j-awt.git"
developerConnection = "scm:git:git://[email protected]:css4j/css4j-awt.git"
url = "https://github.com/css4j/css4j-awt"
}
}
}
}
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 = "${buildDir}/repository/releases"
}
if (project.hasProperty('mavenSnapshotRepoUrl') && project.mavenSnapshotRepoUrl) {
snapshotsUrl = mavenSnapshotRepoUrl
} else {
snapshotsUrl = "${buildDir}/repository/snapshots"
}
url = version.endsWith('-SNAPSHOT') ? snapshotsUrl : releasesUrl
if (project.hasProperty('mavenRepoUsername') &&
project.hasProperty('mavenRepoPassword')) {
credentials.username = mavenRepoUsername
credentials.password = mavenRepoPassword
}
}
}
}