我为exec插件配置了以下pom.xml,但是只有当主类位于src/ main /java中,而不是在src/test/java中时,它才能工作。我不希望这个主类在发行版/发行版中结束。
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>3.1.0</version>
<executions>
<execution>
<id>myexec</id>
<phase>generate-test-sources</phase>
<goals>
<goal>exec</goal>
</goals>
<configuration>
<executable>java</executable>
<classpathScope>test</classpathScope>
<arguments>
<argument>-classpath</argument>
<classpath/>
<argument>com.mypackage.SomeMainClass</argument>
</arguments>
</configuration>
</execution>
</executions>
</plugin>这里的问题是,我试图在类编译之前运行它(它与测试源一起编译,在生成测试源步骤之后)。com.mypackage.SomeMainClass生成要编译和运行的测试源*TestCase.java。
那么,如果我不希望主类在释放的jar中结束,我能做什么呢?我不想只为这个开发一个maven插件。
发布于 2022-11-15 10:32:09
最干净的解决方案可能是将该类视为自己的外部可执行文件,从而将其构建为一个单独的模块。这需要将项目转换为Maven多模块项目,如果还不是Maven多模块项目的话。
https://www.mojohaus.org/exec-maven-plugin/examples/example-exec-using-plugin-dependencies.html
然而,快速而肮脏的解决方案..。Maven允许您设置排除。如果您不希望某些东西最终出现在发布jar中,请过滤掉它。即:
https://stackoverflow.com/questions/74443211
复制相似问题