Skip to content

Commit 2a7d9f3

Browse files
Upgraded gradle and added auto-build script
Summary: - Added auto-build script for jenkins - Upgraded gradle - Changed repository to maven - Better naming for versions - Upgraded to version 1.1 Change-Id: If6b24cbab58bc5f56d8ebcfa8541a87daaf18399
1 parent d35a0fd commit 2a7d9f3

6 files changed

Lines changed: 176 additions & 29 deletions

File tree

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@ proguard-project.txt
3333
.gradle
3434
build
3535

36+
#Secrets
37+
credentials.properties
38+
3639
#Other
3740
.DS_Store
3841
tmp

AndroidSocket/build.gradle

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,15 @@ buildscript {
33
mavenCentral()
44
}
55
dependencies {
6-
classpath 'com.android.tools.build:gradle:0.5.+'
6+
classpath 'com.android.tools.build:gradle:0.13.+'
77
}
88
}
9-
apply plugin: 'android'
9+
10+
apply plugin: 'com.android.application'
1011

1112
repositories {
1213
mavenCentral()
13-
maven {
14-
url "http://192.158.30.128/repository/"
15-
}
14+
maven { url 'https://commondatastorage.googleapis.com/maven-repository/' }
1615
}
1716

1817
dependencies {
@@ -21,12 +20,12 @@ dependencies {
2120
}
2221

2322
android {
24-
compileSdkVersion 18
25-
buildToolsVersion "18"
23+
compileSdkVersion 19
24+
buildToolsVersion "19.1"
2625

2726
defaultConfig {
28-
minSdkVersion 7
29-
targetSdkVersion 18
27+
minSdkVersion 8
28+
targetSdkVersion 19
3029
}
3130
buildTypes {
3231
release {

AndroidSocketIO/build.gradle

Lines changed: 33 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,42 +3,50 @@ buildscript {
33
mavenCentral()
44
}
55
dependencies {
6-
classpath 'com.android.tools.build:gradle:0.5.+'
6+
classpath 'com.android.tools.build:gradle:0.13.+'
77
}
88
}
99

10-
apply plugin: 'android-library'
10+
apply plugin: 'com.android.library'
1111
apply plugin: 'maven'
1212

1313
repositories {
1414
mavenCentral()
15-
maven {
16-
url "http://192.158.30.128/repository/"
17-
}
15+
maven { url 'https://commondatastorage.googleapis.com/maven-repository/' }
1816
}
1917

2018
configurations {
2119
deployerJars
2220
}
2321

2422
dependencies {
25-
deployerJars "org.apache.maven.wagon:wagon-ssh:2.2"
23+
deployerJars 'com.googlesource.gerrit:gs-maven-wagon:3.3.1'
2624
compile "com.google.guava:guava:14.+"
2725
compile "com.google.code.findbugs:jsr305:2.0.1"
2826
compile "javax.inject:javax.inject:1"
2927
}
3028

31-
version = "1.0"
29+
def baseVersionName = "1.1"
30+
if (project.hasProperty("versionSuffix")) {
31+
project.ext.versionSuffix = project.versionSuffix
32+
} else {
33+
project.ext.versionSuffix = "snapshot"
34+
}
35+
if (project.ext.versionSuffix) {
36+
version = "${baseVersionName}-${project.versionSuffix}"
37+
} else {
38+
version = "${baseVersionName}"
39+
}
3240
archivesBaseName = "ausocketio"
3341
group = "com.appunite"
3442

3543
android {
36-
compileSdkVersion 18
37-
buildToolsVersion "18"
44+
compileSdkVersion 19
45+
buildToolsVersion "19.1"
3846

3947
defaultConfig {
40-
minSdkVersion 7
41-
targetSdkVersion 18
48+
minSdkVersion 8
49+
targetSdkVersion 19
4250
}
4351

4452
sourceSets {
@@ -96,16 +104,23 @@ task install(type: Upload, dependsOn: createPomFile) {
96104
}
97105
}
98106

107+
Properties props = new Properties()
108+
def credentialsProperties = file("credentials.properties")
109+
if (credentialsProperties.exists()) {
110+
props.load(new FileInputStream(credentialsProperties))
111+
}
112+
99113
uploadArchives {
100114
description = "Upload archives to maven repository"
101115
dependsOn createPomFile
102-
repositories {
103-
mavenDeployer {
104-
configuration = configurations.deployerJars
105-
repository(url: "sftp://mavenrepo@192.158.30.128/repository/") {
106-
authentication(userName: "mavenrepo")
107-
}
108-
pom = project.ext.pomFile
116+
repositories.mavenDeployer {
117+
configuration = configurations.deployerJars
118+
repository(url: "gs://maven-repository") {
119+
authentication(
120+
userName: "${props.getProperty('mavenUser', null)}" ,
121+
password: "${props.getProperty('mavenPassword', null)}")
109122
}
123+
pom = project.ext.pomFile
110124
}
111125
}
126+

auto-build.sh

Lines changed: 130 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
1+
if [ -f "${HOME}/.ssh/id_rsa" ];
2+
then
3+
echo "Never run this script on your computer - it is designed to run on build server"
4+
exit 1
5+
fi
6+
7+
if [ ! -d "${HOME}/Android" ]; then
8+
mkdir -p "${HOME}/Android" || exit 1
9+
fi
10+
11+
cd "${HOME}/Android" || exit 1
12+
echo "Downloading sdk..."
13+
wget --output-document=android-sdk.tgz --quiet http://dl.google.com/android/android-sdk_r23.0.2-linux.tgz || exit 1
14+
tar xzf android-sdk.tgz > /dev/null || exit 1
15+
16+
export ANDROID_HOME="$HOME/Android/android-sdk-linux"
17+
export PATH="${PATH}:${ANDROID_HOME}/platform-tools"
18+
export PATH="${PATH}:${ANDROID_HOME}/tools/proguard/bin"
19+
export PATH="${PATH}:${ANDROID_HOME}/tools"
20+
export PATH="${PATH}:${ANDROID_NDK_HOME}"
21+
22+
RUN_TESTS=
23+
#RUN_TESTS=yes
24+
25+
echo "Updating sdk..."
26+
echo yes | android update sdk -a -u -t tools > /dev/null || exit 1
27+
echo yes | android update sdk --filter platform-tools --no-ui --force > /dev/null || exit 1
28+
echo yes | android update sdk -a -u -t build-tools-19.1.0 > /dev/null || exit 1
29+
30+
echo "Installing android..."
31+
echo yes | android update sdk --filter android-19 --no-ui --force > /dev/null || exit 1
32+
echo yes | android update sdk --filter addon-google_apis_x86-google-19 --no-ui --force > /dev/null || exit 1
33+
34+
echo "Installing support libraries..."
35+
echo yes | android update sdk --filter extra-android-support --no-ui --force > /dev/null || exit 1
36+
echo yes | android update sdk --filter extra-android-m2repository --no-ui --force > /dev/null || exit 1
37+
echo yes | android update sdk --filter extra-google-m2repository --no-ui --force > /dev/null || exit 1
38+
39+
#echo "Displying current state..."
40+
#android list targets
41+
#android list sdk --no-ui --all --extended
42+
#android list sdk
43+
#find "$ANDROID_HOME/extras/android/m2repository"
44+
#find "$ANDROID_HOME/extras/google/m2repository"
45+
46+
if [ ${RUN_TESTS} ];
47+
then
48+
echo "Creating emulator..."
49+
echo "no" | android create avd \
50+
--device "Nexus 5" \
51+
--name test \
52+
--target "Google Inc.:Google APIs (x86 System Image):19" \
53+
--abi x86 \
54+
--skin WVGA800 \
55+
--sdcard 512M > /dev/null || exit 1
56+
fi
57+
58+
echo "Preparing keys..."
59+
mv /tmp/id_rsa "${HOME}/.ssh/id_rsa" || exit 1
60+
mv /tmp/id_rsa.pub "${HOME}/.ssh/id_rsa.pub" || exit 1
61+
chmod 0600 "${HOME}/.ssh/id_rsa" || exit 1
62+
63+
cat > "${HOME}/.ssh/known_hosts" <<EOF
64+
[review.appunite.com]:29418 ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC7QO9BK5rR1/3draS4UZlfzRuCXsvauubbN3HNcJiFe4rqDNRTW5oKJ4US4wbds9lB58zrUW3e9mK7XiuX1VXcfZp18//kdozreTK2z37vC0l2KfScfn11EjwBsHztEm+ZTm8oir1ihHUsdob9dnMoMCvD1IpM1jwVsogNX8OwluUY4axlBv+meV4YGKN9YoFIEut9oM2eZXuDM7Yz9PxZ034vxtgMLKdIPfJDb11KmtdEkw5wPRBTq/2baYhacP3QZtXOHi2VWyMztmTsEg4Asl+eCSaXfQzNSQgJxWUxkvfX/bHz4/3DPaTsWESn76lwNQQVKKmp88LNQKUwHIEz
65+
EOF
66+
67+
mkdir -p /tmp/workspace || exit 1
68+
cd /tmp/workspace || exit 1
69+
git init work || exit 1
70+
cd work || exit 1
71+
git fetch ssh://jenkins@$GERRIT_HOST:$GERRIT_PORT/$GERRIT_PROJECT $GERRIT_REFSPEC && git checkout FETCH_HEAD || exit 1
72+
73+
cp /tmp/credentials.properties AndroidSocketIO/credentials.properties || exit 1
74+
75+
TASKS="build"
76+
77+
./gradlew --parallel \
78+
--refresh-dependencies ${TASKS} \
79+
--stacktrace \
80+
--project-prop versionSuffix="$GERRIT_CHANGE_NUMBER.$GERRIT_PATCHSET_NUMBER"
81+
82+
OUT=$?
83+
84+
if [ $OUT -eq 0 ];
85+
then
86+
if [ ${RUN_TESTS} ];
87+
then
88+
echo "Waiting for hacks..."
89+
wait $CONNECT_PID
90+
HACKS_OUT=$?
91+
OUT=$HACKS_OUT
92+
93+
if [ $HACKS_OUT -eq 0 ];
94+
then
95+
echo "Running tests..."
96+
97+
# TODO: Run tests
98+
exit 1
99+
./gradlew --parallel --refresh-dependencies \
100+
:Yapert:connectedCheck \
101+
--stacktrace \
102+
--project-prop versionSuffix="$GERRIT_CHANGE_NUMBER.$GERRIT_PATCHSET_NUMBER"
103+
104+
# Ignore tests output
105+
# OUT=$?
106+
else
107+
echo "Failed installing hacks"
108+
fi
109+
110+
fi
111+
fi
112+
113+
if [ $OUT -eq 0 ];
114+
then
115+
if [ ${GERRIT_EVENT_TYPE} == "change-merged" ];
116+
then
117+
./gradlew uploadArchives \
118+
--project-prop versionSuffix="$GERRIT_CHANGE_NUMBER.$GERRIT_PATCHSET_NUMBER"
119+
OUT=$?
120+
fi
121+
fi
122+
123+
124+
mkdir -p /tmp/build/library
125+
mv AndroidSocketIO/build/outputs /tmp/build/library/
126+
127+
mkdir -p /tmp/build/example
128+
mv AndroidSocket/build/outputs /tmp/build/example/
129+
130+
exit $OUT

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
task wrapper(type: Wrapper) {
2-
gradleVersion = '1.6'
2+
gradleVersion = '2.1'
33
}

gradle/wrapper/gradle-wrapper.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
33
distributionPath=wrapper/dists
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists
6-
distributionUrl=http\://services.gradle.org/distributions/gradle-1.6-bin.zip
6+
distributionUrl=http\://services.gradle.org/distributions/gradle-2.1-all.zip

0 commit comments

Comments
 (0)