-
Notifications
You must be signed in to change notification settings - Fork 15
/
build.gradle
311 lines (271 loc) · 8.47 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
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
buildscript {
repositories {
maven {
url "https://plugins.gradle.org/m2/"
}
}
dependencies {
classpath 'com.moowork.gradle:gradle-node-plugin:+'
classpath 'org.kt3k.gradle.plugin:coveralls-gradle-plugin:+'
}
}
apply plugin: 'com.moowork.node'
apply plugin: 'java'
repositories {
mavenCentral()
}
dependencies {
compile 'com.google.code.findbugs:jsr305:3.0.2'
compile 'com.google.code.findbugs:annotations:3.0.1'
testCompile 'junit:junit:4.11'
def javaVersion = org.gradle.util.VersionNumber.parse( System.properties['java.version'] ).getMajor()
if( javaVersion >= 15 ) {
testRuntime 'org.mozilla:rhino:+'
}
}
sourceCompatibility = 1.7
compileJava.options.encoding = 'UTF-8'
javadoc.options.encoding = 'UTF-8'
sourceSets {
main {
java {
srcDir 'src'
}
resources {
srcDir 'src'
}
}
test {
java {
srcDir 'test'
}
resources {
srcDir 'test'
}
}
}
test {
testLogging {
events "failed"
exceptionFormat "short"
}
afterTest { desc, result ->
def color = 31;
switch(result){
case "SUCCESS": color = 32; break;
case "FAIL": color = 31; break;
}
print "\033[0;37mExecuted \033[1m[${desc.className}]\t\033[1;${color}m${desc.name}\033[0;37m\twith result: "
println "\033[0;${color}m${result.resultType}\033[0m"
}
}
/****************************************
* Coverage
****************************************/
apply plugin: 'jacoco'
apply plugin: 'com.github.kt3k.coveralls'
jacoco {
toolVersion = '0.8.3'
}
jacocoTestReport {
tasks.coveralls.dependsOn it
reports {
xml.enabled = true // coveralls plugin depends on xml format report
html.enabled = true
}
}
if( System.getProperty( "java.vm.specification.version" ) > '1.8' ) {
check.dependsOn tasks.coveralls
}
/****************************************
* Deploy to Maven
****************************************/
apply plugin: 'maven'
apply plugin: 'signing'
group = 'de.inetsoftware'
archivesBaseName = 'jlessc'
version = '1.12-SNAPSHOT'
jar {
manifest {
attributes( 'Implementation-Title': 'JLessC, a Less CSS compiler',
'Implementation-Vendor-Id': 'de.inetsoftware',
'Implementation-Vendor': 'i-net software GmbH, Berlin, Germany',
'Implementation-Version': version,
'Automatic-Module-Name': 'de.inetsoftware.jlessc',
'Bundle-SymbolicName': 'de.inetsoftware.jlessc',
'Export-Package': 'com.inet.lib.less',
'Bundle-Version': version)
}
}
task javadocJar(type: Jar) {
classifier = 'javadoc'
from javadoc
}
task sourcesJar(type: Jar) {
classifier = 'sources'
from sourceSets.main.allSource
}
artifacts {
archives javadocJar, sourcesJar
}
signing {
if (project.hasProperty("signing.keyId") ){
sign configurations.archives
}
}
uploadArchives {
repositories {
mavenDeployer {
beforeDeployment { MavenDeployment deployment ->
signing.signPom(deployment)
}
if (project.hasProperty("ossrhUsername") ){
repository(url: "https://oss.sonatype.org/service/local/staging/deploy/maven2/") {
authentication(userName: project["ossrhUsername"], password: project["ossrhPassword"])
}
snapshotRepository(url: "https://oss.sonatype.org/content/repositories/snapshots/") {
authentication(userName: project["ossrhUsername"], password: project["ossrhPassword"])
}
}
pom.project {
name 'JLessC'
packaging 'jar'
// optionally artifactId can be defined here
description 'A Less CSS compiler written completely in Java (pure Java).'
url 'https://github.com/i-net-software/jlessc'
scm {
connection 'scm:git:[email protected]:i-net-software/jlessc.git'
developerConnection 'scm:git:[email protected]:i-net-software/jlessc.git'
url '[email protected]:i-net-software/jlessc.git'
}
licenses {
license {
name 'MIT License'
url 'http://www.opensource.org/licenses/mit-license.php'
}
}
developers {
developer {
id 'vberlin'
name 'Volker Berlin'
email '[email protected]'
organization = 'i-net software'
organizationUrl 'https://www.inetsoftware.de/'
}
}
}
// we have only compile time dependency and no runtime dependency, that we remove all
pom.whenConfigured{pom ->
pom.dependencies.clear()
}
}
}
}
/****************************************
* Benchmark of different less compilers.
****************************************/
apply plugin: 'com.moowork.node'
configurations {
benchmarkLessCSS
benchmarkLessEngine
}
dependencies {
benchmarkLessCSS 'org.lesscss:lesscss:+'
benchmarkLessEngine 'com.asual.lesscss:lesscss-engine:+'
}
// less test file
def lessFile = file("${sourceSets.test.output.resourcesDir}/com/inet/lib/less/samples/bootstrap/bootstrap-3.3.1.less")
/**
* Bundle to call all single benchmark tests.
*/
task benchmark {
dependsOn 'benchmarkJLessC'
dependsOn 'benchmarkLessCSS'
dependsOn 'benchmarkLessEngine'
dependsOn 'benchmarkNodeLessCompile'
}
/**
* Benchmark test for JLessC.
*/
task benchmarkJLessC( dependsOn: processTestResources ) {
dependsOn 'jar'
outputs.upToDateWhen { false }
doFirst {
URL[] urls = [jar.archivePath.toURI().toURL()]
def classLoader = new URLClassLoader( urls );
def compiler = Class.forName( "com.inet.lib.less.Less", true, classLoader ).newInstance();
benchmarkTest( 'JLessC', {
compiler."compile"( lessFile, true )
} )
classLoader.close()
}
}
/**
* Benchmark test for Lesscss.
*/
task benchmarkLessCSS( dependsOn: processTestResources ) {
outputs.upToDateWhen { false }
doFirst {
def classLoader = getClassLoader( configurations.benchmarkLessCSS );
def compiler = Class.forName( "org.lesscss.LessCompiler", true, classLoader ).newInstance();
benchmarkTest( 'Lessccs', {
compiler.compile( lessFile )
} )
classLoader.close()
}
}
/**
* Benchmark test for Lesscss.
*/
task benchmarkLessEngine( dependsOn: processTestResources ) {
outputs.upToDateWhen { false }
doFirst {
def classLoader = getClassLoader( configurations.benchmarkLessEngine );
def compiler = Class.forName( "com.asual.lesscss.LessEngine", true, classLoader ).newInstance();
benchmarkTest( 'LessEngine', {
compiler.compile( lessFile, true )
} )
classLoader.close()
}
}
/**
* NodeJS for compilation test with original less implementation
*/
task benchmarkNodeLessCompile( dependsOn: processTestResources ) {
dependsOn 'npmInstall'
outputs.upToDateWhen { false }
doFirst {
benchmarkTest( 'less.js', {
exec {
workingDir = lessFile.parentFile.absolutePath
commandLine "${buildDir}/../node_modules/less/bin/lessc", lessFile.name, "${lessFile.parentFile}/output.css"
ignoreExitValue = true
}
} );
}
}
/**
* Test routine
* @param testName label for printing
* @param callable call of the compiler
*/
void benchmarkTest( String testName, Closure callable ) {
callable.call() // run once for the JIT
def time = -System.currentTimeMillis()
callable.call()
time += System.currentTimeMillis()
println( "\tResult for ${testName}:\033[1;33m\t${time} ms\033[0m" )
}
/**
* Create a Java ClassLoader from a single configuration.
* @param config the configuration
* @return the ClassLoader
*/
ClassLoader getClassLoader( Configuration config ) {
ArrayList urls = new ArrayList()
config.files.each { File file ->
// println '\t' + file.name
urls += file.toURI().toURL()
}
return new URLClassLoader( urls.toArray(new URL[0]) );
}