小编典典

在Android Gradle中执行Shell脚本

jenkins

我想运行一个shell脚本来在构建我的应用程序时更改string.xml中的值。我应该在哪里在gradle中运行脚本,因为其中没有任务。或者,因为我将使用Jenkins构建应用程序,所以我应该在Jenkins服务器上运行脚本吗?请帮帮我。

    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 {...}

阅读 936

收藏
2020-07-25

共1个答案

小编典典

您可以添加一个preBuild运行脚本并使其依赖于构建的步骤。

task myPreBuild << {
   commandLine './script.sh'
}
build.dependsOn myPreBuild
2020-07-25