The Foundation hosts several Java projects and provides a good level of support for building, testing and releasing Java code.
The most adopted (68% in 2016, according to RebelLabs) build tool for Java is Apache Maven, which provides a standard, modular, convention-based model to build and publish your Java projects; as such, the Foundation provides a Maven Module called Parent POM, containing build configurations that can be easily inherited by the single projects; in provides:
- Plugin configuration for the most common Maven functionalities
- Nightly-built (in Maven terms, snapshots) deployment into Sonatype OSS public repository (oss.sonatype.org)
- Release deployment on the Central Repository
- Rules to validate Central Repository code requirements
- Other integrations for checks and validations
The build process aims to produce reusable Java binaries (artifacts, in Maven terms) in a reliable and reproducible way, from every contributor or consumer workstation; special build requirements should be documented in the project homepage.
The Maven command to build artifacts is
All Java projects hosted by the Foundation are expected to use a groupId that is (or prefixed by)
org.finos and are published on the Maven central repository (also known as Maven Central).
In order to publish artifacts (in Maven terms, artifact deployment), it's necessary to setup some accounts and configure the workstation accordingly; please note that these steps are not mandatory for all project teams, but only for those performing artifact deployment and releases (normally the project lead or a team member elected as release manager).
- Sign up on https://issues.sonatype.org (
https://oss.sonatype.orgMaven repo will use these credentials for authentication).
- Email firstname.lastname@example.org, with the GitHub URL of your project, and your Sonatype Jira ID (from step 1)
- Update your Maven
settings.xmlfile as shown below; using Maven encrypted passwords is strongly advised, to avoid setting up the password in clear text
At this point, you can proceed with the deployment of the snapshot artifacts, by simply invoking
mvn deploy from the project root folder; as a result, artifacts will be publicly available on
oss.sonatype.org and usable by anyone as Maven dependencies.
You can find more info on the Central Repository howto page for Maven.
A badge can be added at the top of the project's root-level [README.md] file, using the following Markdown syntax:
If you want to run this process continuously for each commit, you can integrate with Travis CI or other Continuous Integration systems.
The Maven release process performs the following activities:
- Verify that there are no uncommitted changes in the local workspace.
- Prompt the user for the desired tag, release and development version names.
- Modify and commit release information into the pom.xml file.
- Tag the entire project source tree with the new tag name.
- Extract file revisions versioned under the new tag name.
- Deploy the versioned artifacts to appropriate local and remote repositories.
All the configurations documented in the section above (see snapshot deployment) also apply to the release process; additionally, it is required to:
- Install gpg on the local workstation where the release process is invoked
- Configure settings.xml as shown below
- Test a snapshot deployment (see above), to make sure that you can authenticate against Sonatype servers
At this point you can proceed with the release:
- Run the maven command
mvn release:prepare release:perform -Prelease; the release profile will provide javadocs, sources and gpg signature configuration for the build; if you're not using
finos-parent-pom, you'd need to configure these plugins by yourself; feel free to copy bits and pieces from the FINOS parant
- Promote the staged artifacts by accessing the Nexus staging repositories to:
a. Identify which repository refers to the release process performed on step #1. Look at the description column to identify the specific project (look towards bottom of list).
b. Select the staging repository. To release the request, click the
Close(button on top menu) the release request - this operation will trigger a validation of the artifacts to be released c. Click on the refresh button to update status of repository. Click on
Release(button on top menu) to sync artifacts with the Central Repository and remove staging repository.
Upon release, your component will be published to Central: this typically occurs within 10 minutes, though updates to search can take up to two hours. You can also watch this youtube video to know more about the Nexus staging lifecycle.
If the release command fails with "gpg: signing failed: Inappropriate ioctl for device", run the following command and try again; more info on stackexchange.
Maven allows to generate a documentation website in HTML format and provides different options to publish such content on remote servers; content is composed by:
- Javadocs - can be easily generated using the maven-javadoc-plugin, which is already configured to run during the build by the FINOS Parent Pom; the documentation is delivered in HTML format and included in the target/site/apidocs project sub-folder; to invoke the javadoc generation manually, you can invoke
- Reporting - to collect different metrics from Maven build plugins and publish them as part of the docs.
- Free content - A free structure of documentation content, which supports different template languages (apt, fml, markdown, xdoc and xhtml)
The FINOS Parent POM provides a configuration that allows to publish such content under the FINOS Project Landscape; to enable it, the build must be invoked using the
-Ppublish-site Maven profile. For more info, follow the related Pom documentation and check configuration on the symphony-java-sample-bots project.