-
Notifications
You must be signed in to change notification settings - Fork 6
/
build.gradle
221 lines (179 loc) · 6.09 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
// 1. a build script for jaxb plugin (currently 1.3.6 version can not be applied as a plugin)
buildscript {
repositories {
jcenter()
mavenCentral()
maven {
url "https://plugins.gradle.org/m2/"
}
}
dependencies {
classpath 'com.github.jacobono:gradle-jaxb-plugin:1.3.6'
classpath 'gradle.plugin.nl.javadude.gradle.plugins:license-gradle-plugin:0.13.1'
}
}
// 2. group and version for all projects
subprojects {
group = 'com.netflix.imfutility'
version = '1.0-itunes-beta'
}
// 3. define groups of projects with common configuration
project.ext {
// all Java projects
javaSubprojectList = subprojects
// Java subprojects that generates Java clases from xsd (with jaxb plugin)
xsdJavaSubprojectList = subprojects.findAll {
it.name == 'dpp-conversion-input-xsd' ||
it.name == 'itunes-conversion-input-xsd' ||
it.name == 'imf-conversion-core' ||
it.name == 'imf-conversion-common'
}
// Java projects that produce a test artifacts (.jar with tests)
// to create dependencies between tests in subprojects
testArtifactsJavaSubprojectList = subprojects.findAll {
it.name == 'dpp-conversion' ||
it.name == 'itunes-conversion' ||
it.name == 'imf-conversion-core'
}
}
// 4. configure all Java projects
configure(project.javaSubprojectList) {
// 4.1 Java plugin
apply plugin: 'java'
sourceCompatibility = 1.8
targetCompatibility = 1.8
repositories {
mavenCentral()
jcenter()
flatDir {
dirs '../ttml-java/dist', '../itunes-metadata-film/dist', '../itunes-metadata-tv/dist'
}
}
dependencies {
compile group: 'org.slf4j', name: 'slf4j-api', version: '1.7.21'
compile group: 'org.apache.logging.log4j', name: 'log4j-api', version: '2.5'
compile group: 'org.apache.logging.log4j', name: 'log4j-core', version: '2.5'
compile group: 'org.apache.logging.log4j', name: 'log4j-slf4j-impl', version: '2.5'
}
dependencies {
testCompile group: 'junit', name: 'junit', version: '4.12'
}
tasks.withType(JavaCompile) {
options.encoding = 'UTF-8'
}
// 4.2 Findbugs plugin
apply plugin: 'findbugs'
findbugs {
sourceSets = [sourceSets.main]
excludeFilter = rootProject.file("config/findbugs/findbugs-excludeFilter.xml")
}
tasks.withType(FindBugs) {
// exclude generated classes
// all generated classes must be in 'generated' package!
classes = classes.filter {
!it.path.contains('generated')
}
// create the reports in HTML
reports {
xml.enabled = false
html.enabled = true
}
}
// 4.4. Checkstyle plugin.
apply plugin: 'checkstyle'
checkstyle {
sourceSets = [project.sourceSets.main]
configFile = rootProject.file('config/checkstyle/checkstyle.xml')
}
tasks.withType(Checkstyle) {
exclude '**/generated/**'
}
// 4.5. license task
apply plugin: 'com.github.hierynomus.license'
license {
header rootProject.file('config/GPL_HEADER')
ext.year = 2016
ext.name = "Netflix, Inc."
ext.product = "IMF Conversion Utility"
excludes(["**/generated/**", "**/xsd/imf/**", "**/*.xjb", "**/*.xml", "**/*.hdr", "**/*.mxf"])
}
}
// 5. configure Java projects that generate Java classes from XSD (jaxb plugin)
configure(project.xsdJavaSubprojectList) {
// 5.1 apply jaxb plugin
apply plugin: 'com.github.jacobono.jaxb'
System.setProperty('javax.xml.accessExternalSchema', 'file')
dependencies {
jaxb 'com.sun.xml.bind:jaxb-xjc:2.2.7-b41'
jaxb 'com.sun.xml.bind:jaxb-impl:2.2.7-b41'
jaxb 'javax.xml.bind:jaxb-api:2.2.7'
jaxb "org.jvnet.jaxb2_commons:jaxb2-basics-ant:0.6.5"
jaxb "org.jvnet.jaxb2_commons:jaxb2-basics:0.6.4"
jaxb "org.jvnet.jaxb2_commons:jaxb2-basics-annotate:0.6.4"
jaxb "org.jvnet.jaxb2_commons:jaxb2-value-constructor:3.0"
}
jaxb {
// all XSDs must be under the xsd folder!
xsdDir = "${project.name}/src/main/resources/xsd"
// all XJBs must be under the xjb folder!
bindingsDir = "${project.name}/src/main/resources/xjb"
bindings = ["**/*.xjb"]
xjc {
taskClassname = "org.jvnet.jaxb2_commons.xjc.XJC2Task"
// generatePackages must be specified in xjb bindings
args = ["-Xinheritance", "-Xannotate", "-Xsimplify"]
destinationDir = "src/generated/java"
}
}
// 5.2 include generated code in main and test source sets
sourceSets {
main {
java {
srcDir 'src/generated/java'
}
}
test {
java {
srcDir 'src/generated/java'
}
}
}
// 5.3 delete generated code on clean
clean {
delete 'src/generated'
delete 'schema'
}
// 5.4 execute xjc task (generate all classes) before compilation
compileJava.dependsOn(xjc)
}
// 6. configure Java classes with tests
configure(project.testArtifactsJavaSubprojectList) {
// 6.1 create a .jar with tests to be used as a dependency for other subprojects with dependent tests
configurations {
testArtifacts.extendsFrom testCompile
}
task jarTest(type: Jar, dependsOn: testClasses) {
from sourceSets.test.output
from sourceSets.test.resources
classifier = 'test'
}
artifacts {
testArtifacts jarTest
}
}
// 7. copy the final distribution (of imf-conversion-main) to the build folder of the root project
apply plugin: 'base'
task copyDistr(type: Copy) {
from 'imf-conversion-main/build/distributions'
into "$buildDir"
}
task copyInstall(type: Copy) {
from 'imf-conversion-main/build/install'
into 'install'
}
clean {
delete 'install'
}
copyDistr.dependsOn(subprojects.build)
copyInstall.dependsOn(':imf-conversion-utility:installDist')
build.finalizedBy(copyDistr, copyInstall)