Changing the Maven structure ( src/java to src/Javasource)

后端 未结 4 1733
执笔经年
执笔经年 2021-02-15 16:35

I would like to change the name src/java to src/Javasource because of some CVS concerns Is that possible ?

相关标签:
4条回答
  • 2021-02-15 17:08

    Yes, it is possible but then you have to define sourceDirectory in pom.xml

    0 讨论(0)
  • Yes you can do it; see other answers.

    However, folk wisdom is that it is a bad idea to use non-standard organizations for a Maven project, because (so the story goes) it tends to break Maven plugins (and other tools) that assume the standard organization. (At the very least, tooling is likely to be less thoroughly tested for non-standard organizations.)

    Another issue is that people expect the standard project organization. Indeed, "strong encouragement" of a standard project organization is (IMO) one of Maven's big selling points.


    Can I make a radical suggestion?

    Rather than using a non-standard layout for your project because of CVS's limitations, migrate your source code to a newer version control system in which version history is preserved across file and directory renames.

    This wikipedia page is a good place to start when looking for alternatives.

    0 讨论(0)
  • 2021-02-15 17:28

    You can set the sourceDirectory in the build tag of your POM

      <build>
        <sourceDirectory>src/Javasource</sourceDirectory>
        ...
      </build>
    

    Take a look at Maven - Introduction to the POM.

    0 讨论(0)
  • 2021-02-15 17:31

    Here is a sample build section of a POM that can be used to configure the directories.

    <build>
        <directory>target</directory>
        <outputDirectory>target/classes</outputDirectory>
        <finalName>${artifactId}-${version}</finalName>
        <testOutputDirectory>target/test-classes</testOutputDirectory>
        <sourceDirectory>src/main/java</sourceDirectory>
        <scriptSourceDirectory>src/main/scripts</scriptSourceDirectory>
        <testSourceDirectory>src/test/java</testSourceDirectory>
        <resources>
          <resource>
            <directory>src/main/resources</directory>
          </resource>
        </resources>
        <testResources>
          <testResource>
            <directory>src/test/resources</directory>
          </testResource>
        </testResources>
    </build>
    
    0 讨论(0)
提交回复
热议问题