Run/debug Maven with profile but no tests
Hi!
Theres one thing I havent really been able to get my head around. I have a webapp that is handled with maven.
When I run the webapp I´ve configured it to build a webapp.war and deploy it to a tomcat. I also have maven profiles that needs to be used or
some properties will be renderered as ${important.property}.
If I, in the run/debug settings, tell it to just build the app without any maven goals I dont get the properties that are set in the main pom since they are tied to profiles. That gives me a lot of errors obviously when trying to run the app and the app tries to connect to ${important.property} instead of http://www.somepage.com/target.
If I tell it to run the maven goal "package" as well it runs all my tests. They take a lot of time to run, like serveral minutes (its a pretty massive app with lots of modules). So my question is, what is the best practice around this? The best way would be to use Intellij:s build process that actually recognize the maven profile. It has actually worked before, but now I cant make it happen anymore.
Very grateful for any advice!!
Best regards
Klas
请先登录再写评论。
I don't know of a away to get IDEA's build to do what you want but you can create a run configuration for your package command and check the "Skip Tests" option in the Runner tab. You may have to uncheck the "Use project settings" box to be able to switch that. You can also specify your profiles in the Parameters tab.
FWIW, I've never had my placeholders replaced by the IDEA build - perhaps I'm missing something?
Thans for you reply Russ,
I still have the same problem. When building manually with maven and putting the war in Tomcats webapps container this is not a problem and it has worked out in the past. Very frustrated.
My project has the structure of a base pom project that has two webapps as children.
I´ve set the properties in the base pom like this
<profiles>
<profile>
<id>dev</id>
<activation>
<activeByDefault>false</activeByDefault>
</activation>
<properties>
<profileValue>dev</profileValue>
<ldapUrl>ldap://localhost:1389/dc=someurl,dc=com</ldapUrl>
<ldapUser>cn=Directory Manager</ldapUser>
<ldapPwd>password</ldapPwd>
<ldapOutputType>DEBUG</ldapOutputType>
<....... />
and in the webapp no 1 for example theres a set of properties like this
LDAP_URL=${ldapUrl}
LDAP_USERNAME=${ldapUser}
LDAP_PASSWORD=${ldapPwd}
I´ve chosen the "dev" profile to be active in Intellij and when I build and then deploy the webapp I want the properties belonging to that profile to replace the ones in the properties file.
This works with eclipse, please dont force me to go back to that horrible IDE =(
To resolve this problem :
- I select the desired maven profile (http://www.jetbrains.com/idea/webhelp/activating-and-deactivating-maven-profiles.html)
- and in the settings of my task I check "Make" and a "maven compile goal" (or test-compile for a test).
Hope this helps
Cheers, it does actually work now. Weird, could´ve sworn I tried that but theres so many constellations so who knows. Thanks!