From f4e85c0990602325e90c79fd4b7f587824519c13 Mon Sep 17 00:00:00 2001 From: gutmet Date: Tue, 19 May 2020 23:30:00 +0200 Subject: [PATCH] script to create a new flutter app with release setup * needs default organisation and default key.properties --- createFlutter | 295 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 295 insertions(+) create mode 100755 createFlutter diff --git a/createFlutter b/createFlutter new file mode 100755 index 0000000..2fd4197 --- /dev/null +++ b/createFlutter @@ -0,0 +1,295 @@ +#!/bin/bash + +if [ "$#" -ne 2 ]; then + echo "USAGE: $0 PACKAGE_NAME DESCRIPTION" + exit 1 +fi + +PROJECT_HOME=~/AndroidStudioProjects +ORG_PATH="$PROJECT_HOME/defaultOrg" +KEY_PROPERTIES_PATH="$PROJECT_HOME/defaultKeyProperties" + +packageName="$1" +description="$2" + +echo "Package Name: $packageName" +echo "Description: $description" + + +if [[ -f "$ORG_PATH" ]]; then + org=`cat "$PROJECT_HOME/defaultOrg"` +else + echo "Could not find file with default org in $ORG_PATH" + exit 1 +fi + +if [[ -f "$KEY_PROPERTIES_PATH" ]]; then + keyProperties=`cat "$PROJECT_HOME/defaultKeyProperties"` +else + echo "Could not find file with default key properties in $KEY_PROPERTIES_PATH" + exit 1 +fi + +flutter create --org "$org" "$packageName" || exit 1 + +cd "$packageName" + +######################### +#### create .gitignore ## +######################### + +cat > .gitignore < pubspec.yaml <=2.2.2 <3.0.0" + +dependencies: + flutter: + sdk: flutter + intl: ^0.15.7 + shared_preferences: ^0.5.4+8 + cupertino_icons: ^0.1.2 + +dev_dependencies: + flutter_test: + sdk: flutter + flutter_launcher_icons: "^0.7.3" + +flutter_icons: + image_path: "LauncherIcon.png" + android: true + ios: true + +flutter: + uses-material-design: true + +EOF + + + +######################################### +## generate key.properties for signing ## +######################################### + +cat > android/key.properties < android/app/build.gradle < + localProperties.load(reader) + } +} + +def flutterRoot = localProperties.getProperty('flutter.sdk') +if (flutterRoot == null) { + throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.") +} + +def flutterVersionCode = localProperties.getProperty('flutter.versionCode') +if (flutterVersionCode == null) { + flutterVersionCode = '1' +} + +def flutterVersionName = localProperties.getProperty('flutter.versionName') +if (flutterVersionName == null) { + flutterVersionName = '1.0' +} + +apply plugin: 'com.android.application' +apply from: "\$flutterRoot/packages/flutter_tools/gradle/flutter.gradle" + +def keystoreProperties = new Properties() +def keystorePropertiesFile = rootProject.file('key.properties') +if (keystorePropertiesFile.exists()) { + keystoreProperties.load(new FileInputStream(keystorePropertiesFile)) +} + + +android { + compileSdkVersion 28 + + lintOptions { + disable 'InvalidPackage' + } + + defaultConfig { + // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). + applicationId "$org.$packageName" + minSdkVersion 16 + targetSdkVersion 28 + versionCode flutterVersionCode.toInteger() + versionName flutterVersionName + testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" + } + + signingConfigs { + release { + keyAlias keystoreProperties['keyAlias'] + keyPassword keystoreProperties['keyPassword'] + storeFile file(keystoreProperties['storeFile']) + storePassword keystoreProperties['storePassword'] + } + } + buildTypes { + release { + signingConfig signingConfigs.release + } + } +} + +flutter { + source '../..' +} + +dependencies { + testImplementation 'junit:junit:4.12' + androidTestImplementation 'com.android.support.test:runner:1.0.2' + androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2' +} + +EOF + +##################### +## empty README.md ## +##################### +cat > README.md < Makefile <