Skip to content

Commit

Permalink
Merge pull request #75 from ballerina-platform/central
Browse files Browse the repository at this point in the history
Re-order build tasks to enable publishing to central
  • Loading branch information
madhukaw authored Feb 18, 2021
2 parents 5f3ef9d + f0fcefd commit c3fc0f7
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 5 deletions.
1 change: 1 addition & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ release {
failOnPublishNeeded = false

buildTasks = ["build"]
failOnSnapshotDependencies = true
versionPropertyFile = 'gradle.properties'
tagTemplate = 'v$version'

Expand Down
24 changes: 19 additions & 5 deletions log-ballerina/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ task copyStdlibs(type: Copy) {
}
}

task updateTomlVerions {
task updateTomlVersions {
doLast {
def newConfig = ballerinaConfigFile.text.replace("@project.version@", project.version)
newConfig = newConfig.replace("@toml.version@", tomlVersion)
Expand Down Expand Up @@ -123,8 +123,12 @@ task initializeVariables {
}

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

if (graph.hasTask(":${packageName}-ballerina:test")) {
Expand Down Expand Up @@ -206,6 +210,9 @@ task ballerinaBuild {

task ballerinaPublish {
doLast {
if (project.version.endsWith('-SNAPSHOT')) {
return
}
if (ballerinaCentralAccessToken != null) {
println("Publishing to the ballerina central...")
exec {
Expand All @@ -217,6 +224,8 @@ task ballerinaPublish {
commandLine 'sh', '-c', "$distributionBinPath/bal push ${packageName}"
}
}
} else {
throw new InvalidUserDataException("Central Access Token is not present")
}
}
}
Expand All @@ -229,7 +238,7 @@ task createArtifactZip(type: Zip) {
task createTestableJarZip(type: Zip) {
archiveName("${packageOrg}-${packageName}-${project.version}-testable-jars.zip")
destinationDir(file("${buildDir}/distributions"))
from ("${artifactTestableJar}") {
from("${artifactTestableJar}") {
include '**/*-testable.jar'
}
}
Expand Down Expand Up @@ -261,7 +270,7 @@ copyStdlibs.dependsOn unpackJballerinaTools
ballerinaTest.dependsOn ":${packageName}-native:build"
ballerinaTest.dependsOn ":${packageName}-test-utils:build"
ballerinaTest.dependsOn copyStdlibs
ballerinaTest.dependsOn updateTomlVerions
ballerinaTest.dependsOn updateTomlVersions
ballerinaTest.dependsOn initializeVariables
ballerinaTest.finalizedBy revertTomlFile
test.dependsOn ballerinaTest
Expand All @@ -270,13 +279,18 @@ test.dependsOn ballerinaTest
ballerinaBuild.dependsOn ":${packageName}-native:build"
ballerinaBuild.dependsOn ":${packageName}-test-utils:build"
ballerinaBuild.dependsOn copyStdlibs
ballerinaBuild.dependsOn updateTomlVerions
ballerinaBuild.dependsOn updateTomlVersions
ballerinaBuild.dependsOn initializeVariables
ballerinaBuild.dependsOn test
ballerinaBuild.finalizedBy revertTomlFile
ballerinaBuild.finalizedBy ':log-integration-tests:build'
build.dependsOn ballerinaBuild


ballerinaPublish.finalizedBy revertTomlFile
ballerinaPublish.dependsOn initializeVariables
ballerinaPublish.dependsOn updateTomlVersions
ballerinaPublish.dependsOn ":${packageName}-native:build"
ballerinaPublish.dependsOn ballerinaBuild
publish.dependsOn ballerinaPublish

Expand Down

0 comments on commit c3fc0f7

Please sign in to comment.