forked from groovyfx-project/groovyfx
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
executable file
·196 lines (178 loc) · 6.44 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
/*
* Copyright 2011-2015 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import java.text.SimpleDateFormat
buildscript {
repositories {
jcenter()
mavenCentral()
}
dependencies {
classpath 'org.asciidoctor:asciidoctor-gradle-plugin:1.5.2'
classpath 'org.kt3k.gradle.plugin:coveralls-gradle-plugin:2.4.0'
classpath 'com.github.ben-manes:gradle-versions-plugin:0.11.3'
classpath 'nl.javadude.gradle.plugins:license-gradle-plugin:0.11.0'
classpath 'net.nemerosa:versioning:1.6.0'
}
final javafxHome = System.env['JAVAFX_HOME']
if (javafxHome) {
project.ext.javafxJar = "${javafxHome}/rt/lib/jfxrt.jar"
if (!(new File(project.ext.javafxJar).exists())) {
// If JAVAFX_HOME/rt/lib/jfxrt.jar doesn't exist, maybe the user
// is pointing at the directory containing jfxrt.jar itself?
project.ext.javafxJar = "${javafxHome}/jfxrt.jar"
}
} else {
final javaHome = System.env['JAVA_HOME']
if (javaHome) {
File jfxrt7Jar = new File("${javaHome}/jre/lib/jfxrt.jar")
File jfxrt8Jar = new File("${javaHome}/jre/lib/ext/jfxrt.jar")
if (jfxrt8Jar.exists()) {
project.ext.javafxJar = jfxrt8Jar.canonicalPath
} else if (jfxrt7Jar.exists()) {
project.ext.javafxJar = jfxrt7Jar.canonicalPath
}
}
}
try {
println "JavaFX runtime jar: ${project.ext.javafxJar}"
dependencies {
classpath files(project.ext.javafxJar)
}
} catch (MissingPropertyException mpe) {
println """|
| Please set the environment variable JAVAFX_HOME
| to the directory that contains rt/lib/jfxrt.jar
| of JavaFX version ${groovyfx_requiredJavaFxVersion}.\n""".stripMargin('|')
System.exit 1
}
}
ext {
actualJavaFXVersion = com.sun.javafx.runtime.VersionInfo.runtimeVersion
buildTimeAndDate = new Date()
buildDate = new SimpleDateFormat('yyyy-MM-dd').format(buildTimeAndDate)
buildTime = new SimpleDateFormat('HH:mm:ss.SSSZ').format(buildTimeAndDate)
}
if (! project.ext.actualJavaFXVersion =~ groovyfx_requiredJavaFxVersion) {
println " Required JavaFX version is '${groovyfx_requiredJavaFxVersion}' but actual version is '${project.ext.actualJavaFXVersion}'"
System.exit 1
}
apply plugin: 'groovy'
apply plugin: 'maven'
apply plugin: 'signing'
apply plugin: 'idea'
apply plugin: 'jacoco'
apply plugin: 'eclipse'
apply plugin: 'org.asciidoctor.convert'
apply plugin: 'com.github.kt3k.coveralls'
apply plugin: 'com.github.ben-manes.versions'
apply plugin: 'net.nemerosa.versioning'
repositories {
if (project.hasProperty('groovyfx_useMavenLocal') && Boolean.valueOf(project.groovyfx_useMavenLocal)) { mavenLocal() }
jcenter()
}
configurations {
jansi.extendsFrom(runtime)
}
dependencies {
compile "org.codehaus.groovy:groovy-all:${groovyfx_groovyVersion}"
compile files(project.ext.javafxJar)
testCompile "junit:junit:${groovyfx_junitVersion}"
jansi 'org.fusesource.jansi:jansi:1.11'
println "Groovy: ${groovyfx_groovyVersion}; JUnit: ${groovyfx_junitVersion}"
}
apply {
from 'gradle/demo.gradle'
from 'gradle/deploy.gradle'
from 'gradle/code-quality.gradle'
}
jar {
manifest {
attributes(
'Built-By': System.properties['user.name'],
'Created-By': "${System.properties['java.version']} (${System.properties['java.vendor']} ${System.properties['java.vm.version']})".toString(),
'Build-Date': buildDate,
'Build-Time': buildTime,
'Build-Revision': versioning.info.commit,
'Specification-Title': project.name,
'Specification-Version': project.version,
'Specification-Vendor': 'grovvyfx.org',
'Implementation-Title': project.name,
'Implementation-Version': project.version,
'Implementation-Vendor': 'grovvyfx.org'
)
}
}
signArchives.onlyIf {
project.hasProperty('signing.keyId')
}
uploadArchives.onlyIf {
project.hasProperty('sonatypeUsername') && project.hasProperty('sonatypePassword')
}
idea {
module {
// excludeDirs += file('gradle/') // Gradle directory including the wrapper subdirectory.
excludeDirs += file('.settings/') // Eclipse settings directory.
excludeDirs += file('bin') // Eclipse compilation directory.
excludeDirs += file('out') // IDEA compilation directory.
excludeDirs += file('build') // Gradle compilation directory.
}
project {
ipr {
withXml { provider ->
final node = provider.asNode()
final component = provider.asNode().component
node.component.find { it.'@name' == 'VcsDirectoryMappings' }.mapping[0].'@vcs' = 'Git'
final gradleSettings = node.appendNode('component' , [name: 'GradleSettings'])
gradleSettings.appendNode('option', [name: 'linkedProjectPath', value: '$PROJECT_DIR$/build.gradle'])
}
}
}
}
asciidoctor {
//sources { include 'index.adoc' }
attributes toc: 'left',
doctype: 'book',
icons: 'font',
encoding: 'utf-8',
sectlink: true,
sectanchors: true,
numbered: true,
linkattrs: true,
imagesdir: 'images',
stylesheet: 'css/style.css',
'source-highlighter': 'coderay',
'groovyfx-version': project.version
}
test {
testLogging {
exceptionFormat "full"
}
}
jacoco {
toolVersion = '0.7.4.201502262128'
}
jacocoTestReport {
group = "Reporting"
description = "Generate Jacoco coverage reports after running tests."
additionalSourceDirs = project.files(sourceSets.main.allSource.srcDirs)
sourceDirectories = project.files(sourceSets.main.allSource.srcDirs)
classDirectories = project.files(sourceSets.main.output)
reports {
xml.enabled = true
csv.enabled = false
html.enabled = true
}
}