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
Related
I have a maven project where I'd like to debug tests using IntelliJ. The problem is that when I select the test I'd like to debug IntelliJ first executes mvn install command in order to be able to execute tests against the most recent code, and after this executes the test and allow me to debug.
I have multiple problems with this:
the project contains hundreds of tests which takes 2-3 minutes to execute them. It is super slow especially when I need to restart debugging frequently
if my test compiles, but still fails I can't start debugging since it will fail the maven install part of the execution and IntelliJ doesn't kick off debugging
I haven't found any hints in IntelliJ's doc about how to manipulate the mvn install part of the debugging process
yes, I could start maven in debug mode in the command line and attach IntelliJ to it, but that process is very fragile and it is 2021... let me use the IntelliJ fully...
I tried to add a Before launch step like mvn clean install -Dmaven.test.skip=true, but it results that the test classes won't be compiled.
My question is how can I manipulate the whole Debugging process is IntelliJ, especially the maven install part? What is the good solution here?
I'm using TestNG and the user interface doesn't offer me any option to do manipulate mvn install part.
I would like to add my own commands to delete a specific folder in the mvn repository whenever I run a maven command.
For using maven through the command prompt, this is quite easy since we just update apache-maven-3.5.3\bin\mvn.cmd .
However, I noticed that when we run mvn from intelliJ Maven projects Tool Window, the command run is the following:
C:\mbakOrg\Oracle\JDK\jdk1.8.0_60\bin\java -Dmaven.multiModuleProjectDirectory=
C:\mbakOrg\_CODE\MNE_ARCHIT_GIT\_REPOS\sg-template-store -Dmaven.home=C:\mbakOrg\build\apache-maven-3.5.3 -
Dclassworlds.conf=C:\mbakOrg\build\apache-maven-3.5.3\bin\m2.conf "-javaagent:C:\mbakOrg\devel\JetBrains\IntelliJ IDEA
2017.1.3\lib\idea_rt.jar=42633:C:\mbakOrg\devel\JetBrains\IntelliJ IDEA 2017.1.3\bin" -Dfile.encoding=UTF-8 -classpath
C:\mbakOrg\build\apache-maven-3.5.3\boot\plexus-classworlds-2.5.2.jar org.codehaus.classworlds.Launcher -Didea.version=2017.1.3 clean install
So how will I add a command that will run every time?
Since maven in InteliJis using a custom way to run maven.
Explanation
My problem is basically that the mvn -U command does not properly pull the newest code all the time. Additionally, we are all using a snapshot of a parent project that is being updated quite often to fix issues.
I would strongly discourage modification of mvn.cmd. Even if you figure out how to do it in command line, and in InteliJ, then think about moving to some kind of Continuous Integration framework, like Jenkins for example, which will use default mvn.cmd?
If there is no possibility to achieve what you want with existing Maven tools, I would recommend writing own Maven plugin, (see this tutorial), and put required functionality there. It will guarantee, that this particular piece of code will be executed in all the environments, and this is the way to make sure, that the command will be launched every time.
I've configured various execution and test configurations in my Java IntelliJ project. Is it possible to execute IntelliJ on a given project and configuration from the command line?
Summary
You will need to define a command line build project to run your tests from the command line, as IntelliJ (or any graphical IDE) does not provide tools to do so.
Details for building running tests using Gradle
In the following directions I picked Gradle as command line build language, though some use Ant, or Maven as possible alternatives. The gradle syntax is based on Groovy, which is a JDK-based scripting language.
A sample configuration for a basic java project is here: http://www.vogella.com/tutorials/Gradle/article.html
Once your Gradle project is setup, you can run 'gw test' from command line.
I highly suggest to install gradle wrapper called 'gdub' from here: https://github.com/dougborg/gdub -- this will save typing ./gradlew all the time.
Hope this helps!
I am looking at an internal Maven application I am building in IntelliJ (same results in Eclipse), and everything looks perfectly clean.
I run clean and compile from IntelliJ (using IntelliJ build or using IntelliJ Maven support) and everything compiles fine.
However when I run the build from the command line (mvn clean compile) I am getting build exceptions (see below).
The command line seems to be looking for a genericized parameter (to the "with" method), which we are indeed passing in correctly. However it is complaining as if we were passing in a non-generic parameter.
Obviously mvn on the command line is using a different version of the "with" method than IntelliJ.
Is there any way to ask Maven to tell me which version of a class it is using, in terms of group, artifact and version of the containing jar?
Here is the precise error
[ERROR] \dev\try-deploy-1\src\main\java\com\victor\webui\WebUserInterface.java:[147,47]
attribute(java.lang.String,org.hamcrest.Matcher<java.lang.String>) in
org.openqa.selenium.lift.Matchers cannot be applied to
(java.lang.String,org.hamcrest.Matcher<java.lang.Object>)
Is it possible that you have another version of the class somewhere? try adding a comment on a new line in the file so the line number changes, and re-run the maven compile to see if it still gives the same line number for the error.
In Eclipse, sorry I know you are using IntelliJ, the maven build usually does an offline build that's why it's so fast. There is a way to force it to do a clean with all the jars though and I use that when I get in a bind. It is the Update Project command and it has a box to force the update of snapshots and releases. Maybe Intellij has something like that? Also I'd verify the version you are using on command line is the same as the one IntelliJ is using (I have a few versions installed). You can check Settings in IntelliJ and
mvn -v
on the command line. Finally I'd make sure the settings.xml files you are using for command line and IntelliJ are the same file.
Good luck.
I followed Storm Starter instructions and imported Twitter Storm in IntelliJ. For sake of testing I edited ExclaimationToplogy a bit and used following Maven command to build and run it:
mvn -f m2-pom.xml compile exec:java -Dstorm.topology=storm.starter.ExclamationTopology
But I am more interested to build and run within IDE rather than from command line. What actions do I need to perform?
Thanks
Follow the steps in storm-starter's: Using storm-starter with IntelliJ IDEA
Open Maven's pom.xml file and remove <scope>provided</scope> line from storm dependency. This enables IntelliJ to compile storm dependency on build.
Go to /src/jvm/storm/starter/, right click on ExclamationTopology file and Run 'ExclamationTop....main()'
From within IntelliJ, if you get Clojure related compiler errors involving LocalCluster then .... do a mvn clean install -DskipTests from the command line on the same project first. Then do a 'Rebuild Project' from within IntelliJ. Life is full of mysteries :-).
You need to also ensure that the storm-core is not in provided scope for storm-starter.