mirror of
https://github.com/flutter/samples.git
synced 2025-11-09 06:18:49 +00:00
Configuring travis to build Android. (#206)
This commit is contained in:
18
.travis.yml
18
.travis.yml
@@ -1,6 +1,8 @@
|
|||||||
os:
|
os:
|
||||||
- linux
|
- linux
|
||||||
sudo: false
|
dist: trusty
|
||||||
|
language: android
|
||||||
|
|
||||||
addons:
|
addons:
|
||||||
apt:
|
apt:
|
||||||
sources:
|
sources:
|
||||||
@@ -8,23 +10,35 @@ addons:
|
|||||||
packages:
|
packages:
|
||||||
- libstdc++6
|
- libstdc++6
|
||||||
- fonts-noto
|
- fonts-noto
|
||||||
|
|
||||||
git:
|
git:
|
||||||
depth: 3
|
depth: 3
|
||||||
|
|
||||||
|
android:
|
||||||
|
components:
|
||||||
|
- build-tools-28.0.3
|
||||||
|
- android-28
|
||||||
|
|
||||||
env:
|
env:
|
||||||
- FLUTTER_VERSION=stable
|
- FLUTTER_VERSION=stable
|
||||||
- FLUTTER_VERSION=beta
|
- FLUTTER_VERSION=beta
|
||||||
matrix:
|
|
||||||
|
jobs:
|
||||||
allow_failures:
|
allow_failures:
|
||||||
- env: FLUTTER_VERSION=beta
|
- env: FLUTTER_VERSION=beta
|
||||||
|
|
||||||
before_script:
|
before_script:
|
||||||
- git clone https://github.com/flutter/flutter.git -b $FLUTTER_VERSION
|
- git clone https://github.com/flutter/flutter.git -b $FLUTTER_VERSION
|
||||||
- ./flutter/bin/flutter doctor
|
- ./flutter/bin/flutter doctor
|
||||||
- chmod +x travis_script.sh
|
- chmod +x travis_script.sh
|
||||||
|
|
||||||
script:
|
script:
|
||||||
- ./travis_script.sh
|
- ./travis_script.sh
|
||||||
|
|
||||||
cache:
|
cache:
|
||||||
directories:
|
directories:
|
||||||
- $HOME/shared/.pub-cache
|
- $HOME/shared/.pub-cache
|
||||||
|
|
||||||
notifications:
|
notifications:
|
||||||
email:
|
email:
|
||||||
brogdon+github@gmail.com
|
brogdon+github@gmail.com
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ apply plugin: 'kotlin-android-extensions'
|
|||||||
|
|
||||||
android {
|
android {
|
||||||
compileSdkVersion 28
|
compileSdkVersion 28
|
||||||
buildToolsVersion "29.0.2"
|
|
||||||
defaultConfig {
|
defaultConfig {
|
||||||
applicationId "dev.flutter.example.androidfullscreen"
|
applicationId "dev.flutter.example.androidfullscreen"
|
||||||
minSdkVersion 19
|
minSdkVersion 19
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ apply plugin: 'kotlin-android-extensions'
|
|||||||
|
|
||||||
android {
|
android {
|
||||||
compileSdkVersion 28
|
compileSdkVersion 28
|
||||||
buildToolsVersion "29.0.2"
|
|
||||||
defaultConfig {
|
defaultConfig {
|
||||||
applicationId "dev.flutter.example.androidusingplugin"
|
applicationId "dev.flutter.example.androidusingplugin"
|
||||||
minSdkVersion 19
|
minSdkVersion 19
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ apply plugin: 'kotlin-android-extensions'
|
|||||||
|
|
||||||
android {
|
android {
|
||||||
compileSdkVersion 28
|
compileSdkVersion 28
|
||||||
buildToolsVersion "29.0.2"
|
|
||||||
defaultConfig {
|
defaultConfig {
|
||||||
applicationId "dev.flutter.example.androidusingprebuiltmodule"
|
applicationId "dev.flutter.example.androidusingprebuiltmodule"
|
||||||
minSdkVersion 19
|
minSdkVersion 19
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ void main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// A simple model that uses a [MethodChannel] as the source of truth for the
|
/// A simple model that uses a [MethodChannel] as the source of truth for the
|
||||||
/// state of the counter.
|
/// state of a counter.
|
||||||
///
|
///
|
||||||
/// Rather than storing app state data within the Flutter module itself (where
|
/// Rather than storing app state data within the Flutter module itself (where
|
||||||
/// the native portions of the app can't access it), this module passes messages
|
/// the native portions of the app can't access it), this module passes messages
|
||||||
|
|||||||
@@ -9,13 +9,28 @@ import 'package:flutter/material.dart';
|
|||||||
import 'package:flutter_test/flutter_test.dart';
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
|
|
||||||
import 'package:flutter_module/main.dart';
|
import 'package:flutter_module/main.dart';
|
||||||
|
import 'package:provider/provider.dart';
|
||||||
|
|
||||||
|
class MockCounterModel extends ChangeNotifier implements CounterModel {
|
||||||
|
int _count = 0;
|
||||||
|
|
||||||
|
int get count => _count;
|
||||||
|
|
||||||
|
void increment() {
|
||||||
|
_count++;
|
||||||
|
notifyListeners();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
testWidgets('MiniView smoke test', (WidgetTester tester) async {
|
testWidgets('MiniView smoke test', (WidgetTester tester) async {
|
||||||
// Build our app and trigger a frame.
|
// Build our app and trigger a frame.
|
||||||
await tester.pumpWidget(
|
await tester.pumpWidget(
|
||||||
MaterialApp(
|
MaterialApp(
|
||||||
home: Contents(),
|
home: ChangeNotifierProvider<CounterModel>.value(
|
||||||
|
value: MockCounterModel(),
|
||||||
|
child: Contents(),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ void main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// A simple model that uses a [MethodChannel] as the source of truth for the
|
/// A simple model that uses a [MethodChannel] as the source of truth for the
|
||||||
/// state of the counter.
|
/// state of a counter.
|
||||||
///
|
///
|
||||||
/// Rather than storing app state data within the Flutter module itself (where
|
/// Rather than storing app state data within the Flutter module itself (where
|
||||||
/// the native portions of the app can't access it), this module passes messages
|
/// the native portions of the app can't access it), this module passes messages
|
||||||
|
|||||||
@@ -9,13 +9,28 @@ import 'package:flutter/material.dart';
|
|||||||
import 'package:flutter_test/flutter_test.dart';
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
|
|
||||||
import 'package:flutter_module_using_plugin/main.dart';
|
import 'package:flutter_module_using_plugin/main.dart';
|
||||||
|
import 'package:provider/provider.dart';
|
||||||
|
|
||||||
|
class MockCounterModel extends ChangeNotifier implements CounterModel {
|
||||||
|
int _count = 0;
|
||||||
|
|
||||||
|
int get count => _count;
|
||||||
|
|
||||||
|
void increment() {
|
||||||
|
_count++;
|
||||||
|
notifyListeners();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
testWidgets('MiniView smoke test', (WidgetTester tester) async {
|
testWidgets('MiniView smoke test', (WidgetTester tester) async {
|
||||||
// Build our app and trigger a frame.
|
// Build our app and trigger a frame.
|
||||||
await tester.pumpWidget(
|
await tester.pumpWidget(
|
||||||
MaterialApp(
|
MaterialApp(
|
||||||
home: Contents(),
|
home: ChangeNotifierProvider<CounterModel>.value(
|
||||||
|
value: MockCounterModel(),
|
||||||
|
child: Contents(),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@@ -1,18 +1,31 @@
|
|||||||
set -e
|
set -e
|
||||||
|
|
||||||
# Backs up one directory at a time, looking for one called "flutter".
|
# Backs up one directory at a time, looking for one called "flutter". Once it
|
||||||
|
# finds that directory, an absolute path to it is returned.
|
||||||
function getFlutterPath() {
|
function getFlutterPath() {
|
||||||
local path=".."
|
local path=""
|
||||||
local counter=0
|
local counter=0
|
||||||
|
|
||||||
while [[ "${counter}" -lt 10 ]]; do
|
while [[ "${counter}" -lt 10 ]]; do
|
||||||
[ -d "${path}/flutter" ] && echo "${path}/flutter" && return 0
|
[ -d "${path}flutter" ] && echo "$(pwd)/${path}flutter" && return 0
|
||||||
let counter++
|
let counter++
|
||||||
path="${path}/.."
|
path="${path}../"
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
declare -a PROJECT_NAMES=(
|
localSdkPath=$(getFlutterPath)
|
||||||
|
|
||||||
|
if [ -z "$localSdkPath" ]
|
||||||
|
then
|
||||||
|
echo "Failed to find the Flutter SDK!."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Flutter SDK found at ${localSdkPath}"
|
||||||
|
|
||||||
|
declare -a PROJECT_NAMES=(
|
||||||
|
"add_to_app/flutter_module" \
|
||||||
|
"add_to_app/flutter_module_using_plugin" \
|
||||||
"animations" \
|
"animations" \
|
||||||
"chrome-os-best-practices" \
|
"chrome-os-best-practices" \
|
||||||
"gallery/gallery" \
|
"gallery/gallery" \
|
||||||
@@ -32,14 +45,6 @@ do
|
|||||||
echo "== Testing '${PROJECT_NAME}' on Flutter's $FLUTTER_VERSION channel =="
|
echo "== Testing '${PROJECT_NAME}' on Flutter's $FLUTTER_VERSION channel =="
|
||||||
pushd "${PROJECT_NAME}"
|
pushd "${PROJECT_NAME}"
|
||||||
|
|
||||||
localSdkPath=$(getFlutterPath)
|
|
||||||
|
|
||||||
if [ -z "$localSdkPath" ]
|
|
||||||
then
|
|
||||||
echo "Failed to find Flutter SDK for '${PROJECT_NAME}'."
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Run the analyzer to find any static analysis issues.
|
# Run the analyzer to find any static analysis issues.
|
||||||
"${localSdkPath}/bin/flutter" analyze
|
"${localSdkPath}/bin/flutter" analyze
|
||||||
|
|
||||||
@@ -52,4 +57,26 @@ do
|
|||||||
popd
|
popd
|
||||||
done
|
done
|
||||||
|
|
||||||
|
echo "Building the aar files for 'flutter_module'."
|
||||||
|
pushd add_to_app/flutter_module
|
||||||
|
"${localSdkPath}/bin/flutter" build aar
|
||||||
|
popd
|
||||||
|
|
||||||
|
declare -a ANDROID_PROJECT_NAMES=(
|
||||||
|
"add_to_app/android_fullscreen" \
|
||||||
|
"add_to_app/android_using_plugin" \
|
||||||
|
"add_to_app/android_using_prebuilt_module" \
|
||||||
|
)
|
||||||
|
|
||||||
|
for PROJECT_NAME in "${ANDROID_PROJECT_NAMES[@]}"
|
||||||
|
do
|
||||||
|
echo "== Testing '${PROJECT_NAME}' on Flutter's $FLUTTER_VERSION channel =="
|
||||||
|
pushd "${PROJECT_NAME}"
|
||||||
|
|
||||||
|
./gradlew assembleDebug
|
||||||
|
./gradlew assembleRelease
|
||||||
|
|
||||||
|
popd
|
||||||
|
done
|
||||||
|
|
||||||
echo "-- Success --"
|
echo "-- Success --"
|
||||||
|
|||||||
Reference in New Issue
Block a user