Maven 2.x Eclipse Plugin

Test source directories appear before Main source directories

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Major Major
  • Resolution: Won't Fix
  • Affects Version/s: 2.6
  • Fix Version/s: None
  • Component/s: Core : .project
  • Labels:
    None
  • Environment:
    Maven 2.0.10
  • Number of attachments :
    0

Description

This is either a bug or a questionable feature. When I run eclipse:eclipse on a project that has siblings in its parent POM, two things happen:
(1) the sibling projects become a dependent project, not jar dependencies
(2) src/test appears before src/main in the package explorer.

I can handle #1, but #2 really is a tough adjustment.

Issue Links

Activity

Hide
Paul Benedict added a comment -

I had my team verify this issue occurs starting 2.6. Using 2.5.1 works just fine.

Show
Paul Benedict added a comment - I had my team verify this issue occurs starting 2.6. Using 2.5.1 works just fine.
Hide
John Newman added a comment -

still seeing this in 2.7, main should come before test

Show
John Newman added a comment - still seeing this in 2.7, main should come before test
Hide
Andrea Aime added a comment -

I was cooking up a patch for another issue when I noticed the block of code responsible for this:

// NOTE: Since MNG-3118, test classes come before main classes
        boolean testBeforeMain = isMavenVersion( "[2.0.8,)" );

        if ( testBeforeMain )
        {
            directories.addAll( testDirectories );
            directories.removeAll( mainDirectories );
            directories.addAll( mainDirectories );
        }
        else
        {
            directories.addAll( mainDirectories );
            directories.addAll( testDirectories );
        }

So it would seem it's a maven wide change. I too find having the test directories first very annoying, it should be possible to have an option to get back the old order. It could simply be <testBeforeMain>false</testBeforeMain> in the eclipse configuration. Not hard to make a patch for this too, provided the plugin developers are interested in merging it. I can cook up a patch if the devs provide directions on how they would like the option to be exposed.

Show
Andrea Aime added a comment - I was cooking up a patch for another issue when I noticed the block of code responsible for this:
// NOTE: Since MNG-3118, test classes come before main classes
        boolean testBeforeMain = isMavenVersion( "[2.0.8,)" );

        if ( testBeforeMain )
        {
            directories.addAll( testDirectories );
            directories.removeAll( mainDirectories );
            directories.addAll( mainDirectories );
        }
        else
        {
            directories.addAll( mainDirectories );
            directories.addAll( testDirectories );
        }
So it would seem it's a maven wide change. I too find having the test directories first very annoying, it should be possible to have an option to get back the old order. It could simply be <testBeforeMain>false</testBeforeMain> in the eclipse configuration. Not hard to make a patch for this too, provided the plugin developers are interested in merging it. I can cook up a patch if the devs provide directions on how they would like the option to be exposed.
Hide
Paul Benedict added a comment -

There is no good reason to put src/test in front of src/main for an IDE setup. It is only applicable for running tests (mvn test) so test classes can replace main classes.

Show
Paul Benedict added a comment - There is no good reason to put src/test in front of src/main for an IDE setup. It is only applicable for running tests (mvn test) so test classes can replace main classes.
Hide
Paul Benedict added a comment -

I am relating this issue to MECLIPSE-548 since the classpath ordering may make a difference here.

Show
Paul Benedict added a comment - I am relating this issue to MECLIPSE-548 since the classpath ordering may make a difference here.
Hide
Andrea Aime added a comment -

It actually does, building projects with the eclipse plugin < 2.6 does not create problems.

Show
Andrea Aime added a comment - It actually does, building projects with the eclipse plugin < 2.6 does not create problems.
Hide
Oleksandr Maksymchuk added a comment -

I use test before main feature in my project to be able to override log4j.xml in development to show all messages or any other configuration which I can do in test classpath. So please maintain both possibilities with option.

Show
Oleksandr Maksymchuk added a comment - I use test before main feature in my project to be able to override log4j.xml in development to show all messages or any other configuration which I can do in test classpath. So please maintain both possibilities with option.
Hide
Arnaud Heritier added a comment -

Paul aren't you launching your tests in eclipse ? Don't you want to have the same behavior in Eclipse and in Maven ?
I'll perhaps be the evil advocate but I think if there's an issue to open it's not in our plugin which tries to have a coherent behavior between maven and eclipse but in eclipse. You can ask them to be able to manage several classpath or just to be able to have a different order in the UI and in the project's classpath.
WDYT ?

Show
Arnaud Heritier added a comment - Paul aren't you launching your tests in eclipse ? Don't you want to have the same behavior in Eclipse and in Maven ? I'll perhaps be the evil advocate but I think if there's an issue to open it's not in our plugin which tries to have a coherent behavior between maven and eclipse but in eclipse. You can ask them to be able to manage several classpath or just to be able to have a different order in the UI and in the project's classpath. WDYT ?
Hide
Paul Benedict added a comment - - edited

Arnaud, your point is solid. I concede this is not a bug.... However, this is a PRETTY BIG CHANGE and nowhere does the site documentation call this out.

