将src / main / java与测试类包括在生成的jar中

时间:2018-12-21 20:46:54

标签: maven-jar-plugin cucumber-serenity

我正在尝试生成一个包含src / main / java类和测试类的jar文件。

运行位于src / test / java中的test main方法时遇到问题(使用位于src / main / java中的某些类的例外)。我尝试添加 > $ {project.build.directory} / classs包含它们。我有java.lang.NoClassDefFoundError异常

<plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-jar-plugin</artifactId>
            <version>3.1.1</version>
            <executions>

            <execution>
                <id>Jar Package</id>
                <phase>package</phase>

                <goals>
                    <goal>jar</goal>
                </goals>
            </execution>

                <execution>
                    <id>Jar Tests Package</id>
                    <phase>prepare-package</phase>
                    <goals>
                        <goal>test-jar</goal>
                    </goals>

                </execution>


            </executions>
            <configuration>
                <classifier>everything</classifier>
                <testClassesDirectory>${project.build.directory}/test-classes</testClassesDirectory>
                <classesDirectory>>${project.build.directory}/classes</classesDirectory>
                <excludes>
                    <exclude>features/**</exclude>
                </excludes>
                <includes>
                    <include>**/*</include>
                </includes>
                <archive>

                    <manifest>
                        <addClasspath>true</addClasspath>
                        <mainClass>com.project.test.features.runTests.MainAppTest</mainClass>
                        <classpathPrefix>lib/</classpathPrefix>
                    </manifest>
                    <manifestEntries>
                        <Class-Path>./</Class-Path>
                    </manifestEntries>

                </archive>

            </configuration>
        </plugin>

0 个答案:

没有答案