CINXE.COM

Apache Commons – Building Apache Commons Components

<!DOCTYPE html> <!-- | Generated by Apache Maven Doxia at 19 November 2024 | Rendered using Apache Maven Fluido Skin 1.3.0 --> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <meta charset="UTF-8" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" /> <meta name="author" content="Apache Commons Documentation Team" /> <meta name="Date-Revision-yyyymmdd" content="20241119" /> <meta http-equiv="Content-Language" content="en" /> <title>Apache Commons &#x2013; Building Apache Commons Components</title> <link rel="stylesheet" href="./css/bootstrap.min.css" type="text/css" /> <link rel="stylesheet" href="./css/site.css" type="text/css" /> <link rel="stylesheet" href="./css/print.css" media="print" /> <script type="text/javascript" src="./js/jquery.min.js"></script> <script type="text/javascript" src="./js/bootstrap.min.js"></script> <script type="text/javascript" src="./js/prettify.min.js"></script> <script type="text/javascript" src="./js/site.js"></script> </head> <body class="composite"> <a href="./" id="bannerLeft" title="Apache Commons logo"> <img class="logo-left" src="images/commons-logo.png" alt="Apache Commons logo"/> </a> <div class="clear"></div> <div class="navbar"> <div class="navbar-inner"> <div class="container-fluid"> <a class="brand" href="https://commons.apache.org/">Apache Commons &trade;</a> <ul class="nav"> <li id="publishDate">Last Published: 19 November 2024</li> <li class="divider">|</li> <li id="projectVersion">Version: unspecified</li> </ul> <div class="pull-right"> <ul class="nav"> <li> <a href="components.html" title="Components"> Components</a> </li> <li> <a href="sandbox.html" title="Sandbox"> Sandbox</a> </li> <li> <a href="dormant.html" title="Dormant"> Dormant</a> </li> <li> <a href="https://www.apachecon.com/" class="externalLink" title="ApacheCon"> ApacheCon</a> </li> <li> <a href="https://www.apache.org" class="externalLink" title="Apache"> Apache</a> </li> </ul> </div> </div> </div> </div> <div class="container-fluid"> <table class="layout-table"> <tr> <td class="sidebar"> <div class="well sidebar-nav"> <ul class="nav nav-list"> <li class="nav-header">Commons</li> <li class="none"> <a href="index.html" title="Home"> Home</a> </li> <li class="none"> <a href="https://www.apache.org/licenses/" class="externalLink" title="License"> License</a> </li> <li class="none"> <a href="mail-lists.html" title="Mailing Lists"> Mailing Lists</a> </li> <li class="none"> <a href="team.html" title="PMC"> PMC</a> </li> <li class="collapsed"> <a href="components.html" title="Components"> Components</a> </li> <li class="collapsed"> <a href="sandbox.html" title="Sandbox"> Sandbox</a> </li> <li class="collapsed"> <a href="dormant.html" title="Dormant"> Dormant</a> </li> </ul> <ul class="nav nav-list"> <li class="nav-header">Releases</li> <li class="none"> <a href="downloads/index.html" title="Releases"> Releases</a> </li> </ul> <ul class="nav nav-list"> <li class="nav-header">Source Repositories</li> <li class="none"> <a href="scminfo.html" title="General Information"> General Information</a> </li> <li class="none"> <a href="https://svn.apache.org/viewvc/commons/sandbox/" class="externalLink" title="Sandbox"> Sandbox</a> </li> <li class="none"> <a href="https://svn.apache.org/viewvc/commons/dormant/" class="externalLink" title="Dormant"> Dormant</a> </li> </ul> <ul class="nav nav-list"> <li class="nav-header">General Information</li> <li class="none"> <a href="security.html" title="Security"> Security</a> </li> <li class="none"> <a href="volunteering.html" title="Volunteering"> Volunteering</a> </li> <li class="none"> <a href="patches.html" title="Contributing Patches"> Contributing Patches</a> </li> <li class="none active"> <a href="building.html" title="Building Components"> Building Components</a> </li> <li class="none"> <a href="commons-parent" title="Commons Parent POM"> Commons Parent POM</a> </li> <li class="none"> <a href="build-plugin/index.html" title="Commons Build Plugin"> Commons Build Plugin</a> </li> <li class="none"> <a href="release-plugin/index.html" title="Commons Release Plugin"> Commons Release Plugin</a> </li> <li class="none"> <a href="site-publish.html" title="Site Publication"> Site Publication</a> </li> <li class="none"> <a href="releases/index.html" title="Releasing Components"> Releasing Components</a> </li> <li class="none"> <a href="https://cwiki.apache.org/confluence/display/COMMONS/FrontPage" class="externalLink" title="Wiki"> Wiki</a> </li> </ul> <ul class="nav nav-list"> <li class="nav-header">ASF</li> <li class="none"> <a href="https://www.apache.org/foundation/how-it-works.html" class="externalLink" title="How the ASF works"> How the ASF works</a> </li> <li class="none"> <a href="https://www.apache.org/foundation/getinvolved.html" class="externalLink" title="Get Involved"> Get Involved</a> </li> <li class="none"> <a href="https://www.apache.org/dev/" class="externalLink" title="Developer Resources"> Developer Resources</a> </li> <li class="none"> <a href="https://www.apache.org/foundation/policies/conduct.html" class="externalLink" title="Code of Conduct"> Code of Conduct</a> </li> <li class="none"> <a href="https://privacy.apache.org/policies/privacy-policy-public.html" class="externalLink" title="Privacy"> Privacy</a> </li> <li class="none"> <a href="https://www.apache.org/foundation/sponsorship.html" class="externalLink" title="Sponsorship"> Sponsorship</a> </li> <li class="none"> <a href="https://www.apache.org/foundation/thanks.html" class="externalLink" title="Thanks"> Thanks</a> </li> </ul> </div> <div id="poweredBy"> <a href="https://www.apache.org/events/current-event.html" title="ApacheCon" class="builtBy"> <img class="builtBy" alt="ApacheCon" src="https://www.apache.org/events/current-event-125x125.png" /> </a> <a href="https://maven.apache.org/" title="Maven" class="builtBy"> <img class="builtBy" alt="Maven" src="https://maven.apache.org/images/logos/maven-feather.png" /> </a> </div> </td> <td class="content"> <section> <h2><a name="Introduction"></a>Introduction</h2> <p> This document provides information on setting up and executing builds for Apache Commons components and web sites. The contents include best practices and conventions that Commons components should follow. This information should be useful to committers setting up new components as well as to volunteers who want to build Commons components or web sites from source or to contribute patches to the build artifacts. </p> <p> The assumption throughout is that we are working with a component named &quot;Apache Commons Foo&quot; that uses Maven as its build system, both for distribution binaries and for the web site. </p> <p> Some knowledge of Maven is assumed in this document. Please refer to the <a class="externalLink" href="http://maven.apache.org/guides/">Maven user guide</a> for more information. Commons components now use version 3 of Maven, so this is the Maven version assumed throughout this document. </p> </section> <section> <h2><a name="Commons_Parent_POM"></a>Commons Parent POM</h2> <p> Commons componenents share a common <a href="commons-parent-pom.html">parent POM.</a> This contains common setup to reduce the setup needed in each component POM and standardizes the builds across Commons components. </p> </section> <section> <h2><a name="Local_environment_setup"></a>Local environment setup</h2> <p> To build Apache Commons components or web sites, you need to have Maven installed and the project source files checked out locally. </p> <section> <h3><a name="Getting_and_installing_Maven"></a>Getting and installing Maven</h3> <p> Follow the <a class="externalLink" href="http://maven.apache.org/download.html"> Maven download instructions</a> to download and install Maven. </p> </section> <section> <h3><a name="Checking_out_the_Commons_sources"></a>Checking out the Commons sources</h3> <p> Follow the <a class="externalLink" href="http://commons.apache.org/scminfo.html"> Commons subversion instructions</a> to check out the Commons source files. If you want to build Commons component web sites, you need to have the <code>commons-build</code> module checked out as a peer to whatever component(s) you are trying to generate the site for. If you check out the full set of &quot;trunks&quot; using the svn externals &quot;trunks-proper&quot; or &quot;trunks-sandbox&quot; this will happen automatically. </p> </section> <section> <h3><a name="Configuring_local_properties"></a>Configuring local properties</h3> <p> If you regularly want to build Commons components using a different version of Java than that used to run Maven, you may wish to define the locations of the alternate JDKs in the Maven <code>settings.xml</code> file. See <a href="commons-parent-pom.html#Testing_with_different_Java_versions">testing with different Java versions</a> for more details. Alternatively, you can provide the location of the alternate JDK as a property on the Maven command-line, see below. </p> </section> </section> <section> <h2><a name="Maven_Commands"></a>Maven Commands</h2> <section> <h3><a name="Compile_and_test_with_a_specific_JDK"></a>Compile and test with a specific JDK</h3> <p> To compile and run a component's tests with JDK 1.5. This assumes that the property JAVA_1_5_HOME has been defined in the Maven <code>settings.xml</code> or has been defined as an OS environment variable (if both are defined, settings.xml takes precedence) </p> <div class="source"> <pre>mvn clean test -Pjava-1.5</pre></div> <p> To compile (only) source and test files with Java 1.6 if settings.xml does not contain the property definitions (note this overrides any definition in settings.xml): </p> <div class="source"> <pre>mvn [clean] test-compile -Pjava-1.6 -DJAVA_1_6_HOME=path-to-jdk-home</pre></div> </section> <section> <h3><a name="Running_the_Tests"></a>Running the Tests</h3> <p> To run a component's tests: </p> <div class="source"> <pre>mvn test</pre></div> </section> <section> <h3><a name="Creating_a_jar_file"></a>Creating a jar file</h3> <p> To create a component's jar: </p> <div class="source"> <pre>mvn package</pre></div> </section> <section> <h3><a name="Installing"></a>Installing</h3> <p> To install a component in your local repository: </p> <div class="source"> <pre>mvn install</pre></div> </section> <section> <h3><a name="Source_and_binary_distributions"></a>Source and binary distributions</h3> <p> To create the source and binary distributions for a component (and the javadoc and sources jars): </p> <div class="source"> <pre>mvn -Prelease package</pre></div> </section> <section> <h3><a name="Generating_the_Site"></a>Generating the Site</h3> <p> To generate a components site: </p> <div class="source"> <pre>mvn site</pre></div> </section> </section> </td> </tr> </table> </div> <div class="footer"> <p>Copyright &copy; 2024 <a href="https://www.apache.org/">The Apache Software Foundation</a>. All Rights Reserved.</p> <?xml version="1.0" encoding="UTF-8"?> <div class="center">Apache Commons, Apache, the Apache feather logo, and the Apache Commons project logos are trademarks of The Apache Software Foundation. All other marks mentioned may be trademarks or registered trademarks of their respective owners.</div> </div> </body> </html>

Pages: 1 2 3 4 5 6 7 8 9 10