Skip to content

Commit

Permalink
Add implementation for compiler plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
SasinduDilshara committed Jul 2, 2024
1 parent 30fb9e4 commit 8b2f215
Show file tree
Hide file tree
Showing 29 changed files with 1,266 additions and 124 deletions.
29 changes: 28 additions & 1 deletion ballerina/Dependencies.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

[ballerina]
dependencies-toml-version = "2"
distribution-version = "2201.8.6"
distribution-version = "2201.9.0"

[[package]]
org = "ballerina"
Expand Down Expand Up @@ -40,6 +40,26 @@ modules = [
{org = "ballerina", packageName = "jballerina.java", moduleName = "jballerina.java"}
]

[[package]]
org = "ballerina"
name = "lang.__internal"
version = "0.0.0"
scope = "testOnly"
dependencies = [
{org = "ballerina", name = "jballerina.java"},
{org = "ballerina", name = "lang.object"}
]

[[package]]
org = "ballerina"
name = "lang.array"
version = "0.0.0"
scope = "testOnly"
dependencies = [
{org = "ballerina", name = "jballerina.java"},
{org = "ballerina", name = "lang.__internal"}
]

[[package]]
org = "ballerina"
name = "lang.error"
Expand All @@ -49,13 +69,20 @@ dependencies = [
{org = "ballerina", name = "jballerina.java"}
]

[[package]]
org = "ballerina"
name = "lang.object"
version = "0.0.0"
scope = "testOnly"

[[package]]
org = "ballerina"
name = "test"
version = "0.0.0"
scope = "testOnly"
dependencies = [
{org = "ballerina", name = "jballerina.java"},
{org = "ballerina", name = "lang.array"},
{org = "ballerina", name = "lang.error"}
]
modules = [
Expand Down
19 changes: 9 additions & 10 deletions ballerina/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -87,21 +87,18 @@ task updateTomlFiles {
newConfig = newConfig.replace("@constraint.version@", stdlibDependentConstraintVersion)

ballerinaTomlFile.text = newConfig

// def newCompilerPluginToml = compilerPluginTomlFilePlaceHolder.text.replace("@project.version@", project.version)
// compilerPluginTomlFile.text = newCompilerPluginToml
}
}

task commitTomlFiles {
doLast {
project.exec {
ignoreExitValue true
// if (Os.isFamily(Os.FAMILY_WINDOWS)) {
// commandLine 'cmd', '/c', "git commit Ballerina.toml Dependencies.toml CompilerPlugin.toml -m '[Automated] Update the native jar versions'"
// } else {
// commandLine 'sh', '-c', "git commit Ballerina.toml Dependencies.toml CompilerPlugin.toml -m '[Automated] Update the native jar versions'"
// }
if (Os.isFamily(Os.FAMILY_WINDOWS)) {
commandLine 'cmd', '/c', "git commit Ballerina.toml Dependencies.toml CompilerPlugin.toml -m '[Automated] Update the native jar versions'"
} else {
commandLine 'sh', '-c', "git commit Ballerina.toml Dependencies.toml CompilerPlugin.toml -m '[Automated] Update the native jar versions'"
}
}
}
}
Expand Down Expand Up @@ -136,8 +133,10 @@ updateTomlFiles.dependsOn copyStdlibs

build.dependsOn "generatePomFileForMavenPublication"
build.dependsOn ":${packageName}-native:build"
//build.dependsOn ":${packageName}-compiler-plugin:build"
build.dependsOn deleteDependencyTomlFiles
build.dependsOn ":${packageName}-compiler-plugin:build"
build.dependsOn deleteDependencyTomlFiles

test.dependsOn ":${packageName}-native:build"
//test.dependsOn ":${packageName}-compiler-plugin:build"
test.dependsOn ":${packageName}-native:build"
test.dependsOn ":${packageName}-compiler-plugin:build"
4 changes: 2 additions & 2 deletions build-config/checkstyle/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ apply plugin: 'java'

task downloadCheckstyleRuleFiles(type: Download) {
src([
'https://raw.githubusercontent.com/wso2/code-quality-tools/v1.4/checkstyle/jdk-17/checkstyle.csv',
'https://raw.githubusercontent.com/wso2/code-quality-tools/v1.4/checkstyle/jdk-17/suppressions.csv'
'https://raw.githubusercontent.com/wso2/code-quality-tools/v1.4/checkstyle/jdk-17/checkstyle.xml',
'https://raw.githubusercontent.com/wso2/code-quality-tools/v1.4/checkstyle/jdk-17/suppressions.xml'
])
overwrite false
onlyIfNewer true
Expand Down
6 changes: 6 additions & 0 deletions build-config/resources/CompilerPlugin.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[plugin]
id = "constraint-compiler-plugin"
class = "io.ballerina.stdlib.data.csvdata.compiler.CsvDataCompilerPlugin"

[[dependency]]
path = "../compiler-plugin/build/libs/data.csv-compiler-plugin-@project.version@.jar"
11 changes: 7 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@
*/

plugins {
id "com.github.spotbugs" version "${githubSpotbugsVersion}"
id "com.github.johnrengelman.shadow" version "${githubJohnrengelmanShadowVersion}"
id "de.undercouch.download" version "${underCouchDownloadVersion}"
id "net.researchgate.release" version "${researchgateReleaseVersion}"
id "com.github.spotbugs"
id "com.github.johnrengelman.shadow"
id "de.undercouch.download"
id "net.researchgate.release"
}

allprojects {
Expand Down Expand Up @@ -67,7 +67,10 @@ subprojects {

dependencies {
/* Standard libraries */
ballerinaStdLibs "io.ballerina.stdlib:file-ballerina:${stdlibFileVersion}"
ballerinaStdLibs "io.ballerina.stdlib:io-ballerina:${stdlibIoVersion}"
ballerinaStdLibs "io.ballerina.stdlib:os-ballerina:${stdlibOsVersion}"
ballerinaStdLibs "io.ballerina.stdlib:time-ballerina:${stdlibTimeVersion}"
ballerinaStdLibs "io.ballerina.stdlib:constraint-ballerina:${stdlibConstraintVersion}"
}
}
Expand Down
108 changes: 108 additions & 0 deletions compiler-plugin-test/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
/*
* Copyright (c) 2024, WSO2 LLC. (http://www.wso2.com).
*
* 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 - Csv Compiler Plugin Tests'

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

implementation project(':data.csv-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}"
testImplementation group: 'org.testng', name: 'testng', version: "${testngVersion}"
}

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

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

checkstyleTest.dependsOn(":checkstyle:downloadCheckstyleRuleFiles")

spotbugsTest {
effort "max"
reportLevel "low"
reportsDir = file("$project.buildDir/reports/spotbugs")
reports {
html.enabled true
text.enabled = true
}
def excludeFile = file("${project.projectDir}/spotbugs-exclude.xml")
if(excludeFile.exists()) {
excludeFilter = excludeFile
}
}

spotbugsMain {
enabled false
}

checkstyleMain {
enabled false
}

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

test {
systemProperty "ballerina.offline.flag", "true"
useTestNG()
finalizedBy jacocoTestReport

testLogging {
exceptionFormat = "full"
afterSuite { desc, result ->
if (!desc.parent) { // will match the outermost suite
def output = "Compiler Plugin Tests: ${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))
}
}
}
}

jacocoTestReport {
dependsOn test
reports {
xml.required = true
}
sourceSets project(':data.csv-compiler-plugin').sourceSets.main
}

test.dependsOn ":data.csv-ballerina:build"
Loading

0 comments on commit 8b2f215

Please sign in to comment.