2018-12-13 14:47:20 -05:00
---
2019-08-21 00:48:59 -04:00
id: build
title: "Build from source"
2018-12-13 14:47:20 -05:00
---
2018-11-13 12:38:37 -05:00
<!--
~ 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.
-->
2015-05-05 17:07:32 -04:00
2021-07-20 21:07:34 -04:00
You can build Apache Druid directly from source. Use the version of this page
that matches the version you want to build.
For building the latest code in master, follow the latest version of this page
[here ](https://github.com/apache/druid/blob/master/docs/development/build.md ):
make sure it has `/master/` in the URL.
2018-09-25 13:05:26 -04:00
2024-11-04 21:31:46 -05:00
## Prerequisites
2018-09-25 13:05:26 -04:00
2024-11-04 21:31:46 -05:00
### Installing Java and Maven
2021-07-20 21:07:34 -04:00
2024-07-03 11:23:15 -04:00
- See our [Java documentation ](../operations/java.md ) for information about obtaining a supported JDK
2015-05-05 17:07:32 -04:00
- [Maven version 3.x ](http://maven.apache.org/download.cgi )
2024-11-04 21:31:46 -05:00
### Other Dependencies
2019-05-10 00:29:26 -04:00
2023-02-21 18:03:02 -05:00
- Distribution builds require Python 3.x and the `pyyaml` module.
- Integration tests require `pyyaml` version 5.1 or later.
2019-05-10 00:29:26 -04:00
2024-11-04 21:31:46 -05:00
## Downloading the Source Code
2015-05-05 17:07:32 -04:00
2018-09-25 13:05:26 -04:00
```bash
2020-01-03 12:33:19 -05:00
git clone git@github.com:apache/druid.git
2015-05-05 17:07:32 -04:00
cd druid
```
2024-11-04 21:31:46 -05:00
## Building from Source
2018-09-25 13:05:26 -04:00
2018-11-13 12:38:37 -05:00
The basic command to build Druid from source is:
2018-09-25 13:05:26 -04:00
```bash
2018-11-13 12:38:37 -05:00
mvn clean install
2018-09-25 13:05:26 -04:00
```
2024-11-04 21:31:46 -05:00
This will run static analysis, unit tests, compile classes, and package the projects into JARs. It will _not_ generate the source or binary distribution tarball. Note that this build may take some time to complete.
2018-11-13 12:38:37 -05:00
In addition to the basic stages, you may also want to add the following profiles and properties:
2018-09-25 13:05:26 -04:00
2018-11-13 12:38:37 -05:00
- **-Pdist** - Distribution profile: Generates the binary distribution tarball by pulling in core extensions and dependencies and packaging the files as `distribution/target/apache-druid-x.x.x-bin.tar.gz`
- **-Papache-release** - Apache release profile: Generates GPG signature and checksums, and builds the source distribution tarball as `distribution/target/apache-druid-x.x.x-src.tar.gz`
- **-Prat** - Apache Rat profile: Runs the Apache Rat license audit tool
- **-DskipTests** - Skips unit tests (which reduces build time)
2022-09-19 18:02:17 -04:00
- **-Dweb.console.skip=true** - Skip front end project
2018-09-25 13:05:26 -04:00
2018-11-13 12:38:37 -05:00
Putting these together, if you wish to build the source and binary distributions with signatures and checksums, audit licenses, and skip the unit tests, you would run:
2018-09-25 13:05:26 -04:00
```bash
2018-11-13 12:38:37 -05:00
mvn clean install -Papache-release,dist,rat -DskipTests
```
2021-10-30 13:16:24 -04:00
2024-11-04 21:31:46 -05:00
### Building for Development
2021-05-21 12:04:51 -04:00
2024-11-04 21:31:46 -05:00
For development, use only the dist profile and skip the Apache release and Apache rat profiles.
```bash
mvn clean install -Pdist -DskipTests
```
If you want to speed up the build even more, you can enable parallel building with the `-T1C` option and skip some static analysis checks.
```bash
mvn clean install -Pdist -T1C -DskipTests -Dforbiddenapis.skip=true -Dcheckstyle.skip=true -Dpmd.skip=true -Dmaven.javadoc.skip=true -Denforcer.skip=true
```
You will expect to find your distribution tar file under the `distribution/target` directory.
## Potential issues
### Missing `pyyaml`
2021-07-20 21:07:34 -04:00
2021-05-21 12:04:51 -04:00
You are building Druid from source following the instructions on this page but you get
```
[ERROR] Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.6.0:exec (generate-binary-license) on project distribution: Command execution failed.: Process exited with an error: 1 (Exit value: 1) -> [Help 1]
```
Resolution: Make sure you have Python installed as well as the `yaml` module:
2021-07-20 21:07:34 -04:00
```bash
2021-05-21 12:04:51 -04:00
pip install pyyaml
2021-07-20 21:07:34 -04:00
```
On some systems, ensure you use the Python 3.x version of `pip` :
```bash
pip3 install pyyaml
```