-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle
238 lines (212 loc) · 5.95 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
/*
Copyright (c) 2019-2025, C. Amengual.
Licensed under a BSD-style License. You can find the license here:
https://css4j.github.io/LICENSE.txt
*/
// SPDX-License-Identifier: BSD-3-Clause
plugins {
id 'java'
id 'maven-publish'
}
repositories {
maven {
url = uri('https://repo.maven.apache.org/maven2/')
}
maven {
url = "https://css4j.github.io/maven/"
mavenContent {
releasesOnly()
}
content {
includeGroupByRegex 'io\\.sf\\..*'
}
}
}
dependencies {
annotationProcessor 'org.openjdk.jmh:jmh-generator-annprocess:1.37'
implementation 'org.openjdk.jmh:jmh-core:1.37'
implementation 'io.sf.carte:xml-dtd:4.3'
implementation 'io.sf.carte:css4j:5.2'
implementation(group: 'io.sf.carte', name: 'css4j', version: '5.2', classifier: 'tests')
implementation 'io.sf.carte:css4j-dom4j:5.1'
implementation 'io.sf.carte:echosvg-transcoder:2.0'
implementation ('org.apache.xmlgraphics:batik-transcoder:1.18') {
// Already available from java.xml
exclude group: 'xml-apis', module: 'xml-apis'
// Use packages from web-apis instead
exclude group: 'xml-apis', module: 'xml-apis-ext'
}
implementation ('org.apache.xmlgraphics:batik-codec:1.18') {
// Already available from java.xml
exclude group: 'xml-apis', module: 'xml-apis'
// Use packages from web-apis instead
exclude group: 'xml-apis', module: 'xml-apis-ext'
}
implementation 'org.w3c.css:sac:1.3' // Required by Batik
implementation 'nu.validator:htmlparser:1.4.16'
implementation 'org.jsoup:jsoup:1.18.3'
}
configurations.all {
exclude group: 'jaxen', module: 'jaxen'
}
group = 'io.sf.carte'
version = '0.7'
description = 'JMH benchmark for CSS4J and EchoSVG'
java {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}
sourceSets {
main {
java {
srcDirs = ['src']
}
resources {
srcDirs = ['resources']
}
}
}
tasks.register('lineEndingConversion', CRLFConvert) {
file "$rootDir/LICENSE.txt"
}
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 lineEndingConversion
from ('LICENSE.txt') {
into 'META-INF'
}
}
tasks.register('cleanBuildSrc') {
doLast {
delete("$rootDir/buildSrc/build")
}
}
tasks.named('clean') {
finalizedBy('cleanBuildSrc')
}
tasks.withType(JavaCompile) {
options.encoding = 'UTF-8'
}
// Execute JMH benchmarks
task runJmh(type: JavaExec) {
description = 'Run JMH benchmarks'
dependsOn classes
classpath = sourceSets.main.runtimeClasspath
mainClass = 'org.openjdk.jmh.Main'
def regexp = project.properties.get('jmh.regexp', 'Mark');
def format = project.properties.get('jmh.rf', 'json');
def resultFilename = project.properties.get('jmh.rff', "jmh-result.${format}");
def resultFile = file("${buildDir}/reports/jmh/${resultFilename}")
args regexp
args '-rf', format
args '-rff', resultFile
jvmArgs '-Dfile.encoding=UTF-8'
doFirst {
resultFile.parentFile.mkdirs()
}
}
//create a single Jar with all benchmark dependencies
tasks.register('jmhJar', Jar) {
description = 'Create a single benchmark Jar with dependencies'
archiveFileName = 'benchmarks.jar'
manifest {
attributes(
'Main-Class' : 'org.openjdk.jmh.Main'
)
}
dependsOn configurations.compileClasspath
dependsOn configurations.runtimeClasspath
doFirst {
from sourceSets.main.output
from {
configurations.compileClasspath.collect { it.isDirectory() ? it : zipTree(it) }
}
from {
configurations.runtimeClasspath.findAll { it.name.endsWith('jar') }.collect { zipTree(it) }
}
}
with jar
duplicatesStrategy = 'exclude'
// Modularity does not apply here
exclude 'module-info.class'
// Provided by Java SE
exclude 'javax/**'
// The next ones are provided by java.xml module
exclude 'org/w3c/dom/*'
exclude 'org/w3c/dom/bootstrap/**'
exclude 'org/w3c/dom/events/**'
exclude 'org/w3c/dom/ls/**'
exclude 'org/w3c/dom/ranges/**'
exclude 'org/w3c/dom/traversal/**'
exclude 'org/w3c/dom/views/**'
exclude 'org/xml/**'
// Provided by jdk.xml.dom module
exclude 'org/w3c/dom/css/**'
exclude 'org/w3c/dom/html/**'
exclude 'org/w3c/dom/stylesheets/**'
exclude 'org/w3c/dom/xpath/**'
}
build.dependsOn jmhJar
publishing {
publications {
maven(MavenPublication) {
description = 'css4j benchmarks'
from(components.java)
pom {
description = 'css4j benchmarks'
url = "https://github.com/css4j/benchmark/"
licenses {
license {
name = "BSD 3-clause license"
url = "https://css4j.github.io/LICENSE.txt"
}
}
}
}
}
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
}
}
}
}