<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>JavaPulse &#187; maven</title>
	<atom:link href="http://javapulse.net/tag/maven/feed/" rel="self" type="application/rss+xml" />
	<link>http://javapulse.net</link>
	<description>a finger on the pulse of the freelance Java&#0153; market in the Netherlands</description>
	<lastBuildDate>Sat, 19 Jun 2010 11:00:31 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.5</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Coverage: EMMA, Cobertura, Maven</title>
		<link>http://javapulse.net/2008/09/02/coverage-emma-cobertura-maven/</link>
		<comments>http://javapulse.net/2008/09/02/coverage-emma-cobertura-maven/#comments</comments>
		<pubDate>Tue, 02 Sep 2008 11:48:44 +0000</pubDate>
		<dc:creator>Clara Ko</dc:creator>
				<category><![CDATA[cobertura]]></category>
		<category><![CDATA[coverage]]></category>
		<category><![CDATA[emma]]></category>
		<category><![CDATA[maven]]></category>

		<guid isPermaLink="false">http://javapulse.net/2008/09/02/coverage-emma-cobertura-maven/</guid>
		<description><![CDATA[I finished adding test coverage reports to the nightly build a couple of weeks ago, but only got around to write about it now. This post describes the details of my research into both EMMA and Cobertura. In the end, I went with EMMA mainly because of the server support.
Summary



EMMA
Cobertura


Dump and reset coverage data without [...]]]></description>
			<content:encoded><![CDATA[<p>I finished adding test coverage reports to the nightly build a couple of weeks ago, but only got around to write about it now. This post describes the details of my research into both EMMA and Cobertura. In the end, I went with EMMA mainly because of the server support.</p>
<h3>Summary</h3>
<table border="1">
<tr>
<th></th>
<th>EMMA</th>
<th>Cobertura</th>
</tr>
<tr>
<td>Dump and reset coverage data without shutting down application server</td>
<td>Yes</td>
<td>No</td>
</tr>
<tr>
<td>Source files needed for report</td>
<td>No</td>
<td>Yes</td>
</tr>
<tr>
<td>Wildcard to specify multiple source directories in Ant reporting</td>
<td>Yes</td>
<td>No</td>
</tr>
<tr>
<td>External dependencies (Cobertura&#8217;s ASM version is a potential conflict)</td>
<td>No</td>
<td>Yes</td>
</tr>
<tr>
<td>Released Maven plugin</td>
<td>No</td>
<td>Yes</td>
</tr>
<tr>
<td>Active development</td>
<td>No</td>
<td>Yes</td>
</tr>
</table>
<p>Applications running on a server require the following phases for coverage: instrumentation, running, data collection, and report generation.</p>
<p>Note: In Maven, I&#8217;ve put all EMMA related cofiguration in an &#8216;emma&#8217; profile and all Cobertura-related configuration in an &#8216;cobertura&#8217; profile, each activated by the coverage property (-Dcoverage=emma or -Dcoverage=cobertura) so only one can be run at a time.</p>
<hr/>
<h3>Instrumentation</h3>
<p>There are not much difference between EMMA and Cobertura in the instrumentation phase. Both Maven plugins are similar to use and configure, although Cobertura seems to be more clear in specifying paths.</p>
<h5>Field Reflection</h5>
<p>Note that because classes are that are instrumented have added fields to hold coverage data, it is not possible to reflect through all fields of an instrumented class because EMMA/Cobertura fields are not accessible at runtime. Therefore, it is better to reflect using names of fields that you know are there instead of through all fields. If code change is not possible, exclude the classes to be reflected from the instrumentation.</p>
<p>Our project is a multi-module Maven project. To instrument all modules, only the master pom must be altered.</p>
<h4>EMMA</h4>
<p>&lt;build&gt;<br />
&lt;plugins&gt;<br />
&lt;plugin&gt;<br />
&lt;groupId&gt;org.codehaus.mojo&lt;/groupId&gt;<br />
&lt;artifactId&gt;emma-maven-plugin&lt;/artifactId&gt;<br />
&lt;inherited&gt;true&lt;/inherited&gt;<br />
&lt;executions&gt;<br />
&lt;execution&gt;<br />
&lt;id&gt;instr-emma&lt;/id&gt;<br />
&lt;phase&gt;process-classes&lt;/phase&gt;<br />
&lt;configuration&gt;<br />
&lt;filters&gt;<br />
&lt;filter&gt;+com.mycompany.*&lt;/filter&gt;<br />
&lt;filter&gt;-com.mycompany.*.SomeClass&lt;/filter&gt;<br />
&lt;filter&gt;-com.mycompany.*.*Test&lt;/filter&gt;<br />
&lt;/filters&gt;<br />
&lt;/configuration&gt;<br />
&lt;goals&gt;<br />
&lt;goal&gt;instrument&lt;/goal&gt;<br />
&lt;/goals&gt;<br />
&lt;/execution&gt;<br />
&lt;/executions&gt;<br />
&lt;/plugin&gt;<br />
&lt;/plugins&gt;<br />
&lt;/build&gt;</p>
<p>To access the emma-maven-plugin, the CodeHaus snapshot repository must be added to your pom:</p>
<p>    &lt;pluginRepositories&gt;<br />
        &lt;pluginRepository&gt;<br />
            &lt;id&gt;snapshot.codehaus.org&lt;/id&gt;<br />
            &lt;name&gt;CodeHaus Plugin Snapshots&lt;/name&gt;<br />
            &lt;url&gt;http://snapshots.repository.codehaus.org&lt;/url&gt;<br />
            &lt;snapshots&gt;<br />
                &lt;enabled&gt;true&lt;/enabled&gt;<br />
            &lt;/snapshots&gt;<br />
        &lt;/pluginRepository&gt;<br />
    &lt;/pluginRepositories&gt;</p>
<h4>Cobertura</h4>
<p>Cobertura is very similar:</p>
<p>            &lt;build&gt;<br />
                &lt;plugins&gt;<br />
                    &lt;plugin&gt;<br />
                        &lt;groupId&gt;org.codehaus.mojo&lt;/groupId&gt;<br />
                        &lt;artifactId&gt;cobertura-maven-plugin&lt;/artifactId&gt;<br />
                        &lt;inherited&gt;true&lt;/inherited&gt;<br />
                        &lt;executions&gt;<br />
                            &lt;execution&gt;<br />
                                &lt;id&gt;instr-cobertura&lt;/id&gt;<br />
                                &lt;phase&gt;process-classes&lt;/phase&gt;<br />
                        &lt;configuration&gt;<br />
                            &lt;instrumentation&gt;<br />
                                &lt;includes&gt;<br />
                                    &lt;include&gt;com/mycompany/**/*.class&lt;/include&gt;<br />
                                &lt;/includes&gt;<br />
                                &lt;excludes&gt;<br />
                                    &lt;exclude&gt;com/mycompany/**/SomeClass.class&lt;/exclude&gt;<br />
                                    &lt;exclude&gt;com/mycompany/**/*Test.class&lt;/exclude&gt;<br />
                                &lt;/excludes&gt;<br />
                            &lt;/instrumentation&gt;<br />
                        &lt;/configuration&gt;<br />
                                &lt;goals&gt;<br />
                                    &lt;goal&gt;instrument&lt;/goal&gt;<br />
                                &lt;/goals&gt;<br />
                            &lt;/execution&gt;<br />
                        &lt;/executions&gt;<br />
                    &lt;/plugin&gt;<br />
                &lt;/plugins&gt;<br />
            &lt;/build&gt;</p>
<hr/>
<h3>Running</h3>
<p>Running is the same with or without coverage.<br />
Unit tests are run with the surefire plugin in Maven. While integration tests that require applications to be running on a server must be packaged and deployed before they are run from the client side.</p>
<h4>EMMA</h4>
<p>Because an application running with EMMA connects to the socket &#8216;47653&#8242; by default, a running application server and the test client will conflict for the socket. Therefore, if the test client is running on the same machine as the application server, configure the the socket for the test client by setting the system property -Demma.rt.control.port=12345 for the test client.</p>
<h5>System Properties</h5>
<p>Although the surefire plugin is supposed to allow passing in system properties (see <a href="http://maven.apache.org/plugins/maven-surefire-plugin/examples/system-properties.html" target="_blank">http://maven.apache.org/plugins/maven-surefire-plugin/examples/system-properties.html</a>), it did not work when I tried it. Therefore, I moved back to Ant to run the tests.</p>
<hr/>
<h3>Data Collection</h3>
<h4>EMMA</h4>
<p>The main reason I chose EMMA is because of the ability to dump and reset coverage data without shutting down the application server. EMMA (from version 2.1.5320) provides a tool (ctl) for getting a dump from a server and resetting the data. The ctl tool is accessible from the command line or from Ant. This is useful for running several types of tests where you want to collect coverage data for each separately. Here I use Ant so that it can be platform independent (instead of a .bat or .sh file).</p>
<p>After declaring the emma task (see Appendix), the following is the Ant target to be run from the POM&#8217;s of the test projects:</p>
<p>    &lt;target name=&#8221;emma-server-dump&#8221;&gt;<br />
        &lt;delete file=&#8221;${project.name}/coverage-${server}.ec&#8221; failonerror=&#8221;false&#8221;/&gt;<br />
        &lt;emma&gt;<br />
            &lt;ctl connect=&#8221;${server}:47653&#8243;&gt;<br />
                &lt;command name=&#8221;coverage.get&#8221; args=&#8221;${project.name}/coverage-${server}.ec&#8221; /&gt;<br />
                &lt;command&gt;coverage.reset&lt;/command&gt;<br />
            &lt;/ctl&gt;<br />
        &lt;/emma&gt;<br />
    &lt;/target&gt;</p>
<p>The properties are as follows:</p>
<li>${project.name}: the project where to put the coverage data file</li>
<li>${server}: the server from which to collect coverage data</li>
<h4>Cobertura</h4>
<p>Although Cobertura provides an API (See <a href="http://cobertura.sourceforge.net/faq.html" target="_blank">http://cobertura.sourceforge.net/faq.html</a>) for dumping coverage data from an application running on a server, it must be coded, deployed, and exposed to be triggered yourself. Furthermore, there is no API to reset the data. Therefore, to achieve the same functionality as EMMA, the server must be restarted between different test runs.</p>
<hr/>
<h3>Report Generation</h3>
<p>For both EMMA and Cobertura, it is not possible to specify more than one source directory in the report configuration in Maven. Therefore, generating the report in Maven is only useful for single module Maven projects or for running unit tests where only one source directory is to be considered for the report. Because of this limitation, I reverted to Ant to generate the coverage report for both EMMA and Cobertura.</p>
<h4>EMMA</h4>
<p>The following is a portion of the Ant build file after the emma task has been defined (see Appendix).</p>
<p>    &lt;target name=&#8221;emma-report&#8221;&gt;<br />
        &lt;delete failonerror=&#8221;false&#8221; dir=&#8221;${report.dir}&#8221; /&gt;<br />
        &lt;mkdir dir=&#8221;${report.dir}&#8221; /&gt;<br />
        &lt;emma&gt;<br />
            &lt;report&gt;<br />
                &lt;sourcepath&gt;<br />
                    &lt;dirset dir=&#8221;${top.dir}&#8221;&gt;<br />
                        &lt;include name=&#8221;**/src&#8221; /&gt;<br />
                        &lt;include name=&#8221;**/ejbModule&#8221; /&gt;<br />
                        &lt;include name=&#8221;**/Javasource&#8221; /&gt;<br />
                    &lt;/dirset&gt;<br />
                &lt;/sourcepath&gt;<br />
                &lt;fileset dir=&#8221;${top.dir}&#8221;&gt;<br />
                    &lt;include name=&#8221;${project.dirs}/target/coverage.em&#8221; /&gt;<br />
                    &lt;include name=&#8221;${project.name}/coverage*.ec&#8221; /&gt;<br />
                    &lt;exclude name=&#8221;*Test*/target/coverage.em&#8221; /&gt;<br />
                &lt;/fileset&gt;<br />
                &lt;html outfile=&#8221;${report.dir}/index.html&#8221; /&gt;<br />
            &lt;/report&gt;<br />
        &lt;/emma&gt;<br />
    &lt;/target&gt;</p>
<p>The properties are as follows:</p>
<li>${report.dir}: the directory where the coverage report will be generated</li>
<li>${top.dir}: top project directory when the master pom resides</li>
<li>${project.dirs}: project(s) from where to get instrumentation meta-data (.em). can be a specific name or include wildcard (*)</li>
<li>${project.name}: project(s) from where to get the coverage data (.ec). can be a specific name or include wildcard (*)</li>
<h4>Cobertura</h4>
<p>Because it is not possible to specify more than one source directory in a wildcard, configuring cobertura for reporting is much more annoying. Furthermore, meta-data files and coverage data files (.ser) must be first merged because only one such file can be given for the report.</p>
<p>    &lt;target name=&#8221;merge&#8221;&gt;<br />
        &lt;cobertura-merge datafile=&#8221;${report.dir}/${test.name}.ser&#8221;&gt;<br />
            &lt;fileset dir=&#8221;${top.dir}&#8221;&gt;<br />
                &lt;include name=&#8221;${project1}/target/cobertura/cobertura.ser&#8221; /&gt;<br />
                &lt;exclude name=&#8221;${project2}/target/cobertura/cobertura.ser&#8221; /&gt;<br />
            &lt;/fileset&gt;<br />
        &lt;/cobertura-merge&gt;<br />
    &lt;/target&gt;<br />
    &lt;target name=&#8221;cobertura-report&#8221; depends=&#8221;merge&#8221;&gt;<br />
        &lt;cobertura-report format=&#8221;html&#8221; destdir=&#8221;${report.dir}&#8221; datafile=&#8221;${report.dir}/${test.name}.ser&#8221;&gt;<br />
            &lt;fileset dir=&#8221;${src.dir.1}&#8221;&gt;&lt;include name=&#8221;**/*.java&#8221; /&gt;&lt;/fileset&gt;<br />
            &lt;fileset dir=&#8221;${src.dir.2}&#8221;&gt;&lt;include name=&#8221;**/*.java&#8221; /&gt;&lt;/fileset&gt;<br />
            &lt;fileset dir=&#8221;${src.dir.3}&#8221;&gt;&lt;include name=&#8221;**/*.java&#8221; /&gt;&lt;/fileset&gt;<br />
            &#8230;<br />
        &lt;/cobertura-report&gt;<br />
    &lt;/target&gt;</p>
<p>The &#8220;cobertura-report&#8221; target depends on the &#8220;merge&#8221; target.<br />
The properties are as follows:</p>
<li>${report.dir}: the directory where the coverage report will be generated</li>
<li>${test.name}: the name of the ser file where the (merged) coverage data resides. Must be only one file and merged previously.</li>
<li>${project1}&#8230;${project2}: the project(s) to include/exclude from merge. Can contain wildcards because using Ant fileset.</li>
<li>${src.dir.1}..${src.dir.3}: the source directories specified one at a time.</li>
<hr/>
<h3>Appendix: Declaring EMMA / Cobertura in Ant</h3>
<h4>EMMA</h4>
<p>    &lt;property name=&#8221;emma.home&#8221; value=&#8221;/usr/local/emma&#8221;/&gt;<br />
    &lt;path id=&#8221;emma.lib&#8221;&gt;<br />
        &lt;pathelement location=&#8221;${emma.home}/emma.jar&#8221; /&gt;<br />
        &lt;pathelement location=&#8221;${emma.home}/emma_ant.jar&#8221; /&gt;<br />
    &lt;/path&gt;<br />
    &lt;taskdef resource=&#8221;emma_ant.properties&#8221; classpathref=&#8221;emma.lib&#8221;/&gt;</p>
<h4>Cobertura</h4>
<p>    &lt;property name=&#8221;cobertura.dir&#8221; value=&#8221;/usr/local/cobertura&#8221; /&gt;<br />
    &lt;path id=&#8221;cobertura.classpath&#8221;&gt;<br />
        &lt;fileset dir=&#8221;${cobertura.dir}&#8221;&gt;<br />
            &lt;include name=&#8221;cobertura.jar&#8221; /&gt;<br />
            &lt;include name=&#8221;lib/**/*.jar&#8221; /&gt;<br />
        &lt;/fileset&gt;<br />
    &lt;/path&gt;<br />
    &lt;taskdef classpathref=&#8221;cobertura.classpath&#8221; resource=&#8221;tasks.properties&#8221; /&gt;</p>
]]></content:encoded>
			<wfw:commentRss>http://javapulse.net/2008/09/02/coverage-emma-cobertura-maven/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Axis 1.4 dependency conflicts in Maven</title>
		<link>http://javapulse.net/2007/09/22/axis-14-dependency-conflicts-in-maven/</link>
		<comments>http://javapulse.net/2007/09/22/axis-14-dependency-conflicts-in-maven/#comments</comments>
		<pubDate>Sat, 22 Sep 2007 23:27:54 +0000</pubDate>
		<dc:creator>Clara Ko</dc:creator>
				<category><![CDATA[axis]]></category>
		<category><![CDATA[debugging]]></category>
		<category><![CDATA[maven]]></category>

		<guid isPermaLink="false">http://javapulse.net/2007/09/22/axis-14-dependency-conflicts-in-maven/</guid>
		<description><![CDATA[Awhile back, I was converting an existing project from an Ant build to a Maven build. The project used Axis to send some soap messages. With the Ant build as a reference, I added the appropriate dependencies. But with the Maven build, the Axis call invoke method returned null without throwing an exception. Properly designed [...]]]></description>
			<content:encoded><![CDATA[<p>Awhile back, I was converting an existing project from an Ant build to a Maven build. The project used Axis to send some soap messages. With the Ant build as a reference, I added the appropriate dependencies. But with the Maven build, the Axis call invoke method returned null without throwing an exception. Properly designed software would normally throw a useful exception. And I expect Axis would do so, since it is used so often. I was not able to find anything on the internet that described this problem. And even downloading Axis and debugging through it didn&#8217;t reveal what was happening.</p>
<p>Finally, I noticed that the Maven build (maven-dependency-plugin:copy-dependencies) added more external jars in the classpath than was previously in the Ant build. It contained gnujaxp which was added transitively by jfreechart, also used by the application. By excluding gnujaxp, the Axis call finally worked as expected. I guess the moral of the story is: when getting completely unexpected behavior, there is a good chance that it is dependency conflicts. Looking carefully at the Maven copied dependencies could reveal any unnecessary dependencies. It would be useful to know which part of the code uses which dependencies. In any case, I wonder how many implementation of jaxp are out there.</p>
]]></content:encoded>
			<wfw:commentRss>http://javapulse.net/2007/09/22/axis-14-dependency-conflicts-in-maven/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Maven2 Properties Guide</title>
		<link>http://javapulse.net/2007/09/06/maven2-properties-guide/</link>
		<comments>http://javapulse.net/2007/09/06/maven2-properties-guide/#comments</comments>
		<pubDate>Thu, 06 Sep 2007 08:45:36 +0000</pubDate>
		<dc:creator>Clara Ko</dc:creator>
				<category><![CDATA[maven]]></category>

		<guid isPermaLink="false">http://javapulse.net/2007/09/06/maven2-properties-guide/</guid>
		<description><![CDATA[Maven2 Properties Guide
]]></description>
			<content:encoded><![CDATA[<li><a href="http://docs.codehaus.org/display/MAVENUSER/MavenPropertiesGuide">Maven2 Properties Guide</a><br />
]]></content:encoded>
			<wfw:commentRss>http://javapulse.net/2007/09/06/maven2-properties-guide/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Addendum : Configuring a Maven2 plugin for multiple execution</title>
		<link>http://javapulse.net/2007/09/06/addendum-configuring-a-maven2-plugin-for-multiple-execution/</link>
		<comments>http://javapulse.net/2007/09/06/addendum-configuring-a-maven2-plugin-for-multiple-execution/#comments</comments>
		<pubDate>Thu, 06 Sep 2007 08:37:41 +0000</pubDate>
		<dc:creator>Clara Ko</dc:creator>
				<category><![CDATA[maven]]></category>

		<guid isPermaLink="false">http://javapulse.net/2007/09/06/addendum-configuring-a-maven2-plugin-for-multiple-execution/</guid>
		<description><![CDATA[I found that the way to force reconfiguration for a plugin for multiple execution in the same pom is to specify an id for the execution.
This is a not very well-documented or very obvious part of Maven because the &#60;id&#62; tag is not required in the pom as a child of &#60;execution&#62;. Usually ids are [...]]]></description>
			<content:encoded><![CDATA[<p>I found that the way to force reconfiguration for a plugin for multiple execution in the same pom is to specify an id for the execution.</p>
<p>This is a not very well-documented or very obvious part of Maven because the &lt;id&gt; tag is not required in the pom as a child of &lt;execution&gt;. Usually ids are used so that they can be referenced but this is not the case here.</p>
<p>Specifying an id will allow separate configuration for each execution, but it does not reload dependencies. So if you need to use the same plugin with different dependencies, you still need to do a workaround such as the one I posted <a href="http://javapulse.net/2007/09/03/configuring-axistools-maven-plugin-for-multiple-goals/">here</a> under the section &#8216;Different dependencies for different executions of the same plugin&#8217;.</p>
]]></content:encoded>
			<wfw:commentRss>http://javapulse.net/2007/09/06/addendum-configuring-a-maven2-plugin-for-multiple-execution/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Upgrading Maven2 castor-maven-plugin to use Castor 1.1.2.1</title>
		<link>http://javapulse.net/2007/09/03/upgrading-maven2-castor-maven-plugin-to-use-castor-1121/</link>
		<comments>http://javapulse.net/2007/09/03/upgrading-maven2-castor-maven-plugin-to-use-castor-1121/#comments</comments>
		<pubDate>Mon, 03 Sep 2007 10:32:39 +0000</pubDate>
		<dc:creator>Clara Ko</dc:creator>
				<category><![CDATA[castor]]></category>
		<category><![CDATA[maven]]></category>

		<guid isPermaLink="false">http://javapulse.net/2007/09/03/upgrading-maven2-castor-maven-plugin-to-use-castor-1121/</guid>
		<description><![CDATA[Castor is a tool for generating java objects from xsds. It provides the ability to process XML as Java objects. This is an alternative to building up a DOM tree or implementing callback methods for the SAXParser yourself.
The latest version (1.0) of castor-maven-plugin for Maven2 in the central repo uses Castor version 0.9.7. However, the [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.castor.org">Castor</a> is a tool for generating java objects from xsds. It provides the ability to process XML as Java objects. This is an alternative to building up a DOM tree or implementing callback methods for the SAXParser yourself.</p>
<p>The latest version (1.0) of <a href="http://mojo.codehaus.org/castor-maven-plugin">castor-maven-plugin</a> for Maven2 in the <a href="http://repo1.maven.org/maven2">central repo</a> uses Castor version 0.9.7. However, the newest version of Castor (1.1.2.1) is not backward compatible! The castor plugin for Maven1 has been upgraded, but not for Maven2. Has Castor gone out of fashion since Maven2 was introduced?</p>
<p>Anyway, my project needed Castor 1.1.2.1 for some new functionality, so I downloaded to sources for castor-maven-plugin and the pom from the central repository upgraded the dependencies to Castor 1.1.2.1.</p>
<p>Instead of:<br />
    &lt;dependency&gt;<br />
      &nbsp;&lt;groupId&gt;castor&lt;/groupId&gt;<br />
      &nbsp;&lt;artifactId&gt;castor&lt;/artifactId&gt;<br />
      &nbsp;&lt;version&gt;0.9.7&lt;/version&gt;<br />
    &lt;/dependency&gt;</p>
<p>I now have:<br />
    &lt;dependency&gt;<br />
      &nbsp;&lt;groupId&gt;org.codehaus.castor&lt;/groupId&gt;<br />
      &nbsp;&lt;artifactId&gt;castor&lt;/artifactId&gt;<br />
      &nbsp;&lt;version&gt;1.1.2.1&lt;/version&gt;<br />
    &lt;/dependency&gt;<br />
    &lt;dependency&gt;<br />
      &nbsp;&lt;groupId&gt;org.codehaus.castor&lt;/groupId&gt;<br />
      &nbsp;&lt;artifactId&gt;castor-codegen&lt;/artifactId&gt;<br />
      &nbsp;&lt;version&gt;1.1.2.1&lt;/version&gt;<br />
    &lt;/dependency&gt;<br />
    &lt;dependency&gt;<br />
      &nbsp;&lt;groupId&gt;org.codehaus.castor&lt;/groupId&gt;<br />
      &nbsp;&lt;artifactId&gt;castor-jdo&lt;/artifactId&gt;<br />
      &nbsp;&lt;version&gt;1.1.2.1&lt;/version&gt;<br />
    &lt;/dependency&gt;</p>
<p>Some classes for the Castor builder has been moved, so the import statements for CastorSourceGenerator had to be changed:</p>
<p>From:<br />
import org.exolab.castor.builder.CollectionInfo;<br />
import org.exolab.castor.builder.FieldInfoFactory;</p>
<p>To:<br />
import org.exolab.castor.builder.info.CollectionInfo;<br />
import org.exolab.castor.builder.factory.FieldInfoFactory;</p>
<p>After rebuilding everything, a new version 1.0.1-SNAPSHOT was produced for castor-maven-plugin that uses the latest version (1.1.2.1) of Castor.</p>
<p>I haven&#8217;t yet had time to investigate how to get it into the central repository so you can download the RAR compressed directory of castor-maven-plugin version 1.0.1-SNAPSHOT <a href="http://javapulse.net/wp-content/uploads/1.0.1-SNAPSHOT.rar">here</a>. It is to be placed at ${local.repo}/org/codehaus/mojo/castor-maven-plugin/ together with <a href="http://javapulse.net/wp-content/uploads/maven-metadata-local.xml">maven-metadata-local.xml</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://javapulse.net/2007/09/03/upgrading-maven2-castor-maven-plugin-to-use-castor-1121/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Configuring Maven2 plugin &#8216;axistools-maven-plugin&#8217; for multiple executions</title>
		<link>http://javapulse.net/2007/09/03/configuring-axistools-maven-plugin-for-multiple-goals/</link>
		<comments>http://javapulse.net/2007/09/03/configuring-axistools-maven-plugin-for-multiple-goals/#comments</comments>
		<pubDate>Mon, 03 Sep 2007 09:48:06 +0000</pubDate>
		<dc:creator>Clara Ko</dc:creator>
				<category><![CDATA[axis]]></category>
		<category><![CDATA[maven]]></category>

		<guid isPermaLink="false">http://javapulse.net/2007/09/03/configuring-axistools-maven-plugin-for-multiple-goals/</guid>
		<description><![CDATA[The project I was converting to Maven produces a war file containing an Axis-generated web service. I had to execute all 3 goals of the axistools-maven-plugin: java2wsdl, then wsdl2java, then admin.
Rebinding to a different phase and compiling generated sources after normal classes are already compiled
Normally, wsdl2java is bound to the generate-sources phase and both java2wsdl [...]]]></description>
			<content:encoded><![CDATA[<p>The project I was converting to Maven produces a war file containing an <a href="http://ws.apache.org/axis/">Axis</a>-generated web service. I had to execute all 3 goals of the <a href="http://mojo.codehaus.org/axistools-maven-plugin">axistools-maven-plugin</a>: java2wsdl, then wsdl2java, then admin.</p>
<p><strong>Rebinding to a different phase and compiling generated sources after normal classes are already compiled</strong><br />
Normally, wsdl2java is bound to the <em>generate-sources</em> phase and both java2wsdl and admin are bound to the <em>process-classes</em> phase. But I don&#8217;t have the wsdl to process in the wsdl2java until after the <em>process-classes</em> phase. So I bound the wsdl2java to the <em>generate-test-sources</em> phase and trick Maven into compiling the generated sources as test sources by setting the testSourceDirectory to the wsdl2java generated sources and testOutputDirectory to the same as the normal sources.</p>
<p>    &lt;testSourceDirectory&gt;${basedir}/target/generated-sources/axistools/wsdl2java&lt;/testSourceDirectory&gt;<br />
    &lt;testOutputDirectory&gt;${basedir}/target/classes&lt;/testOutputDirectory&gt;</p>
<p><strong>Configuring a plugin for multiple execution</strong></p>
<blockquote><p>Since this post was published, I found that there is another way to get the multiple executions of the same pom to be reinstantiated. So the following section is no longer valid. See <a href="http://javapulse.net/2007/09/06/addendum-configuring-a-maven2-plugin-for-multiple-execution/">Addendum: Configuring a Maven2 plugin for multiple execution</a>. However, the next section &#8216;Different dependencies for different executions of the same plugin&#8217; is still valid until the bug is fixed.</p></blockquote>
<p>Then I ran into the Maven bug <a href="http://jira.codehaus.org/browse/MNG-1323">#MNG-1323</a> &#8211; plugins are instantiated only once and cached according to the groupId/artifactId during any given Maven run. This means that configurations are not reapplied and dependencies are not reloaded in subsequent executions of the same plugin. To workaround the first problem, I had to put all the configuration properties in the first invocation (java2wsdl):</p>
<p>            &lt;configuration&gt;<br />
            &nbsp;&nbsp;<strong>&lt;!&#8211; java2wsdl &#8211;&gt;</strong><br />
            &nbsp;&nbsp;&lt;filename&gt;${project.name}.wsdl&lt;/filename&gt;<br />
            &nbsp;&nbsp;&lt;classOfPortType&gt;<strong><em>&lt;path to interface or class of webservice&gt;</em></strong>&lt;/classOfPortType&gt;<br />
            &nbsp;&nbsp;&lt;location&gt;<strong><em>&lt;url for access to webservice&gt;</em></strong>&lt;/location&gt;<br />
            &nbsp;&nbsp;&lt;namespace&gt;<strong><em>&lt;namespace used in SOAP&gt;</em></strong>&lt;/namespace&gt;<br />
            &nbsp;&nbsp;&lt;style&gt;rpc&lt;/style&gt;<br />
            &nbsp;&nbsp;&lt;typeMappingVersion&gt;1.1&lt;/typeMappingVersion&gt;<br />
            &nbsp;&nbsp;&lt;use&gt;encoded&lt;/use&gt;<br />
            &nbsp;&nbsp;<strong>&lt;!&#8211; wsdl2java &#8211;&gt;</strong><br />
            &nbsp;&nbsp;&lt;all&gt;true&lt;/all&gt;<br />
            &nbsp;&nbsp;&lt;serverSide&gt;true&lt;/serverSide&gt;<br />
            &nbsp;&nbsp;&lt;sourceDirectory&gt;${basedir}/target/generated-sources/axistools/java2wsdl&lt;/sourceDirectory&gt;<br />
            &nbsp;&nbsp;&lt;wsdlFiles&gt;&lt;wsdlFile&gt;${project.name}.wsdl&lt;/wsdlFile&gt;&lt;/wsdlFiles&gt;<br />
            &nbsp;&nbsp;&lt;noWrapped&gt;false&lt;/noWrapped&gt;<br />
            &nbsp;&nbsp;&lt;mappings&gt;<br />
            &nbsp;&nbsp;&nbsp;&nbsp;&lt;mapping&gt;<br />
            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;namespace&gt;<strong><em>&lt;namespace used for webservice, specified above&gt;</em></strong>&lt;/namespace&gt;<br />
            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;targetPackage&gt;<strong><em>&lt;package for generated sources for wsdl2java&gt;</em></strong>&lt;/targetPackage&gt;<br />
            &nbsp;&nbsp;&nbsp;&nbsp;&lt;/mapping&gt;<br />
            &nbsp;&nbsp;&lt;/mappings&gt;<br />
            &nbsp;&nbsp;&lt;implementationClassName&gt;<strong><em>&lt;path to implementation class of webservice&gt;</em></strong>&lt;/implementationClassName&gt; <strong>&lt;!&#8211; This will be generated as a template to be filled in, but because I started with a webservice implementation, the generated one should be delete from the target classes before packaging &#8211;&gt;</strong><br />
            &nbsp;&nbsp;&lt;servicePortName&gt;${project.name}&lt;/servicePortName&gt;<br />
            &nbsp;&nbsp;&lt;wrapArrays&gt;false&lt;/wrapArrays&gt; <strong>&lt;!&#8211; This one must be specified to prevent mapping of arrays into lists. Notice that this was not configurable for axis ant tasks where it is false by default. &#8211;&gt;</strong><br />
            &nbsp;&nbsp;<strong>&lt;!&#8211; admin &#8211;&gt;</strong><br />
            &nbsp;&nbsp;&lt;inputFiles&gt;<br />
            &nbsp;&nbsp;&nbsp;&nbsp;&lt;inputFile&gt;${basedir}/target/generated-sources/axistools/wsdl2java/<strong><em>&lt;remainder path to generated deploy descriptor&gt;</em></strong>/deploy.wsdd&lt;/inputFile&gt;<br />
            &nbsp;&nbsp;&lt;/inputFiles&gt;<br />
            &nbsp;&nbsp;&lt;isServerConfig&gt;true&lt;/isServerConfig&gt;<br />
            &nbsp;&nbsp;&lt;configOutputDirectory&gt;${basedir}/target/${project.artifactId}-${version}/WEB-INF&lt;/configOutputDirectory&gt;<br />
            &lt;/configuration&gt;</p>
<p><strong>Different dependencies for different executions of the same plugin</strong><br />
To workaround the second problem of applying different dependencies to different executions, I had to reinstall the plugin multiple times to different artifactId&#8217;s because the plugin are cached according to groupId/artifactId, so changing the version wouldn&#8217;t work. Then I found out that <em>install:install-file</em> doesn&#8217;t work for a plugin because the plugin descriptor would not be found. So I had to get the sources and invoke &#8216;mvn install&#8217; for each set of dependencies after specifying the artifactId:</p>
<p>  &lt;artifactId&gt;axistools-maven-plugin<strong><em>-dependencies1</em></strong>&lt;/artifactId&gt;</p>
<p>The install from the sources will eventually call <em>plugin:updateRegistry</em> which makes the plugin descriptor available.</p>
]]></content:encoded>
			<wfw:commentRss>http://javapulse.net/2007/09/03/configuring-axistools-maven-plugin-for-multiple-goals/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Maven2 Bug #MNG-2258 Workaround: plugin execution order</title>
		<link>http://javapulse.net/2007/09/03/maven2-bug-mng-2258-workaround-plugin-execution-order/</link>
		<comments>http://javapulse.net/2007/09/03/maven2-bug-mng-2258-workaround-plugin-execution-order/#comments</comments>
		<pubDate>Mon, 03 Sep 2007 08:53:51 +0000</pubDate>
		<dc:creator>Clara Ko</dc:creator>
				<category><![CDATA[maven]]></category>

		<guid isPermaLink="false">http://javapulse.net/2007/09/03/maven2-bug-mng-2258-workaround-plugin-execution-order/</guid>
		<description><![CDATA[During a Maven build, plugins are executed in a certain order as bound to a specific build lifecycle phase.
In Maven1, it was possible to specify the order of plugin execution within a single phase using the preGoal tag in a plugin configuration. However, this mechanism was removed in Maven2, causing the bug &#8211; MNG-2258: Wrong [...]]]></description>
			<content:encoded><![CDATA[<p>During a Maven build, plugins are executed in a certain order as bound to a specific <a href="http://maven.apache.org/guides/introduction/introduction-to-the-lifecycle.html">build lifecycle</a> phase.</p>
<p>In Maven1, it was possible to specify the order of plugin execution within a single phase using the <em>preGoal</em> tag in a plugin configuration. However, this mechanism was removed in Maven2, causing the bug &#8211; <a href="http://jira.codehaus.org/browse/MNG-2258">MNG-2258: Wrong execution order of plugins in same phase</a>. Since it is not expected to be fixed before Maven 2.1, the workaround that I use is to bind the various plugins to different phases, sometimes misusing phases to preserve order. Knowing the <a href="http://cvs.peopleware.be/training/maven/maven2/buildLifecyclePhases.html">standard bindings</a>, plugins can be bound to various phases that are part of the build lifecycle of the given packaging standard. Plugins bound to a phase that already has a default binding will always be executed after the default plugin. This workaround is preferable to resorting to Ant, because it uses Maven plugins, and so prevents having to configure classpaths for the Ant tasks. It is also preferable because when this bug is fixed in Maven, there would be minimal changes to the build process in the pom.</p>
]]></content:encoded>
			<wfw:commentRss>http://javapulse.net/2007/09/03/maven2-bug-mng-2258-workaround-plugin-execution-order/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Maven2: Build Lifecycle Phases and Plugins</title>
		<link>http://javapulse.net/2007/08/24/maven2-build-lifecycle-phases-and-plugins/</link>
		<comments>http://javapulse.net/2007/08/24/maven2-build-lifecycle-phases-and-plugins/#comments</comments>
		<pubDate>Fri, 24 Aug 2007 12:44:24 +0000</pubDate>
		<dc:creator>Clara Ko</dc:creator>
				<category><![CDATA[maven]]></category>

		<guid isPermaLink="false">http://javapulse.net/2007/08/24/maven2-build-lifecycle-phases-and-plugins/</guid>
		<description><![CDATA[A handy reference for Maven2 build lifecyle phases and plugin goal bindings for the standard packaging types.
http://cvs.peopleware.be/training/maven/maven2/buildLifecyclePhases.html
]]></description>
			<content:encoded><![CDATA[<p>A handy reference for Maven2 build lifecyle phases and plugin goal bindings for the standard packaging types.</p>
<p><a href="http://cvs.peopleware.be/training/maven/maven2/buildLifecyclePhases.html">http://cvs.peopleware.be/training/maven/maven2/buildLifecyclePhases.html</a></p>
]]></content:encoded>
			<wfw:commentRss>http://javapulse.net/2007/08/24/maven2-build-lifecycle-phases-and-plugins/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Test Development with TestNG and Maven</title>
		<link>http://javapulse.net/2007/03/11/test-development-with-testng-and-maven/</link>
		<comments>http://javapulse.net/2007/03/11/test-development-with-testng-and-maven/#comments</comments>
		<pubDate>Sun, 11 Mar 2007 09:15:08 +0000</pubDate>
		<dc:creator>Clara Ko</dc:creator>
				<category><![CDATA[debugging]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[maven]]></category>
		<category><![CDATA[testing]]></category>

		<guid isPermaLink="false">http://javapulse.net/?p=67</guid>
		<description><![CDATA[Update following the discussion in the comments:
The reason for not running/debugging my tests from within Netbeans is because the Netbeans TestNG plugin is not up-to-date. I&#8217;m using TestNG 5.5 while the plugin is written for 4.6 or something like that. I&#8217;m sure that if I&#8217;m using either Eclipse with TestNG or JUnit with Netbeans, the [...]]]></description>
			<content:encoded><![CDATA[<p>Update following the <a href="http://javapulse.net/?p=67#comments">discussion</a> in the comments:<br />
The reason for not running/debugging my tests from within Netbeans is because the Netbeans TestNG plugin is not up-to-date. I&#8217;m using TestNG 5.5 while the plugin is written for 4.6 or something like that. I&#8217;m sure that if I&#8217;m using either Eclipse with TestNG or JUnit with Netbeans, the plugins might be more up-to-date. But, the solution below works for me for now.</p>
<hr/>
<p>As part of a huge refactoring effort, I&#8217;m working with the TestNG, Maven, Netbeans. Not surprisingly, everything has not been a breeze. So I put together these steps to set up test development using TestNG and Maven, and debugging with any IDE. In fact, TestNG can be easily replaced by JUnit here. It&#8217;s more about getting around the <a href="http://maven.apache.org/guides/introduction/introduction-to-the-lifecycle.html">Maven build life cycle</a> during test development.</p>
<p><b>1) Skipping the Maven test phase until test development is complete</b></p>
<p>The first problem I encountered was that the jars get created at the install phase near the end of the Maven build life cycle, which means that if the tests fail, the jar never gets created. Apparently, this is not meant for test development. The solution is to turn off the test phase by setting skip to true in the configuration of the surefire plugin, until all tests pass and can be used for automated testing.<br />
            &lt;plugin&gt;<br />
                &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;<br />
                &lt;artifactId&gt;maven-surefire-plugin&lt;/artifactId&gt;<br />
                &lt;configuration&gt;<br />
                    <b>&lt;skip&gt;true&lt;/skip&gt;</b><br />
                    &lt;suiteXmlFiles&gt;<br />
                        &lt;suiteXmlFile&gt;src/test/config/testng.xml&lt;/suiteXmlFile&gt;<br />
                    &lt;/suiteXmlFiles&gt;<br />
                &lt;/configuration&gt;<br />
            &lt;/plugin&gt;</p>
<p><b><a name="copy">2) Copying all dependencies to target/lib</a></b></p>
<p>This is usually done for any jar that is an executable (contains a main method), so that you can reference the dependencies easily from within the jar manifest.</p>
<p>            &lt;plugin&gt;<br />
                &lt;groupId&gt;org.codehaus.mojo&lt;/groupId&gt;<br />
                &lt;artifactId&gt;dependency-maven-plugin&lt;/artifactId&gt;<br />
                &lt;executions&gt;<br />
                    &lt;execution&gt;<br />
                        &lt;id&gt;copy-dependencies&lt;/id&gt;<br />
                        &lt;phase&gt;package&lt;/phase&gt;<br />
                        &lt;goals&gt;<br />
                            &lt;goal&gt;copy-dependencies&lt;/goal&gt;<br />
                        &lt;/goals&gt;<br />
                        &lt;configuration&gt;<br />
                            &lt;outputDirectory&gt;${project.build.directory}/lib&lt;/outputDirectory&gt;<br />
                            &lt;overWriteReleases&gt;false&lt;/overWriteReleases&gt;<br />
                            &lt;overWriteSnapshots&gt;true&lt;/overWriteSnapshots&gt;<br />
                        &lt;/configuration&gt;<br />
                    &lt;/execution&gt;<br />
                &lt;/executions&gt;<br />
            &lt;/plugin&gt;</p>
<p><b><a name="manifest">3) Referencing dependencies in the jar manifest</a></b></p>
<p>The following creates a manifest in the jar with references to all the dependencies previously copied to lib. Note that the classPrefix is lib.</p>
<p>            &lt;plugin&gt;<br />
                &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;<br />
                &lt;artifactId&gt;maven-jar-plugin&lt;/artifactId&gt;<br />
                &lt;configuration&gt;<br />
                    &lt;jarName&gt;myapp&lt;/jarName&gt;<br />
                    &lt;archive&gt;<br />
                        &lt;manifest&gt;<br />
                            &lt;mainClass&gt;com.mycompany.MyApp&lt;/mainClass&gt;<br />
                            &lt;addClasspath&gt;true&lt;/addClasspath&gt;<br />
                            &lt;classpathPrefix&gt;lib&lt;/classpathPrefix&gt;<br />
                        &lt;/manifest&gt;<br />
                    &lt;/archive&gt;<br />
                &lt;/configuration&gt;<br />
            &lt;/plugin&gt;</p>
<p><b>4) Packaging the tests</b></p>
<p>Next, I add a Maven goal to produce a jar of the test sources.</p>
<p>  mvn clean install <b>jar:test-jar</b></p>
<p>This produces a jar (myapp-tests.jar) in your target directory next to your normal jar (myapp.jar)</p>
<p><b>5) Running the tests with TestNG</b></p>
<p>Then, I run the tests on the command line using TestNG instead of via Maven.</p>
<p>java -cp ./target/myapp.jar;./target/myapp-tests.jar; org.testng.TestNG ./src/test/config/testng.xml</p>
<p>I put the testng.xml in the config directory instead of resources because it is a runtime configuration and does not need to be part of the jar. Everything in the resources directory gets added to the jar.</p>
<p><b>6) Debugging the tests</b><br />
Debugging the tests is simple.</p>
<p>java <b>-Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,server=y,address=8888</b> -cp ./target/myapp.jar;./target/myapp-tests.jar; org.testng.TestNG ./src/test/config/testng.xml</p>
<p>From your IDE, attach your debugger to port 8888 using a SocketAttach to attach to an external program.</p>
]]></content:encoded>
			<wfw:commentRss>http://javapulse.net/2007/03/11/test-development-with-testng-and-maven/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
	</channel>
</rss>
