From aa2c3ac62a3cf036ab663134f2d945776b75d059 Mon Sep 17 00:00:00 2001 From: Nipuna Ranasinghe Date: Thu, 11 Jul 2024 23:38:44 +0530 Subject: [PATCH] Update gradle build with sanitation script validation --- build.gradle | 1 + docs/spec/build.gradle | 42 ++++++++++++++++++++++++++++++++++++++++++ settings.gradle | 3 ++- 3 files changed, 45 insertions(+), 1 deletion(-) create mode 100644 docs/spec/build.gradle diff --git a/build.gradle b/build.gradle index 65c0b8c..33d272a 100644 --- a/build.gradle +++ b/build.gradle @@ -61,6 +61,7 @@ allprojects { def moduleVersion = project.version.replace("-SNAPSHOT", "") task build { + dependsOn(':slack-sanitation:build') dependsOn(':slack-ballerina:build') } diff --git a/docs/spec/build.gradle b/docs/spec/build.gradle new file mode 100644 index 0000000..ba25d7a --- /dev/null +++ b/docs/spec/build.gradle @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2024, WSO2 LLC. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 LLC. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import org.apache.tools.ant.taskdefs.condition.Os + +def files = ["sanitations.bal"]; + +task build { + doLast { + try { + files.each { file -> + println("Building ${file} ...") + exec { + workingDir project.projectDir + if (Os.isFamily(Os.FAMILY_WINDOWS)) { + commandLine 'sh', "/c", "bal build ${file} && exit %%ERRORLEVEL%%" + } else { + commandLine 'sh', "-c", "bal build ${file}" + } + } + } + } catch (Exception e) { + println("Sanitation Script Build failed: " + e.message) + throw e + } + } +} diff --git a/settings.gradle b/settings.gradle index 44c878c..aaabe00 100644 --- a/settings.gradle +++ b/settings.gradle @@ -32,10 +32,11 @@ plugins { rootProject.name = 'module-ballerinax-slack' +include ':slack-sanitation' include ':slack-ballerina' project(':slack-ballerina').projectDir = file("ballerina") - +project(':slack-sanitation').projectDir = file("docs/spec") gradleEnterprise { buildScan { termsOfServiceUrl = 'https://gradle.com/terms-of-service'