-
Notifications
You must be signed in to change notification settings - Fork 24
/
Copy pathbuild.gradle
113 lines (93 loc) · 2.9 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
buildscript {
repositories {
mavenCentral()
maven {
url "https://plugins.gradle.org/m2/"
}
}
}
apply plugin: 'maven'
// print welcome message.
apply from: rootProject.file("gradle/welcome.gradle")
wrapper {
gradleVersion = '6.5.1'
distributionUrl = "https://services.gradle.org/distributions/" +
"gradle-${gradleVersion}-bin.zip"
}
// task to print gradle and groovy versions.
task("versions", group: "help").doLast {
println "Java version: ${System.properties["java.version"]}"
println "Gradle version: ${gradle.gradleVersion}"
println "Groovy version: ${GroovySystem.version}"
}
// task to create main and test source directories.
task("initSourceDirs", group: "build setup").doLast {
// ignore source directories for projects without source sets.
if (!project.hasProperty("sourceSets")) { return }
// list all source directories.
def sourceSets = project.sourceSets as SourceSetContainer
def sourceDirs = sourceSets*.allSource.srcDirs.flatten() as List<File>
// create source directories, for those who not exists.
for (sourceDir in sourceDirs) { sourceDir.mkdirs() }
}
// provide java tasks.
apply plugin: "java"
repositories {
mavenCentral()
}
// java language level.
sourceCompatibility = "8"
targetCompatibility = "8"
// configure publish tasks.
apply from: rootProject.file("gradle/publish-pom.gradle")
// task to create jar with source code.
task("sourceJar", type: Jar) {
group "Build"
description "An archive of the source code"
classifier "sources"
from sourceSets.main.allJava
}
// task to create jar with javadocs.
task("javadocJar", type: Jar) {
group "Build"
description "An archive of the javadoc"
classifier "javadoc"
from javadoc
}
jar.finalizedBy createPom
jar.finalizedBy sourceJar
jar.finalizedBy javadocJar
artifacts {
archives jar
archives sourceJar
archives javadocJar
createPom
}
compileJava {
javadoc {
options.addStringOption("Xdoclint:none", "-quiet")
}
}
ext {
def buildTimeAndDate = new Date()
buildDate = buildTimeAndDate.format("yyyy-MM-dd")
buildTime = buildTimeAndDate.format("HH:mm:ss.SSSZ")
javaVersion = System.properties["java.version"]
javaVendor = System.properties["java.vendor"]
javaVmVersion = System.properties["java.vm.version"]
}
jar {
manifest.attributes(
"Created-By": project.javaVersion +
" (" + project.javaVendor + " " + project.javaVmVersion + ")",
"Build-Date": project.buildDate,
"Build-Time": project.buildTime,
"Specification-Title": project.name,
"Specification-Version": project.version,
"Specification-Vendor": project.vendor,
"Implementation-Title": project.name,
"Implementation-Version": project.version,
"Implementation-Vendor": project.vendor,
"Automatic-Module-Name": "org.testfx.monocle",
)
}