使用Maven转换现有的Web项目 [英] converting existing web project using maven

查看:71
本文介绍了使用Maven转换现有的Web项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直试图将一个产生war文件的Web项目转换为Maven.我现有的项目结构如下-

I have been trying to convert a web project that produces a war file to maven. my existing project structure is as follows -

MyWebProject | -WEB-INF/src-包含一堆软件包,例如com.myweb.client,com.myweb.server等 -WEB-INF/test-包含1个软件包com.myweb.tests -网页脚本-包含一堆脚本(只是一个文件夹;不在类路径上) -misc-files1-包含misc文件集1 -misc-files2-与上述类似

MyWebProject | -- WEB-INF/src - contains a bunch of packages like com.myweb.client, com.myweb.server etc -- WEB-INF/test - contains 1 package com.myweb.tests -- web-scripts - contains bunch of scripts (just a folder; not on classpath) -- misc-files1 - contains misc files sets 1 -- misc-files2 - similar to above

目前正在使用ant脚本创建战争文件,其产生的战争文件结构如下

presently a war file is being created using ant script with the resulting war file structure as follows

myweb.war -Meta-INF(仅包含MANIFEST.MF) -网络信息 -班级 -com.myweb.client -com.myweb.server等 -网络脚本 -misc-files1 -misc-files2

myweb.war - Meta-INF (only contains MANIFEST.MF) - WEB-INF - classes - com.myweb.client - com.myweb.server etc. - web-scripts - misc-files1 - misc-files2

我使用simple-artifact创建了一个基本的maven项目,并添加了我的包.我正在使用maven程序集插件生成war文件,并使用文件集进行过滤.但是我得到的战争档案远不及我从蚂蚁那里得到的档案.这是我的assembly.xml文件的简化版本

i created a basic maven project using simple-artifact and added my packages. i am using maven assembly plugin to generate the war file and using filesets to filter. but my resultant war file is no where close to what i get with ant. here is a shortened version of my assembly.xml file

<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2 http://maven.apache.org/xsd/assembly-1.1.2.xsd">

  <id>assembler</id>
  <formats>
    <format>war</format>
  </formats>
  <includeBaseDirectory>false</includeBaseDirectory>

<dependencySets>
<dependencySet/>
</dependencySets>

<fileSets>

    <fileSet>
        <directory>src/main/java</directory>
        <outputDirectory>WEB-INF</outputDirectory>
        <includes>
        <include>**</include>
        </includes>        
    </fileSet>

    <fileSet>
        <directory>es</directory>
        <outputDirectory>resources1</outputDirectory>
        <includes>
        <include>**</include>
        </includes>        
    </fileSet>
    <fileSet>
        <directory>resources2</directory>
        <outputDirectory>resources2</outputDirectory>
        <includes>
        <include>**/*</include>
        </includes>        
    </fileSet>
    <fileSet>           
    <fileSet>
        <directory>test</directory>
        <outputDirectory>WEB-INF</outputDirectory>
        <includes>
        <include>**</include>
        </includes>        
    </fileSet>

  </fileSets>


</assembly>

要创建自定义战争,请使用程序集插件是正确的方法.我总是可以使用maven-antrun-plugin将我的ant脚本包含在pom中,但是如果可能的话,我想避免使用ant.任何建议.

To create a custom war, is assembly plugin the right approach. I can always include my ant script in pom using maven-antrun-plugin, but i want to avoid using ant if possible. any suggestions.

推荐答案

您应该使用 maven-war-plugin .

这篇关于使用Maven转换现有的Web项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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