Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add useGlobalMavenExecutable configuration #72

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

varijkapil13
Copy link

This PR Addresses #71 by adding a new configuration option to allow users to override usage of M2_HOME to directly use the global mvn variable instead.

This should allow users to allow use maven from IDE's where M2_HOME is sometime forcefully set by the tooling, eg. when using maven from IntelliJ IDEA

@varijkapil13
Copy link
Author

Request someone to please guide me on how to create a PR for an earlier version?
For version 2 in this case.

Thanks

Comment on lines +137 to +141
By default, the plugin will generate the following maven path

```shell
"${env.M2_HOME}/bin/mvn"
```
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As you can see in MavenEnvironment, this is not true :)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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;
Copy link
Member

@reda-alaoui reda-alaoui Jun 4, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 package

I 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.

@varijkapil13 varijkapil13 marked this pull request as draft June 8, 2021 21:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants