Setting up development environment
Please note that this guide is not a 'user guide'. It is not intended for the 'users' who build an application using Netty but for the contributors ('dev') who want to develop Netty itself.
You must use 64-bit operating system.
You must have 64-bit OpenJDK 8 or above from a vendor like AdoptOpenJDK or Azul Systems, Apache Maven 3.1.1 or above, and Git installed on your machine.
If you are on Linux, you have to install the following packages:
# yum install lsb-core autoconf automake libtool make tar \
glibc-devel libaio-devel openssl-devel apr-devel \
lksctp-tools
# apt-get install autoconf automake libtool make tar \
libaio-dev libssl-dev libapr1-dev \
lksctp-tools
Or if using MacOS:
brew install autoconf automake libtool openssl
And need to pay attention to the configuration of git. If using Windows, when you checkout code, LF will be automatically converted to CRLF:
git config --global core.autocrlf true
Or if using MacOS, when you commit code, CRLF will be automatically converted to LF:
git config --global core.autocrlf input
You may also check Building The Native Transports for more information.
To build netty-tcnative (namely, it's BoringSSL part), install also cmake
, ninja-build
and golang
packages. The ninja-build
and golang
on Fedora/CentOS are available in the Fedora EPEL repository.
Then check out the code, and verify that your build environment works with ./mvnw install -DskipTests -T1C
.
This also primes your local Maven cache, allowing you to build individual modules later.
Netty project team uses IntelliJ IDEA as the primary IDE, although we are fine with using other development environments as long as you adhere to our coding style.
If you are on 64-bit operating system, use the 64-bit version of IntelliJ IDEA. For instance, the start menu shortcut points to the 32-bit binary even if you are using 64-bit Windows. You'll have to find the idea64.exe
in the installation directory and use it instead. Otherwise, you'll see IntelliJ IDEA complains that it cannot find io.netty:netty-tcnative:windows-x86_32
.
Netty versions 4.1 and older target Java 6 as the minimum required Java version, and thus needs to compile to Java 6 byte code.
However, for performance, the code base also includes references to newer Java APIs, appropriately guarded with runtime version checks.
For this reason, Netty has to be compiled with --source
and --target
flags, but IntelliJ will by default use the newer --release
flag instead, which also enables API version checks.
Using the --release
flag will cause IntelliJ to produce compilation errors when building the Netty project, so it has to be disabled in the Compiler Settings dialog.
Download this code style configuration and unzip Netty project.xml
into <IntelliJ config directory>/codestyles
directory. Choose 'Netty project' as the default code style.
Download, unzip, and import this inspection profile into your IntelliJ IDEA and use it as the default. See here to learn how to import an inspection profile.
Ensure your modification does not introduce any inspection warning. If you think it's a false positive, suppress the warning by using the @SuppressWarnings
annotation or noinspection
line comment as guided by the IDE. For more information about using the inspector, please refer to the web help pages.
Copyright text:
Copyright $today.year The Netty Project
The Netty Project 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:
https://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.
Keyword to detect copyright in comments:
The Netty project licenses
Allow replacing copyright if old copyright contains:
The Netty project licenses
- Ensure you are using the 64-bit version of Eclipse.
-
Download os-maven-plugin and put it into
<ECLIPSE_INSTALLATION_DIR>/plugins
(Eclipse 4.5) or<ECLIPSE_INSTALLATION_DIR>/dropins
(Eclipse 4.6) directory to work around the problem where m2e does not evaluate an extension specified in ourpom.xml
. (Unlike its name, it's both a Maven plugin and an Eclipse plugin.) - Import the project via the 'File → Import... → Existing Maven Projects' menu.
- Netty project Maven
pom.xml
settings dictate the use of Java SE 1.6, while implicitly using Java 7/8 (1.7/1.8) features if present. This may result in compilation errors in Eclipse. There are two ways to work around this problem: - Look in the 'Window → Preferences → Installed JRE' menu: * Make sure you have Java 7/8 installation available under 'Installed JRE' * Map this Java 7/8 installation onto Java 6: 'Installed JRE → Execution Environments → Java SE 1.6'
- Alternatively, Java 7/8 JRE can be selected on per-project basis for each Netty module.