相关疑难解决方法(0)

jar-with-dependencies和托管依赖项

我们有一个包含大约十几个子项目的父项目.大多数子项目都有测试,因此它们依赖于JUnit.我认为将它作为托管依赖项提取到父pom是有意义的:

<dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.12</version>
            <scope>test</scope>
        </dependency>
    </dependencies>
</dependencyManagement>
Run Code Online (Sandbox Code Playgroud)

在我的一个子项目中 - 仍在努力清理这个 - 我在构建期间需要JUnit.那个pom我现在有:

    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <scope>compile</scope>
    </dependency>
Run Code Online (Sandbox Code Playgroud)

这很好用.事情崩溃的部分是,该项目还需要构建为具有依赖关系的jar,使用:

        <plugin>
            <artifactId>maven-assembly-plugin</artifactId>
            <executions>
                <execution>
                    <phase>package</phase>
                    <goals>
                        <goal>single</goal>
                    </goals>
                </execution>
            </executions>
            <configuration>
                <descriptorRefs>
                    <descriptorRef>jar-with-dependencies</descriptorRef>
                </descriptorRefs>
                <finalName>TestIntegration</finalName>
            </configuration>
        </plugin>
Run Code Online (Sandbox Code Playgroud)

jar-with-dependencies缺少JUnit.请注意,如果我将JUnit作为托管依赖项删除,并将其指定为该项目中的普通依赖项,那么一切都很好.

我如何将jar作为测试范围内的托管依赖项加入jar-with-dependencies?

junit maven

0
推荐指数
1
解决办法
1935
查看次数

标签 统计

junit ×1

maven ×1