Skip to content

Commit

Permalink
Merge pull request #119 from hasathcharu/websockets
Browse files Browse the repository at this point in the history
Integrate `websockets` protocol support
  • Loading branch information
Bhashinee authored Jul 2, 2024
2 parents 5c9c4b5 + 605bffe commit 60db22c
Show file tree
Hide file tree
Showing 674 changed files with 212,243 additions and 842 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
.gradle
/build/
/native.handler/target
target
/native.handler/java-wrapper/build
/native.handler/build
/asyncapi-cli/build
Expand Down
66 changes: 62 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,63 @@
# Asyncapi
This repository is the code base for the ballerina async-api tool
# Ballerina - AsyncAPI Tools
[![Build](https://github.com/ballerina-platform/asyncapi-tools/actions/workflows/build-timestamped-master.yml/badge.svg)](https://github.com/ballerina-platform/asyncapi-tools/actions/workflows/build-timestamped-master.yml)
[![GitHub Last Commit](https://img.shields.io/github/last-commit/ballerina-platform/asyncapi-tools.svg)](https://github.com/ballerina-platform/asyncapi-tools/commits/master)
[![GitHub issues](https://img.shields.io/github/issues/ballerina-platform/ballerina-standard-library/module/asyncpi-tools.svg?label=Open%20Issues)](https://github.com/ballerina-platform/ballerina-library/labels/module%2Fasyncapi-tools)

# Architecture of the repository
![architecture](asyncapi-cli/src/main/resources/architecture.jpg?raw=true)
The AsyncAPI Specification is a specification, which creates an event driven architecture based contract for APIs
detailing all of its resources and channels in both human and machine-readable format for easy development, discovery,
and integration. AsyncAPI tools currently s the following capabilities.

1. Generate Ballerina client code from a given AsyncAPI contract with `http` and `ws` protocols.
2. Export the AsyncAPI definition of a Ballerina service using the `ws` protocol.
3. The asyncapi command in Ballerina is used for AsyncAPI to Ballerina and Ballerina to AsyncAPI code generations.

The `asyncapi` command in Ballerina is used for AsyncAPI to Ballerina and Ballerina to AsyncAPI code generations.

## Building from the Source

### Setting Up the Prerequisites

1. OpenJDK 17 ([Adopt OpenJDK](https://adoptopenjdk.net/) or any other OpenJDK distribution)

>**Info:** You can also use [Oracle JDK](https://www.oracle.com/java/technologies/javase-downloads.html). Set the JAVA_HOME environment variable to the pathname of the directory into which you installed JDK.
2. Export GitHub Personal access token with read package permissions as follows,
```
export packageUser=<Username>
export packagePAT=<Personal access token>
```

### Building the Source

Execute the commands below to build from the source.

1. To build the library:

./gradlew clean build

2. To run the integration tests:

./gradlew clean test

3. To build the module without the tests:

./gradlew clean build -x test

4. To publish to maven local:

./gradlew clean build publishToMavenLocal

## Contributing to Ballerina

As an open-source project, Ballerina welcomes contributions from the community.

For more information, go to the [contribution guidelines](https://github.com/ballerina-platform/ballerina-lang/blob/master/CONTRIBUTING.md).

## Code of Conduct

All contributors are encouraged to read the [Ballerina Code of Conduct](https://ballerina.io/code-of-conduct).

## Useful Links

* Chat live with us via our [Discord server](https://discord.gg/ballerinalang).
* Post all technical questions on Stack Overflow with the [#ballerina](https://stackoverflow.com/questions/tagged/ballerina) tag.
150 changes: 144 additions & 6 deletions asyncapi-cli/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -21,39 +21,176 @@ apply plugin: "checkstyle"

description = "Ballerina - AsyncAPI Tooling - AsyncAPI to Ballerina"

def ballerinaDist = "$project.buildDir/jballerina-tools-${ballerinaLangVersion}"
def runtimePath = "${project.rootDir}/target/ballerina-distribution"

tasks.register("jBallerinaPack")
tasks.register("unpackStdLibs")
tasks.register("copyStdlibs")

configurations.all {
resolutionStrategy.preferProjectModules()
}

configurations {
ballerinaStdLibs
balTools
}

dependencies {
checkstyle project(':checkstyle')
checkstyle "com.puppycrawl.tools:checkstyle:${puppycrawlCheckstyleVersion}"

implementation 'io.apicurio:apicurio-data-models:1.1.15'
implementation 'org.apache.logging.log4j:log4j-core:2.14.1'
implementation "io.apicurio:apicurio-data-models:${apiCurioVersion}"
implementation "org.apache.logging.log4j:log4j-core:${log4jVersion}"
implementation "org.slf4j:slf4j-api:${slf4jVersion}"
implementation "com.fasterxml.jackson.dataformat:jackson-dataformat-yaml:${jacksonDataformatYamlVersion}"
implementation 'commons-io:commons-io:2.11.0'
implementation "commons-io:commons-io:${commonsIoVersion}"
implementation "org.ballerinalang:ballerina-lang:${ballerinaLangVersion}"
implementation "org.ballerinalang:ballerina-parser:${ballerinaLangVersion}"
implementation "org.ballerinalang:ballerina-cli:${ballerinaLangVersion}"
implementation "org.ballerinalang:formatter-core:${ballerinaLangVersion}"
implementation "org.ballerinalang:ballerina-tools-api:${ballerinaLangVersion}"
implementation "org.ballerinalang:ballerina-runtime:${ballerinaLangVersion}"
implementation "io.ballerina.stdlib:http-native:${stdlibHttpVersion}"
implementation "org.ballerinalang:language-server-commons:${ballerinaLangVersion}"
implementation "info.picocli:picocli:4.0.1"
implementation "info.picocli:picocli:${picocliVersion}"
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.6.0'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine'
testImplementation "org.testng:testng:${testngVersion}"

balTools ("org.ballerinalang:jballerina-tools:${ballerinaLangVersion}") {
transitive = false
}

/* Standard libraries */
ballerinaStdLibs "io.ballerina.stdlib:io-ballerina:${stdlibIoVersion}"
ballerinaStdLibs "io.ballerina.stdlib:http-ballerina:${stdlibHttpVersion}"
ballerinaStdLibs "io.ballerina.stdlib:log-ballerina:${stdlibLogVersion}"
ballerinaStdLibs "io.ballerina.stdlib:os-ballerina:${stdlibOsVersion}"
ballerinaStdLibs "io.ballerina.stdlib:mime-ballerina:${stdlibMimeVersion}"
ballerinaStdLibs "io.ballerina.stdlib:regex-ballerina:${stdlibRegexVersion}"
ballerinaStdLibs "io.ballerina.stdlib:crypto-ballerina:${stdlibCryptoVersion}"
ballerinaStdLibs "io.ballerina.stdlib:auth-ballerina:${stdlibAuthVersion}"
ballerinaStdLibs "io.ballerina.stdlib:time-ballerina:${stdlibTimeVersion}"
ballerinaStdLibs "io.ballerina.stdlib:cache-ballerina:${stdlibCacheVersion}"
ballerinaStdLibs "io.ballerina.stdlib:task-ballerina:${stdlibTaskVersion}"
ballerinaStdLibs "io.ballerina.stdlib:file-ballerina:${stdlibFileVersion}"
ballerinaStdLibs "io.ballerina.stdlib:jwt-ballerina:${stdlibJwtVersion}"
ballerinaStdLibs "io.ballerina.stdlib:oauth2-ballerina:${stdlibOAuth2Version}"
ballerinaStdLibs "io.ballerina.stdlib:uuid-ballerina:${stdlibUuidVersion}"
ballerinaStdLibs "io.ballerina.stdlib:url-ballerina:${stdlibUrlVersion}"
ballerinaStdLibs "io.ballerina.stdlib:xmldata-ballerina:${stdlibXmldataVersion}"
ballerinaStdLibs "io.ballerina.stdlib:observe-ballerina:${observeVersion}"
ballerinaStdLibs "io.ballerina:observe-ballerina:${observeInternalVersion}"
ballerinaStdLibs "io.ballerina.stdlib:kafka-ballerina:${stdlibKafkaVersion}"
ballerinaStdLibs "io.ballerina.stdlib:rabbitmq-ballerina:${stdlibRabbitMqVersion}"
ballerinaStdLibs "io.ballerina.stdlib:websocket-ballerina:${stdlibWebsocketVersion}"
ballerinaStdLibs "io.ballerina.stdlib:constraint-ballerina:${stdlibConstraintVersion}"
}

clean {
delete "$project.projectDir/build"
delete "$project.rootDir/target"
}

jBallerinaPack {
doLast {
configurations.balTools.resolvedConfiguration.resolvedArtifacts.each { artifact ->
copy {
from project.zipTree(artifact.getFile())
into new File("${project.buildDir}")
}
copy {
from(project.zipTree(artifact.getFile())) {
eachFile { fcd ->
fcd.relativePath = new RelativePath(!fcd.file.isDirectory(), fcd.relativePath.segments.drop(1))
}
includeEmptyDirs = false
}
into runtimePath
}
}
}
outputs.dir ballerinaDist
}

unpackStdLibs() {
dependsOn(jBallerinaPack)
doLast {
configurations.ballerinaStdLibs.resolvedConfiguration.resolvedArtifacts.each { artifact ->
copy {
from project.zipTree(artifact.getFile())
into new File("${project.buildDir}/extracted-stdlibs/" + artifact.name + "-zip")
}
}
}
}

copyStdlibs() {
dependsOn(unpackStdLibs)
/* Standard Libraries */
doLast {
configurations.ballerinaStdLibs.resolvedConfiguration.resolvedArtifacts.each { artifact ->
def artifactExtractedPath = "${project.buildDir}/extracted-stdlibs/" + artifact.name + "-zip"
copy {
into ballerinaDist
into("repo/bala") {
from "${artifactExtractedPath}/bala"
}
into("repo/cache") {
from "${artifactExtractedPath}/cache"
}
}
copy {
into runtimePath
into("repo/bala") {
from "${artifactExtractedPath}/bala"
}
into("repo/cache") {
from "${artifactExtractedPath}/cache"
}
}
}
def asyncapiCliJar = "${project.rootDir}/asyncapi-cli/build/libs/asyncapi-cli-${project.version}.jar"
copy {
into ballerinaDist
into("bre/lib") {
from "${asyncapiCliJar}"
}
}
copy {
into runtimePath
into("bre/lib") {
from "${asyncapiCliJar}"
}
}
}
}

test {
dependsOn(copyStdlibs)
systemProperty "ballerina.home", ballerinaDist
systemProperty "ballerina.offline.flag", "true"
useTestNG() {
suites "src/test/resources/testng.xml"
}
testLogging.showStandardStreams = true
testLogging {
events "PASSED", "FAILED", "SKIPPED"
afterSuite { desc, result ->
if (!desc.parent) { // will match the outermost suite
def output = "Results: ${result.resultType} (${result.testCount} tests, ${result.successfulTestCount} successes, ${result.failedTestCount} failures, ${result.skippedTestCount} skipped)"
def startItem = '| ', endItem = ' |'
def repeatLength = startItem.length() + output.length() + endItem.length()
println('\n' + ('-' * repeatLength) + '\n' + startItem + output + endItem + '\n' + ('-' * repeatLength))
}
}
}
}

checkstyle {
toolVersion '10.12.0'
toolVersion "${puppycrawlCheckstyleVersion}"
configFile rootProject.file("config/checkstyle/build/checkstyle.xml")
configProperties = ["suppressionFile" : file("${rootDir}/config/checkstyle/build/suppressions.xml")]
}
Expand All @@ -74,7 +211,7 @@ jar {
shadowJar {
configurations = [project.configurations.runtimeClasspath]
dependencies {
include(dependency('io.apicurio:apicurio-data-models:1.1.15'))
include(dependency("io.apicurio:apicurio-data-models:${apiCurioVersion}"))
exclude('META-INF/*.SF')
exclude('META-INF/*.DSA')
exclude('META-INF/*.RSA')
Expand All @@ -90,3 +227,4 @@ compileJava {
}
}

build.dependsOn("copyStdlibs")
Loading

0 comments on commit 60db22c

Please sign in to comment.