build.gradle 4.56 KB
Newer Older
1 2 3 4 5 6 7
// Project information
buildDir = 'bin'
buildscript {
    repositories {
        jcenter()
        mavenCentral()
        mavenLocal()
8
        google()
9 10
    }
    dependencies {
11
        classpath 'com.android.tools.build:gradle:3.1.0'
12 13 14 15 16 17 18 19
    }
}

allprojects {
    repositories {
        jcenter()
        mavenCentral()
        mavenLocal()
20
        google()
21 22 23
    }
}

24 25 26 27
configurations {
    javadocDeps
}

28 29 30
apply plugin: 'com.android.library'

dependencies {
31 32
    implementation 'org.apache.commons:commons-compress:1.16.1'
    javadocDeps 'org.apache.commons:commons-compress:1.16.1'
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
def srcDir = ['./submodules/mediastreamer2/java/src']
def rootSdk = 'android/liblinphone-sdk/'

if (file('android/liblinphone-sdk/android-arm64/share/linphonej/java/org/linphone/core/Factory.java').exists() )
    rootSdk += 'android-arm64'
else if (file('android/liblinphone-sdk/android-arm/share/linphonej/java/org/linphone/core/Factory.java').exists() )
    rootSdk += 'android-arm'
else if (file('android/liblinphone-sdk/android-armv7/share/linphonej/java/org/linphone/core/Factory.java').exists() )
    rootSdk += 'android-armv7'
else if (file('android/liblinphone-sdk/android-x86/share/linphonej/java/org/linphone/core/Factory.java').exists() )
    rootSdk += 'android-x86'
else {
    println ("native sdk not ready yet")
    rootSdk = ""
}

srcDir += [rootSdk+'/share/linphonej/java/org/linphone/core/']
srcDir += ['./submodules/linphone/wrappers/java/classes/']

def excludePackage = []

excludePackage.add('**/gdb.*')
excludePackage.add('**/libopenh264**')
excludePackage.add('**/**tester**')
excludePackage.add('**/LICENSE.txt')
60 61

android {
62 63 64 65 66
    buildTypes {
        release {}
        debug {}
    }

67
    defaultConfig {
68 69
        compileSdkVersion 28
        buildToolsVersion "28.0.0"
70
        multiDexEnabled true
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86
        setProperty("archivesBaseName", "liblinphone-sdk")
    }

    // Signing
    signingConfigs {
        release {
        }
    }
    buildTypes {
        release {
        }
        packaged {
            initWith release
            signingConfig null
            //matchingFallbacks = ['debug', 'release']
        }
87 88 89 90 91 92 93 94 95 96 97
    }

    lintOptions {
        checkReleaseBuilds false
        // Or, if you prefer, you can continue to check for errors in release builds,
        // but continue the build even when errors are found:
        abortOnError false
    }

    sourceSets {
        main {
98 99 100 101 102 103 104
            manifest.srcFile 'AndroidManifestLibrary.xml'
            java.srcDirs = srcDir
            aidl.srcDirs = srcDir
            assets.srcDirs = ["${buildDir}/sdk-assets/assets/"]
            renderscript.srcDirs = srcDir
            jniLibs.srcDirs = ['./android/libs']
            resources.srcDir("res")
105 106 107 108 109

            java.excludes = ['**/mediastream/MediastreamerActivity.java']

            // Exclude some useless files
            packagingOptions {
110
                excludes = excludePackage
111 112 113 114 115 116 117 118 119
            }
        }
        debug.setRoot('build-types/debug')
        release.setRoot('build-types/release')
    }
}

///////////// Task /////////////

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
task(releaseJavadoc, type: Javadoc, dependsOn: "assembleRelease") {
    source = srcDir
    excludes = ['**/mediastream/MediastreamerActivity.java',
                '**/**.html',
                '**/**.aidl']
    classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
    classpath += files(android.libraryVariants.release.javaCompile.classpath.files)
    classpath += configurations.javadocDeps
    options.encoding = 'UTF-8'
}

task sourcesJar(type: Jar) {
    classifier = 'sources'
    from android.sourceSets.main.java.srcDirs
}

task androidJavadocsJar(type: Jar, dependsOn: releaseJavadoc) {
    classifier = 'javadoc'
    from releaseJavadoc.destinationDir
}

task sdkZip(type: Zip) {
    String appName = "liblinphone-android-sdk"
    String gitSha = 'git describe --always'.execute().text.trim()
    String newSdkName = appName + "-" + gitSha + ".zip"

    from('bin/libs',
         'bin/outputs/aar')
    include '*'
    archiveName newSdkName
}

task copyAssets(type: Sync) {
    from rootSdk
    into "${buildDir}/sdk-assets/assets/org.linphone.core"
    include '**/*.png'
    include '**/*.pem'
    include '**/*.mkv'
    include '**/*.wav'
    include '**/*_grammar'

    //rename '(.*)', '$1'.toLowerCase()
    eachFile {
        path = path.toLowerCase() //to workaround case insensitive fs (macosx)
        println("Syncing sdk asset ${sourcePath} to ${path}")
    }
    doFirst {
        println("Syncing sdk assets into root dir ${destinationDir}")
     }
    // do not copy those
    includeEmptyDirs = false

172
}
173
project.tasks['preBuild'].dependsOn 'copyAssets'