2012-11-07 28 views
0

我必须将Java EE应用程序分发到Windows和Linux。应用程序在WEB-INF/bin文件夹中有几个系统相关文件(DLL等)使用Maven在战争中包含系统相关二进制文件

我正在尝试这种方法。

项目文件夹树是这样的:

  • 项目
    - SRC
    ----主要
    ---- Java的
    ------ web应用
    -------- ...
    -------- WEB-INF
    ----------- bin(现在是空文件夹)
    - 目标

我已经感动了所有的bin文件到:

  • 项目
    - DISTRIB
    ----斌
    ------赢得
    ----- - linux的

在第一步我想配置Maven复制DISTRIB /斌/赢到WEB-INF/bin中的目标文件夹中

第二步,当第一步工作时,我将为windows添加两个配置文件,另一个用于linux。

在我的pom.xml中,我已经把这些行:

<build> 
    <plugins> 
     <plugin> 
      <artifactId>maven-assembly-plugin</artifactId> 
      <executions> 
      <execution> 
       <id>distro-assembly</id> 
       <phase>package</phase> 
       <goals> 
       <goal>single</goal> 
       </goals> 
       <configuration> 
       <descriptors> 
        <descriptor>distrib/bin.xml</descriptor> 
       </descriptors> 
       </configuration> 
      </execution> 
      </executions> 
     </plugin> 
    </plugins> 

在这里,你有bin.xml来源:

<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>webtop10.2_bin</id> 
    <fileSets> 
    <fileSet> 
     <directory>${project.build.directory}/distrib/bin/win</directory> 
     <outputDirectory>/WEB-INF/bin</outputDirectory> 
     <includes> 
      <include>*.*</include> 
     </includes> 
     <fileMode>0750</fileMode> 
     <directoryMode>0755</directoryMode> 
     <lineEnding>keep</lineEnding> 
    </fileSet> 
    </fileSets> 
</assembly> 

当我执行MVN包构建成功,但这些文件不会复制到WEB-INF/bin文件夹中。汇编插件说:

[INFO] --- maven-assembly-plugin:2.2-beta-5:single (distro-assembly) @ sibila --- 
[INFO] Reading assembly descriptor: distrib/bin.xml 
[INFO] ------------------------------------------------------------------------ 
[INFO] BUILD SUCCESS 
[INFO] ------------------------------------------------------------------------ 

我是新的Maven,所以我需要帮助。

回答

1

如果你想要的是有复制到战争中的WEB-INF/bin文件夹,然后将二进制文件我不认为你应该使用maven-assembly-plugin

这里是一个更容易的方法:

<build> 
    <plugins> 
     <plugin> 
      <artifactId>maven-war-plugin</artifactId> 
      <version>2.3</version> 
      <configuration> 
       <webResources> 
        <resource> 
         <directory>distrib/win</directory> 
         <targetPath>WEB-INF/bin</targetPath> 
        </resource> 
       </webResources> 
      </configuration> 
     </plugin> 
    </plugins> 
</build> 

这可以用专门构建的配置文件,让你挑Windows或Linux二进制文件。

+0

感谢这是一个完美的解决方案形式我的问题。最好的问候 – user1806859

+0

@ user1806859太好了。如果你也提出了我的答案,我会满足你的问题。 – maba

1

你说你想要复制的文件在project/distrib/bin/win,但是你的程序集描述符的文件集是从${project.build.directory}/distrib/bin/win复制的。除非您在POM中更改了项目的构建目录,否则${project.build.directory}project/target。在您的程序集的文件集的目录大概应该只是distrib/bin/win,因为我相信这个目录是相对于项目基地:

<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>webtop10.2_bin</id> 
    <fileSets> 
     <fileSet> 
      <directory>distrib/bin/win</directory> 

      ... 

     </fileset> 
    </fileSets> 
</assembly> 
相关问题