Import Fluss into an IDE
The sections below describe how to import the Fluss project into an IDE for the development of Fluss itself.
Whenever something is not working in your IDE, try with the Maven
command line first (mvn clean package -DskipTests
) as it might be your IDE
that has a bug or is not properly set up.
Preparation
To get started, please first checkout the Fluss sources from our repository, e.g.
git clone git@github.com:alibaba/fluss.git
IntelliJ IDEA
The following guide has been written for IntelliJ IDEA 2024.3. Some details might differ in other versions. Please make sure to follow all steps
Importing Fluss
- Choose "New" → "Project from Existing Sources".
- Select the root folder of the cloned Fluss repository.
- Choose "Import project from external model" and select "Maven".
- Leave the default options and successively click "Next" until you reach the SDK section.
- If there is no SDK listed, create one using the "+" sign on the top left. Select "JDK", choose the JDK home directory and click "OK". Select the most suitable JDK version. NOTE: A good rule of thumb is to select the JDK version matching the active Maven profile.
- Continue by clicking "Next" until the import is finished.
- Open the "Maven" tab (or right-click on the imported project and find "Maven") and run
"Generate Sources and Update Folders". Alternatively, you can run
mvn clean package -DskipTests
. - Build the Project ("Build" → "Build Project").
Copyright Profile
Every file needs to include the Alibaba license as a header. This can be automated in IntelliJ by adding a Copyright profile:
-
Go to "Settings" → "Editor" → "Copyright" → "Copyright Profiles".
-
Add a new profile and name it "Alibaba".
-
Add the following text as the license text:
Copyright (c) 2024 Alibaba Group Holding Ltd.
Licensed 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. -
Go to "Editor" → "Copyright" and choose the "Fluss" profile as the default profile for this project.
-
Click "Apply".
Required Plugins
Go to "Settings" → "Plugins" and select the "Marketplace" tab. Search for the following plugins, install them, and restart the IDE if prompted:
You will also need to install the google-java-format plugin. However, a specific version of this plugin is required. Download google-java-format v1.7.0.6 and install it as follows. Make sure to never update this plugin.
- Go to "Settings" → "Plugins".
- Click the gear icon and select "Install Plugin from Disk".
- Navigate to the downloaded ZIP file and select it.
Code Formatting
Fluss uses Spotless together with google-java-format to format the Java code.
It is recommended to automatically format your code by applying the following settings:
- Go to "Settings" → "Other Settings" → "google-java-format Settings".
- Tick the checkbox to enable the plugin.
- Change the code style to "Android Open Source Project (AOSP) style".
- Go to "Settings" → "Tools" → "Actions on Save".
- Under "Formatting Actions", select "Optimize imports" and "Reformat code".
- From the "All file types list" next to "Reformat code", select Java and Scala.
For earlier IntelliJ IDEA versions:
- Go to "Settings" → "Other Settings" → "Save Actions".
- Under "General", enable your preferred settings for when to format the code, e.g. "Activate save actions on save".
- Under "Formatting Actions", select "Optimize imports" and "Reformat file".
- Under "File Path Inclusions", add an entry for
.*\.java
to avoid formatting other file types.
You can also format the whole project via Maven by using mvn spotless:apply
.
Checkstyle For Java
Checkstyle is used to enforce static coding guidelines.
- Go to "Settings" → "Tools" → "Checkstyle".
- Set "Scan Scope" to "Only Java sources (including tests)".
- For "Checkstyle Version" select "10.18.2".
- Under "Configuration File" click the "+" icon to add a new configuration.
- Set "Description" to "Fluss".
- Select "Use a local Checkstyle file" and point it to
tools/maven/checkstyle.xml
located within your cloned repository. - Select "Store relative to project location" and click "Next".
- Configure the property
checkstyle.suppressions.file
with the valuesuppressions.xml
and click "Next". - Click "Finish".
- Select "Fluss" as the only active configuration file and click "Apply".
You can now import the Checkstyle configuration for the Java code formatter.
- Go to "Settings" → "Editor" → "Code Style" → "Java".
- Click the gear icon next to "Scheme" and select "Import Scheme" → "Checkstyle Configuration".
- Navigate to and select
tools/maven/checkstyle.xml
located within your cloned repository.
To verify the setup, click "View" → "Tool Windows" → "Checkstyle" and find the "Check Module" button in the opened tool window. It should report no violations.
Common Problems
This section lists issues that developers have run into in the past when working with IntelliJ.
Compilation fails with invalid flag: --add-exports=java.base/sun.net.util=ALL-UNNAMED
This happens if the "java11" Maven profile is active, but an older JDK version is used. Go to "View" → "Tool Windows" → "Maven" and uncheck the "java11" profile. Afterwards, reimport the project.
Compilation fails with package sun.misc does not exist
This happens if you are using JDK 11 and compile to Java 8 with the --release
option. This option is currently incompatible with our build setup.
Go to "Settings" → "Build, Execution, Deployment" → "Compiler" → "Java Compiler" and uncheck the "Use '--release' option for cross-compilation (Java 9 and later)".
Examples fail with a NoClassDefFoundError
for Fluss classes.
This happens if Fluss dependencies are set to "provided", resulting in them not being available
on the classpath. You can either check "Include dependencies with 'Provided' scope" in your
run configuration, or create a test that calls the main()
method of the example.