<?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>spiros.blog() &#187; maven</title>
	<atom:link href="http://www.tzavellas.com/techblog/tag/maven/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.tzavellas.com/techblog</link>
	<description>Spiros Tzavellas’s blog, mostly on software development and Java.</description>
	<lastBuildDate>Fri, 24 Sep 2010 07:42:49 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Statically weaving JPA entities for EclipseLink using Maven</title>
		<link>http://www.tzavellas.com/techblog/2008/10/17/statically-weaving-jpa-entities-for-eclipselink-using-maven/</link>
		<comments>http://www.tzavellas.com/techblog/2008/10/17/statically-weaving-jpa-entities-for-eclipselink-using-maven/#comments</comments>
		<pubDate>Fri, 17 Oct 2008 06:31:07 +0000</pubDate>
		<dc:creator>spiros</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[EclipseLink]]></category>
		<category><![CDATA[jpa]]></category>
		<category><![CDATA[maven]]></category>

		<guid isPermaLink="false">http://www.tzavellas.com/techblog/?p=124</guid>
		<description><![CDATA[EclipseLink provides advanced JPA features such as lazy-loading, change tracking and fetch groups using bytecode weaving. To use bytecode weaving you can either dynamically instrument your entity classes at runtime (via a jvm agent) or use a tool to statically process the .class files after compilation. In this post we will present how to use [...]]]></description>
			<content:encoded><![CDATA[<p><a title="EclipseLink" href="http://eclipse.org/eclipselink">EclipseLink</a> provides advanced JPA features such as lazy-loading, change tracking and fetch groups using bytecode weaving. To use bytecode weaving you can either <a href="http://wiki.eclipse.org/Using_EclipseLink_JPA_Extensions_(ELUG)#How_to_Configure_Dynamic_Weaving_for_JPA_Entities_Using_the_EclipseLink_Agent">dynamically</a> instrument your entity classes at runtime (via a jvm agent) or use a tool to <a href="http://wiki.eclipse.org/Using_EclipseLink_JPA_Extensions_(ELUG)#How_to_Configure_Static_Weaving_for_JPA_Entities">statically</a> process the <em>.class</em> files after compilation. In this post we will present how to use EclipseLink&#8217;s static weaver in a Maven project.</p>
<p>To enable static weaving in a Maven based project we have to add the Eclipselink weaver in the <em>process-classes</em> phase of the <a href="http://maven.apache.org/guides/introduction/introduction-to-the-lifecycle.html">Maven&#8217;s build life cycle</a>. The <em>process-classes</em> phase happens after the <em>compile</em> phase and allows the post-processing of files generated in compile phase. In our case, the EclipseLink weaver will post-process the <em>.class</em> files produced by the compiler to add extra bytecodes that implement the desired JPA functionality (lazy-loading, etc).</p>
<p>In the below code we use the <a href="http://maven.apache.org/plugins/maven-antrun-plugin/">Maven AntRun plugin</a> to call (via the <a href="http://ant.apache.org/manual/CoreTasks/java.html">java ANT task</a>) the command line version of the EclipseLink&#8217;s static weaver. Please note that the class name of the weaver is <strong>org.eclipse.persistence.tools.weaving.jpa.StaticWeave</strong> and not <strong>org.eclipse.persistence.tools.weaving.StaticWeave</strong> as the <a href="http://wiki.eclipse.org/Using_EclipseLink_JPA_Extensions_(ELUG)#How_to_Configure_Static_Weaving_for_JPA_Entities">EclipseLink JPA Extensions</a> wiki page says.</p>
<pre>
&lt;build&gt;
 &lt;plugins&gt;
   &lt;plugin&gt;
     &lt;artifactId&gt;maven-antrun-plugin&lt;/artifactId&gt;
     &lt;executions&gt;
       &lt;execution&gt;
         &lt;phase&gt;process-classes&lt;/phase&gt;
         &lt;configuration&gt;
           &lt;tasks&gt;
             &lt;java classname="org.eclipse.persistence.tools.weaving.jpa.StaticWeave"
                   classpathref="maven.runtime.classpath" fork="true"&gt;
               &lt;arg line="-loglevel FINE -persistenceinfo src/main/resources target/classes target/classes"/&gt;
             &lt;/java&gt;
           &lt;/tasks&gt;
         &lt;/configuration&gt;
         &lt;goals&gt;
           &lt;goal&gt;run&lt;/goal&gt;
         &lt;/goals&gt;
       &lt;/execution&gt;
     &lt;/executions&gt;
   &lt;/plugin&gt;
 &lt;/plugins&gt;
&lt;/build&gt;
</pre>
<p>In addition to the <em>pom.xml</em> changes in order to use static weaving in EclipseLink you have to set the <strong>eclipselink.weaving</strong> property to <strong>static</strong> in the <em>META-INF/peristence.xml</em> file.</p>
<pre>
&lt;property name="eclipselink.weaving" value="static" /&gt;
</pre>
<p>For more information about EclipseLink&#8217;s static weaving see the <a href="http://wiki.eclipse.org/Using_EclipseLink_JPA_Extensions_(ELUG)#How_to_Configure_Static_Weaving_for_JPA_Entities">How to Configure Static Weaving for JPA Entities</a> section of the <a href="http://wiki.eclipse.org/Using_EclipseLink_JPA_Extensions_(ELUG)">Using EclipseLink JPA Extensions</a> wiki page.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.tzavellas.com/techblog/2008/10/17/statically-weaving-jpa-entities-for-eclipselink-using-maven/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>Making Maven 2 work with JUnit 4</title>
		<link>http://www.tzavellas.com/techblog/2007/05/16/making-maven-2-work-with-junit-4/</link>
		<comments>http://www.tzavellas.com/techblog/2007/05/16/making-maven-2-work-with-junit-4/#comments</comments>
		<pubDate>Wed, 16 May 2007 04:38:51 +0000</pubDate>
		<dc:creator>spiros</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[junit]]></category>
		<category><![CDATA[maven]]></category>

		<guid isPermaLink="false">http://www.tzavellas.com/techblog/2007/05/16/making-maven-2-work-with-junit-4/</guid>
		<description><![CDATA[The current stable version (2.2) of the maven-surefire-plugin does not support JUnit 4. So Maven, out of the box, does not work with JUnit 4. Luckily if we want to use JUnit 4 in our Maven based projects we have two choices. The first is to use JUnit4TestAdapter as illustrated in this post. The second [...]]]></description>
			<content:encoded><![CDATA[<p>The current stable version (2.2) of the <a href="http://maven.apache.org/plugins/maven-surefire-plugin/">maven-surefire-plugin</a> <a href="http://jira.codehaus.org/browse/SUREFIRE-31">does not support JUnit 4</a>. So Maven, out of the box, does not work with JUnit 4. Luckily if we want to use JUnit 4 in our Maven based projects we have two choices. The first is to use <code>JUnit4TestAdapter</code> as illustrated in <a href="http://www.jroller.com/page/eu?entry=running_junit_4_test_cases">this</a> post. The second is to use the snapshot version (2.3-SNAPSHOT) of the maven-surefire-plugin that has support for JUnit 4. In a small pet-project I am currently implementing I chose the second option and so far my experience was without any problems.</p>
<p>To use the 2.3-SNAPSHOT you first have to add the Maven snapshot plugin repository into your list of plugin repositories. In your <em>pom.xml</em> add the below XML:</p>
<pre>
&lt;pluginRepositories&gt;
  &lt;pluginRepository&gt;
    &lt;id&gt;apache.org&lt;/id&gt;
    &lt;name&gt;Maven Plugin Snapshots&lt;/name&gt;
    &lt;url&gt;http://people.apache.org/repo/m2-snapshot-repository&lt;/url&gt;
    &lt;releases&gt;
      &lt;enabled&gt;false&lt;/enabled&gt;
    &lt;/releases&gt;
    &lt;snapshots&gt;
      &lt;enabled&gt;true&lt;/enabled&gt;
    &lt;/snapshots&gt;
  &lt;/pluginRepository&gt;
&lt;/pluginRepositories&gt;
</pre>
<p>You can also put this configuration into your <em>~/.m2/settings.xml</em> file to enable this repository for all your projects.</p>
<p>Then go to the maven-surefire-plugin configuration section and change the version from <em>2.2</em> to <em>2.3-SNAPSHOT</em>. For example below I have the maven-surefire-plugin configuration that I use in my pet-project:</p>
<pre>
&lt;plugin&gt;
  &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
  &lt;artifactId&gt;maven-surefire-plugin&lt;/artifactId&gt;
  &lt;version&gt;2.3-SNAPSHOT&lt;/version&gt;
  &lt;configuration&gt;
    &lt;includes&gt;
      &lt;include&gt;**/*Test.java&lt;/include&gt;
    &lt;/includes&gt;
    &lt;forkMode&gt;once&lt;/forkMode&gt;
  &lt;/configuration&gt;
&lt;/plugin&gt;
</pre>
<p>That&#8217;s it, you are done. When you run Maven again the new (2.3-SNAPSHOT) version will be downloaded and you can start using JUnit 4 in you project.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.tzavellas.com/techblog/2007/05/16/making-maven-2-work-with-junit-4/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>

