Pass profile property in Intellij - java

I set several profiles that contain base url
So I could pass -P test or dev in the command in order to change environments
So when I do via command line as mvn clean test .... -P test
that works
However, I cannot find on how to enable such in IntelliJ Idea under job configuration
VM options no good

In IntelliJ under Run/Debug Configuration, click the green + in the top left and click Maven.
Under Command line enter mvn clean test, under Profiles enter your profile name (no need to add -P here, just the name is enough)

Run can use the Maven tool view within IntelliJ to run Maven goals from within IntelliJ. This view is available via View > Tool Windows > Maven.
Here's a screenshot:
You can run any goal by ...
Double clicking it
Right mouse click and choose run from the context menu
Clicking on the run icon (the green right arrow) in the menu bar
When running any of these goals you can specify a profile by clicking on this icon:
Then you can set the profile name in the Command line in Execute Maven Goal dialog:
Note: you might also choose to make your dev profile the default profile so that it is engaged without having to specify it.

Run/Debug Configurations... -> Maven -> "Profiles (separated with space)" textbox

Related

Maven command line arguments in IntelliJ 14.

I've been learning Maven and absolutely love it, it's an incredible tool. I'm currently running mvn clean, build, compile, package etc from terminal. This works fine but I figure I could do all this from the IDE. However, using -clean as a command line arg in the configuration settings throws an error.
The current command is simply idea:idea. When this runs it appears to be building the project and adding resources but no mention of clean / verify etc.
I've searched various jet brains pages but can't find a commandline list. Ideally I'd like to be able to set up a couple of different configurations, these mimicking the cones that I'd call from the terminal.
thanks for any help
In intellij you have Maven Projects Tool Window which you can use to run any maven build phase or plugin goals, you can also create run configurations from them (just right click and select create).
You can also create maven run configurations by yourself using Run/Debug Configurations dialog. There should be maven type available on the list.
However, using -clean as a command line arg in the configuration settings throws an error.
You should pass just clean as command line argument.
You can read more about how to call maven for example from Maven: The Complete Reference

Custom Maven goals in IntelliJ IDEA

I am trying to find the way to configure the custom maven goals in IntelliJ. For e.g. I want the custom goal to be: clean install -U and I want to name it: update, but I can't find how to configure this in IntelliJ. Is this even possible? If so how can I do this?
There are 2 things you can do:
You can right-click your project root in the "Maven Projects" view and select the "Create XXX [install]..." option (where XXX is your project/module name. Then, in the subsequent dialog, specify clean install -U as the command line option. This will create a run configuration that invokes maven (you can name it "update" if you want). While it won't show up in the Maven view, it will be accessible from the normal run/debug configuration.
Alternatively, you can define a new profile in your pom that rebinds "install" to "clean install -U". You won't be able to rename it to "update" in the intelliJ ui, but you can at least ensure that both clean and install are run whenever someone runs the install goal.
Another way to do that is create a new run/debug Maven configuration. There you can specify the full command line arguments and a lot of other things.
Run\Edit configurations...
Select + (to create a new one)\Maven

how run junit + maven with options in intellij 10.5.1 (clean install -Dtest=ClassName)

How can i run mvn with options in intellij 10.5.1 ?
I mean, is it possible or create additional command to run:
clean install -Dtest=myClassName //?
Can i add this in the tab where i see:
clean
install
validate
and etc. ?
Temporary i use it in console. Thanks in advance.
Sure... easiest way is to right click on the lifecycle goal 'install' in the 'Maven projects' panel and select 'Create "Your project name" [install]'. This should bring up the 'Create Run/Debug Configuration' dialog. Simply change the goals to those required (space separated). The properties are on the 'Runner' tab in a table.

In netbeans 7 how do I skip testing and add maven additional parameters when building a maven project?

I want to issue commands like -Dmaven.test.skip=true -Dcheckstyle.skip
Go to your project properties. Right click on the project name in Project Explorer and click Properties. Select Actions.
Select the configuration that you are interested in. Select the action that you are interested in. Under set properties you can add the skip test and so on.
You can also set up global commands by going to:
Tools->Options->Miscellaneous->Maven->Edit Global Custom Goal Definitions.
These will be available to all maven projects.
In Netbeans 8.2 in addition to
Tools->Options->Java->Maven->Execution->Skip Tests (checkbox)
in the same dialog you may need to add -Dmaven.test.skip to the
Global Execution Options (textfield)

Maven launch configurations in Eclipse

while running maven from eclipse you have option to execute these launch configurations by default .. here is the image of that :
Now I can add my own launch configurations and execute them. Like this :
Now instead of running run configurations every time, is it possible that I put my own launch configuration called "Clean install skip tests with assembly" instead of default run configuration #1(Maven assembly:assembly) or can I add #10 configuration to be my created configuration. Thank you
Now instead of running run configurations every time, is it possible that I put my own launch configuration called "Clean install skip tests with assembly" instead of default run configuration #1(Maven assembly:assembly) or can I add #10 configuration to be my created configuration.
I don't think so. But once you've run your Maven Build Run Configuration, it should be listed under the "Run As..." green arrow:
alt text http://img8.imageshack.us/img8/8510/screenshotrun.png
And you can add it as favorite if you want.
When you select Run As > 2 Maven Build (the one with the shortcut. It may not always be 2) you can choose which run configuration to use from a simpler dialog - including your custom.
For skipping tests dont add -D in the goals field. Use the "Skip Tests" checkbox that is below the Profiles input box adn it should work :)

Categories