diff --git a/ballerina/Ballerina.toml b/ballerina/Ballerina.toml index d8ada3f4..e647ec4a 100644 --- a/ballerina/Ballerina.toml +++ b/ballerina/Ballerina.toml @@ -1,7 +1,7 @@ [package] org = "ballerinax" name = "stan" -version = "2.6.0" +version = "2.6.1" authors = ["Ballerina"] keywords = ["service", "client", "messaging", "network", "streaming"] repository = "https://github.com/ballerina-platform/module-ballerinax-stan" @@ -21,8 +21,8 @@ path = "./lib/protobuf-java-3.20.3.jar" [[platform.java11.dependency]] groupId = "io.ballerina.stdlib" artifactId = "stan-native" -version = "2.6.0" -path = "../native/build/libs/stan-native-2.6.0.jar" +version = "2.6.1" +path = "../native/build/libs/stan-native-2.6.1-SNAPSHOT.jar" [build-options] observabilityIncluded=true diff --git a/ballerina/CompilerPlugin.toml b/ballerina/CompilerPlugin.toml index 378bfa09..6ff97ffd 100644 --- a/ballerina/CompilerPlugin.toml +++ b/ballerina/CompilerPlugin.toml @@ -3,4 +3,4 @@ id = "stan-compiler-plugin" class = "io.ballerina.stdlib.stan.plugin.StanCompilerPlugin" [[dependency]] -path = "../compiler-plugin/build/libs/stan-compiler-plugin-2.6.0.jar" +path = "../compiler-plugin/build/libs/stan-compiler-plugin-2.6.1-SNAPSHOT.jar" diff --git a/ballerina/Dependencies.toml b/ballerina/Dependencies.toml index 088b3d7c..cc73dbeb 100644 --- a/ballerina/Dependencies.toml +++ b/ballerina/Dependencies.toml @@ -97,7 +97,7 @@ modules = [ [[package]] org = "ballerina" name = "observe" -version = "1.0.6" +version = "1.0.7" dependencies = [ {org = "ballerina", name = "jballerina.java"} ] @@ -137,7 +137,7 @@ modules = [ [[package]] org = "ballerinax" name = "stan" -version = "2.6.0" +version = "2.6.1" dependencies = [ {org = "ballerina", name = "crypto"}, {org = "ballerina", name = "jballerina.java"}, diff --git a/changelog.md b/changelog.md index c58b6019..4649444f 100644 --- a/changelog.md +++ b/changelog.md @@ -3,6 +3,12 @@ This file contains all the notable changes done to the Ballerina STAN package th The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [Unreleased] + +### Added + +- [Add deprecation warning to compiler plugin.](https://github.com/ballerina-platform/ballerina-standard-library/issues/4227) + ## [2.5.0] - 2022-11-29 ### Changed diff --git a/compiler-plugin-tests/src/test/java/io/ballerina/stdlib/stan/plugin/StanCompilerPluginTest.java b/compiler-plugin-tests/src/test/java/io/ballerina/stdlib/stan/plugin/StanCompilerPluginTest.java index 6f033004..24aa0f21 100644 --- a/compiler-plugin-tests/src/test/java/io/ballerina/stdlib/stan/plugin/StanCompilerPluginTest.java +++ b/compiler-plugin-tests/src/test/java/io/ballerina/stdlib/stan/plugin/StanCompilerPluginTest.java @@ -98,6 +98,15 @@ public void testValidService7() { Assert.assertEquals(diagnosticResult.errors().size(), 0); } + public void testDeprecationNotice() { + Package currentPackage = loadPackage("deprecation_notice"); + PackageCompilation compilation = currentPackage.getCompilation(); + DiagnosticResult diagnosticResult = compilation.diagnosticResult(); + Assert.assertEquals(diagnosticResult.warnings().size(), 1); + Diagnostic diagnostic = (Diagnostic) diagnosticResult.warnings().toArray()[0]; + assertDiagnostic(diagnostic, CompilationErrors.DEPRECATION_WARNING); + } + @Test public void testInvalidService1() { Package currentPackage = loadPackage("invalid_service_1"); diff --git a/compiler-plugin-tests/src/test/resources/ballerina_sources/deprecation_notice/Ballerina.toml b/compiler-plugin-tests/src/test/resources/ballerina_sources/deprecation_notice/Ballerina.toml new file mode 100644 index 00000000..ce36a37e --- /dev/null +++ b/compiler-plugin-tests/src/test/resources/ballerina_sources/deprecation_notice/Ballerina.toml @@ -0,0 +1,4 @@ +[package] +org = "stan_test" +name = "deprecation_notice" +version = "0.1.0" diff --git a/compiler-plugin-tests/src/test/resources/ballerina_sources/deprecation_notice/main.bal b/compiler-plugin-tests/src/test/resources/ballerina_sources/deprecation_notice/main.bal new file mode 100644 index 00000000..a3a04a94 --- /dev/null +++ b/compiler-plugin-tests/src/test/resources/ballerina_sources/deprecation_notice/main.bal @@ -0,0 +1,21 @@ +// Copyright (c) 2023, WSO2 LLC. (https://www.wso2.com) 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 ballerinax/stan; + +public function main() returns error? { + stan:Client stanClient = check new(stan:DEFAULT_URL); +} diff --git a/compiler-plugin/src/main/java/io/ballerina/stdlib/stan/plugin/PluginConstants.java b/compiler-plugin/src/main/java/io/ballerina/stdlib/stan/plugin/PluginConstants.java index 8f4337f4..69e0a073 100644 --- a/compiler-plugin/src/main/java/io/ballerina/stdlib/stan/plugin/PluginConstants.java +++ b/compiler-plugin/src/main/java/io/ballerina/stdlib/stan/plugin/PluginConstants.java @@ -73,7 +73,9 @@ enum CompilationErrors { INVALID_ANNOTATION("Invalid service config annotation. Only @nats:ServiceConfig{} is allowed.", "STAN_116"), INVALID_SERVICE_ATTACH_POINT("Invalid service attach point. Only string literals are allowed.", - "STAN_117"); + "STAN_117"), + DEPRECATION_WARNING("The ballerinax/stan module is being deprecated. NATS enabled applications requiring " + + "persistence should use the JetStreamClient provided by ballerinax/nats module.", "STAN_118"); private final String error; private final String errorCode; diff --git a/compiler-plugin/src/main/java/io/ballerina/stdlib/stan/plugin/StanCodeAnalyzer.java b/compiler-plugin/src/main/java/io/ballerina/stdlib/stan/plugin/StanCodeAnalyzer.java index 2a279b35..1e3aade0 100644 --- a/compiler-plugin/src/main/java/io/ballerina/stdlib/stan/plugin/StanCodeAnalyzer.java +++ b/compiler-plugin/src/main/java/io/ballerina/stdlib/stan/plugin/StanCodeAnalyzer.java @@ -28,6 +28,7 @@ public class StanCodeAnalyzer extends CodeAnalyzer { @Override public void init(CodeAnalysisContext codeAnalysisContext) { + codeAnalysisContext.addSyntaxNodeAnalysisTask(new StanImportAnalysisTask(), SyntaxKind.IMPORT_DECLARATION); codeAnalysisContext.addSyntaxNodeAnalysisTask(new StanServiceAnalysisTask(), SyntaxKind.SERVICE_DECLARATION); } } diff --git a/compiler-plugin/src/main/java/io/ballerina/stdlib/stan/plugin/StanImportAnalysisTask.java b/compiler-plugin/src/main/java/io/ballerina/stdlib/stan/plugin/StanImportAnalysisTask.java new file mode 100644 index 00000000..d800763c --- /dev/null +++ b/compiler-plugin/src/main/java/io/ballerina/stdlib/stan/plugin/StanImportAnalysisTask.java @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2023, WSO2 LLC. (https://www.wso2.com) 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. + */ + +package io.ballerina.stdlib.stan.plugin; + +import io.ballerina.compiler.syntax.tree.ImportDeclarationNode; +import io.ballerina.projects.plugins.AnalysisTask; +import io.ballerina.projects.plugins.SyntaxNodeAnalysisContext; +import io.ballerina.tools.diagnostics.DiagnosticSeverity; + +/** + * STAN import declaration analysis task. + */ +public class StanImportAnalysisTask implements AnalysisTask { + @Override + public void perform(SyntaxNodeAnalysisContext context) { + ImportDeclarationNode importNode = (ImportDeclarationNode) context.node(); + if (importNode.orgName().isPresent() && + importNode.orgName().get().orgName().toString().equals(PluginConstants.PACKAGE_ORG) && + importNode.moduleName().get(0).toString().equals(PluginConstants.PACKAGE_PREFIX)) { + context.reportDiagnostic(PluginUtils.getDiagnostic( + PluginConstants.CompilationErrors.DEPRECATION_WARNING, + DiagnosticSeverity.WARNING, importNode.location())); + } + } +}