0

私はcms-appを持っています。このアプリは約200モジュールを超えています。すべてのモジュールをロードすると、CPU 100%。 PCは非常に遅いです。私はsettings.gradleを変更し、必要なモジュールをロードする。チェンジを変更するときの自動設定.gradle

ビルドバリアントごとにsettings.gradleを変更します。

sample gradle。

android { 
defaultConfig { 
    applicationId "org.myorg.cmsapp" 
    minSdkVersion 16 
    targetSdkVersion 23 
    versionCode 1 
    versionName "1.0" 
    manifestPlaceholders = [ MAPS_API_KEY: "123123123123123" ] 
} 
productFlavors { 
    appA { 
     applicationId "org.myorg.cmsapp" 
     versionName "1.32" 
     versionCode 22 
     manifestPlaceholders = [ MAPS_API_KEY: "12312312" ] 
    } 
    appB { 
     applicationId "ir.myweb.aaa" 
     versionName "1.3" 
     versionCode 3 
     manifestPlaceholders = [ MAPS_API_KEY: "12312312" ] 
    } 
    appC { 
     applicationId "com.mytw.bbb" 
     versionName "1.12" 
     versionCode 18 
     manifestPlaceholders = [ MAPS_API_KEY: "12312312" ] 
    } 
} 
signingConfigs { 
    appA { 
     storeFile file('../keys/appA.jks') 
     keyAlias "appA" 
     storePassword "app123!!#A" 
     keyPassword "[email protected]#A" 
    } 
    appB { 
     storeFile file('../keys/appB.jks') 
     keyAlias "appB" 
     storePassword "appB#[email protected]#12312" 
     keyPassword "ap!#[email protected]" 
    } 
    appC { 
     storeFile file('../keys/appC.jks') 
     keyAlias "appC" 
     storePassword "[email protected]#appC\$" 
     keyPassword "[email protected]#appC\$" 
    } 
} 
buildTypes { 
    release { 
     minifyEnabled true 
     proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 
     productFlavors.appA.signingConfig signingConfigs.appA 
     productFlavors.appB.signingConfig signingConfigs.appB 
     productFlavors.appC.signingConfig signingConfigs.appC 
    } 
} 
} 


dependencies { 
    compile fileTree(include: ['*.jar'], dir: 'libs') 

    appACompile project(path: ':librarysplashscreenone') 
    appACompile project(path: ':libraryhomepageeight', configuration: 'appARelease') 
    appACompile project(path: ':librarycmspagestest', configuration: 'appARelease') 

// appBtCompile project(path: ':librarysplashscreentwo') 
// appBtCompile project(path: ':libraryhomepageeight', configuration: 'appBtRelease') 
// appBtCompile project(path: ':librarycmspagesdefault', configuration: 'appBtRelease') 

// appCCompile project(path: ':librarysplashscreenthree') 
// appCCompile project(path: ':libraryhomepagesix', configuration: 'appCRelease') 
// appCCompile project(path: ':librarycmspagesdefault', configuration: 'appCRelease') 
} 

このタスクを追加すると、ビルドバリアントが変更され、settings.gradleアプリがmain settings.gradleに置き換えられます。

task chackLoadedModule(type:Exec) { 
println " change ... " 
workingDir '../all_module' 

commandLine 'cmd', '/c', 'generator.bat' , getCurrentFlavor() 

    standardOutput = new ByteArrayOutputStream() 

ext.output = { 
    return standardOutput.toString() 
} 
} 

dependencies { 
    preBuild.dependsOn chackLoadedModule 
    ..... 

この解決策は良くありません。 私はビルドバリアントを変更すると、コメントを外してコメントを付ける必要があります。 、何度か働いていません。

答えて

0

私は依存関係の問題を解決しました。しかし、私は問題のロードモジュールを持っています。

dependencies { 
compile fileTree(include: ['*.jar'], dir: 'libs') 

String currentFlavors = getCurrentFlavor(); 

if (currentFlavors == "appA") { 
    appACompile project(path: ':librarysplashscreenone') 
    appACompile project(path: ':libraryhomepageeight', configuration: 'appARelease') 
    appACompile project(path: ':librarycmspagestest', configuration: 'appARelease') 
} 

if (currentFlavors == "appB") { 
    appBtCompile project(path: ':librarysplashscreentwo') 
    appBtCompile project(path: ':libraryhomepageeight', configuration: 'appBtRelease') 
    appBtCompile project(path: ':librarycmspagesdefault', configuration: 'appBtRelease') 
} 

if (currentFlavors == "appC") { 
    appCCompile project(path: ':librarysplashscreenthree') 
    appCCompile project(path: ':libraryhomepagesix', configuration: 'appCRelease') 
    appCCompile project(path: ':librarycmspagesdefault', configuration: 'appCRelease') 
} 
} 

def getCurrentFlavor() { 
    Gradle gradle = getGradle() 
    String tskReqStr = gradle.getStartParameter().getTaskRequests().toString() 
Pattern pattern; 

if(tskReqStr.contains("assemble")) 
    pattern = Pattern.compile("assemble(\\w+)(Release|Debug)") 
else 
    pattern = Pattern.compile("generate(\\w+)(Release|Debug)") 

Matcher matcher = pattern.matcher(tskReqStr) 

if(matcher.find()) 
    return matcher.group(1).toLowerCase() 
else 
{ 
    println "NO MATCH FOUND" 
    return ""; 
} 
} 
関連する問題