开发者

Convert existing web-app file structure to maven file structure?

I have an existing web application that creates a .war file. I want to convert the directory structure to maven's conventions. And I'm a bit lost.

In particular, the current .war, created by an ant target, doesn't copy to the .war anything in the site/statics directory subtree; this is copied by another, different ant target.

But if I want to run, e.g., jetty from maven (and I do!), I'll need to copy site/statics/**/. to somewhere in maven's target directory. I don't know how to do that given maven's conventions.

Thanks.

Here's the existing directory structure as a (sorry) screenshot form Eclip开发者_开发知识库se:

Convert existing web-app file structure to maven file structure?


You would better follow maven default directory structure or if you insist to use your own you need to configure your maven .pom file respectively.

Default Maven war plugin directory structure is explained here and its usage here.

By default ${basedir}/src/main/webapp is where you should put you jsp files and other static or dynamic files that should go to war directory root. To change this default structure you need to add some configuration to you pom. Have a look at different options available at this page and at this page for an example of using them.

Instead of copying your external static file with a script you can use following setting in you pom:

<plugins>
  ...
  <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-war-plugin</artifactId>
    <configuration>
      <webResources>
        <resource>
          <directory>/absolute/path/to/external/static/</directory>
        </resource>
      </webResources>
    </configuration>
  </plugin>
  ...
</plugins>

Directory can be a path relative to you pom or an absolute path (which makes you pom unportable) or be parametrized using ${xxx}

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