Unverified Commit e6fb0c95 authored by Lucio Maciel's avatar Lucio Maciel Committed by GitHub

Merge pull request #679 from RocketChat/sdk-as-jars

Remove the SDK as an module
parents ac2b6927 56690663
#!/bin/bash
CURRENT_DIR=`pwd`
# The SDK dir should be 2 directories up in the tree, so we use dirname 2 times
# to get the common parent dir of the SDK and the app
tmp=`dirname $CURRENT_DIR`
tmp=`dirname $tmp`
SDK_DIR="$tmp/Rocket.Chat.Kotlin.SDK"
echo "CURRENT DIR: $CURRENT_DIR"
echo "SDK DIR: $SDK_DIR"
# check if there are changes not commited
function git_stat {
local __resultvar=$1
cd $SDK_DIR && git diff --shortstat --exit-code
eval $__resultvar="'$?'"
}
# check for changes already on the index not commited
function git_stat_cached {
local __resultvar=$1
cd $SDK_DIR && git diff --cached --shortstat --exit-code
eval $__resultvar="'$?'"
}
# get the SHA of the lastest commit
function git_sha {
temp_sha=`cd $SDK_DIR && git rev-parse --short HEAD`
echo "$temp_sha"
}
# check if the tree is dirty (has modifications not commited yet)
function check_git_dirty {
git_stat stat
git_stat_cached cached
if [ $stat -eq 0 ] && [ $cached -eq 0 ]; then
echo "not dirty"
return 1
else
echo "is dirty"
return 0
fi
}
# check if the saved last commit is the same as the latest SHA in the tree
function check_last_commit {
if [ ! -f $SDK_DIR/.last_commit_hash ]; then
echo "last_commit_hash not found"
return 0
fi
saved_hash=`cat $SDK_DIR/.last_commit_hash`
last_hash=$(git_sha)
#`cd $SDK_DIR && git rev-parse --short HEAD`
if [ "$saved_hash" == "$last_hash" ]; then
echo "same hash as before $saved_hash = $last_hash"
return 1
fi
echo "different commits, build again"
return 0
}
SHA=$(git_sha)
echo "CURRENT SHA: $SHA"
# if the tree is not dirty, there is no new commit and the .jars are still there, just skip the build
if ! check_git_dirty && ! check_last_commit && [ -f $CURRENT_DIR/libs/common-$SHA.jar ] && [ -f $CURRENT_DIR/libs/core-$SHA.jar ]; then
echo "NO BUILD NEEDED"
exit 0
fi
cd $SDK_DIR && ./gradlew common:assemble && cd $CURRENT_DIR
cd $SDK_DIR && ./gradlew core:assemble && cd $CURRENT_DIR
rm $CURRENT_DIR/libs/common* $CURRENT_DIR/libs/core*
mkdir -p $CURRENT_DIR/libs/
cp -v $SDK_DIR/common/build/libs/common-0.1-SNAPSHOT.jar $CURRENT_DIR/libs/common-$SHA.jar
cp -v $SDK_DIR/core/build/libs/core-0.1-SNAPSHOT.jar $CURRENT_DIR/libs/core-$SHA.jar
echo "$SHA" > $SDK_DIR/.last_commit_hash
exit 0
......@@ -14,7 +14,7 @@ android {
versionCode 1
versionName "2.0.0-beta1"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
multiDexEnabled false
multiDexEnabled true
}
buildTypes {
......@@ -22,6 +22,10 @@ android {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
debug {
applicationIdSuffix ".dev"
}
}
packagingOptions {
......@@ -32,7 +36,6 @@ android {
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation project(':core')
implementation project(':player')
implementation libraries.kotlin
......@@ -95,3 +98,10 @@ kotlin {
coroutines "enable"
}
}
// FIXME - build and install the sdk into the app/libs directory
// We were having some issues with the kapt generated files from the sdk when importing as a module
task compileSdk(type:Exec) {
commandLine './build-sdk.sh'
}
preBuild.dependsOn compileSdk
package chat.rocket.android.server.infraestructure;
import android.arch.persistence.room.Dao;
import android.arch.persistence.room.Delete;
import android.arch.persistence.room.Insert;
import android.arch.persistence.room.OnConflictStrategy;
import android.arch.persistence.room.Query;
import android.arch.persistence.room.Update;
import java.util.List;
import io.reactivex.Single;
@Dao
public interface ServerDao {
@Insert(onConflict = OnConflictStrategy.FAIL)
void insertServer(ServerEntity serverEntity);
@Update
void updateServer(ServerEntity serverEntity);
@Delete
void deleteServer(ServerEntity serverEntity);
@Query("SELECT * FROM server")
Single<List<ServerEntity>> getServers();
@Query("SELECT * FROM server WHERE id = :serverId")
Single<ServerEntity> getServer(Long serverId);
}
package chat.rocket.android.server.infraestructure
import android.arch.persistence.room.*
import io.reactivex.Single
@Dao
interface ServerDao {
@Query("SELECT * FROM server")
fun getServers(): Single<List<ServerEntity>>
@Insert(onConflict = OnConflictStrategy.FAIL)
fun insertServer(serverEntity: ServerEntity)
@Update
fun updateServer(serverEntity: ServerEntity)
@Delete
fun deleteServer(serverEntity: ServerEntity)
@Query("SELECT * FROM server WHERE id = :serverId")
fun getServer(serverId: Long?): Single<ServerEntity>
}
......@@ -10,7 +10,7 @@ machine:
GRADLE_OPTS: '-Xmx1024m -Dorg.gradle.jvmargs="-Xmx1024m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError"'
JAVA_OPTS: "-Xms518m -Xmx1024m"
pre:
- git clone https://github.com/RocketChat/Rocket.Chat.Kotlin.SDK.git Rocket.Chat.Kotlin.Sdk
- git clone https://github.com/RocketChat/Rocket.Chat.Kotlin.SDK.git Rocket.Chat.Kotlin.SDK
dependencies:
pre:
......
......@@ -7,7 +7,7 @@ ext {
targetSdk : 27,
buildTools : '27.0.0',
kotlin : '1.2.10',
coroutine : '0.20',
coroutine : '0.21',
dokka : '0.9.15',
kotshi : '0.3.0-beta2',
......
include ':app', 'common', 'core', ':player'
project(':common').projectDir = new File(settingsDir, '../Rocket.Chat.Kotlin.SDK/common')
project(':core').projectDir = new File(settingsDir, '../Rocket.Chat.Kotlin.SDK/core')
include ':app', ':player'
\ 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