0

I have an existing library that I am building in Eclipse and have added the Maven nature to my project using m2e to add dependencies. When I convert it to a Maven project, my existing source directory (and my bin) become normal folders. Is there a reason for this? I am new to Maven, so I am likely doing something wrong, just not sure what...

My project structure is as follows:

workspace
  project
    src (in build path)
    resources (in build path)
    bin (output dir)

I tried both "mvn eclipse:eclipse" and right click on project -> Configure -> Convert to Maven Project, and both removed my src and resources folders from my build path, and after changing the structure to the below, changed the output to target/test-cases. Even if I manually adjust the build path and output, my dependencies don't resolve.

workspace
  project
    src (no longer in build path)
    resources (no longer in build path)
    bin  (no longer output)
    target (new output dir)
      test-cases (empty)
Benny
  • 3,899
  • 8
  • 46
  • 81

1 Answers1

0

I think you have the following structure when working with Eclipse (without Maven):

/workspace
  /project1
    .project
    /src
    /bin

But Maven want to use the following structure

/workspace
  /project1
     .project
     pom.xml
     /src
        /main
           /java
           /resources
        /test
           /java
     /target
        /classes
        /test-classes

and so on. So it is normal, that the folder src is no more directly a source folder for Eclipse, but now there are src/main/java, src/main/resources, ...

So it would be easier in the beginning to start with a new Maven project, and move your original sources to the directories they should belong to. Maven has a long tradition with its "convention over configuration", to deviate from that is possible. Have a look at the answer to "Handling unconventional source directory ..." to fix this.

Community
  • 1
  • 1
mliebelt
  • 15,345
  • 7
  • 55
  • 92
  • Problem is, this is already in source control so creating a whole new project will be pretty cumbersome. Is there any way to set things up in place? – Benny Apr 21 '12 at 19:40
  • Can't you move folder/files into new folder etc. and transfer the old structure to a new one ? – khmarbaise Apr 21 '12 at 19:54
  • So I tried both "mvn eclipse:eclipse" and Configure -> Convert to Maven... and both leave my project without source folders. Even if I manually add them, my Maven references do not resolve (i.e. log4j). Any ideas? – Benny Apr 21 '12 at 20:11