Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change java command to bal command #46

Merged
merged 3 commits into from
May 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Added

### Changed
- [bal tool is not working when java is not installed](https://github.com/ballerina-platform/ballerina-library/issues/6473)

## [1.0.0] - 2024-03-13

### Added
- [Add support for Ballerina Swan Lake Update 8.](https://github.com/ballerina-platform/ballerina-library/issues/5900)
- [Add support for field length constraints (min/max).](https://github.com/ballerina-platform/ballerina-library/issues/5896)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,12 @@ public void execute() {
printStream.println("Generating code for " + schemaPath + "...");
Class<?> clazz = CodegenCmd.class;
ClassLoader classLoader = clazz.getClassLoader();
Path tempFile = Files.createTempFile(null, null);
Path tempFile = Files.createTempFile(null, ".jar");
try (InputStream in = classLoader.getResourceAsStream(EDI_TOOL)) {
Files.copy(in, tempFile, StandardCopyOption.REPLACE_EXISTING);
}
ProcessBuilder processBuilder = new ProcessBuilder(
"java", "-jar", tempFile.toAbsolutePath().toString(), "codegen", schemaPath, outputPath);
"bal", "run", tempFile.toAbsolutePath().toString(), "--", "codegen", schemaPath, outputPath);
processBuilder.inheritIO();
Process process = processBuilder.start();
process.waitFor();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,12 @@ public void execute() {
try {
printStream.println("Generating EDI schema for EDIFACT schema ...");
URL res = ConvertEdifactCmd.class.getClassLoader().getResource("editools.jar");
Path tempFile = Files.createTempFile(null, null);
Path tempFile = Files.createTempFile(null, ".jar");
try (InputStream in = res.openStream()) {
Files.copy(in, tempFile, StandardCopyOption.REPLACE_EXISTING);
}
ProcessBuilder processBuilder = new ProcessBuilder(
"java", "-jar", tempFile.toAbsolutePath().toString(), CMD_NAME, version, type == null ? "" : type,
"bal", "run", tempFile.toAbsolutePath().toString(), "--", CMD_NAME, version, type == null ? "" : type,
dir);
processBuilder.inheritIO();
Process process = processBuilder.start();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,14 +80,15 @@ public void execute() {
Class<?> clazz = ConvertX12Cmd.class;
ClassLoader classLoader = clazz.getClassLoader();
try {
Path tempFile = Files.createTempFile(null, null);
Path tempFile = Files.createTempFile(null, ".jar");
try (InputStream in = classLoader.getResourceAsStream(EDI_TOOL)) {
Files.copy(in, tempFile, StandardCopyOption.REPLACE_EXISTING);
}
List<String> argsList = new ArrayList<>();
argsList.add("java");
argsList.add("-jar");
argsList.add("bal");
argsList.add("run");
argsList.add(tempFile.toAbsolutePath().toString());
argsList.add("--");
argsList.add(CMD_NAME);
if (headersIncluded) {
argsList.add("H");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,11 @@ public void execute() {
try {
Class<?> clazz = EdiCmd.class;
ClassLoader classLoader = clazz.getClassLoader();
Path tempFile = Files.createTempFile(null, null);
Path tempFile = Files.createTempFile(null, ".jar");
try (InputStream in = classLoader.getResourceAsStream(EDI_TOOL)) {
Files.copy(in, tempFile, StandardCopyOption.REPLACE_EXISTING);
}
ProcessBuilder processBuilder = new ProcessBuilder("java", "-jar", tempFile.toAbsolutePath().toString());
ProcessBuilder processBuilder = new ProcessBuilder("bal", "run", tempFile.toAbsolutePath().toString());
processBuilder.inheritIO();
Process process = processBuilder.start();
process.waitFor();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,12 @@ public void execute() {
printStream.println("Converting ESL schemas in " + schemaPath);
Class<?> clazz = LibgenCmd.class;
ClassLoader classLoader = clazz.getClassLoader();
Path tempFile = Files.createTempFile(null, null);
Path tempFile = Files.createTempFile(null, ".jar");
try (InputStream in = classLoader.getResourceAsStream(EDI_TOOL)) {
Files.copy(in, tempFile, StandardCopyOption.REPLACE_EXISTING);
}
ProcessBuilder processBuilder = new ProcessBuilder(
"java", "-jar", tempFile.toAbsolutePath().toString(), "convertESL", schemaPath, basedefPath,
"bal", "run", tempFile.toAbsolutePath().toString(), "--", "convertESL", schemaPath, basedefPath,
outputPath);
Process process = processBuilder.start();
process.waitFor();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,14 +67,14 @@ public void execute() {
printStream.println("Generating library package for " + packageName + " : " + schemaPath);
Class<?> clazz = LibgenCmd.class;
ClassLoader classLoader = clazz.getClassLoader();
Path tempFile = Files.createTempFile(null, null);
Path tempFile = Files.createTempFile(null, ".jar");
try (InputStream in = classLoader.getResourceAsStream(EDI_TOOL)) {
Files.copy(in, tempFile, StandardCopyOption.REPLACE_EXISTING);
}
String orgName = packageName.split("/")[0];
String libName = packageName.split("/")[1];
ProcessBuilder processBuilder = new ProcessBuilder(
"java", "-jar", tempFile.toAbsolutePath().toString(), "libgen", orgName, libName, schemaPath,
"bal", "run", tempFile.toAbsolutePath().toString(), "--", "libgen", orgName, libName, schemaPath,
outputPath);
processBuilder.inheritIO();
Process process = processBuilder.start();
Expand Down
2 changes: 1 addition & 1 deletion edi-tools-package/BalTool.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
id = "edi"

[[dependency]]
path = "resources/edi-tools-cli-1.0.0.jar"
path = "resources/edi-tools-cli-2.0.0.jar"
2 changes: 1 addition & 1 deletion edi-tools-package/Ballerina.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
org = "ballerina"
name = "editoolspackage"
version = "1.0.0"
version = "2.0.0"
authors = ["Ballerina"]
keywords = ["edi"]
license = ["Apache-2.0"]
Expand Down
2 changes: 1 addition & 1 deletion edi-tools/Ballerina.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
org = "ballerina"
name = "editools"
version = "1.0.0"
version = "2.0.0"
authors = ["Ballerina"]
keywords = ["edi"]
license = ["Apache-2.0"]
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
org.gradle.caching=true
group=io.ballerina.stdlib
version=1.0.1
version=2.0.0

#dependency
checkstylePluginVersion=10.12.0
Expand Down
Loading