Checking out Ambari source
The following uses the Ambari git repository for the development process.
...
Follow the instructions under Checkout source code section of "How to contribute" guide.
We'll refer to the top-level "ambari" directory as AMBARI_DIR
in this document.
...
- xCode (if using Mac - free download from the apple store)
- JDK 7 8 (Ambari 2.0 6 and below can be compiled with JDK 7, from Ambari 2.7, it can be compiled with at least JDK 68)
- Apache Maven 3.3.9 or later
Tip: In order to persist your changes to the JAVA_HOME environment variable and add Maven to your path, create the following files:File: ~/.profileCode Block source ~/.bashrc
File: ~/.bashrcCode Block export PATH=/usr/local/apache-maven-3.3.9/bin:$PATH export JAVA_HOME=$(/usr/libexec/java_home) export _JAVA_OPTIONS="-Xmx2048m -XX:MaxPermSize=512m -Djava.awt.headless=true"
- Python 2.6 Python setuptools - python (Ambari 2.6: Download or python 7 or later require Python 2.7 as minimum supported version)
Python setuptools:
for Python : Download and run:
2.6: Download setuptools and run:Code Block sh setuptools-0.6c11-py2.6.egg
for Python 2.7: Download setuptools and run:
Code Block sh setuptools-0.6c11-py2.7.egg
- rpmbuild (rpm-build package)
g++ (gcc-c++ package)
NodeJS - Latest version tested for compatibility is v0.10.44 (as of April 5, 2016). 0.12.x won't work. Download the binary tarball, extract, and put the bin directory in your PATH. Verify that you can run the command node and npm. Alternatively, you can use yum to install NodeJS if you are on Fedora 18:
Code Block #Fedora 18: sudo yum update audit; sudo yum --enablerepo=updates-testing install nodejs npm
Brunch 1.7.20 (to install it, run the following command after NodeJS is installed):
Code Block npm install -g brunch@1.7.20
Verify that you can run the command brunch. Later versions may work, but 1.7.20 is the latest version that has been tested (as of Dec 10, 2015).
Running Unit Tests
Running Unit Tests
mvn clean test
Run unit tests in a single module:
Code Block mvn -pl ambari-server test
Run only Java tests
mvn clean test
Run unit tests in a single module:
Code Block mvn -pl ambari-server test
Run only Java tests:
Code Block mvn -pl ambari-server -DskipPythonTests
Run only specific Java tests:
Code Block mvn -pl ambari-server -DskipPythonTests -Dtest=AgentHostInfoTest test
Run only Python tests:
Code Block mvn -pl ambari-server -DskipSurefireTests test
Run only specific Python tests:
Code Block mvn -pl ambari-server -DskipSurefireTests -Dpython.test.mask=TestUtils.py test
Run only Checkstyle and RAT checks:
Code Block mvn -pl ambari-server -DskipTests test
...
[ERROR] Failed to execute goal on project ambari-metrics-kafka-sink: Could not resolve dependencies for project org.apache.ambari:ambari-metrics-kafka-sink:jar: 2.0 . 0 - 0 : The following artifacts could not be resolved: javax.jms:jms:jar: 1.1 , com.sun.jdmk:jmxtools:jar: 1.2 . 1 , com.sun.jmx:jmxri:jar: 1.2 . 1 : Could not transfer artifact javax.jms:jms:jar: 1.1 from/to java.net (https: //maven-repository.dev.java.net/nonav/repository): No connector available to access repository java.net (https://maven-repository.dev.java.net/nonav/repository) of type legacy using the available factories WagonRepositoryConnectorFactory |
The work around is to manually install the three missing artifacts:
mvn install:install-file -Dfile=jms- 1.1 .pom -DgroupId=javax.jms -DartifactId=jms -Dversion= 1.1 -Dpackaging=jar mvn install:install-file -Dfile=jmxtools- 1.2 . 1 .pom -DgroupId=com.sun.jdmk -DartifactId=jmxtools -Dversion= 1.2 . 1 -Dpackaging=jar mvn install:install-file -Dfile=jmxri- 1.2 . 1 .pom -DgroupId=com.sun.jmx -DartifactId=jmxri -Dversion= 1.2 . 1 -Dpackaging=jar |
If when compiling it seems stuck, and you've already increased Java and Maven heapsize, it could be that Ambari Views has a lot of artifacts, and the rat-check is choking up. In this case, try running
git clean -df (this will remove untracked files and directories) mvn clean package -DskipTests -Drat.ignoreErrors=true or mvn clean package -DskipTests -Drat.skip |
Setting the Version Using Maven
Ambari 2.8+ uses a newer method to update the version when building Ambari.
Code Block | ||||
---|---|---|---|---|
|
...
|
...
|
...
# Update the revision property to |
...
the |
...
release |
...
version
mvn versions:set-property -Dproperty=revision -DnewVersion=2.8.0.0.0
mvn -B clean install package rpm:rpm -DskipTests -Dpython.ver="python >= 2.6" -Preplaceurl |
Code Block | ||||
---|---|---|---|---|
| ||||
# Update the revision property to the release version
mvn versions:set-property -Dproperty=revision -DnewVersion=2.8.0.0.0
mvn -B clean install package rpm:rpm -DskipTests -Psuse11 -Dpython.ver="python >= 2.6" -Preplaceurl |
Code Block | ||||
---|---|---|---|---|
| ||||
# Update the revision property to the release version mvn versions:set-property -Dproperty=revision -DnewVersion=2.8.0.0.0 mvn -B clean install package jdeb:jdeb -DskipTests -Dpython.ver="python >= 2.6" -Preplaceurl |
Ambari 2.7 and Earlier Releases (Deprecated)
Code Block | |||||||
---|---|---|---|---|---|---|---|
| 2.6' as an alternative, which seems to work better in at least one RHEL instance."
| ||||||
| |||||||
mvn versions:set -DnewVersion=${AMBARI_VERSION} #Note: The ambari-metrics project is not wired up to the main ambari project. However there is a dependency on ambari-metrics-common to build the ambari-server RPM. #Hence you also need to set ambari-metrics project version as well. pushd ambari-metrics mvn versions:set -DnewVersion=${AMBARI_VERSION} popd mvn -B clean install package rpm:rpm -DskipTests -Dpython.ver="python >= 2.6" -Preplaceurl |
Code Block | ||||
---|---|---|---|---|
|
...
| ||
| ||
mvn versions:set -DnewVersion=${AMBARI_VERSION} #Note: The ambari-metrics project is not wired up to the main ambari project. However there is a dependency on ambari-metrics-common to build the ambari-server RPM. #Hence you also need to set ambari-metrics project version as well. pushd ambari-metrics mvn versions:set -DnewVersion=${AMBARI_VERSION} popd mvn -B clean install package rpm:rpm -DskipTests -Psuse11 -Dpython.ver="python >= 2.6" -Preplaceurl |
Code Block | ||||
---|---|---|---|---|
| ||||
| ||||
mvn versions:set -DnewVersion=${AMBARI_VERSION} #Note: The ambari-metrics project is not wired up to the main ambari project. However there is a dependency on ambari-metrics-common to build the ambari-server RPM. #Hence you also need to set ambari-metrics project version as well. pushd ambari-metrics mvn versions:set -DnewVersion=${AMBARI_VERSION} popd mvn -B clean install package jdeb:jdeb -DskipTests -Dpython.ver="python >= 2.6" -Preplaceurl |
...