我一直在关注Travis CI docs for Android,所以我可以学习如何开始在我的Android库中使用Travis。但是,我不太了解文档中的很多内容......
到目前为止,我理解的是:
language: android # this means the project will be built in an Android environment
android:
components:
- tools # will be built with latest version of Android SDK tools
- platform-tools # ''
- build-tools-23.0.1 # build tools version of my project
- android-23 # Android SDK version of my project
Travis CI文档还显示了可以使用的其他组件:
# Additional components
- extra-google-google_play_services
- extra-google-m2repository
- extra-android-m2repository
- addon-google_apis-google-19
它提供了更完整的列表here。
但是这些'附加组件'做什么/意味着什么?我猜测extra-android-support
组件可能意味着该项目将使用Android支持库构建,但是其他人?
我查看了Travis tests for Gradle,但我看到其他项目使用的是script: ./gradlew check
,script: ./gradlew clean build check
,script: "./gradlew build"
,还有一些项目没有script
完全没有。 所有这些意味着什么?
答案 0 :(得分:5)
使用.travis.yml
文件,您正在配置要构建和运行代码的计算机。在此文件中,您必须指定所需的所有组件。
该文档显示了已经可用的所有SDK组件(预安装)。您不需要在.travis.yml文件中指定它们,除非您想强制重新安装此组件。
相反,您必须指定未预装的组件
例如,列表中只有build-tools 21.1.1
。这是团队的决定,因为此组件的版本更新更频繁。
这些'附加组件'做什么/意味着什么?
- extra-google-google_play_services
- extra-google-m2repository
- extra-android-m2repository
这些是支持库存储库(与您的SDK Manager一样需要更新),gradle会从中下载build.gradle
文件的依赖项块中添加的支持库。
要获取可用的确切组件名称和描述的列表,请运行命令android list sdk --no-ui --all --extended
你会得到像以下一样的感觉:
# Check Android SDK tools: http://developer.android.com/tools/sdk/tools-notes.html
# Check Android SDK Platform-tools: http://developer.android.com/tools/revisions/platforms.html
tools
platform-tools
# Check BuildTools: http://developer.android.com/tools/revisions/build-tools.html
build-tools-23.0.1
# The API to be used to compile
# Check APIs: http://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels
android-23
android-22
android-21
android-20
android-19
android-18
android-17
android-16
....
# The system images if you need to run emulator during your tests
sys-img-armeabi-v7a-android-23
sys-img-x86-android-23
....
# Google repository from which download the dependencies
# Check extras: http://developer.android.com/sdk/installing/adding-packages.html#GetSupportLib
extra-android-m2repository
extra-android-support
# Check more extras: http://developer.android.com/sdk/installing/adding-packages.html#GetGoogle
extra-google-m2repository
extra-google-google_play_services
extra-google-admob_ads_sdk
extra-google-analytics_sdk_v2
extra-google-gcm
extra-google-google_play_services_froyo
.....
# Source file
source-23
source-22
source-21
...
使用.travis.yml
,您必须告诉travis如何检查 BUILD是否成功。使用script
块指定用于检查构建的命令
如果您的项目在存储库根目录中有build.gradle
文件,则将使用Gradle构建它。这对你来说已经足够了,这取决于你的项目。
gradle使用的默认命令是:
./gradlew build connectedCheck
但你可以覆盖它来规定脚本块。
更多信息here。
如果您想在travis-ci中看到输出,可以查看this。