gcotis
gcotis

Reputation: 117

My source folders are deleted after executing mvn eclipse:eclipse

I execute the command: mvn eclipse:eclipse to add the required librairies included in my pom file. The problem is that any source folder are deleted after executing that command. There is any way to add the libraries without deleting the source folders?

Upvotes: 2

Views: 2952

Answers (2)

allprog
allprog

Reputation: 16780

I'm not sure what you are doing exactly but the eclipse plugin handles only eclipse configuration and does not touch any source folders. If the source folders are removed from your eclipse project, then the project/pom file is not set up correctly.

Since Juno, eclipse contains the m2e maven integration plugin. I suggest you create your first projects using that. It will take care of handling the build process and project setup for you.

Use the New->Project...->Maven Project menu and create the project using the wizard. When it is complete, copy all your existing sources into the new one and manipulate the pom file with the pom editor (eclipse will open the pom file with this editor by default.)

Important note: If you start using m2e, then don't use the command line eclipse:eclipse target any more as all the house keeping is done by m2e from that time on. If something is really messes up in your eclipse project, then you may delete the project from the workspace (don't tick the delete from disk option), run eclipse:clean (to make sure everything is cleaned up) and import your project with the m2e importer (File->Import...->Existing Maven Projects...)

Upvotes: 4

ben75
ben75

Reputation: 28706

As allprog wrote: your source folders are probably not deleted. (but probably removed from your .classpath file)

Maven use a standard configuration for all project. Usually there are 2 source folder (for *.java):

  • /src/main/java for your production code
  • /src/test/java for your test code

It's a good practice to follow this recommandations, but you can choose another location for your production/test code by adding this in your pom.xml:

<build>
    <sourceDirectory>src</sourceDirectory>
    <testSourceDirectory>test</testSourceDirectory>

    ...
</build>

Using multiple source folder for your production code and/or for your test code is not recommended.

Upvotes: 2

Related Questions