7

I am using Maven project, when i create the Maven module of jar packaging, maven auto generates directory structue as src/main/java, src/main/resources, src/test/java and src/test/resources. Can I edit the above names as per my wish? Can I add new folders to the same parent? Also when i googled, I came to know abt super POM, can anybody suggest how to edit the same with the custom directory structure. I have configured sonatype maven to my eclipse from the link http://m2eclipse.sonatype.org/sites/m2e

Boris Pavlović
  • 63,078
  • 28
  • 122
  • 148
user1787641
  • 331
  • 2
  • 8
  • 25
  • No answer, but the question would be WHY you want to change the default layout in the first place. If possible at all, do not change that default structure - it makes life so much easier :-) – Dominik Sandjaja Mar 11 '13 at 08:25
  • 1
    My project consists of many packages, so thought of dividing the same into different folders with respective names.I dont want to add new module as well. – user1787641 Mar 11 '13 at 08:37
  • Having different packages means several modules (multi-module build) this is against the Maven way. As mentinoned before the default structure make life easier. – khmarbaise Mar 11 '13 at 11:11

1 Answers1

8

Assuming you have a good reason to do this, you can rename the folders and indicate to maven what is the edited one by specifying the appropriate properties/sections in pom.xml of your project. I suppose m2e will pick up the changes once made to the pom.

The relevant section in your case would be (from the superpom)

    <sourceDirectory>${project.basedir}/src/main/java</sourceDirectory>
    <testSourceDirectory>${project.basedir}/src/test/java</testSourceDirectory>
    <resources>
      <resource>
        <directory>${project.basedir}/src/main/resources</directory>
      </resource>
    </resources>
    <testResources>
      <testResource>
        <directory>${project.basedir}/src/test/resources</directory>
      </testResource>
    </testResources>

If you want to add additional source folders or resources (not subfolders), then you can use build helper maven plugin. Again, not sure what m2e will do.

Raghuram
  • 51,854
  • 11
  • 110
  • 122