Skip to content
Merged
Show file tree
Hide file tree
Changes from 17 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
1 change: 1 addition & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ This file contains all the notable changes done to the Ballerina TCP package thr

### Added
- [Support logging raw template value in log APIs](https://github.com/ballerina-platform/ballerina-library/issues/3331)
- [Add static code rules](https://github.com/ballerina-platform/ballerina-library/issues/7283)

## [2.5.1] - 2023-01-04

Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,5 @@ integration-tests/Dependencies.toml
# Ballerina
velocity.log*
*Ballerina.lock

compiler-plugin-tests/**/target
16 changes: 11 additions & 5 deletions ballerina/Ballerina.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
org = "ballerina"
name = "log"
version = "2.11.0"
version = "2.11.1"
authors = ["Ballerina"]
keywords = ["level", "format"]
repository = "https://github.com/ballerina-platform/module-ballerina-log"
Expand All @@ -15,12 +15,18 @@ graalvmCompatible = true
[[platform.java21.dependency]]
groupId = "io.ballerina.stdlib"
artifactId = "log-native"
version = "2.11.0"
path = "../native/build/libs/log-native-2.11.0.jar"
version = "2.11.1"
path = "../native/build/libs/log-native-2.11.1-SNAPSHOT.jar"

[[platform.java21.dependency]]
groupId = "io.ballerina.stdlib"
artifactId = "log-compiler-plugin"
version = "2.11.1"
path = "../compiler-plugin/build/libs/log-compiler-plugin-2.11.1-SNAPSHOT.jar"

[[platform.java21.dependency]]
groupId = "io.ballerina.stdlib"
artifactId = "log-test-utils"
version = "2.11.0"
path = "../test-utils/build/libs/log-test-utils-2.11.0.jar"
version = "2.11.1"
path = "../test-utils/build/libs/log-test-utils-2.11.1-SNAPSHOT.jar"
scope = "testOnly"
4 changes: 2 additions & 2 deletions ballerina/CompilerPlugin.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[plugin]
id = "log-compiler-plugin"
class = "io.ballerina.stdlib.log.plugin.LogCompilerPlugin"
class = "io.ballerina.stdlib.log.compiler.LogCompilerPlugin"

[[dependency]]
path = "../compiler-plugin/build/libs/log-compiler-plugin-2.11.0.jar"
path = "../compiler-plugin/build/libs/log-compiler-plugin-2.11.1-SNAPSHOT.jar"
2 changes: 1 addition & 1 deletion ballerina/Dependencies.toml
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ modules = [
[[package]]
org = "ballerina"
name = "log"
version = "2.11.0"
version = "2.11.1"
dependencies = [
{org = "ballerina", name = "io"},
{org = "ballerina", name = "jballerina.java"},
Expand Down
6 changes: 6 additions & 0 deletions build-config/resources/Ballerina.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@ artifactId = "log-native"
version = "@toml.version@"
path = "../native/build/libs/log-native-@project.version@.jar"

[[platform.java21.dependency]]
groupId = "io.ballerina.stdlib"
artifactId = "log-compiler-plugin"
version = "@toml.version@"
path = "../compiler-plugin/build/libs/log-compiler-plugin-@project.version@.jar"

[[platform.java21.dependency]]
groupId = "io.ballerina.stdlib"
artifactId = "log-test-utils"
Expand Down
2 changes: 1 addition & 1 deletion build-config/resources/CompilerPlugin.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[plugin]
id = "log-compiler-plugin"
class = "io.ballerina.stdlib.log.plugin.LogCompilerPlugin"
class = "io.ballerina.stdlib.log.compiler.LogCompilerPlugin"

[[dependency]]
path = "../compiler-plugin/build/libs/log-compiler-plugin-@project.version@.jar"
1 change: 1 addition & 0 deletions codecov.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
fixes:
- "ballerina/log/*/::log-ballerina/"
- "io/ballerina/stdlib/log/compiler/::./compiler-plugin/src/main/java/io/ballerina/stdlib/log/compiler/"

ignore:
- "**/tests"
Expand Down
126 changes: 126 additions & 0 deletions compiler-plugin-tests/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
/*
* Copyright (c) 2025, WSO2 LLC. (http://www.wso2.org).
*
* 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.
*/

plugins {
id 'java'
id 'checkstyle'
id 'com.github.spotbugs'
}

description = 'Ballerina - Log Compiler Plugin Tests'

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

implementation project(':log-compiler-plugin')

testImplementation group: 'org.ballerinalang', name: 'ballerina-lang', version: "${ballerinaLangVersion}"
testImplementation group: 'org.ballerinalang', name: 'ballerina-tools-api', version: "${ballerinaLangVersion}"
testImplementation group: 'org.ballerinalang', name: 'ballerina-parser', version: "${ballerinaLangVersion}"

implementation group: 'org.testng', name: 'testng', version: "${testngVersion}"
}

tasks.withType(JavaCompile) {
options.encoding = 'UTF-8'
}

sourceCompatibility = JavaVersion.VERSION_21

test {
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))
}
}
}
}

