Skip to content

Commit f445c6f

Browse files
authored
Add config for building on Travis CI (#7)
1 parent 8ac03a7 commit f445c6f

File tree

5 files changed

+211
-4
lines changed

5 files changed

+211
-4
lines changed

.travis.yml

Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
sudo: required # disables container-based builds which have a maximum of 4GB of memory
2+
language: android
3+
jdk: oraclejdk8
4+
env:
5+
global:
6+
- ADB_INSTALL_TIMEOUT=15 # wait up to 15 minutes for adb to connect to emulator (2 minutes by default)
7+
- EMULATOR_ANDROID_VERSION=19
8+
- BUILD_ANDROID_VERSION=28
9+
- BUILD_TOOLS_VERSION=28.0.3
10+
before_cache:
11+
- rm -f $HOME/.gradle/caches/modules-2/modules-2.lock
12+
- rm -fr $HOME/.gradle/caches/*/plugin-resolution/
13+
cache:
14+
directories:
15+
- $HOME/.gradle/caches/
16+
- $HOME/.gradle/wrapper/
17+
- $HOME/.android/build-cache
18+
android:
19+
components:
20+
- tools # to get the new `repository-11.xml`
21+
- tools # https://github.com/travis-ci/travis-ci/issues/6040#issuecomment-219367943)
22+
- platform-tools
23+
- build-tools-$BUILD_TOOLS_VERSION
24+
- android-$BUILD_ANDROID_VERSION
25+
- android-$EMULATOR_ANDROID_VERSION
26+
- sys-img-armeabi-v7a-android-$EMULATOR_ANDROID_VERSION
27+
licenses:
28+
- 'android-sdk-license-.+'
29+
before_install:
30+
# List all available targets, device definitions and AVDs.
31+
- sdkmanager --list || true
32+
33+
# Update sdk tools to latest version and install/update components
34+
- yes | sdkmanager "tools" > /dev/null
35+
- yes | sdkmanager "platform-tools" > /dev/null
36+
- yes | sdkmanager "build-tools;$BUILD_TOOLS_VERSION" > /dev/null
37+
38+
- yes | sdkmanager "platforms;android-$EMULATOR_ANDROID_VERSION" > /dev/null
39+
- yes | sdkmanager "platforms;android-$BUILD_ANDROID_VERSION" > /dev/null
40+
41+
# - yes | sdkmanager "system-images;android-24;google_apis;armeabi-v7a" > /dev/null
42+
43+
- yes | sdkmanager --update > /dev/null
44+
- yes | sdkmanager --licenses > /dev/null
45+
46+
# Check components status
47+
- sdkmanager --list || true
48+
49+
before_script:
50+
# local.properties file is not checked in but required (an empty file is good enough)
51+
- touch local.properties
52+
53+
# Make sure gradlew is executable
54+
- chmod +x gradlew
55+
56+
# Create emulator and wait for it to start
57+
- sdkmanager "system-images;android-$EMULATOR_ANDROID_VERSION;google_apis;armeabi-v7a"
58+
- echo no | avdmanager -v create avd -f -n test -k "system-images;android-$EMULATOR_ANDROID_VERSION;google_apis;armeabi-v7a"
59+
# Use new emulator executable location
60+
- $ANDROID_HOME/emulator/emulator -avd test -no-audio -no-window &
61+
- android-wait-for-emulator
62+
63+
# Turn off animations
64+
- adb shell settings put global window_animation_scale 0 &
65+
- adb shell settings put global transition_animation_scale 0 &
66+
- adb shell settings put global animator_duration_scale 0 &
67+
68+
# Wake up
69+
- adb shell input keyevent 82 &
70+
- adb shell input keyevent 1 &
71+
72+
script:
73+
- ./gradlew clean test --stacktrace
74+
75+
# Simpler config, but less up-to-date when it comes to tooling.
76+
# Added here for historical reasons.
77+
# language: android
78+
# jdk: oraclejdk8
79+
# android:
80+
# components:
81+
# - tools
82+
# - platform-tools
83+
# - build-tools-28.0.3
84+
# - android-28
85+
# - android-24
86+
# - sys-img-armeabi-v7a-android-24
87+
# licenses:
88+
# - 'android-sdk-license-.+'
89+
# before_install:
90+
# - yes | sdkmanager "platforms;android-24"
91+
# - yes | sdkmanager "platforms;android-28"
92+
# - yes | sdkmanager "build-tools;28.0.3"
93+
# before_script:
94+
# local.properties file is not checked in but required (an empty file is good enough)
95+
# - touch local.properties
96+
97+
# Make sure gradlew is executable
98+
# - chmod +x gradlew
99+
100+
# Create emulator and wait for it to start
101+
# - echo no | android create avd --force -n test -t android-24 --abi armeabi-v7a
102+
# - emulator -avd test -no-skin -no-window &
103+
# - android-wait-for-emulator
104+
# - adb shell input keyevent 82 &
105+
106+
# before_cache:
107+
# - rm -f $HOME/.gradle/caches/modules-2/modules-2.lock
108+
# - rm -fr $HOME/.gradle/caches/*/plugin-resolution/
109+
# cache:
110+
# directories:
111+
# - $HOME/.gradle/caches/
112+
# - $HOME/.gradle/wrapper/
113+
# - $HOME/.android/build-cache
114+
# script:
115+
# - ./gradlew clean test --stacktrace

gradle/dependencies.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
ext {
22
projectVersion = [
3-
minSdk : 21,
3+
minSdk : 19,
44
targetSdk : 28,
55
compileSdk : 28,
66
kotlin : "1.3.11"

gradlew.bat

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
@if "%DEBUG%" == "" @echo off
2+
@rem ##########################################################################
3+
@rem
4+
@rem Gradle startup script for Windows
5+
@rem
6+
@rem ##########################################################################
7+
8+
@rem Set local scope for the variables with windows NT shell
9+
if "%OS%"=="Windows_NT" setlocal
10+
11+
set DIRNAME=%~dp0
12+
if "%DIRNAME%" == "" set DIRNAME=.
13+
set APP_BASE_NAME=%~n0
14+
set APP_HOME=%DIRNAME%
15+
16+
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
17+
set DEFAULT_JVM_OPTS=
18+
19+
@rem Find java.exe
20+
if defined JAVA_HOME goto findJavaFromJavaHome
21+
22+
set JAVA_EXE=java.exe
23+
%JAVA_EXE% -version >NUL 2>&1
24+
if "%ERRORLEVEL%" == "0" goto init
25+
26+
echo.
27+
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28+
echo.
29+
echo Please set the JAVA_HOME variable in your environment to match the
30+
echo location of your Java installation.
31+
32+
goto fail
33+
34+
:findJavaFromJavaHome
35+
set JAVA_HOME=%JAVA_HOME:"=%
36+
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37+
38+
if exist "%JAVA_EXE%" goto init
39+
40+
echo.
41+
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42+
echo.
43+
echo Please set the JAVA_HOME variable in your environment to match the
44+
echo location of your Java installation.
45+
46+
goto fail
47+
48+
:init
49+
@rem Get command-line arguments, handling Windows variants
50+
51+
if not "%OS%" == "Windows_NT" goto win9xME_args
52+
53+
:win9xME_args
54+
@rem Slurp the command line arguments.
55+
set CMD_LINE_ARGS=
56+
set _SKIP=2
57+
58+
:win9xME_args_slurp
59+
if "x%~1" == "x" goto execute
60+
61+
set CMD_LINE_ARGS=%*
62+
63+
:execute
64+
@rem Setup the command line
65+
66+
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
67+
68+
@rem Execute Gradle
69+
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
70+
71+
:end
72+
@rem End local scope for the variables with windows NT shell
73+
if "%ERRORLEVEL%"=="0" goto mainEnd
74+
75+
:fail
76+
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
77+
rem the _cmd.exe /c_ return code!
78+
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
79+
exit /b 1
80+
81+
:mainEnd
82+
if "%OS%"=="Windows_NT" endlocal
83+
84+
:omega

plugin/build.gradle

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,14 @@ pluginBundle {
4747
}
4848
}
4949

50+
test {
51+
testLogging {
52+
events "passed", "skipped", "failed"
53+
exceptionFormat "full"
54+
showStandardStreams true
55+
}
56+
}
57+
5058
dependencies {
5159
compileOnly gradleApi()
5260
implementation projectDependency.gradlePlugin

plugin/src/test/kotlin/org/neotech/plugin/rootcoverage/IntegrationTest.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
11
package org.neotech.plugin.rootcoverage
22

33
import com.google.common.truth.Truth.assertThat
4-
import org.gradle.testing.jacoco.tasks.JacocoReport
54
import org.gradle.testkit.runner.GradleRunner
65
import org.gradle.testkit.runner.TaskOutcome
76
import org.junit.Test
87
import org.junit.runner.RunWith
98
import org.junit.runners.Parameterized
109
import java.io.File
11-
import java.io.OutputStreamWriter
1210
import kotlin.test.assertEquals
1311

1412
@RunWith(Parameterized::class)
@@ -24,7 +22,9 @@ class IntegrationTest(
2422
val runner = GradleRunner.create()
2523
.withProjectDir(projectRoot)
2624
.withPluginClasspath()
27-
.forwardStdOutput(OutputStreamWriter(System.out))
25+
// Without forwardOutput travis CI could timeout because not output will be reported
26+
// for a long time.
27+
.forwardOutput()
2828
.withArguments("clean", "rootCodeCoverageReport", "--stacktrace")
2929

3030
// Expect no failure

0 commit comments

Comments
 (0)