Maven- 忽略空/没有 `main` 目录

huangapple go评论63阅读模式
英文:

Maven- Ignore empty/no `main` directory

问题

我有一个在Maven中的黄瓜测试项目,它只是用于测试代码 - 它不会产生任何库或代码。

这很有效,但会在输出中产生一个相当烦人的警告:

[警告] JAR 将为空 - 没有标记要包含的内容!

我通过 mvn verify 运行我的黄瓜测试。

我如何告诉Maven忽略我没有 main 文件夹的事实?我以前做过,但不记得如何操作了,也无法访问那个代码库,Google 上也找不到与损坏的Java项目结构无关的修复方法。

英文:

I have a Cucumber test project in Maven that is only meant to have test code- it does not produce any library or code on its own.

This works great, however, produces a rather annoying warning in the output:

[WARNING] JAR will be empty - no content was marked for inclusion!

I am running my Cucumber tests via mvn verify

How can I tell Maven to ignore the fact that I don't have a main folder? I've done it before but can't recall how and don't have access to that codebase anymore, and can't find anything on Google where the fix isn't related to malformed java project structure.

答案1

得分: 0

你可以告诉Maven Jar插件,如果JAR文件为空,可以跳过执行。例如:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-jar-plugin</artifactId>
    <version>3.3.0</version>
    <configuration>
        <skipIfEmpty>true</skipIfEmpty>
    </configuration>
</plugin>
英文:

You can tell the Maven Jar Plugin to skip execution if the jar file would be empty. I.e:

  &lt;plugin&gt;
    &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
    &lt;artifactId&gt;maven-jar-plugin&lt;/artifactId&gt;
    &lt;version&gt;3.3.0&lt;/version&gt;
    &lt;configuration&gt;
      &lt;skipIfEmpty&gt;true&lt;/skipIfEmpty&gt;
    &lt;/configuration&gt;
  &lt;/plugin&gt;

huangapple
  • 本文由 发表于 2023年2月19日 00:02:48
  • 转载请务必保留本文链接:https://go.coder-hub.com/75494576.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定