Search code examples
javamavencucumbercucumber-java

Maven- Ignore empty/no `main` directory


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.


Solution

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

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