Commit 12e95ff7 authored by Lucas Legrand's avatar Lucas Legrand

Added build.gradle files to show necessary changes, README.md edited, still...

Added build.gradle files to show necessary changes, README.md edited, still have to complete it. TODO: Checking README steps.
parent 42769443
INTRODUCTION
Introduction
This project's aim was to allow gradle to retrieve the sdk from a remote repository.
To do so, i decided to create a Maven repository from this Git one.
Until today, integrating liblinphone sdk into a third party application required compiling a sdk from the sources or importing sdk binary files from: http://www.linphone.org/technical-corner/liblinphone/downloads .
In order to ease integration of this sdk, we adapted a Gitlab repository as a Maven one.
Maven is a standardized tool to manage and build Java-based projects, which core unit of work is Project Object Model.
With Gradle and this Maven repository, we now offer the ability to either host or import remotely liblinphone sdk, as any future library.
I used 2 android-linphone projects in order to make it work:
one to produce .aar and generate Maven files, the other one retrieving the dependency from the repository.
PRODUCTION
How to produce and host Liblinphone SDK on our Maven repository
We need a project with a liblinphone-sdk built allowing linphone-android application to build.
In this part we will modify only liblinphone-sdk build.gradle file.
To host Liblinphone SDK and allow future remote import, follow theses steps:
-Add the following line among others apply:
Get Linphone-Android and deploy locally Liblinphone SDK
git clone git@gitlab.linphone.org:BC/public/linphone-android.git
cd linphone-android
git checkout -b master origin/master
git submodule sync && git submodule update --init --recursive
./prepare.py -c && ./prepare.py && make
Set the liblinphone-sdk/build.gradle file as in the Maven repository.
It includes two parts:
apply plugin: 'maven'
-In the Task part:
...
///////////// Task /////////////
uploadArchives {
repositories {
repositories {
mavenDeployer {
repository(url: 'file://localhost/tmp/artifacts/')
def home = "$System.env.HOME"
repository(url: 'file://localhost'+home+'/Workplace/maven_repository/')
pom.project {
groupId 'org.linphone.maven'
artifactId 'liblinphone-sdk'
version "4.0.0"
version project.hasProperty("release") ? "4.0.0-RELEASE": "4.0.0"
}
}
}
......@@ -43,9 +60,21 @@ Options explanation:
Check if linphone-android builds.
Then, in a terminal located at linphone-android's root, type:
gradle clean uploadArchives
In /tmp/artifacts (in our example), start a git project and push produced files to this repository.
Sending files to our repository
In our local repository, start a git project and link it to our Git repository:
Warning: If a not working version is produced, before building it again, clear the whole gradle cache ($HOME/.gradle/caches/), or gradle will produce the same.
......
// Project information
buildDir = 'bin'
def getPackageName() {
return "org.linphone"
}
def firebaseEnable() {
File googleFile = new File('google-services.json')
return googleFile.exists()
}
buildscript {
File googleFile = new File('google-services.json')
repositories {
jcenter()
mavenCentral()
mavenLocal()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.0'
if (googleFile.exists()) {
classpath 'com.google.gms:google-services:3.1.0'
}
}
}
allprojects {
repositories {
jcenter()
mavenCentral()
mavenLocal()
google()
maven{
url "https://gitlab.linphone.org/BC/public/maven_repository/raw/master"
}
}
}
apply plugin: 'com.android.application'
dependencies {
androidTestImplementation('com.android.support.test.espresso:espresso-core:+') {
exclude module: 'support-annotations'
}
androidTestImplementation 'com.jayway.android.robotium:robotium-solo:5.6.3'
androidTestImplementation 'junit:junit:4.12'
implementation 'org.apache.commons:commons-compress:1.16.1'
if (firebaseEnable()) {
implementation 'com.google.firebase:firebase-messaging:15.0.2'
}
implementation 'com.android.support:support-v4:27.0.1'
// implementation project(':liblinphone-sdk')
// releaseImplementation 'org.linphone.maven:liblinphone-sdk:4.0.0-RELEASE'
debugImplementation 'org.linphone.maven:liblinphone-sdk:4.0.0'
}
if (firebaseEnable()) {
apply plugin: 'com.google.gms.google-services'
}
///// Exclude Files /////
def excludeFiles = []
// Exclude firebase file if not enable
if (!firebaseEnable()) {
excludeFiles.add('**/Firebase*')
println '[Push Notification] Firebase disabled'
} else {
excludeFiles.add('**/gcm*')
println '[Push Notification] Firebase enabled'
}
excludeFiles.add('src/android/org/linphone/tutorials/*.java')
def excludePackage = []
excludePackage.add('**/gdb.*')
excludePackage.add('**/libopenh264**')
excludePackage.add('**/**tester**')
excludePackage.add('**/LICENSE.txt')
/////////////////////////
android {
defaultConfig {
compileSdkVersion 28
buildToolsVersion "28.0.0"
applicationId getPackageName()
multiDexEnabled true
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
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
disable 'MissingTranslation', 'UnusedResources'
}
// Signing
signingConfigs {
release {
storeFile file(RELEASE_STORE_FILE)
storePassword RELEASE_STORE_PASSWORD
keyAlias RELEASE_KEY_ALIAS
keyPassword RELEASE_KEY_PASSWORD
}
}
buildTypes {
release {
signingConfig signingConfigs.release
}
packaged {
initWith release
signingConfig null
matchingFallbacks = ['debug', 'release']
}
}
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
def srcDirs = ['src/android']
java.srcDirs = srcDirs
resources.srcDirs = srcDirs
aidl.srcDirs = srcDirs
renderscript.srcDirs = srcDirs
res.srcDirs = ['res']
assets.srcDirs = ['assets']
java.excludes = excludeFiles
// Exclude some useless files
packagingOptions {
excludes = excludePackage
}
}
debug.setRoot('build-types/debug')
release.setRoot('build-types/release')
}
sourceSets {
androidTest {
manifest.srcFile 'AndroidManifest.xml'
def srcDirs = ['src/android', 'src/androidTest']
java.srcDirs = srcDirs
resources.srcDirs = srcDirs
aidl.srcDirs = srcDirs
renderscript.srcDirs = srcDirs
res.srcDirs = ['res']
assets.srcDirs = ['assets']
java.excludes = excludeFiles
// Exclude some useless files
packagingOptions {
excludes = excludePackage
}
}
debug.setRoot('build-types/debug')
release.setRoot('build-types/release')
}
packagingOptions {
pickFirst 'META-INF/NOTICE'
pickFirst 'META-INF/LICENSE'
exclude 'META-INF/MANIFEST.MF'
}
}
// Grant permissions
android.applicationVariants.all { variant ->
def applicationId = getPackageName()
def adb = android.getAdbExecutable().toString()
def variantName = variant.name.capitalize()
def grantPermissionTask = tasks.create("grant${variantName}Permissions").doLast({
"${adb} devices".execute().text.eachLine {
"${adb} shell pm grant ${applicationId} android.permission.RECORD_AUDIO".execute()
"${adb} shell pm grant ${applicationId} android.permission.WRITE_EXTERNAL_STORAGE".execute()
"${adb} shell pm grant ${applicationId} android.permission.CAMERA".execute()
"${adb} shell pm grant ${applicationId} android.permission.READ_PHONE_STATE".execute()
"${adb} shell pm grant ${applicationId} android.permission.READ_CONTACTS".execute()
"${adb} shell pm grant ${applicationId} android.permission.WRITE_CONTACTS".execute()
}
})
}
task runApplication {
doLast {
def result = exec {
executable = android.getAdbExecutable().toString()
ignoreExitValue true
args = ['shell', 'monkey', '-p', getPackageName(), '-c', 'android.intent.category.LAUNCHER', '1']
}
}
}
// Project information
buildDir = 'bin'
buildscript {
repositories {
jcenter()
mavenCentral()
mavenLocal()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.0'
}
}
allprojects {
repositories {
jcenter()
mavenCentral()
mavenLocal()
google()
}
}
configurations {
javadocDeps
}
apply plugin: 'com.android.library'
apply plugin: 'maven'
dependencies {
implementation 'org.apache.commons:commons-compress:1.16.1'
javadocDeps 'org.apache.commons:commons-compress:1.16.1'
}
def srcDir = ['../submodules/mediastreamer2/java/src']
def rootSdk
if (file('android-arm64/share/linphonej/java/org/linphone/core/Factory.java').exists() )
rootSdk = 'android-arm64'
else if (file('android-arm/share/linphonej/java/org/linphone/core/Factory.java').exists() )
rootSdk = 'android-arm'
else if (file('android-armv7/share/linphonej/java/org/linphone/core/Factory.java').exists() )
rootSdk = 'android-armv7'
else if (file('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')
android {
buildTypes {
release {
}
debug {
}
}
defaultConfig {
compileSdkVersion 28
buildToolsVersion "28.0.0"
multiDexEnabled true
setProperty("archivesBaseName", "liblinphone-sdk")
}
// Signing
signingConfigs {
release {
storeFile file(RELEASE_STORE_FILE)
storePassword RELEASE_STORE_PASSWORD
keyAlias RELEASE_KEY_ALIAS
keyPassword RELEASE_KEY_PASSWORD
}
}
buildTypes {
release {
signingConfig signingConfigs.release
}
packaged {
initWith release
signingConfig null
//matchingFallbacks = ['debug', 'release']
}
}
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 {
manifest.srcFile 'AndroidManifestLibrary.xml'
java.srcDirs = srcDir
aidl.srcDirs = srcDir
assets.srcDirs = ["${buildDir}/sdk-assets/assets/"]
renderscript.srcDirs = srcDir
jniLibs.srcDirs = ['../libs']
java.excludes = ['**/mediastream/MediastreamerActivity.java']
// Exclude some useless files
packagingOptions {
excludes = excludePackage
}
}
debug.setRoot('build-types/debug')
release.setRoot('build-types/release')
}
}
///////////// Task /////////////
uploadArchives {
repositories {
mavenDeployer {
def home = "$System.env.HOME"
repository(url: 'file://localhost'+home+'/Workplace/maven_repository/')
pom.project {
groupId 'org.linphone.maven'
artifactId 'liblinphone-sdk'
version project.hasProperty("release") ? "4.0.0-RELEASE": "4.0.0"
}
}
}
}
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
}
project.tasks['preBuild'].dependsOn 'copyAssets'
6c6435f5eea84080087c88d2e2c7a098
\ No newline at end of file
b3871d670c57e1d5ef4c5a4ae506b4d48255c281
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<groupId>org.linphone.maven</groupId>
<artifactId>liblinphone-sdk</artifactId>
<version>4.0.0</version>
<packaging>aar</packaging>
<dependencies>
<dependency>
<groupId>com.android.support</groupId>
<artifactId>multidex</artifactId>
<version>1.0.2</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-compress</artifactId>
<version>1.16.1</version>
<scope>compile</scope>
</dependency>
</dependencies>
</project>
d408b0e46a3e766ad62194684d699e1d
\ No newline at end of file
89f01e5ff2cc0385dd0335e9956640bb353b8461
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<metadata>
<groupId>org.linphone.maven</groupId>
<artifactId>liblinphone-sdk</artifactId>
<versioning>
<release>4.0.0</release>
<versions>
<version>1.0.0</version>
<version>1.0.1</version>
<version>4.0.0</version>
</versions>
<lastUpdated>20180703133814</lastUpdated>
</versioning>
</metadata>
5f407af61b7a1371f5798bd6503ab6f2
\ No newline at end of file
45c9fd68bf6c269b62f1ef550cbb669bb6c25cf0
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment