Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions build-config/resources/BalTool.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[tool]
id = "persist"

[[dependency]]
path = "../persist-cli/build/libs/persist-cli-@project.version@.jar"
8 changes: 8 additions & 0 deletions build-config/resources/Ballerina.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[package]
org = "ballerina"
name = "tool_persist"
version = "@toml.version@"
authors = ["Ballerina"]
keywords = ["persist", "persist tool"]
license = ["Apache-2.0"]
distribution = "2201.12.4"
46 changes: 20 additions & 26 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,11 @@
*/

plugins {
id 'java'
id 'jacoco'
id "com.github.spotbugs" version "${githubSpotbugsVersion}"
id "com.github.johnrengelman.shadow" version "${githubJohnrengelmanShadowVersion}"
id "de.undercouch.download" version "${underCouchDownloadVersion}"
id "net.researchgate.release" version "${researchgateReleaseVersion}"
id "com.github.spotbugs"
id "com.github.johnrengelman.shadow"
id "de.undercouch.download"
id "net.researchgate.release"
}

ext.testngVersion = project.testngVersion
Expand Down Expand Up @@ -61,16 +60,26 @@ allprojects {
url = 'https://mvnrepository.com/artifact/org.testng/testng'
}
}

ext {
snapshotVersion= '-SNAPSHOT'
timestampedVersionRegex = '.*-\\d{8}-\\d{6}-\\w.*\$'
}
}