spotbugsTest {
def classLoader = plugins["com.github.spotbugs"].class.classLoader
def SpotBugsConfidence = classLoader.findLoadedClass("com.github.spotbugs.snom.Confidence")
def SpotBugsEffort = classLoader.findLoadedClass("com.github.spotbugs.snom.Effort")
ignoreFailures = true
effort = SpotBugsEffort.MAX
reportLevel = SpotBugsConfidence.LOW
reportsDir = file("$project.buildDir/reports/spotbugs")
def excludeFile = file("${rootDir}/build-config/spotbugs-exclude.xml")
if (excludeFile.exists()) {
it.excludeFilter = excludeFile
}
reports {
text.enabled = true
}
}

spotbugsMain {
enabled false
}

task validateSpotbugs() {
doLast {
if (spotbugsMain.reports.size() > 0 &&
spotbugsMain.reports[0].destination.exists() &&
spotbugsMain.reports[0].destination.text.readLines().size() > 0) {
spotbugsMain.reports[0].destination?.eachLine {
println 'Failure: ' + it
}
throw new GradleException("Spotbugs rule violations were found.");
}
}
}

tasks.withType(Checkstyle) {
exclude '**/module-info.java'
}

checkstyle {
toolVersion "${project.checkstylePluginVersion}"
configFile rootProject.file("build-config/checkstyle/build/checkstyle.xml")
configProperties = ["suppressionFile": file("${rootDir}/build-config/checkstyle/build/suppressions.xml")]
}

checkstyleMain {
enabled false
}

spotbugsTest.finalizedBy validateSpotbugs
checkstyleTest.dependsOn ':checkstyle:downloadCheckstyleRuleFiles'

compileJava {
doFirst {
options.compilerArgs = [
'--module-path', classpath.asPath,
]
classpath = files()
}
}

test.dependsOn ":log-ballerina:build"
build.dependsOn ":log-ballerina:build"
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
/*
* Copyright (c) 2025, WSO2 LLC. (http://www.wso2.org).
*
* 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.log.compiler.staticcodeanalyzer;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.nio.charset.StandardCharsets;

/**
* Helper class to consume the process streams.
* @since 2.12.0
*/
class ProcessOutputGobbler implements Runnable {
private final InputStream inputStream;
private final StringBuilder output;
private int exitCode;

public ProcessOutputGobbler(InputStream inputStream) {
this.inputStream = inputStream;
this.output = new StringBuilder();
}

@Override
public void run() {
try (BufferedReader reader = new BufferedReader(
new InputStreamReader(inputStream, StandardCharsets.UTF_8))) {
String line;
while ((line = reader.readLine()) != null) {
output.append(line).append("\n");
}
} catch (IOException e) {
this.output.append(e.getMessage());
}
}

public String getOutput() {
return output.toString();
}

public int getExitCode() {
return exitCode;
}

public void setExitCode(int exitCode) {
this.exitCode = exitCode;
}
}
Loading
Loading