This is an automated email from the ASF dual-hosted git repository.

xuanwo pushed a commit to branch java-binding-features
in repository https://gitbox.apache.org/repos/asf/incubator-opendal.git

commit 5a174e84d1ac33ae350fda7f2e4d489a1e026be1
Author: Xuanwo <[email protected]>
AuthorDate: Thu Sep 14 10:59:18 2023 +0800

    ci(bindings/java): Add features support
    
    Signed-off-by: Xuanwo <[email protected]>
---
 .github/workflows/bindings_java.yml |  6 ++-
 .github/workflows/release_java.yml  |  1 +
 bindings/java/Cargo.toml            | 92 ++++++++++++++++++++++++++++---------
 bindings/java/pom.xml               |  3 ++
 bindings/java/tools/build.py        |  4 ++
 5 files changed, 83 insertions(+), 23 deletions(-)

diff --git a/.github/workflows/bindings_java.yml 
b/.github/workflows/bindings_java.yml
index 4d5803fcd..5ed913384 100644
--- a/.github/workflows/bindings_java.yml
+++ b/.github/workflows/bindings_java.yml
@@ -81,10 +81,12 @@ jobs:
         working-directory: bindings/java
         # `mvn install` and `mvn artifact:compare` are required to verify 
reproducible builds:
         # 
https://maven.apache.org/guides/mini/guide-reproducible-builds.html#how-to-test-my-maven-build-reproducibility
+        #
+        # TODO: move redis related tests to a separate job
         shell: bash
         run: |
           if [[ "${{ runner.os }}" != Linux ]]; then
             export NO_DOCKER=true
           fi
-          ./mvnw clean install -DskipTests
-          ./mvnw verify artifact:compare
+          ./mvnw clean install -DskipTests 
-Dcargo-build.features=services-redis
+          ./mvnw verify artifact:compare -Dcargo-build.features=services-redis
diff --git a/.github/workflows/release_java.yml 
b/.github/workflows/release_java.yml
index 6afd3c607..cee529acd 100644
--- a/.github/workflows/release_java.yml
+++ b/.github/workflows/release_java.yml
@@ -68,6 +68,7 @@ jobs:
             -DskipTests=true \
             -Djni.classifier=${{ matrix.classifier }} \
             -Dcargo-build.profile=release \
+            -Dcargo-build.features=services-all \
             -DaltStagingDirectory=local-staging \
             -DskipRemoteStaging=true \
             -DserverId=apache.releases.https \
diff --git a/bindings/java/Cargo.toml b/bindings/java/Cargo.toml
index ee094eda4..09364f268 100644
--- a/bindings/java/Cargo.toml
+++ b/bindings/java/Cargo.toml
@@ -31,57 +31,107 @@ version.workspace = true
 crate-type = ["cdylib"]
 doc = false
 
-[dependencies]
-anyhow = "1.0.71"
-jni = "0.21.1"
-num_cpus = "1.15.0"
-once_cell = "1.17.1"
-tokio = { version = "1.28.1", features = ["full"] }
-
-[dependencies.opendal]
-workspace = true
-features = [
+[features]
+# Enable all opendal default feature by default.
+default = [
   "services-azblob",
   "services-azdls",
-  "services-cacache",
   "services-cos",
+  "services-fs",
+  "services-gcs",
+  "services-ghac",
+  "services-http",
+  "services-ipmfs",
+  "services-memory",
+  "services-obs",
+  "services-oss",
+  "services-s3",
+  "services-webdav",
+  "services-webhdfs",
+]
+
+services-all = [
+  "default",
+
+  "services-cacache",
   "services-dashmap",
   "services-dropbox",
   "services-etcd",
   # FIXME this requires a preinstalled fdb library
   # "services-foundationdb",
-  "services-fs",
   "services-ftp",
-  "services-gcs",
   "services-gdrive",
-  "services-ghac",
   # FIXME how to support HDFS services in bindings?
   # "services-hdfs",
-  "services-http",
   "services-ipfs",
   "services-memcached",
-  "services-memory",
   "services-mini-moka",
   "services-moka",
-  "services-obs",
   "services-onedrive",
-  "services-oss",
   "services-persy",
   "services-postgresql",
   "services-redb",
   "services-redis",
   "services-redis-rustls",
   "services-rocksdb",
-  "services-s3",
   "services-sled",
   "services-supabase",
   "services-tikv",
   "services-vercel-artifacts",
   "services-wasabi",
-  "services-webdav",
-  "services-webhdfs",
 ]
 
+# Default services provided by opendal.
+services-azblob = [ "opendal/services-azblob" ]
+services-azdls = [ "opendal/services-azdls" ]
+services-cos = [ "opendal/services-cos" ]
+services-fs = [ "opendal/services-fs" ]
+services-gcs = [ "opendal/services-gcs" ]
+services-ghac = [ "opendal/services-ghac" ]
+services-http = [ "opendal/services-http" ]
+services-ipmfs = [ "opendal/services-ipmfs" ]
+services-memory = [ "opendal/services-memory" ]
+services-obs = [ "opendal/services-obs" ]
+services-oss = [ "opendal/services-oss" ]
+services-s3 = [ "opendal/services-s3" ]
+services-webdav = [ "opendal/services-webdav" ]
+services-webhdfs = [ "opendal/services-webhdfs" ]
+
+# Optional services provided by opendal.
+services-cacache = ["opendal/services-cacache"]
+services-dashmap = ["opendal/services-dashmap"]
+services-dropbox = ["opendal/services-dropbox"]
+services-etcd = ["opendal/services-etcd"]
+services-foundationdb = ["opendal/services-foundationdb"]
+services-ftp = ["opendal/services-ftp"]
+services-gdrive = ["opendal/services-gdrive"]
+services-hdfs = ["opendal/services-hdfs"]
+services-ipfs = ["opendal/services-ipfs"]
+services-memcached = ["opendal/services-memcached"]
+services-mini-moka = ["opendal/services-mini-moka"]
+services-moka = ["opendal/services-moka"]
+services-onedrive = ["opendal/services-onedrive"]
+services-persy = ["opendal/services-persy"]
+services-postgresql = ["opendal/services-postgresql"]
+services-redb = ["opendal/services-redb"]
+services-redis = ["opendal/services-redis"]
+services-redis-rustls = ["opendal/services-redis-rustls"]
+services-rocksdb = ["opendal/services-rocksdb"]
+services-sftp = ["opendal/services-sftp"]
+services-sled = ["opendal/services-sled"]
+services-supabase = ["opendal/services-supabase"]
+services-tikv = ["opendal/services-tikv"]
+services-vercel-artifacts = ["opendal/services-vercel-artifacts"]
+services-wasabi = ["opendal/services-wasabi"]
+
+[dependencies]
+anyhow = "1.0.71"
+jni = "0.21.1"
+num_cpus = "1.15.0"
+once_cell = "1.17.1"
+tokio = { version = "1.28.1", features = ["full"] }
+opendal = { workspace = true }
+
 # This is not optimal. See also the Cargo issue:
 # https://github.com/rust-lang/cargo/issues/1197#issuecomment-1641086954
 [target.'cfg(unix)'.dependencies.opendal]
diff --git a/bindings/java/pom.xml b/bindings/java/pom.xml
index 2dea1f63f..fd785c931 100644
--- a/bindings/java/pom.xml
+++ b/bindings/java/pom.xml
@@ -53,6 +53,7 @@
         <maven.compiler.target>1.8</maven.compiler.target>
 
         <cargo-build.profile>dev</cargo-build.profile>
+        <cargo-build.features>default</cargo-build.features>
         <jni.classifier>${os.detected.classifier}</jni.classifier>
 
         <assertj.version>3.23.1</assertj.version>
@@ -193,6 +194,8 @@
                                 <argument>${jni.classifier}</argument>
                                 <argument>--profile</argument>
                                 <argument>${cargo-build.profile}</argument>
+                                <argument>--features</argument>
+                                <argument>${cargo-build.features}</argument>
                             </arguments>
                         </configuration>
                     </execution>
diff --git a/bindings/java/tools/build.py b/bindings/java/tools/build.py
index 1492d7dad..2d6b3d2b0 100755
--- a/bindings/java/tools/build.py
+++ b/bindings/java/tools/build.py
@@ -53,10 +53,14 @@ if __name__ == '__main__':
     parser = ArgumentParser(formatter_class=ArgumentDefaultsHelpFormatter)
     parser.add_argument('--classifier', type=str, required=True)
     parser.add_argument('--profile', type=str, default='dev')
+    parser.add_argument('--features', type=str, default='default')
     args = parser.parse_args()
 
     cmd = ['cargo', 'build', '--color=always', f'--profile={args.profile}']
 
+    if args.features:
+        cmd += ['--features', args.features]
+
     target = classifier_to_target(args.classifier)
     if target:
         command = ['rustup', 'target', 'add', target]

Reply via email to