Permalink
9f5ff90 Jul 2, 2018
@devemux86 @ludwigb @schildbach
156 lines (125 sloc) 4.67 KB
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.3'
classpath 'com.github.dcendents:android-maven-gradle-plugin:2.0'
}
}
def filterProjects(filter) {
return subprojects.findAll { project -> filter.contains(project.name) }
}
allprojects {
group = 'org.mapsforge'
version = 'master-SNAPSHOT'
ext.isReleaseVersion = !version.endsWith("SNAPSHOT")
ext.androidBuildVersionTools = "28.0.1"
ext.jUnitVersion = "4.12"
if (JavaVersion.current().isJava8Compatible()) {
tasks.withType(Javadoc) {
options.addStringOption('Xdoclint:none', '-quiet')
logging.captureStandardError LogLevel.INFO
logging.captureStandardOutput LogLevel.INFO
}
}
}
static def androidCompileSdk() { return 28 }
// Minimum API Level by Support Library
static def androidMinSdk() { return 14 }
static def androidTargetSdk() { return 22 }
static def versionCode() { return 1 }
def versionName() { return version }
// Configuration injection for all subprojects
subprojects {
repositories {
google()
jcenter()
maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
}
tasks.withType(JavaCompile) {
sourceCompatibility = JavaVersion.VERSION_1_7
targetCompatibility = JavaVersion.VERSION_1_7
}
}
// Configuration for all plain Java projects
project.ext.javalibraryprojects = ["mapsforge-core", "mapsforge-map", "mapsforge-themes", "mapsforge-map-reader", "mapsforge-map-awt", "mapsforge-map-writer", "mapsforge-poi", "mapsforge-poi-awt", "mapsforge-poi-writer", "spatialite-android"]
project.ext.javaprojects = project.javalibraryprojects + ["mapsforge-samples-awt"]
configure(filterProjects(project.javalibraryprojects)) {
apply plugin: 'maven'
if (project.hasProperty("SONATYPE_USERNAME")) {
afterEvaluate {
project.apply from: "${rootProject.projectDir}/deploy.gradle"
}
}
}
configure(filterProjects(project.javaprojects)) {
apply plugin: 'java-library'
//apply plugin: 'checkstyle'
dependencies {
testImplementation "junit:junit:$jUnitVersion"
}
/*checkstyle {
showViolations = false // turn on for reporting
// as of Gradle 2.2.1 every sub project seems to require a checkstyle file, this
// directive forces all projects to use the shared file in the root project
configFile = rootProject.file('config/checkstyle/checkstyle.xml')
}*/
// set java source encoding, otherwise some tests fail
[compileJava, compileTestJava]*.options*.encoding = 'UTF-8'
}
// Configuration for Android projects
project.ext.androidlibraryprojects = ["mapsforge-map-android", "mapsforge-poi-android"]
project.ext.androidapkprojects = ["mapsforge-samples-android"]
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: 'com.android.library'
apply plugin: 'com.github.dcendents.android-maven'
android.libraryVariants.all { variant ->
def name = variant.buildType.name
if (name == "debug")
return
def task = project.tasks.create "jar${name.capitalize()}", Jar
task.dependsOn variant.javaCompiler
task.from variant.javaCompiler.destinationDir
artifacts.add('archives', task)
}
if (project.hasProperty("SONATYPE_USERNAME")) {
afterEvaluate {
project.apply from: "${rootProject.projectDir}/deploy.gradle"
}
}
}
configure(filterProjects(project.androidprojects)) {
android {
compileSdkVersion androidCompileSdk()
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']
}
}
lintOptions {
abortOnError false
}
}
}