1414 * limitations under the License.
1515 *
1616 */
17+
18+ import org.apache.tools.ant.taskdefs.condition.Os
19+
1720buildscript {
1821 repositories {
1922 maven {
@@ -34,8 +37,8 @@ description = 'Ballerina - Regex Ballerina Generator'
3437def packageName = " regex"
3538def packageOrg = " ballerina"
3639def tomlVersion = stripBallerinaExtensionVersion(" ${ project.version} " )
37- def ballerinaConfigFile = new File (" $project . projectDir /Ballerina.toml" )
38- def originalConfig = ballerinaConfigFile . text
40+ def ballerinaTomlFilePlaceHolder = new File (" ${ project.rootDir } /build-config/resources /Ballerina.toml" )
41+ def ballerinaTomlFile = new File ( " $p roject . projectDir /Ballerina.toml " )
3942
4043def stripBallerinaExtensionVersion (String extVersion ) {
4144 if (extVersion. matches(project. ext. timestampedVersionRegex)) {
@@ -62,15 +65,22 @@ ballerina {
6265
6366task updateTomlFiles {
6467 doLast {
65- def newConfig = ballerinaConfigFile . text. replace(" @project.version@" , project. version)
68+ def newConfig = ballerinaTomlFilePlaceHolder . text. replace(" @project.version@" , project. version)
6669 newConfig = newConfig. replace(" @toml.version@" , tomlVersion)
67- ballerinaConfigFile . text = newConfig
70+ ballerinaTomlFile . text = newConfig
6871 }
6972}
7073
71- task revertTomlFiles {
74+ task commitTomlFiles {
7275 doLast {
73- ballerinaConfigFile. text = originalConfig
76+ project. exec {
77+ ignoreExitValue true
78+ if (Os . isFamily(Os . FAMILY_WINDOWS )) {
79+ commandLine ' cmd' , ' /c' , " git commit Ballerina.toml Dependencies.toml -m \" [Automated] Update the native jar versions\" "
80+ } else {
81+ commandLine ' sh' , ' -c' , " git commit Ballerina.toml Dependencies.toml -m '[Automated] Update the native jar versions'"
82+ }
83+ }
7484 }
7585}
7686
0 commit comments