subprojects {
apply plugin: 'java'
configurations {
externalJars
ballerinaStdLibs
jbalTools
}

dependencies {
/* JBallerina Tools */
jbalTools("org.ballerinalang:jballerina-tools:${ballerinaLangVersion}") {
transitive = false
}

ballerinaStdLibs "io.ballerina.stdlib:io-ballerina:${stdlibIoVersion}"
ballerinaStdLibs "io.ballerina.stdlib:time-ballerina:${stdlibTimeVersion}"
ballerinaStdLibs "io.ballerina.stdlib:sql-ballerina:${stdlibSqlVersion}"
Expand Down Expand Up @@ -112,6 +121,7 @@ def persistGoogleSheetsNativeVersion = "${persistGoogleSheetsNativeVersion}"
def persistRedisNativeVersion = "${persistRedisNativeVersion}"

release {
buildTasks = ['build']
versionPropertyFile = 'gradle.properties'
tagTemplate = 'v${version}'
git {
Expand All @@ -126,13 +136,8 @@ tasks.withType(JavaCompile) {
}

task codeCoverageReport(type: JacocoReport) {
dependsOn = subprojects.test

executionData fileTree(project.rootDir.absolutePath).include("**/build/coverage-reports/*.exec")

subprojects.each {
sourceSets it.sourceSets.main
}
reports {
xml.required = true
html.required = true
Expand All @@ -147,7 +152,7 @@ task codeCoverageReport(type: JacocoReport) {
}
}

task createProperties(dependsOn: processResources) {
task createProperties() {
doLast {
def file = new File("$project.rootDir/persist-cli/src/main/resources/version.properties")
file.withWriter('UTF-8') {
Expand All @@ -160,21 +165,10 @@ task createProperties(dependsOn: processResources) {
}
}

classes {
task build {
dependsOn createProperties
dependsOn(":persist-tool:build")
dependsOn(":examples:build")
}

task copyPersistTool(type: Copy) {
into "$project.rootDir/target"
into("ballerina-distribution/bre/lib") {
from "$project.rootDir/persist-cli/build/libs/persist-cli-${project.version}.jar"
}
}

copyPersistTool.dependsOn ":persist-cli-tests:build"
copyPersistTool.dependsOn ":persist-cli:build"

build.dependsOn copyPersistTool
build.dependsOn ":examples:build"

publish.dependsOn build
47 changes: 39 additions & 8 deletions examples/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ apply plugin: 'java'
description = 'Ballerina - Persist Examples'

def ballerinaDist = "${project.buildDir}/ballerina-distribution"
def tomlVersion = stripBallerinaExtensionVersion("${project.version}")
def balToolFile = new File("$project.projectDir/resources/bal-tools.toml")
def examples = ["medical-center", "rainier"]
def introspectionExamples = ["hospital", "hospital_unsupported"]
def redisDBExamples = ["social_media", "redis_cache"]
Expand All @@ -41,6 +43,20 @@ dependencies {
}
}

def stripBallerinaExtensionVersion(String extVersion) {
if (extVersion.matches(project.ext.timestampedVersionRegex)) {
def splitVersion = extVersion.split('-')
if (splitVersion.length > 3) {
def strippedValues = splitVersion[0..-4]
return strippedValues.join('-')
} else {
return extVersion
}
} else {
return extVersion.replace("${project.ext.snapshotVersion}", "")
}
}

task jBallerinaPack {
doLast {
configurations.balTools.resolvedConfiguration.resolvedArtifacts.each { artifact ->
Expand Down Expand Up @@ -105,16 +121,30 @@ task copyStdlibs() {
}
}

task copyPersistTool() {
dependsOn(copyStdlibs)
doLast() {
copy {
into "$project.buildDir"
into("ballerina-distribution/bre/lib") {
from "$project.rootDir/persist-cli/build/libs/persist-cli-${project.version}.jar"
}
task updateBalToolTomlFile {
doLast {
def newBallerinaToml = balToolFile.text.replace("@toml.version@", tomlVersion)
// Add new bal-tools.toml file to the ballerina-distribution/resources directory
def ballerinaTomlFile = new File("${ballerinaDist}/resources/bal-tools.toml")
// create new file if it does not exist
if (!ballerinaTomlFile.exists()) {
ballerinaTomlFile.getParentFile().mkdirs()
ballerinaTomlFile.createNewFile()
}
ballerinaTomlFile.text = newBallerinaToml
}
}

// copy bala files from persist-tool/build/bala_unzipped/bala to ballerina-distribution/repo/bala
task copyPersistTool(type: Copy) {
dependsOn(":persist-tool:build")
// copy bal-tools.toml file to ballerina-distribution/resources directory
dependsOn(updateBalToolTomlFile)
into ballerinaDist
into("repo/bala") {
from "${project.rootDir}/persist-tool/build/bala_unzipped/bala"
}
doNotTrackState("build needs to run every time")
}

task copyTestResources() {
Expand Down Expand Up @@ -598,6 +628,7 @@ task stopTestRedisContainer() {

copyPersistTool.dependsOn ":persist-cli-tests:build"
copyPersistTool.dependsOn ":persist-cli:build"
copyPersistTool.dependsOn ":persist-tool:build"
copyTestResources.dependsOn copyPersistTool

//generateIntrospectionExamples.dependsOn copyTestResources
Expand Down
6 changes: 6 additions & 0 deletions examples/resources/bal-tools.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[[tool]]
id = "persist"
org = "ballerina"
name = "tool_persist"
version = "@toml.version@"
active = true
5 changes: 3 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
org.gradle.caching=true
group=io.ballerina
version=1.6.1-SNAPSHOT
version=1.7.0-SNAPSHOT

#dependency versions
checkstylePluginVersion=10.12.1
Expand All @@ -11,12 +11,13 @@ underCouchDownloadVersion=5.4.0
researchgateReleaseVersion=2.8.0
testngVersion=7.6.1
jacocoVersion=0.8.10
ballerinaGradlePluginVersion=2.2.4

mySqlDriverVersion=8.0.29
mssqlDriverVersion=11.2.3.jre17
postgresqlDriverVersion=42.6.0

ballerinaLangVersion=2201.12.0
ballerinaLangVersion=2201.13.0-20250613-152200-ecef3657

# Level 01
stdlibIoVersion=1.8.0
Expand Down
51 changes: 43 additions & 8 deletions persist-cli-tests/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ description = 'Ballerina - persist-tools Tooling Test'

def buildDir = "build";
def ballerinaDist = "$project.buildDir/jballerina-tools-${ballerinaLangVersion}"
def tomlVersion = stripBallerinaExtensionVersion("${project.version}")
def balToolFile = new File("$project.projectDir/resources/bal-tools.toml")

configurations {
balTools
Expand All @@ -34,6 +36,20 @@ configurations {
}
}

def stripBallerinaExtensionVersion(String extVersion) {
if (extVersion.matches(project.ext.timestampedVersionRegex)) {
def splitVersion = extVersion.split('-')
if (splitVersion.length > 3) {
def strippedValues = splitVersion[0..-4]
return strippedValues.join('-')
} else {
return extVersion
}
} else {
return extVersion.replace("${project.ext.snapshotVersion}", "")
}
}

dependencies {
checkstyle project(':checkstyle')
checkstyle "com.puppycrawl.tools:checkstyle:${checkstylePluginVersion}"
Expand Down Expand Up @@ -123,7 +139,6 @@ task copyStdlibs() {
doLast {
configurations.ballerinaStdLibs.resolvedConfiguration.resolvedArtifacts.each { artifact ->
def artifactExtractedPath = "${project.buildDir}/extracted-stdlibs/" + artifact.name + "-zip"
def persistCliJar = "${project.rootDir}/persist-cli/build/libs/persist-cli-${project.version}.jar"
copy {
into ballerinaDist
into("repo/bala") {
Expand All @@ -143,13 +158,6 @@ task copyStdlibs() {
from "${artifactExtractedPath}/cache"
}
}
copy {
def testDistribution = "${project.rootDir}/persist-cli-tests/build/ballerina-distribution"
into testDistribution
into("bre/lib") {
from "${persistCliJar}"
}
}
}
}
}
Expand All @@ -166,9 +174,36 @@ task copyTestResources(type: Copy) {
doNotTrackState("build needs to run every time")
}

task updateBalToolTomlFile {
doLast {
def newBallerinaToml = balToolFile.text.replace("@toml.version@", tomlVersion)
// Add new bal-tools.toml file to the ballerina-distribution/resources directory
def ballerinaTomlFile = new File("${ballerinaDist}/resources/bal-tools.toml")
// create new file if it does not exist
if (!ballerinaTomlFile.exists()) {
ballerinaTomlFile.getParentFile().mkdirs()
ballerinaTomlFile.createNewFile()
}
ballerinaTomlFile.text = newBallerinaToml
}
}

// copy bala files from persist-tool/build/bala_unzipped/bala to ballerina-distribution/repo/bala
task copyPersistTool(type: Copy) {
dependsOn(":persist-tool:build")
// copy bal-tools.toml file to ballerina-distribution/resources directory
dependsOn(updateBalToolTomlFile)
into ballerinaDist
into("repo/bala") {
from "${project.rootDir}/persist-tool/build/bala_unzipped/bala"
}
doNotTrackState("build needs to run every time")
}

task copyTestPack(type: Copy) {
dependsOn(copyStdlibs)
dependsOn(copyTestResources)
dependsOn(copyPersistTool)
into buildDir
into("ballerina-distribution/") {
from ballerinaDist
Expand Down
6 changes: 6 additions & 0 deletions persist-cli-tests/resources/bal-tools.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[[tool]]
id = "persist"
org = "ballerina"
name = "tool_persist"
version = "@toml.version@"
active = true
5 changes: 5 additions & 0 deletions persist-cli/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,11 @@ compileJava {
}
}

manifest {
attributes('Implementation-Title': project.name,
'Implementation-Version': project.version)
}

task createArtifactZip(type: Zip) {
dependsOn build
from 'build/libs/'
Expand Down
5 changes: 5 additions & 0 deletions persist-tool/BalTool.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[tool]
id = "persist"

[[dependency]]
path = "../persist-cli/build/libs/persist-cli-1.7.0-SNAPSHOT.jar"
8 changes: 8 additions & 0 deletions persist-tool/Ballerina.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[package]
org = "ballerina"
name = "tool_persist"
version = "1.7.0"
authors = ["Ballerina"]
keywords = ["persist", "persist tool"]
license = ["Apache-2.0"]
distribution = "2201.12.4"
17 changes: 17 additions & 0 deletions persist-tool/Dependencies.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# AUTO-GENERATED FILE. DO NOT MODIFY.

# This file is auto-generated by Ballerina for managing dependency versions.
# It should not be modified by hand.

[ballerina]
dependencies-toml-version = "2"
distribution-version = "2201.13.0-20250613-152200-ecef3657"

[[package]]
org = "ballerina"
name = "tool_persist"
version = "1.7.0"
modules = [
{org = "ballerina", packageName = "tool_persist", moduleName = "tool_persist"}
]

Loading