feat: add useGlobalMavenExecutable configuration#72
feat: add useGlobalMavenExecutable configuration#72varijkapil13 wants to merge 3 commits intoCosium:masterfrom
useGlobalMavenExecutable configuration#72Conversation
|
Request someone to please guide me on how to create a PR for an earlier version? Thanks |
| By default, the plugin will generate the following maven path | ||
|
|
||
| ```shell | ||
| "${env.M2_HOME}/bin/mvn" | ||
| ``` |
There was a problem hiding this comment.
As you can see in MavenEnvironment, this is not true :)
There was a problem hiding this comment.
Yes, sorry.
MavenEnvironment indicates use of maven.home,
whereas README says ${env.M2_HOME}/bin/mvn in How the hook works section.
I'll remove this line, but maybe the other sections needs updating too?
| * the complete path for `mvn` found via `maven.home` variable | ||
| */ | ||
| @Parameter(property = "gcf.useGlobalMavenExecutable", defaultValue = "false") | ||
| private boolean useGlobalMavenExecutable; |
There was a problem hiding this comment.
Are you using a maven wrapper? If not, what are you using exactly?
Isn't there some environment variable or anything set by the executed process to find its path?
That would allow us to avoid setting this property and instead add an automatic path detection to MavenEnvironment.
There was a problem hiding this comment.
I am not using a maven wrapper. I am using IntelliJ IDEA to run maven tasks.
It does infact set the maven.home property when any maven command is run via the IDE but the plugin somehow does not consider it.
IntelliJ sets the following property when running any maven command:
-Dmaven.home=/Applications/JetBrains/apps/IDEA-U/ch-0/211.7442.40/IntelliJ IDEA.app/Contents/plugins/maven/lib/maven3
This is an example how the package command is run:
/Library/Java/JavaVirtualMachines/jdk1.8.0_202.jdk/Contents/Home/bin/java -Dmaven.multiModuleProjectDirectory=/Users/varijkapil/Documents/Work/Development/JavaEE/work-service -Dmaven.home=/Applications/JetBrains/apps/IDEA-U/ch-0/211.7442.40/IntelliJ IDEA.app/Contents/plugins/maven/lib/maven3 -Dclassworlds.conf=/Applications/JetBrains/apps/IDEA-U/ch-0/211.7442.40/IntelliJ IDEA.app/Contents/plugins/maven/lib/maven3/bin/m2.conf -Dmaven.ext.class.path=/Applications/JetBrains/apps/IDEA-U/ch-0/211.7442.40/IntelliJ IDEA.app/Contents/plugins/maven/lib/maven-event-listener.jar -javaagent:/Applications/JetBrains/apps/IDEA-U/ch-0/211.7442.40/IntelliJ IDEA.app/Contents/lib/idea_rt.jar=54014:/Applications/JetBrains/apps/IDEA-U/ch-0/211.7442.40/IntelliJ IDEA.app/Contents/bin -Dfile.encoding=UTF-8 -classpath /Applications/JetBrains/apps/IDEA-U/ch-0/211.7442.40/IntelliJ IDEA.app/Contents/plugins/maven/lib/maven3/boot/plexus-classworlds.license:/Applications/JetBrains/apps/IDEA-U/ch-0/211.7442.40/IntelliJ IDEA.app/Contents/plugins/maven/lib/maven3/boot/plexus-classworlds-2.6.0.jar org.codehaus.classworlds.Launcher -Didea.version=2021.1.2 packageI see in MavenEnvironment that maven.home is given preference, but cannot figure out why it is not considered when this command is run? Instead it writes the following in the pre-commit bash script
/Users/varijkapil/Documents/Work/Development/JavaEE/work-service/mvn
Maybe a little help in this direction would be helpful.
This PR Addresses #71 by adding a new configuration option to allow users to override usage of
M2_HOMEto directly use the globalmvnvariable instead.This should allow users to allow use maven from IDE's where
M2_HOMEis sometime forcefully set by the tooling, eg. when using maven from IntelliJ IDEA