简体   繁体   中英

Execute shell script in android gradle

I want to run a shell script to change the value in string.xml when my app is built. Where should I run my script in gradle, since there is no task in it. Or, because I will build the app use Jenkins, should I run the script on Jenkins server? Please help me out.

    apply plugin: 'com.android.application'

 android {
     compileSdkVersion 22
     buildToolsVersion '22.0.1'
     }

defaultConfig {
   .......
     }

buildTypes {
    release {
      .......
       }
     }

productFlavors {
    development {}
    production {}
     }

sourceSets {
    androidTest {
        setRoot('src/test')
              }
     }

packagingOptions {..}


dependencies {...}

You can add a preBuild step that runs the script and makes it depend on build.

task myPreBuild << {
   commandLine './script.sh'
}
build.dependsOn myPreBuild

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM