This is an automated email from the ASF dual-hosted git repository.
chaokunyang pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/fory.git
The following commit(s) were added to refs/heads/main by this push:
new 880257cad feat(java): use java11 for fory-format module (#2448)
880257cad is described below
commit 880257cadd0345d873896632ff9081a5afe4ea08
Author: Shawn Yang <[email protected]>
AuthorDate: Sun Aug 10 19:12:28 2025 +0800
feat(java): use java11 for fory-format module (#2448)
## What does this PR do?
use java11 for fory-format module
## Related issues
#2422
## Does this PR introduce any user-facing change?
<!--
If any user-facing interface changes, please [open an
issue](https://github.com/apache/fory/issues/new/choose) describing the
need to do so and update the document if necessary.
-->
- [ ] Does this PR introduce any public API change?
- [ ] Does this PR introduce any binary protocol compatibility change?
## Benchmark
<!--
When the PR has an impact on performance (if you don't know whether the
PR will have an impact on performance, you can submit the PR first, and
if it will have impact on performance, the code reviewer will explain
it), be sure to attach a benchmark data here.
-->
---
.github/workflows/ci.yml | 2 +-
.github/workflows/release-java-snapshot.yaml | 2 +-
ci/run_ci.py | 28 ++++++-
ci/tasks/java.py | 112 +++++++++++++++++++++++----
java/fory-format/pom.xml | 4 +-
5 files changed, 125 insertions(+), 23 deletions(-)
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 37fb3c73c..207d97ee9 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -163,7 +163,7 @@ jobs:
with:
python-version: 3.8
- name: Install fory java
- run: cd java && mvn -T10 --no-transfer-progress clean install
-DskipTests && cd -
+ run: python ./ci/run_ci.py java --install-jdks --install-fory
- name: Run Kotlin CI
run: python ./ci/run_ci.py kotlin
diff --git a/.github/workflows/release-java-snapshot.yaml
b/.github/workflows/release-java-snapshot.yaml
index 5050189f4..e523cd7b0 100644
--- a/.github/workflows/release-java-snapshot.yaml
+++ b/.github/workflows/release-java-snapshot.yaml
@@ -40,7 +40,7 @@ jobs:
server-username: NEXUS_USERNAME
server-password: NEXUS_PASSWORD
- name: Publish Fory Java Snapshot
- run: cd java && mvn deploy -Dgpg.skip -DskipTests -Papache-release
+ run: python ./ci/run_ci.py java --version 8 --deploy
env:
NEXUS_USERNAME: ${{ secrets.NEXUS_USER }}
NEXUS_PASSWORD: ${{ secrets.NEXUS_PW }}
diff --git a/ci/run_ci.py b/ci/run_ci.py
index cda65daf1..64fb01154 100644
--- a/ci/run_ci.py
+++ b/ci/run_ci.py
@@ -167,7 +167,22 @@ def parse_args():
default="17",
help="Java version to use for testing",
)
- java_parser.set_defaults(func=lambda version: java.run(version))
+ java_parser.add_argument(
+ "--release",
+ action="store_true",
+ help="Release to Maven Central",
+ )
+ java_parser.add_argument(
+ "--install-jdks",
+ action="store_true",
+ help="Install JDKs",
+ )
+ java_parser.add_argument(
+ "--install-fory",
+ action="store_true",
+ help="Install Fory",
+ )
+ java_parser.set_defaults(func=java.run)
# Kotlin subparser
kotlin_parser = subparsers.add_parser(
@@ -220,16 +235,21 @@ def parse_args():
# Call the appropriate function with the remaining arguments
if command == "java":
if USE_PYTHON_JAVA:
- func(arg_dict.get("version"))
+ func(arg_dict.get("version"), arg_dict.get("release", False))
else:
# Map Python version argument to shell script command
version = arg_dict.get("version", "17")
+ release = arg_dict.get("release", False)
+
+ if release:
+ logging.info("Release mode requested - using Python
implementation")
+ func(version, release)
# For windows_java21 on Windows, use the Python implementation
directly
- if version == "windows_java21" and is_windows():
+ elif version == "windows_java21" and is_windows():
logging.info(
"Using Python implementation for windows_java21 on Windows"
)
- func(version)
+ func(version, release)
elif version == "integration_tests":
run_shell_script("integration_tests")
elif version == "windows_java21":
diff --git a/ci/tasks/java.py b/ci/tasks/java.py
index 275d59fff..36e98be7c 100644
--- a/ci/tasks/java.py
+++ b/ci/tasks/java.py
@@ -20,31 +20,89 @@ import os
from . import common
# JDK versions
-JDKS = [
- "zulu21.28.85-ca-jdk21.0.0-linux_x64",
- "zulu17.44.17-ca-crac-jdk17.0.8-linux_x64",
- "zulu15.46.17-ca-jdk15.0.10-linux_x64",
- "zulu13.54.17-ca-jdk13.0.14-linux_x64",
- "zulu11.66.15-ca-jdk11.0.20-linux_x64",
- "zulu8.72.0.17-ca-jdk8.0.382-linux_x64",
-]
+JDKS = {
+ "8": "zulu21.28.85-ca-jdk21.0.0-linux_x64",
+ "11": "zulu17.44.17-ca-crac-jdk17.0.8-linux_x64",
+ "17": "zulu15.46.17-ca-jdk15.0.10-linux_x64",
+ "21": "zulu13.54.17-ca-jdk13.0.14-linux_x64",
+ "24": "zulu11.66.15-ca-jdk11.0.20-linux_x64",
+}
def install_jdks():
"""Download and install JDKs."""
common.cd_project_subdir("") # Go to the project root
- for jdk in JDKS:
+ for jdk in JDKS.values():
common.exec_cmd(
f"wget -q https://cdn.azul.com/zulu/bin/{jdk}.tar.gz -O
{jdk}.tar.gz"
)
common.exec_cmd(f"tar zxf {jdk}.tar.gz")
+ create_toolchains_xml(JDKS)
+
+
+def create_toolchains_xml(jdk_mappings):
+ """Create toolchains.xml file in ~/.m2/ directory."""
+ import os
+ import xml.etree.ElementTree as ET
+ from xml.dom import minidom
+
+ # Create ~/.m2 directory if it doesn't exist
+ m2_dir = os.path.expanduser("~/.m2")
+ os.makedirs(m2_dir, exist_ok=True)
+
+ # Create the root element
+ toolchains = ET.Element("toolchains")
+
+ for version, jdk_name in jdk_mappings.items():
+ toolchain = ET.SubElement(toolchains, "toolchain")
+
+ # Set type
+ type_elem = ET.SubElement(toolchain, "type")
+ type_elem.text = "jdk"
+
+ # Set provides
+ provides = ET.SubElement(toolchain, "provides")
+ version_elem = ET.SubElement(provides, "version")
+ version_elem.text = version
+ vendor_elem = ET.SubElement(provides, "vendor")
+ vendor_elem.text = "azul"
+
+ # Set configuration
+ configuration = ET.SubElement(toolchain, "configuration")
+ jdk_home = ET.SubElement(configuration, "jdkHome")
+ jdk_home.text = os.path.join(common.PROJECT_ROOT_DIR, jdk_name)
+
+ # Create pretty XML string
+ rough_string = ET.tostring(toolchains, 'unicode')
+ reparsed = minidom.parseString(rough_string)
+ pretty_xml = reparsed.toprettyxml(indent=" ")
+
+ # Add proper XML header with encoding
+ xml_header = '<?xml version="1.0" encoding="UTF8"?>\n'
+ pretty_xml = xml_header + pretty_xml.split('\n', 1)[1] # Remove the
default header and add our custom one
+
+ # Write to ~/.m2/toolchains.xml
+ toolchains_path = os.path.join(m2_dir, "toolchains.xml")
+ with open(toolchains_path, 'w', encoding='utf-8') as f:
+ f.write(pretty_xml)
+
+ logging.info(f"Created toolchains.xml at {toolchains_path}")
+ logging.info("Toolchains configuration:")
+ for version, jdk_name in jdk_mappings:
+ jdk_path = os.path.join(common.PROJECT_ROOT_DIR, jdk_name)
+ logging.info(f" JDK {version}: {jdk_path}")
+
+def install_fory():
+ """Install Fory."""
+ common.cd_project_subdir("java")
+ common.exec_cmd("mvn -T16 --batch-mode --no-transfer-progress install
-DskipTests")
def run_java8():
"""Run Java 8 tests."""
logging.info("Executing fory java tests with Java 8")
common.cd_project_subdir("java")
- common.exec_cmd("mvn -T16 --batch-mode --no-transfer-progress test")
+ common.exec_cmd("mvn -T16 --batch-mode --no-transfer-progress test -pl
'!fory-format'")
logging.info("Executing fory java tests succeeds")
@@ -114,7 +172,7 @@ def run_integration_tests():
logging.info("latest_jdk_tests: JDK 21")
# Set Java 21 as the current JDK
- java_home = os.path.join(common.PROJECT_ROOT_DIR, JDKS[0])
+ java_home = os.path.join(common.PROJECT_ROOT_DIR, JDKS["21"])
os.environ["JAVA_HOME"] = java_home
os.environ["PATH"] = f"{java_home}/bin:{os.environ.get('PATH', '')}"
@@ -135,7 +193,7 @@ def run_integration_tests():
# First round: Generate serialized data files
logging.info("First round: Generate serialized data files for each JDK
version")
- for jdk in JDKS:
+ for jdk in JDKS.values():
java_home = os.path.join(common.PROJECT_ROOT_DIR, jdk)
os.environ["JAVA_HOME"] = java_home
os.environ["PATH"] = f"{java_home}/bin:{os.environ.get('PATH', '')}"
@@ -147,7 +205,7 @@ def run_integration_tests():
# Second round: Test cross-JDK compatibility
logging.info("Second round: Test cross-JDK compatibility")
- for jdk in JDKS:
+ for jdk in JDKS.values():
java_home = os.path.join(common.PROJECT_ROOT_DIR, jdk)
os.environ["JAVA_HOME"] = java_home
os.environ["PATH"] = f"{java_home}/bin:{os.environ.get('PATH', '')}"
@@ -178,9 +236,33 @@ def run_graalvm_test():
logging.info("Execute graalvm tests succeed!")
-def run(java_version=None):
+def run_release():
+ """Release to Maven Central."""
+ logging.info(f"Starting release to Maven Central with Java")
+ install_jdks()
+ common.cd_project_subdir("java")
+
+ # Clean and install without tests first
+ logging.info("Cleaning and installing dependencies")
+ common.exec_cmd("mvn -T10 -B --no-transfer-progress clean install
-DskipTests")
+
+ # Deploy to Maven Central
+ logging.info("Deploying to Maven Central")
+ common.exec_cmd("mvn deploy -Dgpg.skip -DskipTests -Papache-release")
+
+ logging.info("Release to Maven Central completed successfully")
+
+
+def run(java_version=None, release=False, install_jdks=False,
install_fory=False):
"""Run Java CI tasks based on the specified Java version."""
- if java_version == "8":
+ if install_jdks:
+ install_jdks()
+ if install_fory:
+ install_fory()
+ if release:
+ logging.info("Release mode enabled - will release to Maven Central")
+ run_release()
+ elif java_version == "8":
run_java8()
elif java_version == "11":
run_java11()
diff --git a/java/fory-format/pom.xml b/java/fory-format/pom.xml
index 40c875522..298a37052 100644
--- a/java/fory-format/pom.xml
+++ b/java/fory-format/pom.xml
@@ -36,8 +36,8 @@
</description>
<properties>
- <maven.compiler.source>8</maven.compiler.source>
- <maven.compiler.target>8</maven.compiler.target>
+ <maven.compiler.source>11</maven.compiler.source>
+ <maven.compiler.target>11</maven.compiler.target>
<arrow.version>15.0.0</arrow.version>
<jackson-bom.version>2.16.0</jackson-bom.version>
<fory.java.rootdir>${basedir}/..</fory.java.rootdir>
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]