英文:
How to include junit tests in maven-assembly-plugin?
问题
我有一个使用 maven-assembly-plugin
构建最终 JAR 文件的旧应用程序。
问题:mvn package
跳过了所有的 junit
测试(到目前为止还没有任何测试)。
问题:我如何强制汇总插件在构建最终 JAR 文件之前先执行测试?
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<archive>
<manifest>
<mainClass>package_path.foo</mainClass>
</manifest>
</archive>
<descriptors>
<descriptor>src/main/assembly/test-jar-with-dependencies.xml</descriptor>
</descriptors>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
英文:
I have a legacy app that builds the final jar using maven-assembly-plugin
.
Problem: mvn package
skips all junit
tests (there have not been any so far).
Question: how can I force the assembly plugin to execute tests first before building the final jar?
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<archive>
<manifest>
<mainClass>package_path.foo</mainClass>
</manifest>
</archive>
<descriptors>
<descriptor>src/main/assembly/test-jar-with-dependencies.xml</descriptor>
</descriptors>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
答案1
得分: 1
把 maven-surefire-plugin
丢失了。从 spring-boot
来的,我不知道必须显式添加此插件来执行 @Test
类。
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.1.2</version>
</plugin>
英文:
It turned out that the maven-surefire-plugin
was missing. Comming from spring-boot
, I was not aware this plugin has to be added explicit for executing @Test
classes.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.1.2</version>
</plugin>
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论