-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
42 changed files
with
90 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,6 +11,7 @@ | |
.mtj.tmp/ | ||
|
||
# Package Files # | ||
*.jar | ||
*.war | ||
*.nar | ||
*.ear | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# Examples | ||
|
||
This directory contains a collection of sample code examples written in Ballerina. These examples demonstrate various | ||
use cases of the module. You can follow the instructions below to build and run these examples. | ||
|
||
## Running an Example | ||
|
||
Execute the following commands to build an example from the source. | ||
|
||
* To build an example | ||
|
||
`bal build <example-name>` | ||
|
||
|
||
* To run an example | ||
|
||
`bal run <example-name>` | ||
|
||
## Building the Examples with the Local Module | ||
|
||
**Warning**: Because of the absence of support for reading local repositories for single Ballerina files, the bala of | ||
the module is manually written to the central repository as a workaround. Consequently, the bash script may modify your | ||
local Ballerina repositories. | ||
|
||
Execute the following commands to build all the examples against the changes you have made to the module locally. | ||
|
||
* To build all the examples | ||
|
||
`./build.sh build` | ||
|
||
|
||
* To run all the examples | ||
|
||
`./build.sh run` |
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
#!/bin/bash | ||
|
||
BAL_EXAMPLES_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" | ||
BAL_CENTRAL_DIR="$HOME/.ballerina/repositories/central.ballerina.io/" | ||
BAL_HOME_DIR="$BAL_EXAMPLES_DIR/../ballerina" | ||
|
||
set -e | ||
|
||
case "$1" in | ||
build) | ||
BAL_CMD="build" | ||
;; | ||
run) | ||
BAL_CMD="run" | ||
;; | ||
*) | ||
echo "Invalid command provided: '$1'. Please provide 'build' or 'test' as the command." | ||
exit 1 | ||
;; | ||
esac | ||
|
||
# Read Ballerina package name | ||
BAL_PACKAGE_NAME=$(awk -F'"' '/^name/ {print $2}' "$BAL_HOME_DIR/Ballerina.toml") | ||
|
||
# Push the package to the local repository | ||
cd "$BAL_HOME_DIR" && | ||
bal pack && | ||
bal push --repository=local | ||
|
||
# Remove the cache directories in the repositories | ||
cacheDirs=($(ls -d "$BAL_CENTRAL_DIR"/cache-* 2>/dev/null)) | ||
for dir in "${cacheDirs[@]}"; do | ||
[ -d "$dir" ] && rm -r "$dir" | ||
done | ||
echo "Successfully cleaned the cache directories" | ||
|
||
# Update the central repository | ||
BAL_DESTINATION_DIR="$HOME/.ballerina/repositories/central.ballerina.io/bala/ballerinax/$BAL_PACKAGE_NAME" | ||
BAL_SOURCE_DIR="$HOME/.ballerina/repositories/local/bala/ballerinax/$BAL_PACKAGE_NAME" | ||
[ -d "$BAL_DESTINATION_DIR" ] && rm -r "$BAL_DESTINATION_DIR" | ||
[ -d "$BAL_SOURCE_DIR" ] && cp -r "$BAL_SOURCE_DIR" "$BAL_DESTINATION_DIR" | ||
echo "Successfully updated the local central repositories" | ||
|
||
# Loop through examples in the examples directory | ||
find "$BAL_EXAMPLES_DIR" -type f -name "*.bal" | while read -r BAL_EXAMPLE_FILE; do | ||
bal "$BAL_CMD" --offline "$BAL_EXAMPLE_FILE" | ||
done |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.