2014-06-26 13 views
1

使用行家遮阳帘插件我试图按照以下步骤创建一个项目文件结构:Maven的遮阳复制WEB-INF

enter image description here

的问题是,下面的POM配置不创建WEB-INF目录。

<plugin> 
      <groupId>org.apache.maven.plugins</groupId> 
      <artifactId>maven-shade-plugin</artifactId> 
      <version>2.3</version> 
      <executions> 
       <execution> 
        <phase>package</phase> 
        <goals> 
         <goal>shade</goal> 
        </goals> 
        <configuration> 
         <filters> 
          <filter> 
           <artifact>*:*</artifact> 
           <excludes> 
            <exclude>META-INF/*.SF</exclude> 
            <exclude>META-INF/*.DSA</exclude> 
            <exclude>META-INF/*.RSA</exclude> 
           </excludes> 
          </filter> 
         </filters> 
         <createDependencyReducedPom>true</createDependencyReducedPom> 
         <transformers> 
          <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer"> 
           <mainClass>com.my.package.Main</mainClass> 
          </transformer> 
         </transformers> 
        </configuration> 
       </execution> 
      </executions> 
     </plugin> 

基本上我需要将我的web.xml文件,类和lib文件复制到项目根目录WEB-INF中。

更新:抱歉,我从我的pom复制了错误的插件到原来的问题!

更新:如果我从pom声明中添加包装:<packaging>war</packaging>根据OQ完成WEB-INF文件结构。但是,通过此声明,com目录现在不包含我的包,因此无法找到主类。

它的外观与<packaging>war</packaging>

enter image description here

应该怎么看:

enter image description here

+0

听起来像是你尝试创建一个WAR归档,为什么不使用maven-受战争为此目的的插件? – khmarbaise

+0

我试过了maven-war-plugin。我正在尝试与主类创建可执行的战争。但是,主类不能在默认包中。它必须在声明的包中。 – tarka

回答

0

maven-assembly插件可以让更多的灵活性,这将是很容易实现使用Assembly插件


+0

我不熟悉maven-assembly-plugin。似乎没有多少运气。 – tarka

+0

它的程序集描述符是非常直接的,你指定输入目录和输出目录里面的程序集为你组装它,检查一些例子 –

0

有很多可能的答案,以实现与Maven预期的效果。然而,根据我给我更新发现,加入Maven的antrun-插件用以下解决我的问题:

<plugin> 
      <artifactId>maven-antrun-plugin</artifactId> 
      <executions> 
       <execution> 
        <id>move-main-class</id> 
        <phase>compile</phase> 
        <configuration> 
         <tasks> 
          <copy todir="${project.build.directory}/${project.artifactId}"> 
           <fileset dir="${project.build.directory}/classes/"> 
           </fileset> 
          </copy> 
         </tasks> 
        </configuration> 
        <goals> 
         <goal>run</goal> 
        </goals> 
       </execution> 
      </executions> 
     </plugin>