-
Notifications
You must be signed in to change notification settings - Fork 1
Maven
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 |
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
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.
See Test Setup
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.
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>
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).