Skip to content
Snippets Groups Projects
Commit 55c992ba authored by Benoît Harrault's avatar Benoît Harrault
Browse files

Improve build process

parent a8fe0dee
No related branches found
No related tags found
1 merge request!68Resolve "Improve build process"
Pipeline #6200 passed
This commit is part of merge request !68. Comments created here will be created in the context of that merge request.
Showing
with 114 additions and 82 deletions
...@@ -23,14 +23,27 @@ android:build-debug: ...@@ -23,14 +23,27 @@ android:build-debug:
- echo keyAlias=$ANDROID_DEBUG_KEY_ALIAS >> android/key.properties - echo keyAlias=$ANDROID_DEBUG_KEY_ALIAS >> android/key.properties
- echo keyPassword=$ANDROID_DEBUG_KEY_PASSWORD >> android/key.properties - echo keyPassword=$ANDROID_DEBUG_KEY_PASSWORD >> android/key.properties
# build flutter app # build flutter app
- VERSION_NAME="$(grep '^version:' pubspec.yaml | cut -d' ' -f2 | cut -d'+' -f1)"
- echo "${VERSION_NAME}"
- VERSION_CODE="$(grep '^version:' pubspec.yaml | cut -d' ' -f2 | cut -d'+' -f2)"
- echo "${VERSION_CODE}"
- flutter packages get - flutter packages get
- flutter clean - flutter clean
- flutter build apk --debug --split-per-abi
- flutter build apk --debug - flutter build apk --debug
# prepare artifact # prepare artifact
- find . -name "*.apk" # where is my apk? - BASE_APK_FOLDER="build/app/outputs/flutter-apk"
- APP_NAME="$(grep 'namespace' android/app/build.gradle | cut -d'"' -f2)"
- >
if [ "$(find "${BASE_APK_FOLDER}" -name "*.apk")" != "" ]; then
for APK in ${BASE_APK_FOLDER}/*.apk; do
mv -v "${APK}" "$(echo "${APK}" | sed "s|\.apk|_${VERSION_CODE}.apk|" | sed "s|/app-|/${APP_NAME}-|")"
done
fi
- find "${BASE_APK_FOLDER}" -name "*.apk" # where are my apk?
artifacts: artifacts:
paths: paths:
- build/app/outputs/apk/debug - build/app/outputs/flutter-apk
expire_in: 1 week expire_in: 1 week
interruptible: true interruptible: true
...@@ -52,9 +65,12 @@ android:build-release: ...@@ -52,9 +65,12 @@ android:build-release:
- echo keyAlias=$ANDROID_KEY_ALIAS >> android/key.properties - echo keyAlias=$ANDROID_KEY_ALIAS >> android/key.properties
- echo keyPassword=$ANDROID_KEY_PASSWORD >> android/key.properties - echo keyPassword=$ANDROID_KEY_PASSWORD >> android/key.properties
# build flutter app # build flutter app
- VERSION_FILE="$(find . -name 'gradle.properties' | head -n1)" - BASE_APK_FOLDER="build/app/outputs/flutter-apk"
- VERSION_NAME="$(grep '^app.versionName=' "${VERSION_FILE}" | cut -d'=' -f2)" - echo "${BASE_APK_FOLDER}"
- VERSION_CODE="$(grep '^app.versionCode=' "${VERSION_FILE}" | cut -d'=' -f2)" - mkdir -p "${BASE_APK_FOLDER}"
- VERSION_NAME="$(grep '^version:' pubspec.yaml | cut -d' ' -f2 | cut -d'+' -f1)"
- VERSION_CODE="$(grep '^version:' pubspec.yaml | cut -d' ' -f2 | cut -d'+' -f2)"
- APP_NAME="$(grep 'namespace' android/app/build.gradle | cut -d'"' -f2)"
- TAG_NAME="Release_${VERSION_NAME}_${VERSION_CODE}" - TAG_NAME="Release_${VERSION_NAME}_${VERSION_CODE}"
- echo "${TAG_NAME}" - echo "${TAG_NAME}"
- > - >
...@@ -63,13 +79,20 @@ android:build-release: ...@@ -63,13 +79,20 @@ android:build-release:
else else
flutter packages get flutter packages get
flutter clean flutter clean
flutter build apk --release --split-per-abi
flutter build apk --release flutter build apk --release
fi fi
# prepare artifact # prepare artifact
- find . -name "*.apk" # where is my apk? - >
if [ "$(find "${BASE_APK_FOLDER}" -name "*.apk")" != "" ]; then
for APK in ${BASE_APK_FOLDER}/*.apk; do
mv -v "${APK}" "$(echo "${APK}" | sed "s|\.apk|_${VERSION_CODE}.apk|" | sed "s|/app-|/${APP_NAME}-|")"
done
fi
- find "${BASE_APK_FOLDER}" -name "*.apk" # where are my apk?
artifacts: artifacts:
paths: paths:
- build/app/outputs/apk/release - build/app/outputs/flutter-apk
expire_in: 1 week expire_in: 1 week
interruptible: true interruptible: true
...@@ -89,9 +112,8 @@ application:release: ...@@ -89,9 +112,8 @@ application:release:
- git config user.email "${GITLAB_USER_EMAIL}" - git config user.email "${GITLAB_USER_EMAIL}"
- git config user.name "${GITLAB_USER_NAME}" - git config user.name "${GITLAB_USER_NAME}"
- git remote set-url origin https://oauth2:${GITLAB_ACCESS_TOKEN}@${CI_SERVER_HOST}/${CI_PROJECT_PATH} - git remote set-url origin https://oauth2:${GITLAB_ACCESS_TOKEN}@${CI_SERVER_HOST}/${CI_PROJECT_PATH}
- VERSION_FILE="$(find . -name 'gradle.properties' | head -n1)" - VERSION_NAME="$(grep '^version:' pubspec.yaml | cut -d' ' -f2 | cut -d'+' -f1)"
- VERSION_NAME="$(grep '^app.versionName=' "${VERSION_FILE}" | cut -d'=' -f2)" - VERSION_CODE="$(grep '^version:' pubspec.yaml | cut -d' ' -f2 | cut -d'+' -f2)"
- VERSION_CODE="$(grep '^app.versionCode=' "${VERSION_FILE}" | cut -d'=' -f2)"
- TAG_NAME="Release_${VERSION_NAME}_${VERSION_CODE}" - TAG_NAME="Release_${VERSION_NAME}_${VERSION_CODE}"
- echo "${TAG_NAME}" - echo "${TAG_NAME}"
- > - >
......
...@@ -7,5 +7,7 @@ gradle-wrapper.jar ...@@ -7,5 +7,7 @@ gradle-wrapper.jar
GeneratedPluginRegistrant.java GeneratedPluginRegistrant.java
# Remember to never publicly share your keystore. # Remember to never publicly share your keystore.
# See https://flutter.dev/docs/deployment/android#reference-the-keystore-from-the-app # See https://flutter.dev/to/reference-keystore
key.properties key.properties
**/*.keystore
**/*.jks
...@@ -4,32 +4,6 @@ plugins { ...@@ -4,32 +4,6 @@ plugins {
id "dev.flutter.flutter-gradle-plugin" id "dev.flutter.flutter-gradle-plugin"
} }
def localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists()) {
localPropertiesFile.withReader('UTF-8') { reader ->
localProperties.load(reader)
}
}
def gradleProperties = new Properties()
def gradlePropertiesFile = rootProject.file('gradle.properties')
if (gradlePropertiesFile.exists()) {
gradlePropertiesFile.withReader('UTF-8') { reader ->
gradleProperties.load(reader)
}
}
def appVersionCode = gradleProperties.getProperty('app.versionCode')
if (appVersionCode == null) {
appVersionCode = '1'
}
def appVersionName = gradleProperties.getProperty('app.versionName')
if (appVersionName == null) {
appVersionName = '1.0'
}
def keystoreProperties = new Properties() def keystoreProperties = new Properties()
def keystorePropertiesFile = rootProject.file('key.properties') def keystorePropertiesFile = rootProject.file('key.properties')
if (keystorePropertiesFile.exists()) { if (keystorePropertiesFile.exists()) {
...@@ -37,33 +11,69 @@ if (keystorePropertiesFile.exists()) { ...@@ -37,33 +11,69 @@ if (keystorePropertiesFile.exists()) {
} }
android { android {
compileSdkVersion 34 namespace = "org.benoitharrault.puzzlegame"
namespace "org.benoitharrault.puzzlegame" compileSdk = flutter.compileSdkVersion
ndkVersion = flutter.ndkVersion
compileOptions {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = JavaVersion.VERSION_1_8
}
defaultConfig { defaultConfig {
applicationId "org.benoitharrault.puzzlegame" applicationId = "org.benoitharrault.puzzlegame"
minSdkVersion flutter.minSdkVersion minSdk = flutter.minSdkVersion
targetSdkVersion 30 targetSdk = flutter.targetSdkVersion
versionCode appVersionCode.toInteger() versionCode = flutter.versionCode
versionName appVersionName versionName = flutter.versionName
archivesBaseName = "$applicationId" + "_" + "$versionCode"
} }
signingConfigs { signingConfigs {
release { release {
keyAlias keystoreProperties['keyAlias'] keyAlias = keystoreProperties['keyAlias']
keyPassword keystoreProperties['keyPassword'] keyPassword = keystoreProperties['keyPassword']
storeFile keystoreProperties['storeFile'] ? file(keystoreProperties['storeFile']) : null storeFile = keystoreProperties['storeFile'] ? file(keystoreProperties['storeFile']) : null
storePassword keystoreProperties['storePassword'] storePassword = keystoreProperties['storePassword']
} }
} }
buildTypes { buildTypes {
release { release {
signingConfig signingConfigs.release signingConfig = signingConfigs.release
}
}
splits {
abi {
reset()
include 'armeabi', 'armeabi-v7a', 'arm64-v8a', 'x86', 'x86_64'
} }
} }
} }
ext.abiCodes = [
'armeabi': 1,
'armeabi-v7a': 2,
'arm64-v8a': 3,
'x86': 4,
'x86_64': 5,
]
import com.android.build.OutputFile
android.applicationVariants.all { variant ->
variant.outputs.each { output ->
def perAbiVersionCodeIncrement = project.ext.abiCodes.get(output.getFilter(OutputFile.ABI))
if (perAbiVersionCodeIncrement != null) {
output.versionCodeOverride = variant.versionCode * 1000 + perAbiVersionCodeIncrement
}
}
}
flutter { flutter {
source '../..' source = "../.."
} }
<manifest xmlns:android="http://schemas.android.com/apk/res/android" <manifest xmlns:android="http://schemas.android.com/apk/res/android">
package="org.benoitharrault.puzzlegame">
<!-- Flutter needs it to communicate with the running application
to allow setting breakpoints, to provide hot reload, etc.
-->
<uses-permission android:name="android.permission.INTERNET"/> <uses-permission android:name="android.permission.INTERNET"/>
</manifest> </manifest>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" <manifest xmlns:android="http://schemas.android.com/apk/res/android">
package="org.benoitharrault.puzzlegame"> <application
<application
android:label="puzzlegame" android:label="puzzlegame"
android:name="${applicationName}"
android:icon="@mipmap/ic_launcher"> android:icon="@mipmap/ic_launcher">
<activity <activity
android:name=".MainActivity" android:name=".MainActivity"
android:exported="true"
android:launchMode="singleTop" android:launchMode="singleTop"
android:taskAffinity=""
android:theme="@style/LaunchTheme" android:theme="@style/LaunchTheme"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode" android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
android:hardwareAccelerated="true" android:hardwareAccelerated="true"
...@@ -27,4 +29,10 @@ ...@@ -27,4 +29,10 @@
android:name="flutterEmbedding" android:name="flutterEmbedding"
android:value="2" /> android:value="2" />
</application> </application>
<queries>
<intent>
<action android:name="android.intent.action.PROCESS_TEXT"/>
<data android:mimeType="text/plain"/>
</intent>
</queries>
</manifest> </manifest>
package org.benoitharrault.puzzlegame;
import io.flutter.embedding.android.FlutterActivity;
public class MainActivity extends FlutterActivity {
}
package org.benoitharrault.puzzlegame
import io.flutter.embedding.android.FlutterActivity
class MainActivity: FlutterActivity()
<manifest xmlns:android="http://schemas.android.com/apk/res/android" <manifest xmlns:android="http://schemas.android.com/apk/res/android">
package="org.benoitharrault.puzzlegame">
<!-- Flutter needs it to communicate with the running application
to allow setting breakpoints, to provide hot reload, etc.
-->
<uses-permission android:name="android.permission.INTERNET"/> <uses-permission android:name="android.permission.INTERNET"/>
</manifest> </manifest>
...@@ -5,12 +5,12 @@ allprojects { ...@@ -5,12 +5,12 @@ allprojects {
} }
} }
rootProject.buildDir = '../build' rootProject.buildDir = "../build"
subprojects { subprojects {
project.buildDir = "${rootProject.buildDir}/${project.name}" project.buildDir = "${rootProject.buildDir}/${project.name}"
} }
subprojects { subprojects {
project.evaluationDependsOn(':app') project.evaluationDependsOn(":app")
} }
tasks.register("clean", Delete) { tasks.register("clean", Delete) {
......
org.gradle.jvmargs=-Xmx1536M org.gradle.jvmargs=-Xmx4G -XX:MaxMetaspaceSize=2G -XX:+HeapDumpOnOutOfMemoryError
android.useAndroidX=true android.useAndroidX=true
android.enableJetifier=true android.enableJetifier=true
app.versionName=0.1.1
app.versionCode=63
distributionBase=GRADLE_USER_HOME distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-all.zip
zipStoreBase=GRADLE_USER_HOME zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.3-all.zip
...@@ -5,10 +5,9 @@ pluginManagement { ...@@ -5,10 +5,9 @@ pluginManagement {
def flutterSdkPath = properties.getProperty("flutter.sdk") def flutterSdkPath = properties.getProperty("flutter.sdk")
assert flutterSdkPath != null, "flutter.sdk not set in local.properties" assert flutterSdkPath != null, "flutter.sdk not set in local.properties"
return flutterSdkPath return flutterSdkPath
} }()
settings.ext.flutterSdkPath = flutterSdkPath()
includeBuild("${settings.ext.flutterSdkPath}/packages/flutter_tools/gradle") includeBuild("$flutterSdkPath/packages/flutter_tools/gradle")
repositories { repositories {
google() google()
...@@ -19,8 +18,8 @@ pluginManagement { ...@@ -19,8 +18,8 @@ pluginManagement {
plugins { plugins {
id "dev.flutter.flutter-plugin-loader" version "1.0.0" id "dev.flutter.flutter-plugin-loader" version "1.0.0"
id "com.android.application" version "7.2.2" apply false id "com.android.application" version "8.1.0" apply false
id "org.jetbrains.kotlin.android" version "1.9.22" apply false id "org.jetbrains.kotlin.android" version "1.8.22" apply false
} }
include ":app" include ":app"
Improve build process, split packages per ABI.
Amélioration du processus de construction. Éclatement des packages par ABI.
...@@ -3,7 +3,7 @@ description: A puzzle game application. ...@@ -3,7 +3,7 @@ description: A puzzle game application.
publish_to: "none" publish_to: "none"
version: 0.1.1+63 version: 0.2.0+64
environment: environment:
sdk: "^3.0.0" sdk: "^3.0.0"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment