【问题标题】:what are the disadvantages of not using maven default layout?不使用 Maven 默认布局有什么缺点?
【发布时间】:2011-07-02 04:12:00
【问题描述】:

我们不能有自己的自定义布局和修改过的 POM 吗..除了复杂的 POM 之外还有其他缺点吗

【问题讨论】:

  • 如果你这样做,你将失去约定优于配置的好处,你将无休止地与 maven 战斗,你会发誓 maven 是你曾经使用过的最糟糕的工具.
  • @Rulmeq:这是一个很好的答案!我想知道你为什么要发表评论。

标签: java maven-2 maven pom.xml


【解决方案1】:

我猜你的意思是项目目录布局:

是的,这是完全可定制的(请参阅POM Reference)。

示例:

<build>
    <sourceDirectory>sources</sourceDirectory>
    <directory>output</directory>
    <outputDirectory>${project.build.directory}/compiled-classes
    </outputDirectory>
</build>

这会将源文件夹设置为sources,将目标文件夹设置为output,将编译器输出文件夹设置为output/compiled-classes

如果您需要其他源文件夹,则不能在 &lt;build&gt; 元素中指定它们,但可以在 add them dynamically with the buildhelper plugin 中指定。

如果您只使用表现良好的标准 maven 插件,这应该可以按预期工作。但是,可能有一些带有硬编码路径的插件,例如src/main/javatarget/classes。您的里程可能会有所不同。

【讨论】:

    猜你喜欢
    • 2013-01-08
    • 2023-03-19
    • 1970-01-01
    • 2018-03-05
    • 2015-04-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多