使用非标准目录布局使用Maven [英] Using maven using non standard directory layout

查看:73
本文介绍了使用非标准目录布局使用Maven的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将maven应用于已经具有目录结构的现有项目.我可以从上一个问题中找到以下内容.

I am trying to apply maven to an existing project which already has a directory structure in place. All I can find from previous question is the following.

Maven目录结构

但是,我的要求更加详细.请参阅下面的目录结构:

However, my requirement is more detailed. Please see below for the directory structure:

 <root dir>
    |
    +--src-java
    |
    +--src-properties
    |
    +--WEB-INF

我知道我们可以有类似的东西

I know we could have something like

<build>
<sourceDirectory>src-java</sourceDirectory>
...
</build>

但是sourceDirectory仅适用于JAVA源代码,如果我没记错的话.

But sourceDirectory is for JAVA source code only, if I'm not mistaken.

对于上述结构,如何在pom.xml中声明它?现在移动目录是我的最后选择.

For the above structure, how do I declare it in pom.xml? Moving the directory is my last option right now.

推荐答案

我想您需要具有与下面类似的内容.

I guess you need to have something similar to below.

看到WEB-INF,我想你想发动一场战争. Maven war插件可以做到这一点.您将需要对此进行一些配置,因为文件夹结构是非标准的-例如,您可能需要使用webXml属性指定web.xml的位置.这些内容记录在使用页面中.

Seeing WEB-INF, I assume you want to build a war. Maven war plugin does this. You will need to configure this a bit since the folder structure is non-standard - for instance you may need to specify the location of web.xml using webXml property. These are documented in the usage page.

<build>
    <sourceDirectory>src-java</sourceDirectory>
    ...
    <resources>
      <resource>
        <directory>src-properties</directory>
      </resource>
    </resources>
    ...
    <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-war-plugin</artifactId>
                <configuration>
                    <warSourceDirectory>WEB-INF</warSourceDirectory>
                    ...
                </configuration>
            </plugin>
     </plugins>
</build>

这篇关于使用非标准目录布局使用Maven的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