Search code examples
shellbuild.gradlereact-nativebuild-toolsbitrise

Edit build.gradle through bitrise workflow


I have to normalize the build tool versions of the imported dependencies in react-native android part before run the project.

The solution that I came up with is adding following snippet to the root build.gradle,

subprojects {
    ...
    afterEvaluate { subproject ->
        if ((subproject.plugins.hasPlugin('android') || 
            subproject.plugins.hasPlugin('android-library'))) {
            android {
                buildToolsVersion "26.0.2"
            }
        }
    }

}

Rather than adding this manually, I need to edit this build.gradle and add the snippet through a script or shell command. This has to be done using bitrise.

Any suggestions?


Solution

  • Figured out myself. Can use file overwrite mechanism, for example in my case used 'Change value in file' step to overwrite the build.gradle easily.

    Step  1

    Step 2