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.
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.
How can I compile (if changes were made) and run Jenkins from source on localhost without running any tests?
Obviously that I read the documentation but this doesn't really say how to run it without any tests, only to how to compile the war file.
The funny part is that the doc page even specifies on how to run inside the debugger but that's not what I want.
I just want to write a script that compiles and runs it, ideally even killing it if it was already running (so I can run it multiple times without worrying about being unable to start).
I am on MacOS but I am pretty sure that solution would work on almost any system.
Jenkins used maven as it's build tool, so just add this system parameter
mvn -DskipTests=true ...
to skip the tests.
It seems that running Jenkins from build needs something long like like
mvn clean install -pl war -am -DskipTests && java -jar war/target/jenkins.war
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
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.
When Hudson goes to build my project, it executes Maven as follows:
Executing Maven: -B -f /path/to/root/pom.xml clean install
This works fine on most projects. (The -B is for "batch" or "non-interactive mode", BTW).
But for this one project that uses AndroMDA (which I can't recommend for future projects, it's really a pain-in-the-butt; slows down the build by 1000% with code generation for things that could be trivially done with inheritance and annotation-based config).
For some reason unbeknown to me, when Maven is given the -B flag the generated classes are no put on the classpath causing compilation errors for references to the generated classes. I've tested building manually with -B and without it and the result is that it builds fine without -B (outside of Hudson) and it doesn't build with -B (again, outside of Hudson).
Using Hudson version 1.369 and an external Maven 2.2.1 install.
Any advice greatly appreciated!!!
P.S. Hudson is AWESOME!!!!
The simplest version would be to have a free style project, and call maven yourself.