如何从多模块maven项目创建单个目标?

时间:2014-05-30 09:45:35

标签: java maven maven-assembly-plugin

我有一个具有以下结构的项目。

Parnet
  |
   Module 1(create a jar)
  |
   Module 2(create a war)

构建完这个项目之后我想拥有

 Parent
  |
   target
      |
       settings-include a property file which required to initialize 
      |
       lib- include all dependency for module 1 and 2
      |
       run.sh-use to run  

我试过maven-assembly-plugin。但每次只复制设置文件夹和run.sh。

归档目标的正确方法是什么?

编辑:

我的主要pom.xml

         <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-dependency-plugin</artifactId>
            <version>2.5.1</version>
            <executions>
                <execution>
                    <id>copy-dependencies</id>
                    <phase>package</phase>
                    <goals>
                        <goal>copy-dependencies</goal>
                    </goals>
                    <configuration>
                        <outputDirectory>
                            ${project.build.directory}/lib/
                        </outputDirectory>
                    </configuration>
                </execution>
            </executions>
        </plugin>

         <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-assembly-plugin</artifactId>
            <version>2.4</version>
            <executions>
                <execution>
                    <id>assembly</id>
                    <phase>package</phase>
                    <goals>
                        <goal>single</goal>
                    </goals>
                </execution>
            </executions>
            <configuration>
                <descriptors>
                    <descriptor>assembly-descriptor.xml</descriptor>
                </descriptors>
                <appendAssemblyId>false</appendAssemblyId>
            </configuration>
        </plugin>

assembly-descriptor.xml

<formats>
    <format>dir</format>
    <format>zip</format>
</formats>

<includeBaseDirectory>false</includeBaseDirectory>

<fileSets>
    <fileSet>
        <directory>settings</directory>
    </fileSet>
    <fileSet>
        <includes>
            <include>run*</include>
            <include>start*</include>
            <include>log4j.properties</include>
        </includes>
    </fileSet>
    <fileSet>
        <directory>${project.build.directory}</directory>
        <outputDirectory>/</outputDirectory>
        <includes>
            <include>*.jar</include>
        </includes>
    </fileSet>
    <fileSet>
        <directory>${project.build.directory}/lib</directory>
        <outputDirectory>/lib</outputDirectory>
    </fileSet>
</fileSets>

0 个答案:

没有答案