Skip to content

Commit

Permalink
Extract add h2 dependency logic
Browse files Browse the repository at this point in the history
Introduces a new function, `addH2Dependency`, to the build.gradle script. This function is responsible for appending the H2 database dependency details to the Ballerina TOML file.
  • Loading branch information
dsplayerX committed Mar 22, 2024
1 parent 49e303a commit 763a9a4
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions ballerina/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -1082,6 +1082,15 @@ task testExamples() {
}
}

def addH2Dependency = { filePath ->
// Add the H2 database dependency to Ballerina.toml file
def tomlFile = new File(filePath)
tomlFile.append("\n\n[[platform.java17.dependency]]")
tomlFile.append("\nartifactId = \"h2\"")
tomlFile.append("\nversion = \"2.2.224\"")
tomlFile.append("\ngroupId = \"com.h2database\"")
}

def buildAndTestStandardLibs = { distPath, stdlibTest, isStageTest, testMinorVersionDifference ->
def exitVal
def additionalBuildParams = ""
Expand All @@ -1102,11 +1111,7 @@ def buildAndTestStandardLibs = { distPath, stdlibTest, isStageTest, testMinorVer
commandLine 'cmd', '/c', "${distPath}/bin/bal.bat init test"
}
if (stdlibTest == 'transaction') {
def tomlFile = new File("${distPath}/${stdlibTest}/Ballerina.toml")
tomlFile.append("\n\n[[platform.java17.dependency]]")
tomlFile.append("\nartifactId = \"h2\"")
tomlFile.append("\nversion = \"2.2.224\"")
tomlFile.append("\ngroupId = \"com.h2database\"")
addH2Dependency("${distPath}/${stdlibTest}/Ballerina.toml")
}
} else {
exec {
Expand All @@ -1132,11 +1137,7 @@ def buildAndTestStandardLibs = { distPath, stdlibTest, isStageTest, testMinorVer
commandLine 'sh', '-c', "${distPath}/bin/bal init test"
}
if (stdlibTest == 'transaction') {
def tomlFile = new File("${distPath}/${stdlibTest}/Ballerina.toml")
tomlFile.append("\n\n[[platform.java17.dependency]]")
tomlFile.append("\nartifactId = \"h2\"")
tomlFile.append("\nversion = \"2.2.224\"")
tomlFile.append("\ngroupId = \"com.h2database\"")
addH2Dependency("${distPath}/${stdlibTest}/Ballerina.toml")
}
} else {
exec {
Expand Down

0 comments on commit 763a9a4

Please sign in to comment.