首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >某些文件的maven-assembly-plugin

某些文件的maven-assembly-plugin
EN

Stack Overflow用户
提问于 2009-11-23 23:59:27
回答 2查看 5.5K关注 0票数 2

我有多模块项目,这是父pom。

代码语言:javascript
复制
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.atoms</groupId>
    <artifactId>atoms-parent</artifactId>
    <packaging>pom</packaging>
    <version>1.0</version>
    <url/>
    <modules>
        <module>atoms-persistence</module>
        <module>atoms-reglas</module>
        <module>atoms-webservice</module>
    </modules>
    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>

                <configuration>
                    <source>1.5</source>
                    <target>1.5</target>
                </configuration>
            </plugin>
            <plugin>
                <artifactId>maven-assembly-plugin</artifactId>
                <configuration>
                    <descriptors>
                        <descriptor>assemble.xml</descriptor>
                    </descriptors>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>

在atoms persitence项目中,我有以下文件:

Com.Atoms.vo。*

Com.Atoms.service。*

Com.Atoms.da.*

在原子-雷格拉斯中我有:

Com.Atoms.ruls.*

如何使用程序集插件创建只包含以下类的jar:

com.atoms.vo.*和com.Atoms.ruls.*?

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2009-11-24 00:10:45

试着这样做:

代码语言:javascript
复制
<assembly>
    <id>atoms</id>
    <formats>
        <format>jar</format>
    </formats>
    <includeBaseDirectory>false</includeBaseDirectory>
    <fileSets>
        <fileSet>
            <directory>${basedir}/target/classes
            </directory>
            <outputDirectory>/</outputDirectory>
            <includes>
                <include>com/atoms/vo.**</include>
                <include>com/atoms/rules/**</include>
            </includes>
        </fileSet>
    </fileSets>
</assembly>
票数 5
EN

Stack Overflow用户

发布于 2009-11-24 00:13:49

首先,显式指定您希望在pom.xml中使用大于或等于2.2-beta-3的maven程序集插件版本(稍后需要的unpackOptions元素的includes/excludes在2.2-beta-3之前的版本中的行为与预期不同)。我在这里使用2.2-beta-4版本:

代码语言:javascript
复制
<plugin>
  <artifactId>maven-assembly-plugin</artifactId>
  <version>2.2-beta-4</version>
  <configuration>
    <descriptors>
      <descriptor>assemble.xml</descriptor>
    </descriptors>
  </configuration>
</plugin>

然后,使用您选择的模块声明一个moduleSets,并指定要在assembly.xml中使用includes解压它们的二进制内容

代码语言:javascript
复制
<assembly>
  <id>my-assembly</id>
  <formats>
    <format>jar</format>
  </formats>
  <includeBaseDirectory>false</includeBaseDirectory>
  <moduleSets>
    <moduleSet>
      <includes>
        <include>com.atoms:atoms-persistence</include>
        <include>com.atoms:atoms-reglas</include>
      </includes>
      <binaries>
        <outputDirectory>/</outputDirectory>
        <unpack>true</unpack>
        <unpackOptions>
          <includes>
            <include>com/atoms/vo/**</include>
            <include>com/atoms/rules/**</include>
          </includes>
        </unpackOptions>
      </binaries>
    </moduleSet>
  </moduleSets>
</assembly>

最后,从父项目运行以下命令:

代码语言:javascript
复制
mvn clean package assembly:assembly

这将构建一个只包含所需类的target/atoms-parent-1.0-my-assembly.jar

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/1784077

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档