facebook

Bug? Maven4MyEclipse, JUnit, output folder

  1. MyEclipse IDE
  2.  > 
  3. Maven for MyEclipse (Maven4MyEclipse)
Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #289940 Reply

    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:

    <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.

    #289982 Reply

    Riyad Kalla
    Member

    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.

    #289988 Reply

    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.

    #290102 Reply

    Riyad Kalla
    Member

    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.

    #290738 Reply

    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.

Viewing 5 posts - 1 through 5 (of 5 total)
Reply To: Bug? Maven4MyEclipse, JUnit, output folder

You must be logged in to post in the forum log in