Skip to content
Browse files

Addition of Apache Maven support

This patch enables Apache Maven build support for JArgs, while maintaining Apache Ant support. Moreover the package name of JArgs was changed to `com.sanityinc.jargs'
  • Loading branch information...
1 parent 87e0009 commit b43c56a57ffc47da1f5238755e51bd86d501265f penSec.IT UG (haftungsbeschränkt) committed Sep 15, 2012
View
4 .gitignore
@@ -1,4 +1,2 @@
-/classes
-/doc
-/lib/jargs*.jar
+target
*~
View
14 doc/CHANGES → CHANGES
@@ -1,3 +1,13 @@
+Changes from 1.0 to 2.0
+=======================
+
+- Addition of generics to the code
+
+- Support for maven build infrastructure
+
+- Package moved to com.sanityinc.jargs
+
+
Changes from 0.5 to 1.0
=======================
@@ -19,6 +29,7 @@ Changes from 0.5 to 1.0
- Some code clean-ups.
+
Changes from 0.4 to 0.5
=======================
@@ -30,6 +41,7 @@ Changes from 0.4 to 0.5
- More tests
+
Changes from 0.3 to 0.4
=======================
@@ -39,6 +51,7 @@ Changes from 0.3 to 0.4
- Support locale-dependent parsing of Double options
+
Changes from 0.2 to 0.3
=======================
@@ -64,3 +77,4 @@ Changes from 0.2 to 0.3
- Added overridden CmdLineParser.parse() which takes a Locale instance,
and made both versions of the method final.
+
View
48 README.md
@@ -9,7 +9,7 @@ JArgs command-line argument parsing library
All rights reserved.
-Released under the terms of the BSD licence. See the file LICENCE for
+Released under the terms of the BSD licence. See the file `LICENCE` for
details.
@@ -19,43 +19,51 @@ Prerequisites
For each prerequisite, the version with which JArgs has been tested is given
in parentheses. Any version equal to or later than this should work.
-Apache Ant (1.4.1), by The Apache Software Foundation, from
-http://ant.apache.org/. Ant is used to build JArgs, and to run its tests.
+To build JArgs and run its tests you need on of
-JUnit (4.3.1), by Eric Gamma, et al, from http://www.junit.org/.
-JUnit is used to run the unit tests, and is not needed to run the library
-itself.
+- [Apache Ant](http://ant.apache.org/) (1.8.2), by The Apache Software
+ Foundation
+- [Apache Maven](http://maven.apache.org/) (3.0.4), by The Apache Software
+ Foundation
+
+Moreover [JUnit](http://www.junit.org/) (4.3.1), by Eric Gamma, is used to run
+the unit tests, but is not needed to run the library itself.
Installation
------------
-To compile, package, and test the code, run
+To compile, package, and test the code, run either
ant
+or
+ mvn clean package javadoc:javadoc jar:test-jar
-Two jars are created, one called `lib/jargs.jar`, which contains the runtime
-library, and one called `lib/jargs-test.jar`, which contains the unit tests and
-the examples. The Javadoc APIs are created in `doc/api`.
+Two jars are created, one called `target/jargs-$VERSION$.jar`, which contains
+the runtime library, and one called `target/jargs-$VERSION$-tests.jar`, which
+contains the unit tests and the examples. The Javadoc APIs are created in
+`target/site/apidocs`.
-To use the library with your own code, simply ensure that `lib/jargs.jar` is on
-the CLASSPATH.
+To use the library with your own code, simply ensure that
+`target/jargs-$VERSION$.jar` is on the CLASSPATH.
Documentation
-------------
The main documentation is the detailed worked example in
-`src/jargs/examples/gnu/OptionTest.java`, plus the generated API documentation
-in `doc/api/`.
+`src/test/resources/com/sanityinc/jargs/examples/gnu/OptionTest.java`, plus the
+generated API documentation in `target/site/apidocs`.
Package contents
----------------
-- `src/jargs/gnu` -- The library itself.
-- `src/jargs/examples/gnu` -- Examples showing how to use the library.
-- `src/jargs/test/gnu` -- JUnit tests.
-- `doc/` -- API and other documentation.
-- `classes/` -- Compiled classes, once built.
-- `lib/` -- JArgs jars, once built.
+- `src/main/java/com/sanityinc/jargs` -- The library itself.
+- `src/test/resources/com/sanityinc/jargs/examples` -- Examples showing how to
+ use the library.
+- `src/test/java/com/sanityinc/jargs` -- JUnit tests.
+- `target/site/apidocs` -- API and other documentation.
+- `target/classes` -- Compiled classes, once built.
+- `target/` -- JArgs jars, once built.
+
View
3 TODO
@@ -1,4 +1,5 @@
JArgs to-do list
================
-Nothing! (Fate, consider yourself tempted.)
+- Remove Java 1.1 code idioms (Iterator)
+
View
123 build.xml
@@ -1,85 +1,122 @@
+<?xml version="1.0" ?>
+
+<!--
+ | Copyright (c) 2001-2012 Steve Purcell.
+ | Copyright (c) 2002 Vidar Holen.
+ | Copyright (c) 2002 Michal Ceresna.
+ | Copyright (c) 2005 Ewan Mellor.
+ | Copyright (c) 2010-2012 penSec.IT UG (haftungsbeschränkt).
+ |
+ | All rights reserved.
+ |
+ | Redistribution and use in source and binary forms, with or without
+ | modification, are permitted provided that the following conditions are met:
+ | Redistributions of source code must retain the above copyright notice, this
+ | list of conditions and the following disclaimer. Redistributions in binary
+ | form must reproduce the above copyright notice, this list of conditions and
+ | the following disclaimer in the documentation and/or other materials provided
+ | with the distribution. Neither the name of the copyright holder nor the names
+ | of its contributors may be used to endorse or promote products derived from
+ | this software without specific prior written permission.
+ |
+ | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
+ | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ | POSSIBILITY OF SUCH DAMAGE.
+-->
+
<project default="build" basedir=".">
<property name="Name" value="Jargs"/>
+ <property name="version" value="2.0-SNAPSHOT"/>
<property name="debug" value="on"/>
- <property name="build.src" value="src"/>
- <property name="build.classes" value="classes"/>
+ <property name="build.src" value="src/main/java"/>
+ <property name="build.classes" value="target/classes"/>
+ <property name="test.src" value="src/test/java"/>
+ <property name="test.classes" value="target/test-classes"/>
+ <property name="examples.src" value="src/test/resources"/>
+ <property name="examples.classes" value="target/examples-classes"/>
<property name="source-version" value="1.5" />
<property name="jdk-version" value="1.5" />
- <property name="javadoc.outdir" value="doc/api"/>
+ <property name="javadoc.outdir" value="target/site/apidocs"/>
<property name="javadoc.doctitle" value="JArgs command line option parsing library"/>
- <property name="javadoc.header" value='For updates and more see &lt;a target="_top" href="http://jargs.sourceforge.net/"&gt;jargs.sourceforge.net&lt;/a&gt;'/>
+ <property name="javadoc.header" value='For updates and more see &lt;a target="_top" href="http://jargs.sanityinc.com/"&gt;jargs.sanityinc.com&lt;/a&gt;'/>
<property name="javadoc.bottom" value='Copyright &amp;copy; 2001-2012 Steve Purcell. Copyright &amp;copy; 2002 Vidar Holen. Copyright &amp;copy; 2002 Michal Ceresna. Copyright &amp;copy; 2005 Ewan Mellor. Copyright (c) 2010-2012 penSec.IT UG (haftungsbeschränkt). Released under the terms of the BSD licence.'/>
- <property name="javadoc.packages" value="jargs.gnu"/>
+ <property name="javadoc.packages" value="com.sanityinc.jargs"/>
<property name="junit.jar" value="/usr/share/java/junit.jar"/>
<target name="build" description="Build and test Jargs."
depends="compile,jars,javadoc,test" />
<target name="compile">
- <mkdir dir="classes"/>
+ <mkdir dir="${build.classes}"/>
<javac destdir="${build.classes}" debug="${debug}"
- source="${source-version}" target="${jdk-version}">
+ source="${source-version}" target="${jdk-version}"
+ includeantruntime="false">
<classpath path="${build.classes}:${java.class.path}"/>
<src path="${build.src}" />
- <exclude name="jargs/test/**"/>
</javac>
</target>
- <target name="compile-test">
- <mkdir dir="classes"/>
- <javac destdir="${build.classes}" debug="${debug}"
- source="${source-version}" target="${jdk-version}">
+ <target name="compile-test" depends="compile">
+ <mkdir dir="${test.classes}"/>
+ <javac destdir="${test.classes}" debug="${debug}"
+ source="${source-version}" target="${jdk-version}"
+ includeantruntime="false">
+ <classpath path="${build.classes}:${junit.jar}:${java.class.path}"/>
+ <src path="${test.src}" />
+ </javac>
+ </target>
+
+ <target name="compile-examples" depends="compile">
+ <mkdir dir="${examples.classes}"/>
+ <javac destdir="${examples.classes}" debug="${debug}"
+ source="${source-version}" target="${jdk-version}"
+ includeantruntime="false">
<classpath path="${build.classes}:${junit.jar}:${java.class.path}"/>
- <src path="${build.src}/jargs/test" />
+ <src path="${examples.src}" />
</javac>
</target>
<target name="jars" depends="runtimejar,testjar" />
<target name="runtimejar" depends="compile">
- <mkdir dir="dist"/>
- <mkdir dir="lib"/>
- <copy todir="dist">
- <fileset dir="classes"/>
+ <mkdir dir="target"/>
+ <mkdir dir="target/jar-temp"/>
+ <copy todir="target/jar-temp">
+ <fileset dir="${build.classes}"/>
</copy>
- <delete dir="dist/jargs/examples"/>
- <delete dir="dist/jargs/test"/>
- <jar jarfile="lib/jargs.jar" basedir="dist"/>
- <delete dir="dist"/>
+ <jar jarfile="target/jargs-${version}.jar" basedir="target/jar-temp"/>
+ <delete dir="target/jar-temp"/>
</target>
- <target name="testjar" depends="compile-test">
- <mkdir dir="dist"/>
- <mkdir dir="lib"/>
- <copy todir="dist">
- <fileset dir="classes"/>
+ <target name="testjar" depends="compile-test,compile-examples">
+ <mkdir dir="target"/>
+ <mkdir dir="target/jar-temp"/>
+ <copy todir="target/jar-temp">
+ <fileset dir="${test.classes}"/>
+ <fileset dir="${examples.src}"/>
</copy>
- <delete dir="dist/jargs/gnu"/>
- <jar jarfile="lib/jargs-test.jar" basedir="dist"/>
- <delete dir="dist"/>
+ <jar jarfile="target/jargs-${version}-tests.jar" basedir="target/jar-temp"/>
+ <delete dir="target/jar-temp"/>
</target>
<target name="test" depends="compile,compile-test">
<java classname="org.junit.runner.JUnitCore"
- classpath="${build.classes}:${junit.jar}:${java.class.path}" >
- <arg value="jargs.test.gnu.AllTests"/>
- </java>
- </target>
-
- <target name="testgui" depends="compile,compile-test">
- <java classname="junit.swingui.TestRunner" fork="true"
- classpath="${build.classes}:${junit.jar}:${java.class.path}">
- <arg value="jargs.test.gnu.AllTests"/>
+ classpath="${build.classes}:${test.classes}:${junit.jar}:${java.class.path}" >
+ <arg value="com.sanityinc.jargs.AllTests"/>
</java>
</target>
<target name="clean"
description="Remove all generated files.">
- <delete dir="dist" />
- <delete dir="classes" />
- <delete dir="${javadoc.outdir}" />
- <delete file="lib/jargs.jar" />
- <delete file="lib/jargs-test.jar" />
+ <delete dir="target" />
</target>
<target name="javadoc">
View
1 doc/.cvsignore
@@ -1 +0,0 @@
-api
View
2 lib/.cvsignore
@@ -1,2 +0,0 @@
-jargs.jar
-jargs-test.jar
View
87 pom.xml
@@ -0,0 +1,87 @@
+<?xml version="1.0" ?>
+
+<!--
+ | Copyright (c) 2001-2012 Steve Purcell.
+ | Copyright (c) 2002 Vidar Holen.
+ | Copyright (c) 2002 Michal Ceresna.
+ | Copyright (c) 2005 Ewan Mellor.
+ | Copyright (c) 2010-2012 penSec.IT UG (haftungsbeschränkt).
+ |
+ | All rights reserved.
+ |
+ | Redistribution and use in source and binary forms, with or without
+ | modification, are permitted provided that the following conditions are met:
+ | Redistributions of source code must retain the above copyright notice, this
+ | list of conditions and the following disclaimer. Redistributions in binary
+ | form must reproduce the above copyright notice, this list of conditions and
+ | the following disclaimer in the documentation and/or other materials provided
+ | with the distribution. Neither the name of the copyright holder nor the names
+ | of its contributors may be used to endorse or promote products derived from
+ | this software without specific prior written permission.
+ |
+ | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
+ | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ | POSSIBILITY OF SUCH DAMAGE.
+-->
+
+<project>
+ <modelVersion>4.0.0</modelVersion>
+
+ <groupId>com.sanityinc</groupId>
+ <artifactId>jargs</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <packaging>jar</packaging>
+
+ <name>JArgs</name>
+ <description>JArgs command line option parsing library</description>
+ <url>http://jargs.sanityinc.com</url>
+
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ </properties>
+
+ <licenses>
+ <license>
+ <name>New BSD License</name>
+ <url>http://www.opensource.org/licenses/BSD-3-Clause</url>
+ <distribution>repo</distribution>
+ </license>
+ </licenses>
+
+ <dependencies>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.3.1</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>2.5.1</version>
+ <configuration>
+ <source>1.5</source>
+ <target>1.5</target>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-javadoc-plugin</artifactId>
+ <version>2.8.1</version>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
View
7 src/jargs/gnu/CmdLineParser.java → ...va/com/sanityinc/jargs/CmdLineParser.java
@@ -30,7 +30,7 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-package jargs.gnu;
+package com.sanityinc.jargs;
import java.text.NumberFormat;
import java.text.ParseException;
@@ -51,8 +51,8 @@
* @author Steve Purcell
* @author penSec.IT UG (haftungsbeschränkt)
*
- * @version $Revision$
- * @see jargs.examples.gnu.OptionTest
+ * @version 2.0
+ * @see com.sanityinc.jargs.examples.OptionTest
*/
public class CmdLineParser {
@@ -620,3 +620,4 @@ public final void parse( String[] argv, Locale locale )
private Map<String, Option<?>> options = new HashMap<String, Option<?>>(10);
private Map<String, List<?>> values = new HashMap<String, List<?>>(10);
}
+
View
3 src/jargs/test/gnu/AllTests.java → ...st/java/com/sanityinc/jargs/AllTests.java
@@ -30,7 +30,7 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-package jargs.test.gnu;
+package com.sanityinc.jargs;
import org.junit.runner.RunWith;
import org.junit.runners.Suite;
@@ -43,3 +43,4 @@
})
public class AllTests {
}
+
View
6 ...jargs/test/gnu/CmdLineParserTestCase.java → ...anityinc/jargs/CmdLineParserTestCase.java
@@ -30,10 +30,9 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-package jargs.test.gnu;
+package com.sanityinc.jargs;
-import jargs.gnu.CmdLineParser;
-import jargs.gnu.CmdLineParser.Option;
+import com.sanityinc.jargs.CmdLineParser.Option;
import java.util.Collection;
import java.util.Iterator;
@@ -297,3 +296,4 @@ private void assertArrayEquals(Object[] expected, Object[] actual) {
}
}
+
View
7 src/jargs/test/gnu/CustomOptionTestCase.java → ...sanityinc/jargs/CustomOptionTestCase.java
@@ -30,10 +30,9 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-package jargs.test.gnu;
+package com.sanityinc.jargs;
-import jargs.gnu.CmdLineParser;
-import jargs.gnu.CmdLineParser.Option;
+import com.sanityinc.jargs.CmdLineParser.Option;
import java.text.DateFormat;
import java.text.ParseException;
@@ -103,5 +102,5 @@ protected Date parseValue( String arg, Locale locale )
}
}
-
}
+
View
5 src/jargs/examples/gnu/AutoHelpParser.java → ...ityinc/jargs/examples/AutoHelpParser.java
@@ -30,9 +30,9 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-package jargs.examples.gnu;
+package com.sanityinc.jargs.examples;
-import jargs.gnu.CmdLineParser;
+import com.sanityinc.jargs.CmdLineParser;
import java.util.ArrayList;
import java.util.Iterator;
@@ -117,3 +117,4 @@ public static void main( String[] args ) {
}
}
+
View
6 src/jargs/examples/gnu/CustomOptionTest.java → ...yinc/jargs/examples/CustomOptionTest.java
@@ -30,9 +30,10 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-package jargs.examples.gnu;
+package com.sanityinc.jargs.examples;
+
+import com.sanityinc.jargs.CmdLineParser;
-import jargs.gnu.CmdLineParser;
import java.text.DateFormat;
import java.text.ParseException;
import java.util.Locale;
@@ -104,3 +105,4 @@ public static void main( String[] args ) {
}
}
+
View
15 ...xamples/gnu/OptionParserSubclassTest.java → ...gs/examples/OptionParserSubclassTest.java
@@ -30,9 +30,9 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-package jargs.examples.gnu;
+package com.sanityinc.jargs.examples;
-import jargs.gnu.CmdLineParser;
+import com.sanityinc.jargs.CmdLineParser;
public class OptionParserSubclassTest {
@@ -81,11 +81,12 @@ public static void main( String[] args ) {
System.exit(2);
}
- CmdLineParser.Option[] allOptions =
- new CmdLineParser.Option[] { MyOptionsParser.VERBOSE,
- MyOptionsParser.NAME,
- MyOptionsParser.SIZE,
- MyOptionsParser.FRACTION };
+ CmdLineParser.Option<?>[] allOptions = new CmdLineParser.Option<?>[] {
+ MyOptionsParser.VERBOSE,
+ MyOptionsParser.NAME,
+ MyOptionsParser.SIZE,
+ MyOptionsParser.FRACTION
+ };
for ( int j = 0; j<allOptions.length; ++j ) {
System.out.println(allOptions[j].longForm() + ": " +
View
7 src/jargs/examples/gnu/OptionTest.java → .../sanityinc/jargs/examples/OptionTest.java
@@ -30,10 +30,10 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-package jargs.examples.gnu;
+package com.sanityinc.jargs.examples;
-import jargs.gnu.CmdLineParser;
-import jargs.gnu.CmdLineParser.Option;
+import com.sanityinc.jargs.CmdLineParser;
+import com.sanityinc.jargs.CmdLineParser.Option;
import java.util.Collection;
import java.util.Iterator;
@@ -166,3 +166,4 @@ public static void main( String[] args ) {
System.exit(0);
}
}
+

0 comments on commit b43c56a

Please sign in to comment.
Something went wrong with that request. Please try again.