Skip to content

Commit

Permalink
Enable publishing to b7a central
Browse files Browse the repository at this point in the history
  • Loading branch information
ThishaniLucas committed Feb 11, 2021
1 parent 2e70123 commit c57d539
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 62 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
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
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 c57d539

Please sign in to comment.