Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
ayeshLK committed Oct 27, 2023
0 parents commit 310b0ad
Show file tree
Hide file tree
Showing 13 changed files with 836 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Ensure all Java files use LF.
*.java eol=lf
Empty file added .github/CODEOWNERS
Empty file.
45 changes: 45 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# Ignore Gradle project-specific cache directory
.gradle

# Build Files
target
build

# IDEA Files
.idea/
*.iml
*.ipr
*.iws

# Package Files #
!gradle/wrapper/gradle-wrapper.jar
*.jar
*.war
*.nar
*.ear
*.zip
*.tar.gz
*.rar

# MacOS
*.DS_Store

# Ballerina
velocity.log*
*Ballerina.lock

# VSCode
.vscode
.project
.settings/
ballerina/.project
ballerina/.settings/
build-config/checkstyle/.classpath
build-config/checkstyle/.project
build-config/checkstyle/.settings/
native/.classpath
native/.project
native/.settings/
test-utils/.classpath
test-utils/.project
test-utils/.settings/
173 changes: 173 additions & 0 deletions ballerina/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,173 @@
// Copyright (c) 2023, 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

buildscript {
repositories {
maven {
url = 'https://maven.pkg.github.com/ballerina-platform/plugin-gradle'
credentials {
username System.getenv("packageUser")
password System.getenv("packagePAT")
}
}
}
dependencies {
classpath "io.ballerina:plugin-gradle:${project.ballerinaGradlePluginVersion}"
}
}

description = 'Ballerina - IBM MQ Package'

def packageName = "ibm.ibmmq"
def packageOrg = "ballerinax"
def tomlVersion = stripBallerinaExtensionVersion("${project.version}")
def ballerinaTomlFilePlaceHolder = new File("${project.rootDir}/build-config/resources/Ballerina.toml")
def ballerinaTomlFile = new File("$project.projectDir/Ballerina.toml")

def stripBallerinaExtensionVersion(String extVersion) {
if (extVersion.matches(project.ext.timestampedVersionRegex)) {
def splitVersion = extVersion.split('-')
if (splitVersion.length > 3) {
def strippedValues = splitVersion[0..-4]
return strippedValues.join('-')
} else {
return extVersion
}
} else {
return extVersion.replace("${project.ext.snapshotVersion}", "")
}
}

apply plugin: 'io.ballerina.plugin'

ballerina {
packageOrganization = packageOrg
module = packageName
langVersion = ballerinaLangVersion
testCoverageParam = "--code-coverage --coverage-format=xml --includes=*"
}

configurations {
externalJars
}

// dependencies {
// /* SLF4J dependencies */
// externalJars(group: 'org.slf4j', name: 'slf4j-api', version: "${slf4jVersion}") {
// transitive = false
// }
// /* JMS dependencies */
// externalJars(group: 'javax.jms', name: 'javax.jms-api', version: "${javaxJmsVersion}") {
// transitive = false
// }
// }

task updateTomlFiles {
doLast {
def newConfig = ballerinaTomlFilePlaceHolder.text.replace("@project.version@", project.version)
newConfig = newConfig.replace("@toml.version@", tomlVersion)
ballerinaTomlFile.text = newConfig
}
}

task commitTomlFiles {
doLast {
project.exec {
ignoreExitValue true
if (Os.isFamily(Os.FAMILY_WINDOWS)) {
commandLine 'cmd', '/c', "git commit -m \"[Automated] Update the native jar versions\" Ballerina.toml Dependencies.toml"
} else {
commandLine 'sh', '-c', "git commit -m '[Automated] Update the native jar versions' Ballerina.toml Dependencies.toml"
}
}
}
}

// task startActiveMQServer() {
// doLast {
// if (!Os.isFamily(Os.FAMILY_WINDOWS)) {
// def stdOut = new ByteArrayOutputStream()
// exec {
// commandLine 'sh', '-c', "docker ps --filter name=activemq-test"
// standardOutput = stdOut
// }
// if (!stdOut.toString().contains("activemq-test")) {
// println "Starting ActiveMQ server."
// exec {
// commandLine 'sh', '-c', "docker-compose -f tests/resources/docker-compose.yaml up -d"
// standardOutput = stdOut
// }
// println stdOut.toString()
// sleep(5 * 1000)
// } else {
// println "ActiveMQ server is already running."
// }
// }
// }
// }

// task stopActiveMQServer() {
// doLast {
// if (!Os.isFamily(Os.FAMILY_WINDOWS)) {
// def stdOut = new ByteArrayOutputStream()
// exec {
// commandLine 'sh', '-c', "docker ps --filter name=activemq-test"
// standardOutput = stdOut
// }
// if (stdOut.toString().contains("activemq-test")) {
// println "Stopping ActiveMQ server."
// exec {
// commandLine 'sh', '-c', "docker-compose -f tests/resources/docker-compose.yaml rm -svf"
// standardOutput = stdOut
// }
// println stdOut.toString()
// sleep(5 * 1000)
// } else {
// println "ActiveMQ server is not started."
// }
// }
// }
// }

