Skip to content

Commit 3a7e9b6

Browse files
authored
Merge pull request #11 from ThishaniLucas/dev
Enable publishing to b7a central
2 parents 3e966b7 + 3b7c1f0 commit 3a7e9b6

File tree

6 files changed

+61
-65
lines changed

6 files changed

+61
-65
lines changed

.github/workflows/publish-release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
with:
1818
java-version: 11
1919
- name: Set version env variable
20-
run: echo "VERSION=$((grep -w 'version' | cut -d= -f2) < gradle.properties | cut -d- -f1)" >> $GITHUB_ENV
20+
run: echo "VERSION=$((grep -w 'version' | cut -d= -f2) < gradle.properties | rev | cut --complement -d- -f1 | rev)" >> $GITHUB_ENV
2121
- name : Pre release depenency version update
2222
env:
2323
GITHUB_TOKEN: ${{ secrets.BALLERINA_BOT_TOKEN }}

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ It has support for regex functionalities like checking whether a string matches
1414

1515
The **Issues** and **Projects** tabs are disabled for this repository as this is part of the Ballerina Standard Library. To report bugs, request new features, start new discussions, view project boards, etc., go to the Ballerina Standard Library [parent repository](https://github.com/ballerina-platform/ballerina-standard-library).
1616

17-
This repository contains only the source code of the module.
17+
This repository contains only the source code of the package.
1818

1919
## Building from the Source
2020

@@ -40,15 +40,15 @@ Execute the commands below to build from source.
4040

4141
./gradlew clean test
4242

43-
3. To build the module without the tests:
43+
3. To build the package without the tests:
4444

4545
./gradlew clean build -x test
4646

4747
4. To debug the tests:
4848

4949
./gradlew clean build -Pdebug=<port>
5050
51-
5. To debug the module with Ballerina language:
51+
5. To debug the package with Ballerina language:
5252

5353
./gradlew clean build -PbalJavaDebug=<port>
5454

build.gradle

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -83,24 +83,3 @@ release {
8383
task build {
8484
dependsOn('regex-ballerina:build')
8585
}
86-
87-
task codeCoverageReport(type: JacocoReport) {
88-
executionData fileTree(project.rootDir.absolutePath).include("**/build/coverage-reports/*.exec")
89-
90-
subprojects.each {
91-
sourceSets it.sourceSets.main
92-
}
93-
94-
reports {
95-
xml.enabled = true
96-
html.enabled = true
97-
csv.enabled = true
98-
xml.destination = new File("${buildDir}/reports/jacoco/report.xml")
99-
html.destination = new File("${buildDir}/reports/jacoco/report.html")
100-
csv.destination = new File("${buildDir}/reports/jacoco/report.csv")
101-
}
102-
103-
onlyIf = {
104-
true
105-
}
106-
}

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
org.gradle.caching=true
22
group=org.ballerinalang
3-
version=0.6.2-SNAPSHOT
3+
version=0.7.0-alpha2-SNAPSHOT
44
ballerinaLangVersion=2.0.0-alpha3-SNAPSHOT

regex-ballerina/Package.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
## Module overview
1+
## Package overview
22

3-
This module provides the following regex utility functions.
3+
This package provides the following regex utility functions.
44

55
* `matches` - Checks whether a string matches a given regex.
66
* `replaceAll` - Replaces every occurrence of a substring that matches a given regex in a string, with another string provided.

regex-ballerina/build.gradle

Lines changed: 54 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,20 @@ import org.apache.tools.ant.taskdefs.condition.Os
1919

2020
description = 'Ballerina - Regex Ballerina Generator'
2121

22+
def packageName = "regex"
23+
def packageOrg = "ballerina"
24+
def snapshotVersion = "-SNAPSHOT"
25+
def tomlVersion = project.version.replace("${snapshotVersion}", "")
26+
def ballerinaConfigFile = new File("$project.projectDir/Ballerina.toml")
27+
def artifactBallerinaDocs = file("$project.projectDir/build/docs_parent/")
28+
def artifactCacheParent = file("$project.projectDir/build/cache_parent/")
29+
def artifactLibParent = file("$project.projectDir/build/lib_parent/")
30+
def artifactCodeCoverageReport = file("$project.projectDir/target/cache/tests_cache/coverage/ballerina.exec")
31+
def artifactTestableJar = file("$project.projectDir/target/cache/${packageOrg}/${packageName}/${tomlVersion}/java11/")
32+
def ballerinaCentralAccessToken = System.getenv('BALLERINA_CENTRAL_ACCESS_TOKEN')
33+
def originalConfig = ballerinaConfigFile.text
34+
def distributionBinPath = project.projectDir.absolutePath + "/build/target/extracted-distributions/jballerina-tools-zip/jballerina-tools-${ballerinaLangVersion}/bin"
35+
2236
configurations {
2337
jbalTools
2438
}
@@ -47,18 +61,6 @@ task unpackJballerinaTools(type: Copy) {
4761
}
4862
}
4963

50-
def packageName = "regex"
51-
def packageOrg = "ballerina"
52-
def ballerinaConfigFile = new File("$project.projectDir/Ballerina.toml")
53-
def artifactBallerinaDocs = file("$project.projectDir/build/docs_parent/")
54-
def artifactCacheParent = file("$project.projectDir/build/cache_parent/")
55-
def artifactLibParent = file("$project.projectDir/build/lib_parent/")
56-
def artifactCodeCoverageReport = file("$project.projectDir/target/cache/tests_cache/coverage/ballerina.exec")
57-
def tomlVersion = project.version.split("-")[0]
58-
def ballerinaCentralAccessToken = System.getenv('BALLERINA_CENTRAL_ACCESS_TOKEN')
59-
def originalConfig = ballerinaConfigFile.text
60-
def distributionBinPath = project.projectDir.absolutePath + "/build/target/extracted-distributions/jballerina-tools-zip/jballerina-tools-${ballerinaLangVersion}/bin"
61-
6264
task updateTomlVersions {
6365
doLast {
6466
def newConfig = ballerinaConfigFile.text.replace("@project.version@", project.version)
@@ -75,6 +77,7 @@ task revertTomlFile {
7577

7678
def debugParams = ""
7779
def balJavaDebugParam = ""
80+
def testParams = ""
7881

7982
task initializeVariables {
8083
if (project.hasProperty("debug")) {
@@ -83,6 +86,24 @@ task initializeVariables {
8386
if (project.hasProperty("balJavaDebug")) {
8487
balJavaDebugParam = "BAL_JAVA_DEBUG=${project.findProperty("balJavaDebug")}"
8588
}
89+
90+
gradle.taskGraph.whenReady { graph ->
91+
if (graph.hasTask(":${packageName}-ballerina:build") || graph.hasTask(":${packageName}-ballerina:publish")) {
92+
ballerinaTest.enabled = false
93+
}
94+
95+
if (graph.hasTask(":${packageName}-ballerina:test")) {
96+
testParams = "--code-coverage --includes=*"
97+
} else {
98+
testParams = "--skip-tests"
99+
}
100+
101+
if (graph.hasTask(":${packageName}-ballerina:publish")) {
102+
ballerinaPublish.enabled = true
103+
} else {
104+
ballerinaPublish.enabled = false
105+
}
106+
}
86107
}
87108

88109
task ballerinaTest {
@@ -114,16 +135,6 @@ task ballerinaBuild {
114135
dependsOn(initializeVariables)
115136
finalizedBy(revertTomlFile)
116137

117-
def testParams = "--skip-tests"
118-
gradle.taskGraph.whenReady { graph ->
119-
if (graph.hasTask(':regex-ballerina:build') || graph.hasTask(':regex-ballerina:publish')) {
120-
ballerinaTest.enabled = false
121-
}
122-
if (graph.hasTask(':regex-ballerina:test')) {
123-
testParams = "--code-coverage --includes=*"
124-
}
125-
}
126-
127138
doLast {
128139
// Build and populate caches
129140
exec {
@@ -146,20 +157,6 @@ task ballerinaBuild {
146157
into file("$artifactCacheParent/cache/")
147158
}
148159

149-
// Publish to central
150-
if (!project.version.endsWith('-SNAPSHOT') && ballerinaCentralAccessToken != null && project.hasProperty("publishToCentral")) {
151-
println("Publishing to the ballerina central..")
152-
exec {
153-
workingDir project.projectDir
154-
environment "JAVA_OPTS", "-DBALLERINA_DEV_COMPILE_BALLERINA_ORG=true"
155-
if (Os.isFamily(Os.FAMILY_WINDOWS)) {
156-
commandLine 'cmd', '/c', "$distributionBinPath/bal.bat push && exit %%ERRORLEVEL%%"
157-
} else {
158-
commandLine 'sh', '-c', "$distributionBinPath/bal push"
159-
}
160-
}
161-
162-
}
163160
// Doc creation and packing
164161
exec {
165162
workingDir project.projectDir
@@ -181,6 +178,23 @@ task ballerinaBuild {
181178
outputs.dir artifactLibParent
182179
}
183180

181+
task ballerinaPublish {
182+
doLast {
183+
if (ballerinaCentralAccessToken != null) {
184+
println("Publishing to the ballerina central...")
185+
exec {
186+
workingDir project.projectDir
187+
environment "JAVA_OPTS", "-DBALLERINA_DEV_COMPILE_BALLERINA_ORG=true"
188+
if (Os.isFamily(Os.FAMILY_WINDOWS)) {
189+
commandLine 'cmd', '/c', "$distributionBinPath/bal.bat push ${packageName} && exit %%ERRORLEVEL%%"
190+
} else {
191+
commandLine 'sh', '-c', "$distributionBinPath/bal push ${packageName}"
192+
}
193+
}
194+
}
195+
}
196+
}
197+
184198
task createArtifactZip(type: Zip) {
185199
destinationDirectory = file("$buildDir/distributions")
186200
from ballerinaBuild
@@ -201,7 +215,7 @@ publishing {
201215
repositories {
202216
maven {
203217
name = "GitHubPackages"
204-
url = uri("https://maven.pkg.github.com/ballerina-platform/module-ballerina-regex")
218+
url = uri("https://maven.pkg.github.com/ballerina-platform/module-${packageOrg}-${packageName}")
205219
credentials {
206220
username = System.getenv("packageUser")
207221
password = System.getenv("packagePAT")
@@ -212,3 +226,6 @@ publishing {
212226

213227
updateTomlVersions.dependsOn unpackJballerinaTools
214228
build.dependsOn ballerinaBuild
229+
230+
ballerinaPublish.dependsOn ballerinaBuild
231+
publish.dependsOn ballerinaPublish

0 commit comments

Comments
 (0)