Skip to content

Commit

Permalink
Merge pull request #52 from ThishaniLucas/dev-origin
Browse files Browse the repository at this point in the history
Enable publishing to b7a central
  • Loading branch information
daneshk authored Feb 11, 2021
2 parents 2e70123 + 8459ba1 commit 965c016
Show file tree
Hide file tree
Showing 6 changed files with 66 additions and 70 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/publish-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
with:
java-version: 11
- name: Set version env variable
run: echo "VERSION=$((grep -w 'version' | cut -d= -f2) < gradle.properties | cut -d- -f1)" >> $GITHUB_ENV
run: echo "VERSION=$((grep -w 'version' | cut -d= -f2) < gradle.properties | rev | cut --complement -d- -f1 | rev)" >> $GITHUB_ENV
- name: Pre release depenency version update
env:
GITHUB_TOKEN: ${{ secrets.BALLERINA_BOT_TOKEN }}
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Ballerina Time Library
The Time library is one of the standard library modules of the<a target="_blank" href="https://ballerina.io/"> Ballerina
</a> language.

This module provides implementations related to time, date, time zones, and durations.
This package provides implementations related to time, date, time zones, and durations.

For more information go to [The Time Module](https://ballerina.io/learn/api-docs/ballerina/time/).

Expand All @@ -19,7 +19,7 @@ For example demonstrations of the usage, go to [Ballerina By Examples](https://b

Issues and Project 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. please visit Ballerina Standard Library [parent repository](https://github.com/ballerina-platform/ballerina-standard-library).

This repository only contains the source code for the module.
This repository only contains the source code for the package.

## Building from the Source

Expand All @@ -44,15 +44,15 @@ Execute the commands below to build from source.

./gradlew clean test

3. To build the module without the tests:
3. To build the package without the tests:

./gradlew clean build -x test

4. To debug the tests:

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

./gradlew clean build -PbalJavaDebug=<port>

Expand Down
21 changes: 0 additions & 21 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -81,24 +81,3 @@ release {
task build {
dependsOn('time-ballerina:build')
}

task codeCoverageReport(type: JacocoReport) {
executionData fileTree(project.rootDir.absolutePath).include("**/build/coverage-reports/*.exec")

subprojects.each {
sourceSets it.sourceSets.main
}

reports {
xml.enabled = true
html.enabled = true
csv.enabled = true
xml.destination = new File("${buildDir}/reports/jacoco/report.xml")
html.destination = new File("${buildDir}/reports/jacoco/report.html")
csv.destination = new File("${buildDir}/reports/jacoco/report.csv")
}

onlyIf = {
true
}
}
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
org.gradle.caching=true
group=org.ballerinalang
version=1.0.8-SNAPSHOT
version=1.1.0-alpha2-SNAPSHOT
ballerinaLangVersion=2.0.0-alpha3-SNAPSHOT
puppycrawlCheckstyleVersion=8.18
8 changes: 4 additions & 4 deletions time-ballerina/Package.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
## Module Overview
## Package Overview

This module provides implementations related to time, date, time zones, and durations.
This package provides implementations related to time, date, time zones, and durations.

The module has two main types as [Time](records/Time.html) and [TimeZone](records/TimeZone.html). The `Time` type represents a time associated with a given time zone. It has `time` and `zone` as its attributes. The `TimeZone` type represents the time zone associated with a given time. It has `id` and `offset` as its attributes. An `id` can be one of the following:
The package has two main types as [Time](records/Time.html) and [TimeZone](records/TimeZone.html). The `Time` type represents a time associated with a given time zone. It has `time` and `zone` as its attributes. The `TimeZone` type represents the time zone associated with a given time. It has `id` and `offset` as its attributes. An `id` can be one of the following:

* If `id` equals `Z`, the result is UTC.
* If `id` equals `GMT`, `UTC`, or `UT`, it is equivalent to UTC.
* If `id` starts with `+` or `-`, the ID is parsed as an offset. The offset can be specified in one of the following ways: `+h`, `+hh`, `+hh:mm`, `-hh:mm`, `+hhmm`, `-hhmm`, `+hh:mm:ss`, `-hh:mm:ss`, `+hhmmss`, `-hhmmss`
* Also, `id` can be a region-based zone ID. The format is `{area}/{city}` e.g., "America/Panama". The zones are based on IANA Time Zone Database (TZDB) supplied data.

For information on the operations, which you can perform with this module, see the below **Functions**. For an example on the usage of the operations, see the [Time Example](https://ballerina.io/learn/by-example/time.html).
For information on the operations, which you can perform with this package, see the below **Functions**. For an example on the usage of the operations, see the [Time Example](https://ballerina.io/learn/by-example/time.html).

### Patterns for formatting and parsing

Expand Down
95 changes: 56 additions & 39 deletions time-ballerina/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,20 @@ import org.apache.tools.ant.taskdefs.condition.Os

description = 'Ballerina - Time Ballerina Generator'

def packageName = "time"
def packageOrg = "ballerina"
def snapshotVersion = "-SNAPSHOT"
def tomlVersion = project.version.replace("${snapshotVersion}", "")
def ballerinaConfigFile = new File("$project.projectDir/Ballerina.toml")
def artifactBallerinaDocs = file("$project.projectDir/build/docs_parent/")
def artifactCacheParent = file("$project.projectDir/build/cache_parent/")
def artifactLibParent = file("$project.projectDir/build/lib_parent/")
def artifactCodeCoverageReport = file("$project.projectDir/target/cache/tests_cache/coverage/ballerina.exec")
def artifactTestableJar = file("$project.projectDir/target/cache/${packageOrg}/${packageName}/${tomlVersion}/java11/")
def ballerinaCentralAccessToken = System.getenv('BALLERINA_CENTRAL_ACCESS_TOKEN')
def originalConfig = ballerinaConfigFile.text
def distributionBinPath = project.projectDir.absolutePath + "/build/target/extracted-distributions/jballerina-tools-zip/jballerina-tools-${ballerinaLangVersion}/bin"

configurations {
jbalTools
}
Expand All @@ -27,7 +41,7 @@ dependencies {
jbalTools ("org.ballerinalang:jballerina-tools:${ballerinaLangVersion}") {
transitive = false
}
compile project(':time-native')
compile project(":${packageName}-native")
}

clean {
Expand All @@ -49,18 +63,6 @@ task unpackJballerinaTools(type: Copy) {
}
}

def packageName = "time"
def packageOrg = "ballerina"
def ballerinaConfigFile = new File("$project.projectDir/Ballerina.toml")
def artifactBallerinaDocs = file("$project.projectDir/build/docs_parent/")
def artifactCacheParent = file("$project.projectDir/build/cache_parent/")
def artifactLibParent = file("$project.projectDir/build/lib_parent/")
def artifactCodeCoverageReport = file("$project.projectDir/target/cache/tests_cache/coverage/ballerina.exec")
def tomlVersion = project.version.split("-")[0]
def ballerinaCentralAccessToken = System.getenv('BALLERINA_CENTRAL_ACCESS_TOKEN')
def originalConfig = ballerinaConfigFile.text
def distributionBinPath = project.projectDir.absolutePath + "/build/target/extracted-distributions/jballerina-tools-zip/jballerina-tools-${ballerinaLangVersion}/bin"

task updateTomlVersions {
doLast {
def newConfig = ballerinaConfigFile.text.replace("@project.version@", project.version)
Expand All @@ -77,6 +79,7 @@ task revertTomlFile {

def debugParams = ""
def balJavaDebugParam = ""
def testParams = ""

task initializeVariables {
if (project.hasProperty("debug")) {
Expand All @@ -85,6 +88,24 @@ task initializeVariables {
if (project.hasProperty("balJavaDebug")) {
balJavaDebugParam = "BAL_JAVA_DEBUG=${project.findProperty("balJavaDebug")}"
}

gradle.taskGraph.whenReady { graph ->
if (graph.hasTask(":${packageName}-ballerina:build") || graph.hasTask(":${packageName}-ballerina:publish")) {
ballerinaTest.enabled = false
}

if (graph.hasTask(":${packageName}-ballerina:test")) {
testParams = "--code-coverage --includes=*"
} else {
testParams = "--skip-tests"
}

if (graph.hasTask(":${packageName}-ballerina:publish")) {
ballerinaPublish.enabled = true
} else {
ballerinaPublish.enabled = false
}
}
}

task ballerinaTest {
Expand Down Expand Up @@ -117,16 +138,6 @@ task ballerinaBuild {
dependsOn(initializeVariables)
finalizedBy(revertTomlFile)

def testParams = "--skip-tests"
gradle.taskGraph.whenReady { graph ->
if (graph.hasTask(':time-ballerina:build') || graph.hasTask(':time-ballerina:publish')) {
ballerinaTest.enabled = false
}
if (graph.hasTask(':time-ballerina:test')) {
testParams = "--code-coverage --includes=*"
}
}

doLast {
// Build and populate caches
exec {
Expand All @@ -149,20 +160,6 @@ task ballerinaBuild {
into file("$artifactCacheParent/cache/")
}

// Publish to central
if (!project.version.endsWith('-SNAPSHOT') && ballerinaCentralAccessToken != null && project.hasProperty("publishToCentral")) {
println("Publishing to the ballerina central..")
exec {
workingDir project.projectDir
environment "JAVA_OPTS", "-DBALLERINA_DEV_COMPILE_BALLERINA_ORG=true"
if (Os.isFamily(Os.FAMILY_WINDOWS)) {
commandLine 'cmd', '/c', "$distributionBinPath/bal.bat push && exit %%ERRORLEVEL%%"
} else {
commandLine 'sh', '-c', "$distributionBinPath/bal push"
}
}

}
// Doc creation and packing
exec {
workingDir project.projectDir
Expand All @@ -184,6 +181,23 @@ task ballerinaBuild {
outputs.dir artifactLibParent
}

task ballerinaPublish {
doLast {
if (ballerinaCentralAccessToken != null) {
println("Publishing to the ballerina central...")
exec {
workingDir project.projectDir
environment "JAVA_OPTS", "-DBALLERINA_DEV_COMPILE_BALLERINA_ORG=true"
if (Os.isFamily(Os.FAMILY_WINDOWS)) {
commandLine 'cmd', '/c', "$distributionBinPath/bal.bat push ${packageName} && exit %%ERRORLEVEL%%"
} else {
commandLine 'sh', '-c', "$distributionBinPath/bal push ${packageName}"
}
}
}
}
}

task createArtifactZip(type: Zip) {
destinationDirectory = file("$buildDir/distributions")
from ballerinaBuild
Expand All @@ -204,7 +218,7 @@ publishing {
repositories {
maven {
name = "GitHubPackages"
url = uri("https://maven.pkg.github.com/ballerina-platform/module-ballerina-time")
url = uri("https://maven.pkg.github.com/ballerina-platform/module-${packageOrg}-${packageName}")
credentials {
username = System.getenv("packageUser")
password = System.getenv("packagePAT")
Expand All @@ -213,6 +227,9 @@ publishing {
}
}

ballerinaBuild.dependsOn ":time-native:build"
ballerinaBuild.dependsOn ":${packageName}-native:build"
updateTomlVersions.dependsOn unpackJballerinaTools
build.dependsOn ballerinaBuild

ballerinaPublish.dependsOn ballerinaBuild
publish.dependsOn ballerinaPublish

0 comments on commit 965c016

Please sign in to comment.