forked from mapsforge/mapsforge
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
122 lines (96 loc) · 3.12 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 {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.13.+'
}
}
def filterProjects(filter) {
return subprojects.findAll { project -> filter.contains(project.name) }
}
allprojects {
group = 'org.mapsforge'
version = '0.5.0'
ext.androidBuildVersionTools = "21.0.1"
ext.jUnitVersion = "4.11"
description = """The mapsforge project provides free and open software for OpenStreetMap-based applications."""
}
// no injection of functions, so via inheritance
def androidMinSdk() { return 9 }
def androidTargetSdk() { return 21 }
def versionCode() { return 50 }
def versionName() { return version }
// Configuration injection for all subprojects
subprojects {
repositories {
mavenCentral()
}
}
// Configuration for all plain Java projects
project.ext.javaprojects = ["mapsforge-core", "mapsforge-map-reader", "mapsforge-map", "mapsforge-map-awt", "mapsforge-map-writer", "SwingMapViewer"]
configure(filterProjects(project.javaprojects)) {
apply plugin: 'java'
apply plugin: 'checkstyle'
apply plugin: 'pmd'
dependencies {
testCompile group: 'junit', name: 'junit', version:"$jUnitVersion"
}
checkstyle {
showViolations = false // turn on for reporting
configFile = new File("config/checkstyle/checkstyle.xml")
}
// set java source encoding, otherwise some tests fail
[compileJava, compileTestJava]*.options*.encoding = 'UTF-8'
pmd {
ruleSetFiles = files("../config/pmd/pmd_ruleset.xml")
ignoreFailures = true
}
}
// Configuration for Android projects
project.ext.androidlibraryprojects = ["mapsforge-map-android"]
project.ext.androidapkprojects = ["Samples"]
project.ext.androidprojects = project.androidlibraryprojects + project.androidapkprojects
// TODO get checkstyle and pmd working for android (right now it does not work out of the box, so better wait for official fix)
configure(filterProjects(project.androidapkprojects)) {
apply plugin: 'com.android.application'
}
configure(filterProjects(project.androidlibraryprojects)) {
apply plugin: 'android-library'
android.libraryVariants.all { variant ->
def name = variant.buildType.name
if (name.equals("debug")) {
print "Skipping debug jar"
return; // Skip debug builds.
}
def task = project.tasks.create "jar${name.capitalize()}", Jar
task.dependsOn variant.javaCompile
task.from variant.javaCompile.destinationDir
artifacts.add('archives', task);
}
}
configure(filterProjects(project.androidprojects)) {
android {
compileSdkVersion androidTargetSdk()
buildToolsVersion "$androidBuildVersionTools"
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
defaultConfig {
versionCode versionCode()
versionName versionName()
minSdkVersion androidMinSdk()
targetSdkVersion androidTargetSdk()
}
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src/main/java']
resources.srcDirs = ['src']
res.srcDirs = ['res']
assets.srcDirs = ['assets']
}
}
}
}