You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@openjpa.apache.org by Adam Hardy <ad...@cyberspaceroad.com> on 2009/03/04 12:00:36 UTC

OpenJPA Maven Plugin

I now use the openjpa-maven-plugin to enhance my persistence-enabled classes, 
but I have a couple of projects which rely on a superclass, which needs 
enhancing and testing.

I put this in a seperate project and wrote some unit tests for it, which needed 
a few real entity beans to demonstrate parent-child relationships etc. So I 
coded up a couple of entity beans for testing only, in this project.

I don't want these test-only entity beans in my jar, so I put them in the 
src/test/java directory, and this caused me some confusion when configuring 
openjpa-maven-plugin.

I have a couple of issues getting this to work. From debug logging, i can see 
that openjpa-maven-plugin is not including the test directory in the classpath, 
despite this config:

<execution>
   <phase>process-test-classes</phase>
   <id>enhanceTestEntities</id>
   <goals>
     <goal>enhance</goal>
   </goals>
   <configuration>
     <classes>
       ${build.testOutputDirectory}/org/permacode/atomic/domain/entity
     </classes>
     <outputDirectory>${build.testOutputDirectory}</outputDirectory>
     <toolProperties>
       <property>
         <name>properties</name>
         <value>
           ${build.testOutputDirectory}/META-INF/persistence.xml#OpenJpaTest
         </value>
       </property>
     </toolProperties>
   </configuration>
</execution>

So it fails with a ClassNotFoundException - is there anything I can configure to 
get the test dir into the classpath?

Thanks
Adam

Re: OpenJPA Maven Plugin

Posted by Randy Watler <wa...@wispertel.net>.
Sorry... I meant Mark!

Mark, let me know if you want me to submit a patch.

Randy

