Menelaos
Menelaos

Reputation: 25725

IntelliJ maven vs normal maven

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.

Upvotes: 2

Views: 163

Answers (1)

AreSo
AreSo

Reputation: 643

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.

Upvotes: 3

Related Questions