forked from AdamaJava/adamajava
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
121 lines (108 loc) · 3.52 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
buildscript {
repositories {
maven {
url = uri("https://plugins.gradle.org/m2/")
}
}
dependencies {
classpath("com.github.spotbugs.snom:spotbugs-gradle-plugin:6.0.4")
}
}
apply plugin: 'base'
ext {
revision = "git rev-parse --short HEAD".execute().text.trim()
adamalib = file('adama/build/lib').absolutePath
//create version from verionId
// by using the file construct, we can access the version.txt from the subprojects
// its better groovy/gradle too
file('version.txt').withReader { verionId = it.readLine() + "-" + revision }
}
subprojects {
apply plugin: 'java'
apply plugin: 'checkstyle'
apply plugin: 'eclipse'
apply plugin: "com.github.spotbugs"
sourceCompatibility = 21
spotbugs {
ignoreFailures = true
spotbugsTest.enabled = false
}
//output to html, the default is xml
spotbugsMain {
reports {
html {
enabled = true
destination = file("$buildDir/reports/spotbugs/spotbugs.html")
stylesheet = 'fancy-hist.xsl'
}
}
}
repositories {
mavenCentral()
flatDir(dirs:"$projectDir/../lib")
}
checkstyle {
configFile = file('../config/google_check.xml')
toolVersion = '10.12.4'
checkstyleTest.enabled=false
}
checkstyleMain.onlyIf {project.hasProperty('checkstyle')}
checkstyleMain {
mustRunAfter test
mustRunAfter compileJava
}
dependencies {
testImplementation 'junit:junit:4.13.2'
}
sourceSets {
main { java.srcDirs=['src']; resources.srcDirs=['src'] }
test { java.srcDirs=['test']; test.resources.srcDirs=['test'] }
}
build.doLast {
println "${project}: copy ${configurations.runtimeClasspath.collect { File file -> file.name }} to ${adamalib} and build/flat"
copy { from configurations.runtimeClasspath,libsDirectory; into file('build/flat') }
copy { from configurations.runtimeClasspath,libsDirectory; into adamalib }
}
jar.doFirst {
manifest {
if(project.hasProperty('mainClassName') && project.getProperty('mainClassName') != null ) {
attributes 'Main-Class' : project.mainClassName
}
attributes 'Implementation-Title': project.name,
'Implementation-Version': verionId,
'SVN-Version': revision,
'Built-By': System.properties['user.name'],
'Date': new java.util.Date().toString(),
'Class-Path' : project.configurations.runtimeClasspath.collect { it.name }.join(' ')
}
}
}
//create adama/build/lib under root before subprojects build
build.doLast {
delete(adamalib)
mkdir (adamalib)
copy{ from libsDirName; into 'adama/build/lib'; include '**/*.so' }
println "${project} build.doLast: copied from ${libsDirName} to " + adamalib
}
task dist(type: Zip) {
def zippedDir = "${project.name}"
into(zippedDir){
into ('lib') {from 'adama/build/lib'}
into ('licenses') { from 'adama/licenses' }
into ('bin') { from 'adama/bin'; fileMode = 0755 }
println "${project} inside task dist"
}
destinationDirectory = 'adama/build/distributions' as File
}
task latest_dist(type: Zip) {
archiveVersion = verionId
def zippedDir = "${project.name}"
destinationDirectory = new java.io.File("adama/build/latest_distributions")
into(zippedDir) {
into('lib') { from 'adama/build/lib' }
into('bin') { from 'adama/bin'; fileMode = 0755 }
into('licenses') { from 'adama/licenses' }
println "${project} inside task latest_dist"
}
}
clean.doLast { ant { delete(dir: "adama/build") }}