Randy Watler wrote:
> Adam,
>
> After rereading Matt's question and your original problem report, I 
> believe you are asking how to get the target/test-classes directory 
> within a single project added to the class path used to invoke the 
> enhancer. By default, the existing target/classes directory is 
> included, but not target/test-classes.
>
> I believe that we could add a new tag/mojo list member called 
> "additionalClasspathElements". AFAICT, that is the conventional 
> approach to this. We could also add a mojo member for 
> testClasspathElements and use those if available... i.e. in the 
> process-test-classes phase.
>
> Matt... do you want me to submit a patch with either change, or do you 
> want to handle this?
>
> Randy
>
> Randy Watler wrote:
>> Adam,
>>
>> I stand corrected. Let me take a look for you.
>>
>> Randy
>>
>> Adam Hardy wrote:
>>> Randy Watler on 04/03/09 14:28, wrote:
>>>> Just to clarify.... this is also using version 1.0 of the plugin? I 
>>>> dont think <classes> is supported if so. Did you try this?
>>>>
>>>> <includes>${build.testOutputDirectory}/org/permacode/atomic/domain/entity/*.class</includes> 
>>>>
>>>>
>>>> Just checking before I diagnose for you,
>>>
>>> Yes, I mean 1.1-SNAPSHOT actually.
>>>
>>> Is this not the correct documentation?
>>>
>>> http://mojo.codehaus.org/openjpa-maven-plugin/enhance-mojo.html
>>>
>>>
>>
>>
>
>


Re: OpenJPA Maven Plugin

Posted by Randy Watler <wa...@wispertel.net>.
Adam,

After rereading Matt's question and your original problem report, I 
believe you are asking how to get the target/test-classes directory 
within a single project added to the class path used to invoke the 
enhancer. By default, the existing target/classes directory is included, 
but not target/test-classes.

I believe that we could add a new tag/mojo list member called 
"additionalClasspathElements". AFAICT, that is the conventional approach 
to this. We could also add a mojo member for testClasspathElements and 
use those if available... i.e. in the process-test-classes phase.

Matt... do you want me to submit a patch with either change, or do you 
want to handle this?

Randy

Randy Watler wrote:
> Adam,
>
> I stand corrected. Let me take a look for you.
>
> Randy
>
> Adam Hardy wrote:
>> Randy Watler on 04/03/09 14:28, wrote:
>>> Just to clarify.... this is also using version 1.0 of the plugin? I 
>>> dont think <classes> is supported if so. Did you try this?
>>>
>>> <includes>${build.testOutputDirectory}/org/permacode/atomic/domain/entity/*.class</includes> 
>>>
>>>
>>> Just checking before I diagnose for you,
>>
>> Yes, I mean 1.1-SNAPSHOT actually.
>>
>> Is this not the correct documentation?
>>
>> http://mojo.codehaus.org/openjpa-maven-plugin/enhance-mojo.html
>>
>>
>
>


Re: OpenJPA Maven Plugin

Posted by Adam Hardy <ad...@cyberspaceroad.com>.
No problem! I'm just glad someone's willing to look at it. I answered Mark 
Struberg's message - although I didn't say much more than I've said already.

Randy Watler on 04/03/09 15:31, wrote:
> Adam,
> 
> I stand corrected. Let me take a look for you.
> 
> Randy
> 
> Adam Hardy wrote:
>> Randy Watler on 04/03/09 14:28, wrote:
>>> Just to clarify.... this is also using version 1.0 of the plugin? I 
>>> dont think <classes> is supported if so. Did you try this?
>>>
>>> <includes>${build.testOutputDirectory}/org/permacode/atomic/domain/entity/*.class</includes> 
>>>
>>>
>>> Just checking before I diagnose for you,
>>
>> Yes, I mean 1.1-SNAPSHOT actually.
>>
>> Is this not the correct documentation?
>>
>> http://mojo.codehaus.org/openjpa-maven-plugin/enhance-mojo.html
>>
>>
> 
> 


Re: OpenJPA Maven Plugin

Posted by Randy Watler <wa...@wispertel.net>.
Adam,

I stand corrected. Let me take a look for you.

Randy

Adam Hardy wrote:
> Randy Watler on 04/03/09 14:28, wrote:
>> Just to clarify.... this is also using version 1.0 of the plugin? I 
>> dont think <classes> is supported if so. Did you try this?
>>
>> <includes>${build.testOutputDirectory}/org/permacode/atomic/domain/entity/*.class</includes> 
>>
>>
>> Just checking before I diagnose for you,
>
> Yes, I mean 1.1-SNAPSHOT actually.
>
> Is this not the correct documentation?
>
> http://mojo.codehaus.org/openjpa-maven-plugin/enhance-mojo.html
>
>


Re: OpenJPA Maven Plugin

Posted by Adam Hardy <ad...@cyberspaceroad.com>.
Randy Watler on 04/03/09 14:28, wrote:
> Just to clarify.... this is also using version 1.0 of the plugin? I dont 
> think <classes> is supported if so. Did you try this?
> 
> <includes>${build.testOutputDirectory}/org/permacode/atomic/domain/entity/*.class</includes> 
> 
> 
> Just checking before I diagnose for you,

Yes, I mean 1.1-SNAPSHOT actually.

Is this not the correct documentation?

http://mojo.codehaus.org/openjpa-maven-plugin/enhance-mojo.html


Re: OpenJPA Maven Plugin

Posted by Randy Watler <wa...@wispertel.net>.
Adam,

Just to clarify.... this is also using version 1.0 of the plugin? I dont 
think <classes> is supported if so. Did you try this?

<includes>${build.testOutputDirectory}/org/permacode/atomic/domain/entity/*.class</includes>

Just checking before I diagnose for you,

Randy

Adam Hardy wrote:
> I now use the openjpa-maven-plugin to enhance my persistence-enabled 
> classes, but I have a couple of projects which rely on a superclass, 
> which needs enhancing and testing.
>
> I put this in a seperate project and wrote some unit tests for it, 
> which needed a few real entity beans to demonstrate parent-child 
> relationships etc. So I coded up a couple of entity beans for testing 
> only, in this project.
>
> I don't want these test-only entity beans in my jar, so I put them in 
> the src/test/java directory, and this caused me some confusion when 
> configuring openjpa-maven-plugin.
>
> I have a couple of issues getting this to work. From debug logging, i 
> can see that openjpa-maven-plugin is not including the test directory 
> in the classpath, despite this config:
>
> <execution>
>   <phase>process-test-classes</phase>
>   <id>enhanceTestEntities</id>
>   <goals>
>     <goal>enhance</goal>
>   </goals>
>   <configuration>
>     <classes>
>       ${build.testOutputDirectory}/org/permacode/atomic/domain/entity
>     </classes>
>     <outputDirectory>${build.testOutputDirectory}</outputDirectory>
>     <toolProperties>
>       <property>
>         <name>properties</name>
>         <value>
>           
> ${build.testOutputDirectory}/META-INF/persistence.xml#OpenJpaTest
>         </value>
>       </property>
>     </toolProperties>
>   </configuration>
> </execution>
>
> So it fails with a ClassNotFoundException - is there anything I can 
> configure to get the test dir into the classpath?
>
> Thanks
> Adam
>