开发者

Exclude directory from src/main/webapp from copying to target/app-SNAPSHOT directory

I have project which builds .war file with maven. There is standard src/main/webapp directory. I have also some GWT code there which is compiled by GWT maven plugin. Sometimes I run GWT application from Eclipse, then GWT Eclipse plugin compiles it to src/main/webapp/ap开发者_运维技巧p.policy (app.policy is name of my GWT module). This is OK.

app
|-src/main/webapp
| |-app.policy              (directory created by Eclipse GWT plugin)
|target
  |-app-1.0-SNAPSHOT        (directory created by Maven while building war)
  | |-app.policy            
  |-app-1.0-SNAPSHOT.war

If src/main/webapp/app.policy does not exist, gwt-maven-plugin creates target/app-1.0-SNAPSHOT/app.policy and it is included in WAR. This is desired behavior.

The problem is if src/main/webapp/app.policy exists. Then it is copied to target/app-1.0-SNAPSHOT/app.policy and is not fully overwritten by what gwt-maven-plugin creates. Can I somehow exclude src/main/webapp/app.policy from being copied to target/app-1.0-SNAPSHOT directory?

I tried <warSourceExcludes>, but it doesn't work. It makes app.policy not go into .war, which is not what I want. I want it in .war, but I want it to be created by maven-gwt-plugin, not copied from src/main/webapp.


Try to exclude the file from maven resources:

  <build>
    ...
    <resources>
      <resource>
        <directory>src/main/webapp</directory>
        <excludes>
          <exclude>app.policy</exclude>
        </excludes>
      </resource>
      ...
    </resources>
    ...
  </build>

If this works then you can add this configuration to a maven profile.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