diff --git a/cli/ballerina-cli/src/main/java/io/ballerina/cli/task/RunBallerinaPreBuildToolsTask.java b/cli/ballerina-cli/src/main/java/io/ballerina/cli/task/RunBallerinaPreBuildToolsTask.java index 1c4ce384f0f7..93ff18e09110 100644 --- a/cli/ballerina-cli/src/main/java/io/ballerina/cli/task/RunBallerinaPreBuildToolsTask.java +++ b/cli/ballerina-cli/src/main/java/io/ballerina/cli/task/RunBallerinaPreBuildToolsTask.java @@ -53,7 +53,7 @@ public void execute(Project project) { boolean hasTomlErrors = project.currentPackage().manifest().diagnostics().hasErrors(); if (hasTomlErrors) { toolDiagnostics.forEach(outStream::println); - throw createLauncherException("Ballerina.toml validation for pre build tool execution contains errors"); + throw createLauncherException("ballerina.toml validation for pre build tool execution contains errors"); } List tools = project.currentPackage().manifest().tools(); ServiceLoader buildRunners = ServiceLoader.load(BuildToolRunner.class); @@ -103,7 +103,7 @@ private void validateOptionsToml(Toml optionsToml, String toolName) throws IOExc optionsToml.diagnostics().forEach(outStream::println); for (Diagnostic d : optionsToml.diagnostics()) { if (d.diagnosticInfo().severity().equals(DiagnosticSeverity.ERROR)) { - throw new ProjectException("Ballerina.toml validation for build tool execution contains errors"); + throw new ProjectException("ballerina.toml validation for build tool execution contains errors"); } } } diff --git a/cli/ballerina-cli/src/test/java/io/ballerina/cli/cmd/BuildCommandTest.java b/cli/ballerina-cli/src/test/java/io/ballerina/cli/cmd/BuildCommandTest.java index a8cc6695226d..628a46431c6c 100644 --- a/cli/ballerina-cli/src/test/java/io/ballerina/cli/cmd/BuildCommandTest.java +++ b/cli/ballerina-cli/src/test/java/io/ballerina/cli/cmd/BuildCommandTest.java @@ -1169,17 +1169,22 @@ public Object[][] provideToolPropertiesDiagnostics() { { "build-tool-with-invalid-missing-toml-properties", "build-tool-with-invalid-missing-toml-properties.txt", - "error: Ballerina toml validation for pre build tool execution contains errors" + "error: ballerina.toml validation for pre build tool execution contains errors" }, { "build-tool-with-invalid-missing-optional-toml-properties", "build-tool-with-invalid-missing-optional.txt", - "error: Ballerina toml validation for build tool execution contains errors", + "error: ballerina.toml validation for build tool execution contains errors" }, { "build-tool-with-diagnostics", "build-tool-with-diagnostics.txt", - "error: Pre build tool openapi execution contains errors" + "error: pre-build tool openapi execution contains errors" + }, + { + "build-tool-with-recurring-tool-properties", + "build-tool-with-recurring-tool-properties.txt", + "error: ballerina.toml validation for pre build tool execution contains errors" } }; } diff --git a/cli/ballerina-cli/src/test/resources/test-resources/build-tool-with-recurring-tool-properties/Ballerina.toml b/cli/ballerina-cli/src/test/resources/test-resources/build-tool-with-recurring-tool-properties/Ballerina.toml new file mode 100644 index 000000000000..137618bdc710 --- /dev/null +++ b/cli/ballerina-cli/src/test/resources/test-resources/build-tool-with-recurring-tool-properties/Ballerina.toml @@ -0,0 +1,20 @@ +[package] +org = "foo" +name = "winery" +version = "0.1.0" + +[[tool.openapi]] +id = "generate-delivery-client" +filePath = "delivery.json" +targetModule = "delivery" +options.mode = "client" + +[[tool.openapi]] +id = "generate-delivery-client" +filePath = "delivery1.json" +options.mode = "client" + +[[tool.grpc]] +id = "generate-grpc-client" +filePath = "delivery2.json" +targetModule = "delivery" diff --git a/cli/ballerina-cli/src/test/resources/test-resources/build-tool-with-recurring-tool-properties/main.bal b/cli/ballerina-cli/src/test/resources/test-resources/build-tool-with-recurring-tool-properties/main.bal new file mode 100644 index 000000000000..0a995997c547 --- /dev/null +++ b/cli/ballerina-cli/src/test/resources/test-resources/build-tool-with-recurring-tool-properties/main.bal @@ -0,0 +1,3 @@ +public function main() { + return "Hello, World!"; +} diff --git a/cli/ballerina-cli/src/test/resources/test-resources/command-outputs/unix/build-tool-with-invalid-missing-toml-properties.txt b/cli/ballerina-cli/src/test/resources/test-resources/command-outputs/unix/build-tool-with-invalid-missing-toml-properties.txt index 642de934a441..6d004ad5967f 100644 --- a/cli/ballerina-cli/src/test/resources/test-resources/command-outputs/unix/build-tool-with-invalid-missing-toml-properties.txt +++ b/cli/ballerina-cli/src/test/resources/test-resources/command-outputs/unix/build-tool-with-invalid-missing-toml-properties.txt @@ -1,2 +1,2 @@ -ERROR [Ballerina.toml:(6:1,9:24)] empty string found for key '[filePath]' -ERROR [Ballerina.toml:(6:1,9:24)] missing key '[targetModule]' in table '[tool.openapi]' in 'Ballerina.toml'. +ERROR [Ballerina.toml:(6:1,9:24)] empty string found for key '[filePath]' in table '[tool.openapi]'. +WARNING [Ballerina.toml:(6:1,9:24)] missing key '[targetModule]' in table '[tool.openapi]'. Default module will be taken as target module. diff --git a/cli/ballerina-cli/src/test/resources/test-resources/command-outputs/unix/build-tool-with-recurring-tool-properties.txt b/cli/ballerina-cli/src/test/resources/test-resources/command-outputs/unix/build-tool-with-recurring-tool-properties.txt new file mode 100644 index 000000000000..dd694b2eb514 --- /dev/null +++ b/cli/ballerina-cli/src/test/resources/test-resources/command-outputs/unix/build-tool-with-recurring-tool-properties.txt @@ -0,0 +1,4 @@ +ERROR [Ballerina.toml:(6:1,10:24)] recurring target module delivery found in Ballerina.toml. Target module must be unique for each tool +ERROR [Ballerina.toml:(6:1,10:24)] recurring tool id generate-delivery-client found in Ballerina.toml. Tool id must be unique for each tool +WARNING [Ballerina.toml:(12:1,15:24)] missing key '[targetModule]' in table '[tool.openapi]'. Default module will be taken as target module. +WARNING [Ballerina.toml:(17:1,20:26)] tool options validation skipped due to: Schema file not found: grpc-options-schema.json diff --git a/cli/ballerina-cli/src/test/resources/test-resources/command-outputs/windows/build-tool-with-invalid-missing-toml-properties.txt b/cli/ballerina-cli/src/test/resources/test-resources/command-outputs/windows/build-tool-with-invalid-missing-toml-properties.txt index 642de934a441..6d004ad5967f 100644 --- a/cli/ballerina-cli/src/test/resources/test-resources/command-outputs/windows/build-tool-with-invalid-missing-toml-properties.txt +++ b/cli/ballerina-cli/src/test/resources/test-resources/command-outputs/windows/build-tool-with-invalid-missing-toml-properties.txt @@ -1,2 +1,2 @@ -ERROR [Ballerina.toml:(6:1,9:24)] empty string found for key '[filePath]' -ERROR [Ballerina.toml:(6:1,9:24)] missing key '[targetModule]' in table '[tool.openapi]' in 'Ballerina.toml'. +ERROR [Ballerina.toml:(6:1,9:24)] empty string found for key '[filePath]' in table '[tool.openapi]'. +WARNING [Ballerina.toml:(6:1,9:24)] missing key '[targetModule]' in table '[tool.openapi]'. Default module will be taken as target module. diff --git a/cli/ballerina-cli/src/test/resources/test-resources/command-outputs/windows/build-tool-with-recurring-tool-properties.txt b/cli/ballerina-cli/src/test/resources/test-resources/command-outputs/windows/build-tool-with-recurring-tool-properties.txt new file mode 100644 index 000000000000..dd694b2eb514 --- /dev/null +++ b/cli/ballerina-cli/src/test/resources/test-resources/command-outputs/windows/build-tool-with-recurring-tool-properties.txt @@ -0,0 +1,4 @@ +ERROR [Ballerina.toml:(6:1,10:24)] recurring target module delivery found in Ballerina.toml. Target module must be unique for each tool +ERROR [Ballerina.toml:(6:1,10:24)] recurring tool id generate-delivery-client found in Ballerina.toml. Tool id must be unique for each tool +WARNING [Ballerina.toml:(12:1,15:24)] missing key '[targetModule]' in table '[tool.openapi]'. Default module will be taken as target module. +WARNING [Ballerina.toml:(17:1,20:26)] tool options validation skipped due to: Schema file not found: grpc-options-schema.json diff --git a/compiler/ballerina-lang/src/test/java/io/ballerina/projects/BallerinaTomlTests.java b/compiler/ballerina-lang/src/test/java/io/ballerina/projects/BallerinaTomlTests.java index 2cddef77487b..46c017cee78b 100644 --- a/compiler/ballerina-lang/src/test/java/io/ballerina/projects/BallerinaTomlTests.java +++ b/compiler/ballerina-lang/src/test/java/io/ballerina/projects/BallerinaTomlTests.java @@ -214,12 +214,12 @@ public Object[][] provideBallerinaTomlWithInvalidEntries() { return new Object[][] { { "missing-tool-entries.toml", - "missing key '[filePath]' in table '[tool.openapi]' in 'Ballerina.toml'.", - "missing key '[targetModule]' in table '[tool.openapi]' in 'Ballerina.toml'." + "missing key '[filePath]' in table '[tool.openapi]'.", + "missing key '[id]' in table '[tool.openapi]'." }, { "invalid-tool-entries.toml", - "empty string found for key '[filePath]'", + "empty string found for key '[filePath]' in table '[tool.openapi]'.", "incompatible type found for key '[targetModule]': expected 'STRING'" } }; diff --git a/compiler/ballerina-lang/src/test/resources/ballerina-toml/missing-tool-entries.toml b/compiler/ballerina-lang/src/test/resources/ballerina-toml/missing-tool-entries.toml index 1e6ecd792db4..74d5e2986adb 100644 --- a/compiler/ballerina-lang/src/test/resources/ballerina-toml/missing-tool-entries.toml +++ b/compiler/ballerina-lang/src/test/resources/ballerina-toml/missing-tool-entries.toml @@ -4,5 +4,4 @@ org = "foo" version = "0.1.0" [[tool.openapi]] -id = "generate-delivery-client" options.mode = "client"