cd ~/projects
The steps described below are designed to allow you to quickly build RHQ in as few steps as possible. After you become more familiar with the code base and more proficient with the build system, you should check out our Advanced Build Notes for additional things you will find helpful in working with the RHQ Maven build system.
If you only want to build RHQ plugins, there is no need to build the full server. We will talk about this below
If you do not want to build RHQ from source, you can instead download a binary distribution.
If you want to get familiar with how each of the individual modules in the source tree contribute to the overall built product, please read the Module Overview.
In order to compile the RHQ source code, you will need the Java Developer's Kit (JDK), which includes javac - the Java Runtime Environment (JRE) will not suffice, since it does not include javac.
Download the latest release of JDK 7 available for your OS from either Oracle here or OpenJDK and install it.
Set the following environment variables in your .profile (UNIX) or System environment (Windows) - you must ensure you set these if you have multiple Java installations on your box, to ensure Maven picks up the correct JDK that you want to use:
JAVA_HOME=JDK7_install_dir
PATH=$JAVA_HOME/bin:existing_PATH
The RPM for Maven found on some Fedora versions is too old to work with RHQ. In this case, you will need to be install Maven manually.
Download the latest release of Maven 3.x from http://maven.apache.org/download.html.
Unzip it somewhere on your system (e.g. C:\opt, /opt/maven).
Set the following environment variables in your .profile (UNIX) or System environment (Windows):
MAVEN_HOME=maven_install_dir
MAVEN_OPTS="-Xms256M -Xmx768M -XX:PermSize=128M -XX:MaxPermSize=256M -XX:ReservedCodeCacheSize=96M"
PATH=$MAVEN_HOME/bin:existing_PATH
RHQ uses git for source code control. In order to download ("checkout") the sources, you need to have a git client installed.
You may browse the RHQ git repository at http://git.fedorahosted.org/git/rhq/rhq.git
You may browse the sources at https://github.com/rhq-project.
Access to the git repository can be done via the git command line or via a plugin to your IDE.
To run git commands independently of your IDE, you can install git from http://git-scm.com/download.
Eclipse - Eclipse now hosts the git plug-in which provides some of the git features. For info on the Eclipse git plug-in, see http://www.eclipse.org/egit/.
IntelliJ IDEA - IntelliJ 9 and later has built-in support for git.
If you only want to work on the plugins or helper modules, you can skip this step
See the PostgreSQL Quick Start Installation Guide to install and configure PostgreSQL
Make sure to create the rhqadmin user and rhq database. Note: to ensure the initial mvn build below succeeds, you also need to have created a database called "rhqdev".
While moving to GitHub, we have split the RHQ sources into three repositories
rhq-core: core classes of RHQ, the server, agent and UI and the platform plugin
rhq-plugins: all agent plugins except the platform plugin
rhq-helpers: miscellaneous helpers that are not part of the server distribution
If you only want to work on existing or new plugins, to work with the latest released version of RHQ you do not need to check out rhq-core or rhq-helpers.
If you want to work on the plugins or helpers against the current development branch ("master"), you also need to check out rhq-core
Open a command prompt and cd to the directory where you want the RHQ sources to live, e.g.:
cd ~/projects
Clone the RHQ source from the git repo:
git clone git://git.fedorahosted.org/git/rhq/rhq.git
or if your firewall prevents using the git protocol you can also clone via http (much slower though)
git clone http://git.fedorahosted.org/git/rhq/rhq.git
or for developer access:
git clone ssh://git.fedorahosted.org/git/rhq/rhq.git
Note: if your fedora user name is different from the local one or you have a different public key for
fedora than some default one, you need to specify it to git/ssh.
To do so you can add this to ~/.ssh/config:
$ cat ~/.ssh/config Host git.fedorahosted.org IdentityFile id_fedorahosted_rsa User joedev
So in this example the fedora user is joedev and the ssh key is in ~/.ssh/id_fedorahosted_rsa
If you are on Windows, make sure you do not checkout the RHQ code into a directory with a long path, as this will cause errors during the build and startup.
If you only want to build the plugins for a previously released version, you can skip the building of the server and the database installation.
check out rhq-plugins repo
cd rhq-plugins
git checkout <branch> where <branch> is the name of a released RHQ version – e.g. release-4.6.0 for rhq-4.6
mvn install
Make sure you have set up the settings.xml file as described in Advanced Build Notes including uncommenting the postgres profile.
Make sure you have the Databases set up
createuser rhqadmin createdb -O rhqadmin rhq createdb -O rhqadmin rhqdev
Open a command prompt and cd to the directory where the RHQ sources live, e.g.:
cd ~/projects/rhq
Build RHQ:
mvn -Penterprise,dev -Ddbsetup -DskipTests install
The first time you build RHQ, it will take up to an hour, because it will need to download many 3rd party dependency jars for both RHQ and Maven itself. Subsequent builds will be significantly faster, especially if you only build specific modules.
"-Ddbsetup" is only required the first time you build; thereafter, the schema will be created in your database, and you won't need to do it again unless a) the schema changes and needs to be rebuilt or b) you want to clean out your database and rebuild the schema.
You do not need to rebuild your container after performing a subsequent -Ddbsetup, but you will want to restart your agent --fullcleanconfig.
The RHQ BuildNumber is set to the git sha1.
If you have been building RHQ for a while and you notice that the versions of any dependencies in the dependencyManagement section of the root POM have changed due to a recent commit, you MUST build from root. If you don't, the {m2_repo}/org/rhq/rhq-parent/{currentVersion}/rhq-parent-{currentVersion}.pom file will be stale, and will be used when resolving dependencies locally, and thus you won't resolve to the latest dependencies. If you don't want to take the "hit" of building from root, you can build ONLY the root module by saying "mvn -N install" from the root, which will update the aforementioned POM in your local repository without building all modules.
If you run into test failures, run with the option -DskipTests so that those will be still built, but not executed. -Dmaven.test.skip will also skip building them and subsequent compilation will fail.
Because you built using the -Pdev Maven profile, you can also run the RHQ Server container that is built to <rhq-root>/dev-container. See Advanced Build Notes for more information on the enterprise and dev profiles. Typically, developers will want to use the dev-container.
Switch to the RHQ bin directory. If simulating production:
cd <rhq-root>/modules/enterprise/server/appserver/target/rhq-server-<version>/bin
If using the dev-container:
cd <rhq-root>/dev-container/rhq-server/bin
Starting with version 4.8 RHQ is installed/started/stopped using the new RHQ Control Script. See RHQ Control Script before continuing, but to run RHQ the first time you will basically perform:
> ./rhqctl install
This will install the Cassandra storage node, the server, and an agent, and will start them all. You then can further use the control program to start, stop or get status on the RHQ components.
Also, see Advanced Build Notes for more on using the dev-container, if applicable.
First start the RHQ server, which is built to <rhq-root>/modules/enterprise/server/appserver/target/rhq-server-<version>:
./rhq-server.(sh|bat) console
You may want to use the rhq-server-console.bat script - you can double click it to start the server. The rhq-server.bat expects a command line argument "console" so you cannot just double-click it from a Windows Explorer window to start it.
If you did not build with -Pdev, then once the RHQ server is fully started, complete the installation by running rhq-installer.(sh|bat) located in the same directory where the server startup script is found. If you did follow the instructions above (which included using -Pdev), the installer will run for you automatically when you start the server.
Point your browser to http://localhost:7080 and login as user rhqadmin, password rhqadmin.
Next start the RHQ agent, which is built to <rhq-root>/modules/enterprise/agent/target/rhq-agent-<version>:
cd <rhq-root>/modules/enterprise/agent/target/rhq-agent-<version>/bin ./rhq-agent.(sh|bat)
The agent uses Java preferences which stores settings in the Windows registry (if on Windows) or $HOME/.java (if on UNIX). To purge the settings, run with the -L option.
Once the agent is fully started, a platform should appear in the autodiscovery UI page (under the main Inventory view); import this platform into RHQ's inventory.
You can also run your build of the RHQ CLI:
cd <rhq-root>/modules/enterprise/remoting/cli/target/rhq-remoting-cli-<version>/bin ./rhq-cli.(sh|bat) -u rhqadmin -p rhqadmin
See Running the RHQ CLI for more information about the CLI environment.
If you want to contribute to RHQ, you can load the code base in your favorite Java IDE. We have some tips for the big two here: