小编guy*_*ymi的帖子

如何在maven-assembly-plugin中包含与"提供"范围的依赖关系

我正在与maven战斗,通过使用maven-assembly-plugin将一个带有'提供'范围的托管依赖包含到tar文件中.

我使用超级父pom文件作为我所有项目的基础.大多数项目将部署在应用程序服务器下,因此在超级父pom下声明了两个常见的依赖项.下面是超级母公司的相关管理部门:

http://maven.apache.org/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.xxx.integration</groupId>
    <artifactId>super-parent</artifactId>
    <packaging>pom</packaging>
    <version>1.1.3</version>
    <name>super parent</name>
    <url>http://maven.apache.org.check</url>
.
.
.
    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>junit</groupId>
                <artifactId>junit</artifactId>
                <version>${junit.version}</version>
                <scope>test</scope>
            </dependency>
            <dependency>
                <groupId>log4j</groupId>
                <artifactId>log4j</artifactId>
                <version>${log4j.version}</version>
                <scope>provided</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>
Run Code Online (Sandbox Code Playgroud)

log4j.version = 2.0.8

在一个继承的项目(这是一个独立的应用程序)中,我使用带有dependencySets的maven-assembly-plugin,以便将依赖库包含在tar文件中.当然我也希望包含log4j库.

下面是从超级父母继承的pom:

<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">
    <parent>
        <groupId>com.xxx.integration</groupId>
        <artifactId>super-parent</artifactId>
        <version>1.1.3</version>
    </parent>
    <modelVersion>4.0.0</modelVersion>
    <artifactId>plugin-cc-checker</artifactId>
    <name>plugin-cc-checker</name>
    <version>2.1</version>

    <build>
        <plugins>
            <plugin>
                <artifactId>maven-assembly-plugin</artifactId>
                <dependencies>
                    <dependency>
                        <groupId>com.orca.integration</groupId>
                        <artifactId>integration-assembly-descriptor</artifactId>
                        <version>1.1.1</version>
                    </dependency>
                </dependencies>
                <executions>
                    <execution>
                        <id>make-assembly-according-to-distribution-xml</id>
                        <phase>package</phase>
                        <goals>
                            <goal>single</goal>
                        </goals>
                        <configuration>
                            <finalName>${artifactId}</finalName>
                            <!-- This is where we use our shared assembly descriptor --> …
Run Code Online (Sandbox Code Playgroud)

maven

22
推荐指数
2
解决办法
2万
查看次数

标签 统计

maven ×1