publishing {
publications {
maven(MavenPublication) {
artifact source: createArtifactZip, extension: 'zip'
}
}
repositories {
maven {
name = "GitHubPackages"
url = uri("https://maven.pkg.github.com/ballerina-platform/module-${packageOrg}-${packageName}")
credentials {
username = System.getenv("publishUser")
password = System.getenv("publishPAT")
}
}
}
}

updateTomlFiles.dependsOn copyStdlibs

// test.dependsOn startActiveMQServer
// build.finalizedBy stopActiveMQServer

build.dependsOn ":ibm.ibmmq-native:build"
build.dependsOn "generatePomFileForMavenPublication"
publishToMavenLocal.dependsOn build
publish.dependsOn build
19 changes: 19 additions & 0 deletions build-config/resources/Ballerina.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
[package]
org = "ballerinax"
name = "ibm.ibmmq"
version = "@toml.version@"
authors = ["Ballerina"]
keywords = ["ibm-mq"]
repository = "https://github.com/ballerina-platform/module-ballerinax-ibm.ibmmq"
icon = "icon.png"
license = ["Apache-2.0"]
distribution = "2201.8.0"

[platform.java17]
graalvmCompatible = true

[[platform.java17.dependency]]
groupId = "io.ballerina.stdlib"
artifactId = "ibm.ibmmq-native"
version = "@toml.version@"
path = "../native/build/libs/[email protected]@.jar"
102 changes: 102 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
// Copyright (c) 2023, 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.

plugins {
id "com.github.spotbugs-base"
id "com.github.johnrengelman.shadow"
id "de.undercouch.download"
id "net.researchgate.release"
}

ext.ballerinaLangVersion = project.ballerinaLangVersion

allprojects {
group = project.group
version = project.version

apply plugin: 'jacoco'
apply plugin: 'maven-publish'

repositories {
mavenLocal()

maven {
url = 'https://maven.wso2.org/nexus/content/repositories/releases/'
}

maven {
url = 'https://maven.wso2.org/nexus/content/groups/wso2-public/'
}

maven {
url = 'https://repo.maven.apache.org/maven2'
}

maven {
url = 'https://maven.pkg.github.com/ballerina-platform/*'
credentials {
username System.getenv("packageUser")
password System.getenv("packagePAT")
}
}
}

ext {
snapshotVersion= '-SNAPSHOT'
timestampedVersionRegex = '.*-\\d{8}-\\d{6}-\\w.*\$'
}
}

subprojects {

configurations {
ballerinaStdLibs
}

dependencies {
/* Standard libraries */
ballerinaStdLibs "io.ballerina.stdlib:time-ballerina:${stdlibTimeVersion}"
ballerinaStdLibs "io.ballerina.stdlib:log-ballerina:${stdlibLogVersion}"
ballerinaStdLibs "io.ballerina.stdlib:uuid-ballerina:${stdlibUuidVersion}"
ballerinaStdLibs "io.ballerina.stdlib:crypto-ballerina:${stdlibCryptoVersion}"
ballerinaStdLibs "io.ballerina.stdlib:io-ballerina:${stdlibIoVersion}"
ballerinaStdLibs "io.ballerina.stdlib:observe-ballerina:${observeVersion}"
ballerinaStdLibs "io.ballerina:observe-ballerina:${observeInternalVersion}"
}

task allDeps(type: DependencyReportTask) {}
}

def moduleVersion = project.version.replace("-SNAPSHOT", "")

release {
failOnPublishNeeded = false

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

git {
requireBranch = "release-${moduleVersion}"
pushToRemote = 'origin'
}
}

task build {
dependsOn(':ibm.ibmmq-ballerina:build')
dependsOn(':ibm.ibmmq-native:build')
}
27 changes: 27 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
org.gradle.caching=true
group=io.ballerina.lib
version=0.0.1-SNAPSHOT
ballerinaLangVersion=2201.8.0

checkstylePluginVersion=10.12.1
spotbugsPluginVersion=5.0.14
shadowJarPluginVersion=8.1.1
downloadPluginVersion=5.4.0
releasePluginVersion=2.8.0
ballerinaGradlePluginVersion=2.0.1

#stdlib dependencies

# Level 01
stdlibTimeVersion=2.4.0
stdlibIoVersion=1.6.0

# Level 02
stdlibLogVersion=2.9.0
stdlibCryptoVersion=2.5.0

# Level 03
stdlibUuidVersion=1.7.0

observeVersion=1.2.0
observeInternalVersion=1.2.0
6 changes: 6 additions & 0 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.2.1-bin.zip
networkTimeout=10000
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Loading

0 comments on commit 310b0ad

Please sign in to comment.