-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
160 lines (138 loc) · 4.21 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
// Default tasks
defaultTasks 'licenseFormatMain', 'licenseFormatTest', 'build'
// Apply plugins
apply plugin: 'application'
apply plugin: 'java'
apply plugin: 'license'
apply plugin: 'maven'
// Basic project information
group = 'ca.sapon'
archivesBaseName = 'jici'
version = '0.0.1-SNAPSHOT'
mainClassName = "ca.sapon.jici.Main"
// Extended project information
ext.projectName = 'JICI'
ext.inceptionYear = '2015'
ext.currentYear = '2016'
ext.packaging = 'jar'
ext.url = 'http://sapon.ca/jici'
ext.description = 'Java interpreter and code interaction'
ext.author = 'Aleksi Sapon'
// Minimum version of Java required
sourceCompatibility = '1.7'
targetCompatibility = '1.7'
// Define variables
ext.buildNumber = project.hasProperty("buildNumber") ? buildNumber : '0'
ext.ciSystem = project.hasProperty("ciSystem") ? ciSystem : 'unknown'
ext.commit = project.hasProperty("commit") ? commit : 'unknown'
// Plugin repositories and dependencies
buildscript {
repositories {
mavenCentral()
jcenter()
}
dependencies {
classpath 'nl.javadude.gradle.plugins:license-gradle-plugin:0.7.0'
}
}
// Non-plugin repositories and dependencies
repositories {
mavenLocal()
mavenCentral()
}
dependencies {
testCompile 'junit:junit:4.8.2'
}
// Filter, process, and include resources
processResources {
from(rootProject.rootDir) {
include 'LICENSE.txt'
}
}
// License header formatting
import nl.javadude.gradle.plugins.license.License
tasks.withType(License).each { licenseTask ->
licenseTask.exclude '**/*.frag'
licenseTask.exclude '**/*.ttf'
licenseTask.exclude '**/*.vert'
licenseTask.exclude '**/*.yml'
licenseTask.exclude '**/*.xml'
}
license {
ext.name = projectName
ext.author = author
ext.url = url
ext.year = inceptionYear + '-' + currentYear
header rootProject.file('HEADER.txt')
ignoreFailures true
strictCheck true
mapping {
java = 'SLASHSTAR_STYLE'
}
}
// Source compiler configuration
configure([compileJava, compileTestJava]) {
options.compilerArgs << '-Xlint:all'
options.compilerArgs << '-Xlint:-path'
options.deprecation = true
}
javadoc {
options.encoding = 'UTF-8'
options.charSet = 'UTF-8'
}
task sourceJar(type: Jar) {
classifier = 'sources'
from sourceSets.main.allSource
}
task javadocJar(type: Jar, dependsOn: javadoc) {
classifier = 'javadoc'
from javadoc.destinationDir
}
artifacts {
archives sourceJar
archives javadocJar
}
processResources {
// Include in final JAR
from 'LICENSE.txt'
}
// JAR manifest configuration
jar {
manifest {
attributes "Main-Class": mainClassName,
"Built-By": System.properties['user.name'],
"Created-By": System.properties['java.vm.version'] + " (" + System.properties['java.vm.vendor'] + ")",
"Implementation-Title": name,
"Implementation-Version": version + "+" + ciSystem + "-b" + buildNumber + ".git-" + commit,
"Implementation-Vendor": url
}
}
run {
standardInput = System.in
}
// Modified from: http://stackoverflow.com/a/36130467
tasks.withType(Test) {
testLogging {
// set options for log level LIFECYCLE
events "passed", "skipped", "failed", "standardError"
showExceptions true
exceptionFormat "full"
showCauses true
showStackTraces true
// set options for log level DEBUG and INFO
debug {
events "started", "passed", "skipped", "failed", "standardOut", "standardError"
exceptionFormat "full"
}
info.events = debug.events
info.exceptionFormat = debug.exceptionFormat
afterSuite { desc, result ->
if (!desc.parent) { // will match the outermost suite
def output = "Results: ${result.resultType} (${result.testCount} tests, ${result.successfulTestCount} successes, ${result.failedTestCount} failures, ${result.skippedTestCount} skipped)"
def startItem = '| ', endItem = ' |'
def repeatLength = startItem.length() + output.length() + endItem.length()
println('\n' + ('-' * repeatLength) + '\n' + startItem + output + endItem + '\n' + ('-' * repeatLength))
}
}
}
}