Perhaps I wouldn't be so alarmed by this new feature if #1 (as stated above) didn't come with it:
(1) the sibling projects become a dependent project, not jar dependencies

Seriously, no one on my team can upgrade to 2.6 because of this. We do not want sibling projects to be dependent projects. Is this another documentation deficit?

Show
Paul Benedict added a comment - - edited Arnaud, your point is solid. I concede this is not a bug.... However, this is a PRETTY BIG CHANGE and nowhere does the site documentation call this out. Perhaps I wouldn't be so alarmed by this new feature if #1 (as stated above) didn't come with it: (1) the sibling projects become a dependent project, not jar dependencies Seriously, no one on my team can upgrade to 2.6 because of this. We do not want sibling projects to be dependent projects. Is this another documentation deficit?
Hide
Rustam Abdullaev added a comment -

This needs to be made configurable!!!

Show
Rustam Abdullaev added a comment - This needs to be made configurable!!!
Hide
Paul Benedict added a comment -

This issue cannot be fixed by any Maven plugin. The "problem" is inside Eclipse, which orders the folders as listed in the configuration. To change the order, an RFE with Eclipse should be created.

Show
Paul Benedict added a comment - This issue cannot be fixed by any Maven plugin. The "problem" is inside Eclipse, which orders the folders as listed in the configuration. To change the order, an RFE with Eclipse should be created.
Hide
Arnaud Heritier added a comment -

Hi paul, I forgot to reply to your previous comment. Yes this is probably a problem of documentation. It should be reviewed. I saw many problem with it.
I don't think using sibling projects instead of jar dependencies i sa bad thing (it should improve the speed of the build) but we should provide an option to deactivate it and perhaps we shouldn't activate it by default

Show
Arnaud Heritier added a comment - Hi paul, I forgot to reply to your previous comment. Yes this is probably a problem of documentation. It should be reviewed. I saw many problem with it. I don't think using sibling projects instead of jar dependencies i sa bad thing (it should improve the speed of the build) but we should provide an option to deactivate it and perhaps we shouldn't activate it by default
Hide
Paul Benedict added a comment -

Sure. Let's keep this issue closed and open up a new related ticket.

Show
Paul Benedict added a comment - Sure. Let's keep this issue closed and open up a new related ticket.
Hide
Jilles van Gurp added a comment -

Sorry, but this is really annoying behavior. Basically, the order of stuff in eclipse classpath has no relevance whatsoever in terms of semantics as far as I can see. Basically you should be able to randomize the order and not have any functional difference.

The main argument in MECLIPSE-318 seems to be that maven resolves dependencies in some order, which has changed recently. Fine, but the eclipse classpath represents the outcome of that process, not the actual process. And if the outcome is that main depends on test somehow, that would be pretty messed up. Also, from usability point of view, not having the first thing listed being the main src package is not the best thing to have.

So, I would like to request this ticket be reopened and fixed. This "it's a feature not a bug" kind of reflex is the easy way out here. Fixing the behavior to be logical is better than documenting why it is counter intuitive (which it is).

If it is actually required, i.e. there exist eclipse projects that do not work unless test is listed before main, which I strongly doubt, it needs to be documented why things will break otherwise. Even so, that is probably something you would want to fix in your project rather than in maven.

Show
Jilles van Gurp added a comment - Sorry, but this is really annoying behavior. Basically, the order of stuff in eclipse classpath has no relevance whatsoever in terms of semantics as far as I can see. Basically you should be able to randomize the order and not have any functional difference. The main argument in MECLIPSE-318 seems to be that maven resolves dependencies in some order, which has changed recently. Fine, but the eclipse classpath represents the outcome of that process, not the actual process. And if the outcome is that main depends on test somehow, that would be pretty messed up. Also, from usability point of view, not having the first thing listed being the main src package is not the best thing to have. So, I would like to request this ticket be reopened and fixed. This "it's a feature not a bug" kind of reflex is the easy way out here. Fixing the behavior to be logical is better than documenting why it is counter intuitive (which it is). If it is actually required, i.e. there exist eclipse projects that do not work unless test is listed before main, which I strongly doubt, it needs to be documented why things will break otherwise. Even so, that is probably something you would want to fix in your project rather than in maven.
Hide
Paul Benedict added a comment -

Jilles, but this is not a bug. The fact that the Eclipse IDE displays the classpath entries in the same order as the configuration file is not a problem of this plugin. Any tool will have this problem that puts their test directories first. The issue needs to be addressed in Eclipse itself. Granted, the problem is annoying, but the itch needs to be scratched correctly.

Show
Paul Benedict added a comment - Jilles, but this is not a bug. The fact that the Eclipse IDE displays the classpath entries in the same order as the configuration file is not a problem of this plugin. Any tool will have this problem that puts their test directories first. The issue needs to be addressed in Eclipse itself. Granted, the problem is annoying, but the itch needs to be scratched correctly.

People

Vote (3)
Watch (2)

Dates

  • Created:
    Updated:
    Resolved: