在另一个模块java中包含并重新定位maven依赖

问题描述 投票:0回答:1

我有一个多模块 Maven 项目,我使用 Maven 的阴影插件构建它。我有一个名为“distribution”的模块,其中包括所有其他模块,然后进行构建。我的问题是我有一个 Maven 依赖项,它在另一个模块中,但我找不到分发模块将其包含在阴影 jar 中的解决方案。

包含依赖项的核心模块(组ID dev.demeng):

<?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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<artifactId>InventoryArchiver-core</artifactId>
<version>${project.parent.version}</version>
<packaging>jar</packaging>

<parent>
    <groupId>dev.nandi0813</groupId>
    <artifactId>InventoryArchiver-parent</artifactId>
    <version>4.0.0-SNAPSHOT</version>
</parent>

<properties>
    <maven.compiler.source>17</maven.compiler.source>
    <maven.compiler.target>17</maven.compiler.target>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<repositories>
    <repository>
        <id>papermc-repo</id>
        <url>https://repo.papermc.io/repository/maven-public/</url>
    </repository>

    <repository>
        <id>sonatype</id>
        <url>https://oss.sonatype.org/content/groups/public/</url>
    </repository>

    <!-- Vault -->
    <repository>
        <id>jitpack.io</id>
        <url>https://jitpack.io</url>
    </repository>

    <repository>
        <id>demeng-repo</id>
        <name>Demeng's Repository</name>
        <url>https://repo.demeng.dev/releases</url>
    </repository>
</repositories>

<dependencies>
    <dependency>
        <groupId>io.papermc.paper</groupId>
        <artifactId>paper-api</artifactId>
        <version>1.19.4-R0.1-SNAPSHOT</version>
        <scope>provided</scope>
    </dependency>

    <dependency>
        <groupId>com.github.MilkBowl</groupId>
        <artifactId>VaultAPI</artifactId>
        <version>1.7</version>
        <scope>provided</scope>
    </dependency>

    <dependency>
        <groupId>dev.demeng</groupId>
        <artifactId>sentinel-java-wrapper</artifactId>
        <version>1.2.0</version>
        <exclusions>
            <exclusion>
                <groupId>com.google.code.gson</groupId>
                <artifactId>gson</artifactId>
            </exclusion>
        </exclusions>
    </dependency>
</dependencies>

分发pom:

<artifactId>InventoryArchiver-distribution</artifactId>
<version>${project.parent.version}</version>
<packaging>jar</packaging>

<parent>
    <groupId>dev.nandi0813</groupId>
    <artifactId>InventoryArchiver-parent</artifactId>
    <version>4.0.0-SNAPSHOT</version>
</parent>

<properties>
    <maven.compiler.source>17</maven.compiler.source>
    <maven.compiler.target>17</maven.compiler.target>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<build>
    <defaultGoal>clean install</defaultGoal>

    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-shade-plugin</artifactId>
            <version>3.3.0</version>
            <executions>
                <execution>
                    <phase>package</phase>
                    <goals>
                        <goal>shade</goal>
                    </goals>
                    <configuration>
                        <shadedArtifactAttached>true</shadedArtifactAttached>

                        <artifactSet>
                            <includes>
                                <include>dev.nandi0813:InventoryArchiver-*</include>
                                <include>dev.demeng.sentinel.wrapper</include>
                            </includes>
                        </artifactSet>

                        <relocations>
                            <relocation>
                                <pattern>dev.demeng.sentinel.wrapper</pattern>
                                <shadedPattern>dev.nandi0813.inventoryarchiver.sentinel</shadedPattern>
                            </relocation>
                        </relocations>

                        <createDependencyReducedPom>false</createDependencyReducedPom>

                        <finalName>inventoryArchiver-${project.version}</finalName>
                        <outputDirectory>
                    </configuration>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>

<dependencies>
    <dependency>
        <groupId>dev.nandi0813</groupId>
        <artifactId>InventoryArchiver-core</artifactId>
        <version>${project.parent.version}</version>
    </dependency>
    <dependency>
        <groupId>dev.nandi0813</groupId>
        <artifactId>InventoryArchiver-spigot_1_8</artifactId>
        <version>${project.parent.version}</version>
    </dependency>
    <dependency>
        <groupId>dev.nandi0813</groupId>
        <artifactId>InventoryArchiver-spigot_1_12_2</artifactId>
        <version>${project.parent.version}</version>
    </dependency>
    <dependency>
        <groupId>dev.nandi0813</groupId>
        <artifactId>InventoryArchiver-spigot_1_13_2</artifactId>
        <version>${project.parent.version}</version>
    </dependency>
</dependencies>
java maven dependencies maven-shade-plugin relocation
1个回答
0
投票

我解决了问题。

它是一个 : 符号而不是 。在包含部分...

dev.demeng.sentinel.wrapper

© www.soinside.com 2019 - 2024. All rights reserved.