does IntelliJ IDEA compile invoke the Maven lifecycle?

Hi everyone,

I have some issues running tests from within IntelliJ IDEA which rely on the proper execution of the maven lifecycle.

I have a Maven project which has some custom actions added to the lifecycle. Basically here's what it's doing:

src/test/resources/META-INF/persistence.xml: this file contains a token

i use the maven-antrun-plugin to collect a list of all JPA entities and store them into a file. this list is patched into the persistence.xml.

the persistence.xml later is used during execution of some unit tests.

using maven on the command line this approach works fine. however in the IDE i cannot run my tests. the persistence.xml that's used still contain the unreplaced token.

looking at the Project structure i see that src/test/resources is added as a test sources folder which is correct. however IntelliJ IDEA doesn't seem to execute the maven lifecycle (process-test-resources).

My Questions:
* Should the IDE execute the Lifecycle? Am I doing something wrong?
* If the Lifecycle is not executed. What are my alternatives to hook my custom actions in the IDE build?

thanks for any suggestions.

   Alphonse Bendt

Comment actions Permalink


You can assign and Maven goal as a a pre/post-compile task or pre-execution task.
See Run Configurations->Before launch section.

With this option you may execute your antrun goal to modify the persisnece.xml file.

Comment actions Permalink

This information is in my module pom.xml and associated with the 'generate-test-sources' life cycle.
However, IJ does not make use of that information.
So for each individual test I run I have to add this goal, which takes extra typing.

If would be nice if :
1) On a per module basis IJ allowed users to specify a list of maven lifecycles to recognize.
    So when a user selected run on a JUnit test it would run the 'generate-test-sources' life cycle before executing the unit test.

2) Building on the functionality of #1 if IJ imported the lifecycle info such as:

Users would not have to setup that information manually for every unit test.



Please sign in to leave a comment.