Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 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"
51 changes: 25 additions & 26 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,15 @@
*/

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"
}

def packageName = "persist"

ext.testngVersion = project.testngVersion

allprojects {
Expand Down Expand Up @@ -61,16 +62,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 +123,7 @@ def persistGoogleSheetsNativeVersion = "${persistGoogleSheetsNativeVersion}"
def persistRedisNativeVersion = "${persistRedisNativeVersion}"

release {
buildTasks = ['build']
versionPropertyFile = 'gradle.properties'
tagTemplate = 'v${version}'
git {
Expand All @@ -126,13 +138,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 +154,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 +167,13 @@ task createProperties(dependsOn: processResources) {
}
}

classes {
dependsOn createProperties
}
//classes {
// dependsOn createProperties
//}

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"
}
task build {
dependsOn(":${packageName}-tool:build")
dependsOn(":examples:build")
}

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

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

publish.dependsOn build
3 changes: 2 additions & 1 deletion 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,6 +11,7 @@ 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
Expand Down
11 changes: 3 additions & 8 deletions persist-cli-tests/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,7 @@ description = 'Ballerina - persist-tools Tooling Test'
def buildDir = "build";
def ballerinaDist = "$project.buildDir/jballerina-tools-${ballerinaLangVersion}"

configurations {
balTools
dist {
transitive true
}
}
def packageName = "persist"

dependencies {
checkstyle project(':checkstyle')
Expand All @@ -42,7 +37,7 @@ dependencies {
testImplementation "org.ballerinalang:ballerina-cli:${ballerinaLangVersion}"
testImplementation group: 'info.picocli', name: 'picocli', version: '4.7.1'

balTools ("org.ballerinalang:jballerina-tools:${ballerinaLangVersion}") {
jbalTools ("org.ballerinalang:jballerina-tools:${ballerinaLangVersion}") {
transitive = false
}

Expand All @@ -67,7 +62,7 @@ clean {

task jBallerinaPack {
doLast {
configurations.balTools.resolvedConfiguration.resolvedArtifacts.each { artifact ->
configurations.jbalTools.resolvedConfiguration.resolvedArtifacts.each { artifact ->
copy {
from project.zipTree(artifact.getFile())
into new File("${project.buildDir}")
Expand Down
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
8 changes: 8 additions & 0 deletions persist-tool/.devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"image": "ballerina/ballerina-devcontainer:2201.12.4",
"customizations": {
"vscode": {
"extensions": ["WSO2.ballerina"]
}
}
}
11 changes: 11 additions & 0 deletions persist-tool/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Ballerina generates this directory during the compilation of a package.
# It contains compiler-generated artifacts and the final executable if this is an application package.
target/

# Ballerina maintains the compiler-generated source code here.
# Remove this if you want to commit generated sources.
generated/

# Contains configuration values used during development time.
# See https://ballerina.io/learn/provide-values-to-configurable-variables/ for more details.
Config.toml
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.12.0"

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

2 changes: 2 additions & 0 deletions persist-tool/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Ballerina Persist-Tools
===================
106 changes: 106 additions & 0 deletions persist-tool/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
/*
* Copyright (c) 2025, WSO2 LLC. (http://www.wso2.org).
*
* WSO2 LLC. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/

import org.apache.tools.ant.taskdefs.condition.Os

plugins {
id 'io.ballerina.plugin'
}

description = 'Ballerina - Persist Tool'

def packageName = "tool_persist"
def packageOrg = "ballerina"
def tomlVersion = stripBallerinaExtensionVersion("${project.version}")
def ballerinaTomlFilePlaceHolder = new File("${project.rootDir}/build-config/resources/Ballerina.toml")
def balToolTomlFilePlaceHolder = new File("${project.rootDir}/build-config/resources/BalTool.toml")
def ballerinaTomlFile = new File("$project.projectDir/Ballerina.toml")
def balToolTomlFile = new File("$project.projectDir/BalTool.toml")

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}", "")
}
}

ballerina {
packageOrganization = packageOrg
module = packageName
langVersion = ballerinaLangVersion
platform = "java21"
}

task updateTomlFiles {
doLast {
def newBallerinaToml = ballerinaTomlFilePlaceHolder.text.replace("@toml.version@", tomlVersion)
ballerinaTomlFile.text = newBallerinaToml

def newBalToolTomlFile = balToolTomlFilePlaceHolder.text.replace("@project.version@", project.version)
balToolTomlFile.text = newBalToolTomlFile
}
}

task commitTomlFiles {
doLast {
project.exec {
ignoreExitValue true
if (Os.isFamily(Os.FAMILY_WINDOWS)) {
commandLine 'cmd', '/c', "git commit -m \"[Automated] Update the native jar versions\" Ballerina.toml Dependencies.toml BalTool.toml"
} else {
commandLine 'sh', '-c', "git commit -m '[Automated] Update the native jar versions' Ballerina.toml Dependencies.toml BalTool.toml"
}
}
}
}

publishing {
publications {
maven(MavenPublication) {
artifact source: createArtifactZip, extension: 'zip'
}
}
repositories {
maven {
name = "GitHubPackages"
url = uri("https://maven.pkg.github.com/ballerina-platform/persist-tools")
credentials {
username = System.getenv("packageUser")
password = System.getenv("packagePAT")
}
}
}
}

updateTomlFiles.dependsOn copyStdlibs

build.dependsOn updateTomlFiles
build.dependsOn "generatePomFileForMavenPublication"
build.dependsOn ":persist-cli:build"
build.dependsOn ":persist-cli-tests:build"

publishToMavenLocal.dependsOn build
publish.dependsOn build
15 changes: 15 additions & 0 deletions persist-tool/persist_tool.bal
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// Copyright (c) 2025 WSO2 LLC. (http://www.wso2.org).
//
// WSO2 LLC. licenses this file to you under the Apache License,
// Version 2.0 (the "License"); you may not use this file except
// in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
Loading
Loading