Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
449 views
in Technique[技术] by (71.8m points)

bash - 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 {...}
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...