Post new topic   Reply to topic
View previous topic Printable version Log in to check your private messages View next topic
Author Message
laurilehtinen
Post subject: Bug? Maven4MyEclipse, JUnit, output folder  PostPosted: Oct 14, 2008 - 06:53 PM



Joined: Sep 19, 2008
Posts: 4

I am seeing the following behavior in MyEclipse 7.0M2:

If my test classes are not found in target/test-classes, running them with JUnit from within MyEclipse results in a ClassNotFoundException.

This is an issue for us in a MyEclipse maven project which is also a web project, where we define the default output folder as /src/main/webapp/WEB-INF/classes. This can be configured automatically with mvn eclipse:eclipse:

Code:
<plugin>
  <artifactId>maven-eclipse-plugin</artifactId>
  <configuration>
    <outputDirectory>src/main/webapp/WEB-INF/classes</outputDirectory>
  </configuration>
</plugin>


However, there is to be no way to specifically define the output folder for test classes. Looking into the maven eclipse plugin's source, it seems to be designed to separate the test classes from the non-test classes ONLY if no custom output folder is defined (look for "testOutput" in http://svn.apache.org/viewvc/maven/plugins/tags/maven-eclipse-plugin-2.5.1/src/main/java/org/apache/maven/plugin/eclipse/EclipsePlugin.java?view=markup).

If I remove the maven nature from my project, the test classes are being found from my custom output folder. If i add the maven nature to my project, they are only found if they are in target/test-classes.

In my mind, a correct solution would be to honor the custom output folder settings when looking for the test classes even when the maven nature is added.

If I'm doing or assuming something wrong, please let me know.
 
 View user's profile Send private message  
Reply with quote Back to top
support-rkalla
Post subject: RE: Bug? Maven4MyEclipse, JUnit, output folder  PostPosted: Oct 15, 2008 - 07:14 PM
Registered Member
Registered Member


Joined: Jan 06, 2004
Posts: 23855

laurilehtinen,

It is generally felt that test classes should not be compiled out into your deployable build directory, because you don't want your tests deplyed with your project (which is what would happen if you had them compiled into WEB-INF/classes). That is the reason that Maven is defaultnig to building them out into test-classes output dir.

_________________
Riyad
MyEclipse Support
 
 View user's profile Send private message Visit poster's website  
Reply with quote Back to top
laurilehtinen
Post subject: RE: Bug? Maven4MyEclipse, JUnit, output folder  PostPosted: Oct 15, 2008 - 08:42 PM



Joined: Sep 19, 2008
Posts: 4

I did not intend to sound like it was a good thing to deploy test classes with your project.

I just wanted to let you know that using the MyEclipse's maven feature introduces a problem that does not exist without it.

We have found MyEclipse's web project nature very useful as it gives us instant deployment in a development environment and it supports having jars in the local maven repository. However, to use it in the way we have found it to be most useful, we need to override maven's default output location (we use /src/main/webapp/WEB-INF/classes as I said earlier), and can no longer have functioning unit tests working under target/test-classes. They have to end up in either the custom default output folder or a test-classes folder next to it. Both of these work fine without the maven feature, neither of them work with it.

Bottom line - the way it works now, we would not upgrade our licenses to be able to use the maven feature as it introduces a considerable problem.
 
 View user's profile Send private message  
Reply with quote Back to top
support-rkalla
Post subject: RE: Bug? Maven4MyEclipse, JUnit, output folder  PostPosted: Oct 20, 2008 - 01:58 PM
Registered Member
Registered Member


Joined: Jan 06, 2004
Posts: 23855

laurilehtinen,

Thank you for the clarification; I do agree that this behavior is suboptimal, I'll file a PR for the dev team to look into this for a future release.

_________________
Riyad
MyEclipse Support
 
 View user's profile Send private message Visit poster's website  
Reply with quote Back to top
support-eugene
Post subject: Re: Bug? Maven4MyEclipse, JUnit, output folder  PostPosted: Nov 07, 2008 - 07:13 PM
Registered Member
Registered Member


Joined: May 12, 2005
Posts: 473

laurilehtinen,
Maven eclipse plugin is not a preferred way to import existing Maven project into MyEclipse. It is not tailored for MyEclipse and is limited in its functionality.

If you use MyEclipse 7.0M2 or MyEclipse 6.6 (that will be released soon) you can use m2eclipse UI to import your project into MyEclipse. That code will perform some additional configuration steps to improve project compatibility with project. Even better - we can improve that code according to your feedback :)

To import existing Maven project (MyEclipse 7.0M2 and 6.6):
1. Open preference page at following path: "MyEclipse Enterprise Workbench/Maven4MyEclipse".
2. Check "Enable all m2eclipse features" checkbox.
3. Import your project using Import wizard "Maven Projects" from "General" category. You can access import wizards using File->Import... from the main MyEclipse menu.

Please tell us if this works for you.

_________________
Eugene
MyEclipse Support
 
 View user's profile Send private message Visit poster's website  
Reply with quote Back to top
Display posts from previous:     
Jump to:  
All times are GMT - 6 Hours
Post new topic   Reply to topic
View previous topic Printable version Log in to check your private messages View next topic
Powered by PNphpBB2 © 2003-2004 The PNphpBB Group
Credits