【问题标题】:Maven – Modules and moduleSet VS dependency and dependencySetsMaven – 模块和模块集 VS 依赖和依赖集
【发布时间】:2011-12-19 15:21:55
【问题描述】:

我们有安装文件夹,我们使用 maven 来打包发布,
这个安装文件夹有一些静态文件和一个 pom.xml
构建目标是将静态文件复制到目标安装文件夹和存储库中的一些 zip
工件 - 展开它们并将它们放在 /unzipped 下的目标文件夹中。

安装文件夹:

/installation_folder
pom.xml
    /some_files
             /file1
             /file2

目标文件夹应该是这样的:

/target
    /installation_files
        /some_files
             /file1
             /file2
        /unzipped
             /prj1   - unzipped artifact prj1 from the repository
             /prj2   - unzipped artifact prj2 from the repository

在这个“安装 pom”上——我有一个对汇编 xml 的引用;我能够复制静态文件 - 并从存储库中获取工件,
问题是——从存储库中复制 zip 并将它们展开到目标/解压缩文件夹中
我应该使用模块和模块集还是依赖和依赖集?
如果 pom.xml + assembly.xml 看起来像: 项目组 安装项目 呸

<modules>
    <module>prj1</module>        
    <module>prj2</module>       
</modules>

...

和assembly.xml:

<moduleSets>
    <moduleSet>
        <includes>
            <include>*:*</include>
        </includes>
            <binaries>
            <unpack>true</unpack>
            </binaries>
        </binaries>
    </moduleSet> 


或者应该是这样的:

<project>
<groupId>project.group</groupId>
<artifactId>installation_project</artifactId>
<packaging>pom</packaging>

    <dependencies>

        <dependency>
            <artifactId>prj1</artifactId>
            <groupId>gruop_id</groupId>
            <version>1.0-SNAPSHOT</version>
            <type>zip</type>
        </dependency>
        <dependency>
            <artifactId>prj2</artifactId>
            <groupId>gruop_id</groupId>
            <version>2.0</version>
            <type>zip</type>
        </dependency>
    </dependencies>

...

和assembly.xml:

<dependencySets>
    <dependencySet>
        <outputDirectory>installation_files/unzipped/</outputDirectory>
        <outputFileNameMapping>${artifact.artifactId}</outputFileNameMapping>
        <includes>
            <include>*:*:zip</include>
        </includes>
        <unpack>true</unpack>
    </dependencySet>
</dependencySets>

谢谢!

【问题讨论】:

    标签: maven-2 pom.xml


    【解决方案1】:

    另一种方法是只使用 maven 依赖插件,目标=unpack。

    <plugin>
       <artifactId>maven-dependency-plugin</artifactId>
       <executions>
         <execution>
           <id>unpack</id>
           <phase>generate-resources</phase>
           <goals>
              <goal>unpack</goal>
           </goals>
           <configuration>
             <artifactItems>
               <artifactItem>
                  <groupId></groupId>
                  <artifactId></artifactId>
                  <version></version>
                  <type></type>
                  <overWrite></overWrite>
                  <outputDirectory></outputDirectory>
               </artifactItem>
             </artifactItems>
           </configuration>
         </execution>
       </executions>
    </plugin>
    

    另一种方法是使用程序集插件,但我发现这很麻烦,并且通常用于比简单的解压缩/压缩更复杂的程序集创建。

    【讨论】:

      猜你喜欢
      • 2010-10-22
      • 2011-03-09
      • 1970-01-01
      • 2015-06-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多