From f0fcefd6d8ef568f5196765bb7554eb0b0554d63 Mon Sep 17 00:00:00 2001 From: MadhukaHarith Date: Thu, 18 Feb 2021 21:39:08 +0530 Subject: [PATCH] Re-order build tasks to enable publishing to central --- build.gradle | 1 + log-ballerina/build.gradle | 24 +++++++++++++++++++----- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/build.gradle b/build.gradle index c73e95ad..18b675bc 100644 --- a/build.gradle +++ b/build.gradle @@ -105,6 +105,7 @@ release { failOnPublishNeeded = false buildTasks = ["build"] + failOnSnapshotDependencies = true versionPropertyFile = 'gradle.properties' tagTemplate = 'v$version' diff --git a/log-ballerina/build.gradle b/log-ballerina/build.gradle index cfc34f71..24512726 100644 --- a/log-ballerina/build.gradle +++ b/log-ballerina/build.gradle @@ -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) @@ -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")) { @@ -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 { @@ -217,6 +224,8 @@ task ballerinaPublish { commandLine 'sh', '-c', "$distributionBinPath/bal push ${packageName}" } } + } else { + throw new InvalidUserDataException("Central Access Token is not present") } } } @@ -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' } } @@ -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 @@ -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