Skip to content
CowanSM edited this page Jul 12, 2012 · 7 revisions

1. Installation
    a. Maven Installation
    b. External Libraries
2. Building And Packaging
    a. Building For Thredds
3. Testing
    a. Configuration
    b. Running
4. Deploying
    b. Deploying For Sonatype
5. Documentation
    b. Creating Javadocs

Installation

Steps for Maven installation:

  1. Download Maven
  2. Maven Installation Instructions

Installing external, un-hosted libraries

To include any external libraries that are not hosted by a maven repo, use the following command:

mvn install:install-file
-Dfile=\<path-to-file\>
-DgroupId=\<group-id\>
-DartifactId=\<artifact-id\>
-Dversion=\<version\>
-Dpackaging=\<packaging\>
-DgeneratePom=true

Where:

  • <path-to-file> the path to the file to load
  • <group-id> the group that the file should be registered under
  • <artifact-id> the artifact name for the file
  • <version> the version of the file
  • <packaging> the packaging of the file e.g. jar

Building and Packaging

Building For Thredds

To build the ncSOS-<version>.jar to use in the THREDDS server, you can use the following Maven command:

mvn clean package -DskipTests=true -Dmaven.skip.tests=true

As is implied, this will skip all of the sos tests and go directly to building a new jar. Tests need to be set up (code change) in order to properly run on each individual computer and broken tests will prevent Maven from fully building the target jar. The tests also can take a long time to run (close to 10 minutes), so it is recommended that you run the tests individually from packaging the jar. See below for how to setup the tests to run on a computer.

Testing

Configuration

To test the ncSOS package, you can use the maven testing utilizing junit. Before running tests you'll need to edit the tests_config.xml file (found in the resources folder) and make sure that the paths in the xml are pointing to the correct places.

Below is the contents of the tests_config.xml:
<testConfiguration>
  <getCaps>
    <outputBase>C:/Users/scowan/Projects/maven/ncSOS/src/test/java/com/asascience/ncSOS/getCaps/output/</outputBase>
    <tomcatLocation>C:/apache_tomcat/apache-tomcat-7.0.27/</tomcatLocation>
    <projectDir>C:/Users/scowan/Projects/maven/ncSOS/</projectDir>
  </getCaps>

  <getObs>
    <outputBase>C:/Users/scowan/Projects/maven/ncSOS/src/test/java/com/asascience/ncSOS/getObs/output/</outputBase>
  </getObs>
</testConfiguration>

<getCaps> contains all of the file structure for running SOSgetCapsTest.java
<getObs> contains all of the file structure for running SOSgetObsTest.java
<outputBase> is used to place the output files generated by the tests
<tomcatLocation> details the location of the local tomcat installation
<projectDir> is the location where the ncSOS project resides

Note: Each of the file paths have a trailing directory slash, this is expected in the tests and they will fail without it.

Running Tests

To run the tests you can run the Maven command below

mvn test

If you want to run a single test, for example SOSgetCapsTest.java, use the following Maven instruction

mvn test -Dtest=SOSgetCapsTest.java

Another useful option is the -X option which will print out debug logging. If this option is used, it is recommended to pipe the output to a text file (windows example):

mvn test -X > test_output.txt 2>&1

(The 2>&1 pipes stderr to stdout, which will be printed to the file).

In addition to the output of the tests, surefire creates reports in the /target/surefire-reports folder that will hold specific failures and errors for each test run.

Deploying

Deploying To Sonatype

Note:<\b> You must have a valid Sonatype JIRA account in order to deploy to the Sonatype repo (see here)
You must also edit your Maven settings.xml as detailed here<\a>

ncSOS's pom is setup to be a child of the sonatype oss pom. This ensures that when deployed, ncSOS will be uploaded to the sonatype servers as a snapshot (or staged for release).

To deploy ncSOS to sonatype use the following Maven instruction:

mvn clean deploy

By default, 'deploy' will upload the project to the server to be staged for release. If you want to upload a snapshot of the project you need to edit the version of the project in pom.xml:

<version>0.1a</version>

By adding a -SNAPSHOT to the version string, sonatype will treat the upload as such and will put it in the snapshot repo. The above, as a snapshot, would look:

<version>0.1a-SNAPSHOT</version>

Documentation

Generating Javadocs

Generating javadocs with maven is straightforward. Make sure that the pom.xml has the following set of tags defined:

<reporting>
  <plugins>
    <plugin>
      <groupId>org.apache.maven.plugins</groupId>
      <artifactId>maven-javadoc-plugin</artifactId>
      <version>2.4</version>
      <configuration>
        <aggregate>true</aggregate>
        <quiet>true</quiet>
      </configuration>
    </plugin>
  </plugins>
</reporting>

With the preceeding in place then simply run mvn javadoc:javadoc to generate the javadocs for the project. (It is recommended you 'clean' before generating the javadocs).

Clone this wiki locally