Flutter依賴的文件(Flutter產(chǎn)物)
echo 'Clean old build'find . -d -name 'build' | xargs rm -rf./flutter/bin/flutter cleanecho 'Get packages'./flutter/bin/flutter packages getecho 'Build release AOT'./flutter/bin/flutter build aot --release --preview-dart-2 --output-dir=build/flutteroutput/aotecho 'Build release Bundle'./flutter/bin/flutter build bundle --precompiled --preview-dart-2 --asset-dir=build/flutteroutput/flutter_assets
project.android.buildTypes.each { addFlutterJarImplementationDependency(project, releaseFlutterJar)}project.android.buildTypes.whenObjectAdded { addFlutterJarImplementationDependency(project, releaseFlutterJar)}private static void addFlutterJarImplementationDependency(Project project, releaseFlutterJar) { project.dependencies { String configuration if (project.getConfigurations().findByName('implementation')) { configuration = 'implementation' } else { configuration = 'compile' } add(configuration, project.files { releaseFlutterJar }) }}
// merge flutter assetsdef allertAsset ='${project.projectDir.getAbsolutePath()}/flutter/assets/release'Task mergeFlutterAssets = project.tasks.create(name: 'mergeFlutterAssets${variant.name.capitalize()}', type: Copy) { dependsOn mergeFlutterMD5Assets from (allertAsset){ include 'flutter_assets/**' // the working dir and its files include 'vm_snapshot_data' include 'vm_snapshot_instr' include 'isolate_snapshot_data' include 'isolate_snapshot_instr' } into variant.mergeAssets.outputDir}variant.outputs[0].processResources.dependsOn(mergeFlutterAssets)
echo 'Clean packflutter input(flutter build)'rm -f -r android/packflutter/flutter/# 拷貝flutter.jarecho 'Copy flutter jar'mkdir -p android/packflutter/flutter/flutter/android-arm-release && cp flutter/bin/cache/artifacts/engine/android-arm-release/flutter.jar '$_'# 拷貝assetecho 'Copy flutter asset'mkdir -p android/packflutter/flutter/assets/release && cp -r build/flutteroutput/aot/* '$_'mkdir -p android/packflutter/flutter/assets/release/flutter_assets && cp -r build/flutteroutput/flutter_assets/* '$_'# 將flutter庫(kù)和flutter_app打成aar 同時(shí)publish到Ali-mavenecho 'Build and publish idlefish flutter to aar'cd androidif [ -n '$1' ]then ./gradlew :packflutter:clean :packflutter:publish -PAAR_VERSION=$1else ./gradlew :packflutter:clean :packflutter:publishficd ../
# 將plugin發(fā)布到Ali-mavenecho 'Start publish flutter-plugins'for line in $(cat .flutter-plugins)do plugin_name=${line%%=*} echo 'Build and publish plugin:' ${plugin_name} cd android if [ -n '$1' ] then ./gradlew :${plugin_name}:clean :${plugin_name}:publish -PAAR_VERSION=$1 else ./gradlew :${plugin_name}:clean :${plugin_name}:publish fi cd ../done
configurations.all { resolutionStrategy.cacheChangingModulesFor 0, 'seconds'}ext { flutter_aar_version = '6.0.2-SNAPSHOT'}dependencies { //flutter主工程依賴:包含基于flutter開發(fā)的功能、flutter引擎lib compile('com.taobao.fleamarket:IdleFishFlutter:${getFlutterAarVersion(project)}') { changing = true } //...其他依賴}static def getFlutterAarVersion(project) { def resultVersion = project.flutter_aar_version if (project.hasProperty('FLUTTER_AAR_VERSION')) { resultVersion = project.FLUTTER_AAR_VERSION } return resultVersion}
echo '===清理flutter歷史編譯==='./flutter/bin/flutter cleanecho '===重新生成plugin索引==='./flutter/bin/flutter packages getecho '===生成App.framework和flutter_assets==='./flutter/bin/flutter build ios --release
echo '===生成各個(gè)plugin的二進(jìn)制庫(kù)文件==='cd ios/Pods#/usr/bin/env xcrun xcodebuild clean#/usr/bin/env xcrun xcodebuild build -configuration Release ARCHS='arm64 armv7' BUILD_AOT_ONLY=YES VERBOSE_SCRIPT_LOGGING=YES -workspace Runner.xcworkspace -scheme Runner BUILD_DIR=../build/ios -sdk iphoneosfor plugin_name in ${plugin_arr}do echo '生成lib${plugin_name}.a...' /usr/bin/env xcrun xcodebuild build -configuration Release ARCHS='arm64 armv7' -target ${plugin_name} BUILD_DIR=../../build/ios -sdk iphoneos -quiet /usr/bin/env xcrun xcodebuild build -configuration Debug ARCHS='x86_64' -target ${plugin_name} BUILD_DIR=../../build/ios -sdk iphonesimulator -quiet echo '合并lib${plugin_name}.a...' lipo -create '../../build/ios/Debug-iphonesimulator/${plugin_name}/lib${plugin_name}.a' '../../build/ios/Release-iphoneos/${plugin_name}/lib${plugin_name}.a' -o '../../build/ios/Release-iphoneos/${plugin_name}/lib${plugin_name}.a'doneecho '===生成注冊(cè)入口的二進(jìn)制庫(kù)文件==='for reg_enter_name in 'flutter_plugin_entrance' 'flutter_service_register'do echo '生成lib${reg_enter_name}.a...' /usr/bin/env xcrun xcodebuild build -configuration Release ARCHS='arm64 armv7' -target ${reg_enter_name} BUILD_DIR=../../build/ios -sdk iphoneos /usr/bin/env xcrun xcodebuild build -configuration Debug ARCHS='x86_64' -target ${reg_enter_name} BUILD_DIR=../../build/ios -sdk iphonesimulator echo '合并lib${reg_enter_name}.a...' lipo -create '../../build/ios/Debug-iphonesimulator/${reg_enter_name}/lib${reg_enter_name}.a' '../../build/ios/Release-iphoneos/${reg_enter_name}/lib${reg_enter_name}.a' -o '../../build/ios/Release-iphoneos/${reg_enter_name}/lib${reg_enter_name}.a'done
Standalone模式下構(gòu)建流程
聯(lián)系客服