Community
Participate
Working Groups
how to reproduce: 1) have an eclipse project with source folder in src (NOT src/main/java) 2) add a pom.xml to it that does NOT specify <sourceDirectory /> 3) add maven nature to it 4) choose "Maven->Update Project Configuration" Result: Proj does not build any more. Digging into it you'll notice that maven removed the src-folder from the eclipse settings. Afaik m2e would default the source-folder to src/main/java if this folder would exist at the time we told m2e to update the project configuration. I had an eclipse setting that pointed to src which was removed by m2e when updating the eclipse proj. IMHO m2e should default to src if maven could not find out about the src location (no setting in the pom, no src/main/java folder). Workaround: Add <sourceDirectory>src</sourceDirectory> to the build section of your pom.
<sourceDirectory>src</sourceDirectory> is not a workaround but a solution to a misconfiguration problem of yours. if you don't specify the <sourceDirectory> element, then it's value comes from the default root pom (as shipping with every maven binary). The default value is src/main/java, if you want something else, you need to configure it. You can verify the content of your effective pom by running the mvn help:effective-pom command on your project to see what sourceDirectory you have specified. as far as I can tell, your project should not even compile correctly when run with maven. resolving as invalid, thought to be a user configuration problem, please reopen if you disagree.
If you convert a non-maven Eclipse Java project, m2e would need to configure source folders correctly. m2e doesn't handle that correctly even in the case pom.xml doesn't exist (when skipping step #2 in comment #0). Try the following: - create the default Eclipse Java project (src is the source folder) - do not create pom.xml - call Configure>Convert to Maven Project m2e will remove the source folder. This is a bug in m2e.
thanks for the details. the problem is therefore in Convert to Maven Project which shall set the source directory. However please note that if you had any jar libraries defined or any other configuration around that is not backed by a pom element in the new pom, you will loose those as well, or at least get a non-buildable maven buid.
ability to preserve custom .classpath entries is tracked separately as bug 353266
I have legacy projects that I converted to use Maven, but cannot use within Eclipse for the reasons discussed. From command line or within IntelliJ, the projects build just fine, but because of m2e's handling of the source directory, it doesn't work correctly within Eclipse. Please move this enhancement soon as its make it difficult for developers who want to use Maven (and yes, you could change the directory structure, but unfortunately that's not an option for all the wrong reasons).
m2e 1.1 creates <sourceDirectory> pom.xml element as part of "convert to maven" action. If this does not work for you, please open a new bugreport and provide small standalone example project and exact steps to reproduce the problem. *** This bug has been marked as a duplicate of bug 359340 ***
Moved to https://github.com/eclipse-m2e/m2e-core/issues/