如何在Maven中使用源代码生成WAR? [英] How to generate a WAR with the source code in Maven?

查看:127
本文介绍了如何在Maven中使用源代码生成WAR?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想分发使用Maven 生成的Web应用程序,其中包含源代码.如何使用Maven做到这一点?

I want to distribute the war of my web application generated with Maven with the source code inside it. How to do that with Maven?

推荐答案

可以将maven-war-plugin配置为包含源目录,因为它是Web资源:

It is possible configure the maven-war-plugin to include the source directory as it was a web resource:

 <build>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-war-plugin</artifactId>
        <configuration>
          <webResources>
            <resource>
              <directory>${build.sourceDirectory}</directory>
              <targetPath>sources</targetPath>
            </resource>
          </webResources>
        </configuration>
      </plugin>
    </plugins>
  </build>

Java源代码将包含在战争中的sources目录中.当然,您应该使资源目录适应您自己的Maven布局.

The java sources will be included in a sources directory in the war. Of course you should adapt the resource directory to your own maven layout.

这篇关于如何在Maven中使用源代码生成WAR?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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