如何在Maven中编辑目录结构? [英] How to edit the directory structure in Maven?
问题描述
我正在使用Maven项目,当我创建jar包装的Maven模块时,maven自动生成目录结构为src/main/java
,src/main/resources
,src/test/java
和src/test/resources
.我可以根据自己的意愿编辑上述名称吗?我可以将新文件夹添加到同一父文件夹吗?另外,当我用Google搜索时,我知道abt超级POM,有人可以建议如何使用自定义目录结构对其进行编辑.我已经从 http://m2eclipse.sonatype.org/sites/m2e
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
推荐答案
假设您有充分的理由这样做,则可以重命名文件夹并通过在pom.xml
您的项目.我想m2e将对pom进行更改.
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.
与您的情况相关的部分是(来自 superpom )
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.
这篇关于如何在Maven中编辑目录结构?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!