* I was interesting in both the Xdoc and JUnit dashboard capabilities of Maven 2 (and how they compared
to Maven 1).
* To start, Maven 2 has a nice built in archetype that you can use to create an entire site. From the
Maven 2 User Guide, you use the following piece of command line magic:
mvn archetype:create -DgroupId=com.mycompany.app -DartifactId=my-app -DarchetypeGroupId=org.apache.maven.archetypes -DarchetypeArtifactId=maven-archetype-site
* Unfortunately this didn't work. It is supposed to create a project called my-app with directories
site, test, and main under my-app/src, but only site was created. So I used the above archetype
command, then used the default archetype to make normal project in the /tmp directory, and then
cp -r'd the main and test directories.
* I also had to copy the Junit <dependency/> stuff into the pom.xml of the site archetype.
* Next I ran "mvn site" but had to do this twice for some reason to get a successful build. The
token site was built in my-app/target/site.
* OK, now I run the tests. Looking around, I finally found the target that actually creates the
html dashboard reports for your test. It is
mvn surefire-report:report
The resulting report summary of your tests will be placed in target/site/surefire-report.html
* But note however that "mvn site" and "mvn surefire-report:report", while they both make HTML files
under the target/site directory, will not be combined in the same XDoc generated page.
* So how do you make extra stuff show up in the generated site? All of the web page configuration
is contained in my-app/src/site/site.xml. Open this and edit. Add the <item> to the <menu> section.
<?xml version="1.0" encoding="ISO-8859-1"?>
<project name="Maven">
<bannerLeft>
<name>Maven</name>
<src>http://maven.apache.org/images/apache-maven-project.png</src>
<href>http://maven.apache.org/</href>
</bannerLeft>
<bannerRight>
<src>http://maven.apache.org/images/maven-small.gif</src>
</bannerRight>
<body>
<links>
<item name="Apache" href="http://www.apache.org/" />
<item name="Maven 1.0" href="http://maven.apache.org/"/>
<item name="Maven 2" href="http://maven.apache.org/maven2/"/>
</links>
<menu name="Maven 2.0">
<item name="APT Format" href="format.html"/>
<item name="FAQ" href="faq.html"/>
<item name="Xdoc Example" href="xdoc.html"/>
<!-- Added this item here -->
<item name="Unit Reports" href="surefire-report.html"/>
</menu>
${reports}
</body>
</project>
* Also note that the ${reports} will add all the usual maven "Project Info" links on the left hand
side bar.
* Maven's pom also has a <reporting> section. Looks like this:
<project>
...
<reporting>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-project-info-reports-plugin</artifactId>
</plugin>
</plugins>
</reporting>
...
</project>
This tag is at the same level as <dependencies>, <build>, etc.
* I ran this, by the way, with "mvn clean surefire-report:report site" to clean, make the surefire
report, and then make the site.
Subscribe to:
Post Comments (Atom)
4 comments:
Sounds like a lot of hassle you went through. I also wonder what other people have gone through and if they even made an analysis to see if maven is beneficial to use at all.
Jar version and repository management alone make Maven more useful than Ant for build systems. I won't compare Maven to Eclipse as a development environment (since I use Emacs), but I am primarily interested in using Maven for source code distribution and deployment.
Wow. I wish I had found this BEFORE all of my hassle with m2 site generation. Good write up.
Wow. I wish I had found this BEFORE all of my hassle with m2 site generation. Good write up.
As far as maven being beneficial, it is. It has it's quirks just like any other build tool.
However maven 2 is nothing like maven 1. It's like they should have named it something else. That was a bit annoying quasi-learning a new build tool.
Post a Comment