diff --git a/.github/workflows/central-publish.yml b/.github/workflows/central-publish.yml index 96d1eed..a4ff485 100644 --- a/.github/workflows/central-publish.yml +++ b/.github/workflows/central-publish.yml @@ -27,7 +27,7 @@ jobs: env: packageUser: ${{ github.actor }} packagePAT: ${{ secrets.GITHUB_TOKEN }} - run: ./gradlew build -x test + run: ./gradlew build -x check -x test - name: Create lib directory if not exists run: mkdir -p ballerina/lib - name: Run Trivy vulnerability scanner diff --git a/.github/workflows/publish-release.yml b/.github/workflows/publish-release.yml index 32c2d8e..70ba934 100644 --- a/.github/workflows/publish-release.yml +++ b/.github/workflows/publish-release.yml @@ -25,7 +25,7 @@ jobs: run: | git config --global user.name ${{ secrets.BALLERINA_BOT_USERNAME }} git config --global user.email ${{ secrets.BALLERINA_BOT_EMAIL }} - ./gradlew build -x test + ./gradlew build -x check -x test - name: Create lib directory if not exists run: mkdir -p ballerina/lib - name: Run Trivy vulnerability scanner diff --git a/.github/workflows/trivy-scan.yml b/.github/workflows/trivy-scan.yml index a8af7e3..15a6ff8 100644 --- a/.github/workflows/trivy-scan.yml +++ b/.github/workflows/trivy-scan.yml @@ -20,7 +20,7 @@ jobs: env: packageUser: ${{ github.actor }} packagePAT: ${{ secrets.GITHUB_TOKEN }} - run: ./gradlew build -x test + run: ./gradlew build -x check -x test - name: Create lib directory if not exists run: mkdir -p ballerina/lib - name: Run Trivy vulnerability scanner diff --git a/ballerina/Ballerina.toml b/ballerina/Ballerina.toml index d52d305..d8baaa3 100644 --- a/ballerina/Ballerina.toml +++ b/ballerina/Ballerina.toml @@ -1,12 +1,21 @@ [package] org = "ballerinax" name = "h2.driver" -version = "0.1.0" +version = "1.0.0" authors = ["Ballerina"] keywords = ["H2"] repository = "https://github.com/ballerina-platform/module-ballerinax-h2.driver" license = ["Apache-2.0"] distribution = "2201.7.0" +[platform.java11] +graalvmCompatible = true + [[platform.java11.dependency]] path = "./lib/h2-2.2.220.jar" + +[[platform.java11.dependency]] +groupId = "io.ballerina.stdlib" +artifactId = "h2.driver-native" +version = "1.0.0" +path = "../native/build/libs/h2.driver-native-1.0.0-SNAPSHOT.jar" diff --git a/ballerina/Dependencies.toml b/ballerina/Dependencies.toml index b69cde2..bb8be24 100644 --- a/ballerina/Dependencies.toml +++ b/ballerina/Dependencies.toml @@ -10,7 +10,7 @@ distribution-version = "2201.7.0" [[package]] org = "ballerinax" name = "h2.driver" -version = "0.1.0" +version = "1.0.0" modules = [ {org = "ballerinax", packageName = "h2.driver", moduleName = "h2.driver"} ] diff --git a/ballerina/build.gradle b/ballerina/build.gradle index ade1e18..713125c 100644 --- a/ballerina/build.gradle +++ b/ballerina/build.gradle @@ -107,3 +107,5 @@ publishing { build.dependsOn "unpackJballerinaTools" build.dependsOn "generatePomFileForMavenPublication" +build.dependsOn ":${packageName}-native:build" +test.dependsOn ":${packageName}-native:build" diff --git a/build-config/resources/Ballerina.toml b/build-config/resources/Ballerina.toml index 5dfecc0..c5e47b1 100644 --- a/build-config/resources/Ballerina.toml +++ b/build-config/resources/Ballerina.toml @@ -8,5 +8,14 @@ repository = "https://github.com/ballerina-platform/module-ballerinax-h2.driver" license = ["Apache-2.0"] distribution = "2201.7.0" +[platform.java11] +graalvmCompatible = true + [[platform.java11.dependency]] path = "./lib/h2-@h2.driver.version@.jar" + +[[platform.java11.dependency]] +groupId = "io.ballerina.stdlib" +artifactId = "h2.driver-native" +version = "@toml.version@" +path = "../native/build/libs/h2.driver-native-@project.version@.jar" diff --git a/build.gradle b/build.gradle index 1505410..e379efa 100644 --- a/build.gradle +++ b/build.gradle @@ -97,6 +97,7 @@ release { } task build { + dependsOn("${packageName}-native:build") dependsOn("${packageName}-ballerina:build") } diff --git a/gradle.properties b/gradle.properties index aa98186..c1e23fb 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,5 +1,5 @@ group=io.ballerina.stdlib -version=0.1.1-SNAPSHOT +version=1.0.0-SNAPSHOT githubSpotbugsVersion=4.0.5 githubJohnrengelmanShadowVersion=5.2.0 diff --git a/native/build.gradle b/native/build.gradle new file mode 100644 index 0000000..894e605 --- /dev/null +++ b/native/build.gradle @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2022 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. + * + */ + +plugins { + id 'java' +} + +description = 'Ballerina - H2 driver Java Native' + +tasks.withType(JavaCompile) { + options.encoding = 'UTF-8' +} + +sourceCompatibility = JavaVersion.VERSION_11 + +compileJava { + doFirst { + options.compilerArgs = [ + '--module-path', classpath.asPath, + ] + classpath = files() + } +} diff --git a/native/src/main/resources/META-INF/native-image/io.ballerina.stdlib/mysql.driver-native/reflect-config.json b/native/src/main/resources/META-INF/native-image/io.ballerina.stdlib/mysql.driver-native/reflect-config.json new file mode 100644 index 0000000..caea2c5 --- /dev/null +++ b/native/src/main/resources/META-INF/native-image/io.ballerina.stdlib/mysql.driver-native/reflect-config.json @@ -0,0 +1,179 @@ +[ + { + "name": "org.h2.Driver" + }, + { + "name":"org.h2.jdbcx.JdbcDataSource", + "queryAllPublicMethods":true, + "methods":[ + { + "name":"", + "parameterTypes":[] + }, + { + "name":"setLoginTimeout", + "parameterTypes":["int"] + }, + { + "name":"setPassword", + "parameterTypes":["java.lang.String"] + }, + { + "name":"setUrl", + "parameterTypes":["java.lang.String"] + }, + { + "name":"setUser", + "parameterTypes":["java.lang.String"] + } + ] + }, + { + "name": "org.h2.mvstore.db.LobStorageMap$BlobMeta$Type", + "fields": [ + { + "name": "INSTANCE" + } + ] + }, + { + "name": "org.h2.mvstore.db.LobStorageMap$BlobReference$Type", + "fields": [ + { + "name": "INSTANCE" + } + ] + }, + { + "name": "org.h2.mvstore.db.NullValueDataType", + "fields": [ + { + "name": "INSTANCE" + } + ] + }, + { + "name": "org.h2.mvstore.db.RowDataType$Factory", + "methods": [ + { + "name": "", + "parameterTypes": [] + } + ] + }, + { + "name": "org.h2.mvstore.tx.VersionedValueType$Factory", + "methods": [ + { + "name": "", + "parameterTypes": [] + } + ] + }, + { + "name": "org.h2.mvstore.type.ByteArrayDataType", + "fields": [ + { + "name": "INSTANCE" + } + ] + }, + { + "name": "org.h2.mvstore.type.LongDataType", + "fields": [ + { + "name": "INSTANCE" + } + ] + }, + { + "name": "org.h2.store.fs.async.FilePathAsync", + "methods": [ + { + "name": "", + "parameterTypes": [] + } + ] + }, + { + "name": "org.h2.store.fs.disk.FilePathDisk", + "methods": [ + { + "name": "", + "parameterTypes": [] + } + ] + }, + { + "name": "org.h2.store.fs.mem.FilePathMem", + "methods": [ + { + "name": "", + "parameterTypes": [] + } + ] + }, + { + "name": "org.h2.store.fs.mem.FilePathMemLZF", + "methods": [ + { + "name": "", + "parameterTypes": [] + } + ] + }, + { + "name": "org.h2.store.fs.niomapped.FilePathNioMapped", + "methods": [ + { + "name": "", + "parameterTypes": [] + } + ] + }, + { + "name": "org.h2.store.fs.niomem.FilePathNioMem", + "methods": [ + { + "name": "", + "parameterTypes": [] + } + ] + }, + { + "name": "org.h2.store.fs.niomem.FilePathNioMemLZF", + "methods": [ + { + "name": "", + "parameterTypes": [] + } + ] + }, + { + "name": "org.h2.store.fs.retry.FilePathRetryOnInterrupt", + "methods": [ + { + "name": "", + "parameterTypes": [] + } + ] + }, + { + "name": "org.h2.store.fs.split.FilePathSplit", + "methods": [ + { + "name": "", + "parameterTypes": [] + } + ] + }, + { + "name": "org.h2.store.fs.zip.FilePathZip", + "methods": [ + { + "name": "", + "parameterTypes": [] + } + ] + } +] diff --git a/native/src/main/resources/META-INF/native-image/io.ballerina.stdlib/mysql.driver-native/resource-config.json b/native/src/main/resources/META-INF/native-image/io.ballerina.stdlib/mysql.driver-native/resource-config.json new file mode 100644 index 0000000..2751e7c --- /dev/null +++ b/native/src/main/resources/META-INF/native-image/io.ballerina.stdlib/mysql.driver-native/resource-config.json @@ -0,0 +1,10 @@ +{ + "resources": { + "includes": [ + { + "pattern": "\\Qorg/h2/util/data.zip\\E" + } + ] + }, + "bundles": [] +} diff --git a/settings.gradle b/settings.gradle index 0c2ba8e..96c5fc6 100644 --- a/settings.gradle +++ b/settings.gradle @@ -13,8 +13,10 @@ plugins { rootProject.name = 'ballerinax-h2.driver' +include ':h2.driver-native' include ':h2.driver-ballerina' +project(':h2.driver-native').projectDir = file('native') project(':h2.driver-ballerina').projectDir = file('ballerina') gradleEnterprise {