Cannot run tests in Intellij of a Maven module packaged as POM
See reproducer below.
We're maintaining https://github.com/neo4j/neo4j-kafka-connector.
This is a multi-module Maven project.
One of its module, called packaging, has the sole responsibility of handling the creation of various artefacts (ZIPs, JARs).
We wanted to add tests to this module, without changing its packaging type (currently pom).
The reason we don't want to change the packaging is that we don't want to publish the JAR of that specific module, as it would likely add confusion/noise for our users.
We added the required Maven pom-level settings for the test folder and the necessary bindings for the Kotlin test compilation and execution. This works well with the command line.
However, when trying to run the tests within Intellij, the IDE complains that there is no defined output path for this module.
Is there a way to automatically set it? Are there specific Maven settings that we need to add to our pom so that Intellij infers the proper paths and the tests can run?
As a proof it works on the command line, you can try to run this:
```
git clone https://github.com/Emrehzl94/neo4j-kafka-connector.git -b validate-configuration-files # fork of my colleague Emre
mvn -f neo4j-kafka-connector install -DskipTests
mvn -f neo4j-kafka-connector -pl packaging test # this should pass
```
请先登录再写评论。
Hello, Florent!
Thank you for reporting this!
Maven Projects with pom packaging are not meant to have source code or tests of their own, as they are designed to be parent Projects / aggregators for other Projects.
IDEA follows Maven's best practices and does not, by default, designate any Content Roots for such Projects.
You can set the Content Roots and Output Paths manually, but those will be reverted after a Maven Sync.
Thanks for the reply.
I do agree with your general description, POM modules do not usually include any code. We can indeed set the test output path manually, but as you pointed out, it's reset every time a Maven sync occurs so it's not very convenient in the long term.
I would argue that Content Roots and Output Paths could be inferred in our case too, instead of stopping all inference at the `pom` packaging type. After all, we declare a `<testSourceDirectory>`, a `<testOutputDirectory>` and bind the necessary goals to compile and run our tests.
If Maven accepts it, why not IDEA?
Florent Biville Thank you for providing the details on your use-case!
I've created a YouTrack Issue for this functionality and assigned it to the R&D Team, so they can consider implementing it.