问题
I am trying to make new developers of my maven project to have as easy start as possible. I am using and recommending IntelliJ IDEA as an IDE for them. I am pretty satisfied with the results of importing the maven project to IDEA. The only complication that I have now is importing of the working directory from the surefire plugin.
In my pom.xml I have the following:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.7.2</version>
<configuration>
<workingDirectory>target/work</workingDirectory>
</configuration>
</plugin>
This works fine when i run the tests from command line (mvn test). When I create new Idea project, the JUnit tests need aditional setup however. The working directory is ignored and I have to manually set it up to be able to run the tests properly.
Do you have any idea how to make Idea import the working directory for JUnit properly?
回答1:
Please check a discussion in this issue. There an easy workaround for this problem:
set working directory to $MODULE_DIR$
in the defaults for the run configuration that you will use.
来源:https://stackoverflow.com/questions/8397860/how-to-import-working-directory-for-junit-from-maven-to-idea