forked from opensensorhub/osh-core
-
Notifications
You must be signed in to change notification settings - Fork 0
/
common.gradle
173 lines (148 loc) · 4.36 KB
/
common.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
ext.oshCoreVersion = '1.2.0-SNAPSHOT'
allprojects {
group = 'org.sensorhub'
repositories {
//jcenter()
maven { url "http://repo.maven.apache.org/maven2" }
}
}
subprojects {
apply plugin: 'java'
apply plugin: 'osgi'
apply plugin: 'eclipse'
apply plugin: 'maven-publish'
sourceCompatibility = 1.7
targetCompatibility = 1.7
ext.details = null
ext.pom = {} // pom data that subprojects can append to
tasks.withType(JavaCompile) {
options.encoding = 'UTF-8'
options.compilerArgs << "-Xlint:-options"
}
tasks.withType(Javadoc) {
options.encoding = 'UTF-8'
options.addStringOption('Xdoclint:none', '-quiet')
}
eclipse {
classpath {
downloadJavadoc = true
}
}
// add embedded config for embedding jars in bundle
configurations {
embedded
compile {
extendsFrom embedded
}
}
// default test dependencies
dependencies {
testCompile 'junit:junit:4.11'
testCompile 'xmlunit:xmlunit:1.6'
}
// print test names
test {
testLogging {
events 'PASSED', 'FAILED'
showCauses true
showStackTraces true
exceptionFormat 'full'
}
}
// do packaging stuff at the end in case subprojects add extra info
afterEvaluate { project ->
// jar content
project.jar {
into('lib') {
from {
project.configurations.embedded
}
}
// OSGi manifest info
manifest {
// main info
symbolicName project.group + '.' + project.name
if (project.description != null)
attributes 'Bundle-Description': project.description
// add embedded jars to OSGi classpath
def classpath = '.'
project.configurations.embedded.each {
classpath += ',lib/' + it.name
}
attributes 'Bundle-ClassPath': classpath
// native libs location
def resourcesFolder = new File(projectDir, '/src/main/resources')
def nativeFolder = new File(resourcesFolder, '/lib/native')
if (nativeFolder.exists()) {
def nativePaths = ''
fileTree(dir: nativeFolder).files.each {
def path = resourcesFolder.toPath().relativize(it.toPath())
def osname = path.getName(2)
def proc = path.getName(3)
nativePaths += 'osname=' + osname + '; '
nativePaths += 'processor=' + proc + '; '
nativePaths += path.toString() + ', '
}
attributes 'Bundle-NativeCode': nativePaths
}
}
}
// maven artifact content
project.publishing {
publications {
mavenJava(MavenPublication) {
from components.java
pom.withXml {
asNode().get('version') + ({
resolveStrategy = Closure.DELEGATE_FIRST
name project.description
if (project.details != null)
description project.details
url 'http://www.opensensorhub.org'
licenses {
license {
name 'Mozilla Public License Version 2.0'
url 'http://www.mozilla.org/MPL/2.0'
distribution 'repo'
}
}
def repoName = projectDir.parentFile.name
scm {
url 'https://github.com/opensensorhub/' + repoName + '/tree/master/' + project.name
connection 'scm:git:git://github.com/opensensorhub/' + repoName + '.git'
}
issueManagement {
url 'https://github.com/opensensorhub/' + repoName + '/issues'
system 'GitHub Issues'
}
} >> project.pom)
}
}
}
}
}
// custom task to install in local maven repo
task install
install.dependsOn('build')
install.dependsOn('publishToMavenLocal')
}
// distribution zip files
apply plugin: 'java'
apply plugin: 'distribution'
tasks.jar.enabled = false
afterEvaluate { // disable all distTar tasks
tasks.each {
if (it.name.endsWith('istTar'))
it.enabled = false
}
}
// collect all configured repositories in parent build
afterEvaluate { project ->
if (gradle.parent != null) {
gradle.parent.rootProject {
repositories.addAll(project.repositories)
}
}
}
// include release stuff
//apply from: './release.gradle'