Skip to content
CowanSM edited this page Jul 25, 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. Installation InstructionsMaven

Installing external, un-hosted libraries

To include any external libraries that are not hosted by a maven repo, use the following command: bash 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

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: ```xml C:/Users/scowan/Projects/maven/ncSOS/src/test/java/com/asascience/ncSOS/getCaps/output/ C:/apache_tomcat/apache-tomcat-7.0.27/ C:/Users/scowan/Projects/maven/ncSOS/

    <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: You must have a valid Sonatype JIRA account in order to deploy to the Sonatype repo: https://docs.sonatype.org/display/Repository/Sonatype+OSS+Maven+Repository+Usage+Guide#SonatypeOSSMavenRepositoryUsageGuide-2.Signup

You must also edit your Maven settings.xml as detailed here: https://docs.sonatype.org/display/Repository/Sonatype+OSS+Maven+Repository+Usage+Guide#SonatypeOSSMavenRepositoryUsageGuide-7a.1.POMandsettingsconfig

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: 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: xml <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: xml <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