maven-archetype
A maven-archetype for github-hosted Java projects.
Introduction
maven-archetype
lets you build a simple maven project that is hosted on github. It not only contains the standard src
and pom.xml
structure, but furthermore includes a couple of more files that I routinely use for Java projects like:
- a GPL3 license,
- static code analysis and reports using
findbugs
,pmd
andcheckstyle
, - a unit-test suite using
JUnit
and logging usinglog4j/slf4j
, - badges for the project status, build status using Travis CI and code coverage using Jacoco,
- custom README.md, TODO.md and VERSIONS.md files and
- a prototype
Main.java
+TestSuite.java
.
The resulting folder-structure looks like this:
|____emptyproject4j
| |____.codecov.yml
| |____.gitignore
| |____.travis.yml
| |____build.sh
| |____config
| | |____checkstyle
| | | |____checkstyle.xml
| | |____pmd
| | | |____ruleset.xml
| |____emptyproject4j
| |____LICENSE
| |____pom.xml
| |____README.md
| |____src
| | |____main
| | | |____java
| | | | |____net
| | | | | |____groupID
| | | | | | |____emptyproject4j
| | | | | | | |____Main.java
| | |____test
| | | |____java
| | | | |____net
| | | | | |____groupID
| | | | | | |____tests
| | | | | | | |____emptyproject4j
| | | | | | | | |____TestSuite.java
| |____TODO.md
| |____VERSIONS.md
Installation
Download the most recent release and unpack it. Afterwards install the project using:
mvn clean install
Using mvn
of course requires you to have maven.
Usage
Building a scaffold
If you want to build the scaffold call this on the command line:
mvn archetype:generate \
-DarchetypeGroupId=net.digital-alexandria \
-DarchetypeArtifactId=java-bones \
-DarchetypeVersion=0.2 \
-DgroupId=<net.groupID> \
-DartifactId=<emptyproject4j> \
-Duser='<my name>' \
-Dgithubuser=<githubuser> \
-Demail='<[email protected]>' \
-Ddescription='<this project is just awesome>'
Just don't forget to customize the data within the <
, >
(also remove the brackets).
Building the project
Packaging and running is done using
./build.sh
./emptyproject4j
I think you need to chmod +x build.sh/emptyproject4j
before.
Alternatively you can of course use the standard
mvn clean project
This creates target/emptyproject4j-standalone.jar
which you can call using
java -jar target/emptyproject4j-standalone.jar
Checking and code analysis
Check and validate your code using
mvn verify
mvn test
This calls pmd
, checkstyle
, findbugs
and surefire
.
You can also call the goals separately with
mvn checkstyle:check
mvn pmd:check
mvn findbugs:check
mvn test
Code coverage
Code coverage is generated using
mvn jacoco:report
Author
- Simon Dirmeier [email protected]