Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 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 .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ hbase-shaded-protobuf/src/main/resources
.idea
*.iml
.flattened-pom.xml
toolchains.xml
62 changes: 60 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,14 +92,72 @@ modern JDKs. Due to a bug in JDK, we cannot generate this code using a more
modern version of the JDK. See
[HBASE-26773](https://issues.apache.org/jira/browse/HBASE-26773) for details.

## Jetty 12 and Dual JDK Requirement

Starting with version 4.1.12, this project requires JDK 8 and JDK 17 to accommodate different HBase versions:

- **HBase 2.x**: Uses JDK 8 compatible modules (including `hbase-shaded-jetty` with Jetty 9)
- **HBase 3.x**: Uses JDK 17 modules (including `hbase-shaded-jetty-12-plus-*` with Jetty 12)

### Why Dual JDK Support?

Jetty 12 requires JDK 17 for compilation, but HBase 2.x deployments cannot move to Jetty 12 for JDK 8 compatibility. Our solution provides a single release containing modules for both JDK versions, eliminating the need for separate branches or releases.

### Why toolchains are required?
Maven needs explicit toolchain configuration to automatically select JDK 8 for existing modules and JDK 17 for Jetty 12 modules. Environment variables alone are insufficient.

### Files
- `generate-toolchains.sh` - Script to generate toolchains.xml with configurable paths
- `toolchains.xml` - Generated Maven toolchains configuration file (not checked in)

## Build/Deploy

To build, make sure that your environment uses JDK8, then just run:
### Local Development Setup

1. **Install both JDK versions**: JDK 8 and JDK 17
2. **Set environment variables**:
```sh
export JAVA8_HOME=/path/to/your/jdk8
export JAVA17_HOME=/path/to/your/jdk17
```
3. **Choose your toolchain setup approach** (see options below)

### Toolchain Setup Options

**Option 1: Project-local toolchains.xml**
```sh
# Generate and use project-specific toolchains
export JAVA8_HOME=/path/to/your/jdk8
export JAVA17_HOME=/path/to/your/jdk17
./dev-support/generate-toolchains.sh

mvn clean install -t toolchains.xml
```

**Option 2: Global Maven toolchains setup**
```sh
# Setup toolchains in ~/.m2/ directory
export JAVA8_HOME=/path/to/your/jdk8
export JAVA17_HOME=/path/to/your/jdk17
./dev-support/generate-toolchains.sh
cp toolchains.xml ~/.m2/toolchains.xml

mvn clean install
```

### CI/Jenkins Setup

For Jenkins/CI environments, the project auto-detects Java installations at standard paths:
- Java 8: `/usr/lib/jvm/java-8`
- Java 17: `/usr/lib/jvm/java-17`

Simply run the toolchain generation script and build:
```sh
mvn clean package
./generate-toolchains.sh
mvn clean install -t ./toolchains.xml
```


## Release

To cut a release candidate, update JIRA. The hbase-thirdparty currently uses
Expand Down
94 changes: 94 additions & 0 deletions dev-support/generate-toolchains.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
#!/usr/bin/env bash
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF 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.

# Script to generate toolchains.xml with configurable Java paths

# Set default paths if environment variables are not set
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is great.
The release scripts should also be amended to to call this when releasing hbase-thirdparty
(assuming that the release script supports hbase-thirdparty)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @stoty yes you are absolutely right, release script would need some patching to understanding toolchains. Will take this up as part of release process. Thanks for highlighting.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Created HBASE-29490

if [ -z "$JAVA8_HOME" ]; then
echo "Trying to detect Java 8 installation (Jenkins/CI standard path)"
if [ -d "/usr/lib/jvm/java-8" ]; then
JAVA8_HOME="/usr/lib/jvm/java-8"
else
echo "Warning: JAVA8_HOME not set and Java 8 not found at /usr/lib/jvm/java-8"
echo "For local development, please set JAVA8_HOME environment variable"
JAVA8_HOME="/usr/lib/jvm/java-8"
fi
fi

if [ -z "$JAVA17_HOME" ]; then
echo "Trying to detect Java 17 installation (Jenkins/CI standard path)"
if [ -d "/usr/lib/jvm/java-17" ]; then
JAVA17_HOME="/usr/lib/jvm/java-17"
else
echo "Warning: JAVA17_HOME not set and Java 17 not found at /usr/lib/jvm/java-17"
echo "For local development, please set JAVA17_HOME environment variable"
JAVA17_HOME="/usr/lib/jvm/java-17"
fi
fi

echo "Generating toolchains.xml with:"
echo " JAVA8_HOME: $JAVA8_HOME"
echo " JAVA17_HOME: $JAVA17_HOME"

# Generate toolchains.xml
cat > toolchains.xml << EOF
<?xml version="1.0" encoding="UTF-8"?>
<toolchains xmlns="http://maven.apache.org/TOOLCHAINS/1.1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/TOOLCHAINS/1.1.0 http://maven.apache.org/xsd/toolchains-1.1.0.xsd">
<!--
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF 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.
*/

-->
<toolchain>
<type>jdk</type>
<provides>
<version>1.8</version>
</provides>
<configuration>
<jdkHome>$JAVA8_HOME</jdkHome>
</configuration>
</toolchain>
<toolchain>
<type>jdk</type>
<provides>
<version>17</version>
</provides>
<configuration>
<jdkHome>$JAVA17_HOME</jdkHome>
</configuration>
</toolchain>
</toolchains>
EOF

echo "toolchains.xml generated successfully!"
4 changes: 3 additions & 1 deletion dev-support/jenkins/Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,9 @@ pipeline {
DOCKERFILE_REL = "${SRC_REL}/dev-support/jenkins/Dockerfile"
YETUS_DRIVER_REL = "${SRC_REL}/dev-support/jenkins/jenkins_precommit_github_yetus.sh"
ARCHIVE_PATTERN_LIST = '*.dump'
SET_JAVA_HOME = '/opt/java/openjdk'
SET_JAVA_HOME = "/usr/lib/jvm/java-8"
JAVA8_HOME = "/usr/lib/jvm/java-8"
JAVA17_HOME = "/usr/lib/jvm/java-17"
PLUGINS = 'all'
}

Expand Down
Loading