-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.gradle
More file actions
179 lines (155 loc) · 5.44 KB
/
build.gradle
File metadata and controls
179 lines (155 loc) · 5.44 KB
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
// the following is included to work with local Ivy repo during SN development
// see https://docs.gradle.org/current/userguide/variant_model.html#sub:ivy-mapping-to-variants
abstract class IvyVariantDerivationRule implements ComponentMetadataRule {
@Inject abstract ObjectFactory getObjects()
void execute(ComponentMetadataContext context) {
// This filters out any non Ivy module
if(context.getDescriptor(IvyModuleDescriptor) == null) {
return
}
context.details.addVariant("runtimeElements", "runtime") {
attributes {
attribute(LibraryElements.LIBRARY_ELEMENTS_ATTRIBUTE, getObjects().named(LibraryElements, LibraryElements.JAR))
attribute(Category.CATEGORY_ATTRIBUTE, getObjects().named(Category, Category.LIBRARY))
attribute(Usage.USAGE_ATTRIBUTE, getObjects().named(Usage, Usage.JAVA_RUNTIME))
}
}
context.details.addVariant("apiElements", "compile") {
attributes {
attribute(LibraryElements.LIBRARY_ELEMENTS_ATTRIBUTE, getObjects().named(LibraryElements, LibraryElements.JAR))
attribute(Category.CATEGORY_ATTRIBUTE, getObjects().named(Category, Category.LIBRARY))
attribute(Usage.USAGE_ATTRIBUTE, getObjects().named(Usage, Usage.JAVA_API))
}
}
}
}
buildscript {
repositories {
mavenLocal()
mavenCentral()
maven { url "https://plugins.gradle.org/m2/" }
}
}
subprojects {
apply plugin: "checkstyle"
apply plugin: "java"
group = "net.solarnetwork.node"
sourceCompatibility = 1.8
targetCompatibility = 1.8
repositories {
mavenCentral()
maven { url "https://dev.solarnetwork.net/archive/repository/solarnetwork-stage/" }
ivy {
url "file:///${System.properties['user.home']}/.ivy2/local"
patternLayout {
artifact "[organisation]/[module]/[revision]/[artifact]-[revision](-[classifier]).[ext]"
ivy "[organisation]/[module]/[revision]/[artifact]-[revision](-[classifier]).[ext]"
}
}
}
[
compileJava,
compileTestJava
].each() {
it.options.compilerArgs += [
"-Xlint:all",
"-Xlint:-options",
"-Xlint:-path",
"-Xlint:-try"
]
it.options.encoding = "UTF-8"
if (rootProject.hasProperty('failOnWarnings') && rootProject.failOnWarnings.toBoolean()) {
it.options.compilerArgs += ["-Werror"]
}
}
compileTestJava {
options.compilerArgs += [
"-Xlint:-serial"
]
}
jar.manifest {
attributes('Implementation-Title': name,
'Implementation-Version': version,
'Built-By': System.getProperty('user.name'),
'Built-JDK': System.getProperty('java.version'),
'Source-Compatibility': sourceCompatibility,
'Target-Compatibility': targetCompatibility)
}
javadoc.options {
encoding = 'UTF-8'
use = true
links 'https://docs.oracle.com/javase/8/docs/api/'
source = "8"
}
ext {
checkstyleVersion = '8.34'
javaxAnnotationVersion = '1.3.2'
wordWrapVersion = '0.1.6'
libraries = [
// Test dependencies.
hamcrest: 'org.hamcrest:hamcrest-library:2.2',
junit: 'org.junit.jupiter:junit-jupiter:5.7.2',
mockito: 'org.mockito:mockito-core:3.9.0',
mockitoJupiter: 'org.mockito:mockito-junit-jupiter:3.9.0'
]
}
ext['netty.version'] = '4.1.63.Final'
dependencies {
components { all(IvyVariantDerivationRule) }
testImplementation libraries.junit,
libraries.hamcrest,
libraries.mockito,
libraries.mockitoJupiter
}
// Disable JavaDoc doclint on Java 8. It's annoying.
if (JavaVersion.current().isJava8Compatible()) {
allprojects {
tasks.withType(Javadoc) {
options.addStringOption('Xdoclint:none', '-quiet')
}
}
}
// For jdk10 we must explicitly choose between html4 and html5, otherwise we get a warning
if (JavaVersion.current().isJava10Compatible()) {
allprojects {
tasks.withType(Javadoc) {
options.addBooleanOption('html5', true)
}
}
}
checkstyle {
toolVersion = "8.34"
configFile = rootProject.file('config/checkstyle/checkstyle.xml')
ignoreFailures = false
if (rootProject.hasProperty("checkstyle.ignoreFailures")) {
ignoreFailures = rootProject.properties["checkstyle.ignoreFailures"].toBoolean()
}
}
checkstyleMain {
source = fileTree(dir: "src/main", include: "**/*.java")
}
checkstyleTest {
source = fileTree(dir: "src/test", include: "**/*.java")
}
task javadocJar(type: Jar) {
from javadoc
classifier = 'javadoc'
archiveClassifier = 'javadoc'
}
task sourcesJar(type: Jar) {
from sourceSets.main.allSource
classifier = 'sources'
archiveClassifier = 'sources'
}
// At a test failure, log the stack trace to the console so that we don't
// have to open the HTML in a browser.
test {
testLogging {
exceptionFormat = 'full'
showExceptions true
showCauses true
showStackTraces true
}
maxHeapSize = '1500m'
}
}