-
Notifications
You must be signed in to change notification settings - Fork 39
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -74,6 +74,13 @@ public class InstallHooksMojo extends AbstractMavenGitCodeFormatMojo { | |
@Parameter(property = "gcf.preCommitHookPipeline", defaultValue = "") | ||
private String preCommitHookPipeline; | ||
|
||
/** | ||
* Set to `true` to use the global `mvn` executable in the hooks script otherwise will default to | ||
* 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. Choose a reason for hiding this commentThe 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? There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 IntelliJ sets the following property when running any maven command:
This is an example how the /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 Maybe a little help in this direction would be helpful. |
||
|
||
public void execute() throws MojoExecutionException { | ||
if (!isExecutionRoot()) { | ||
getLog().debug("Not in execution root. Do not execute."); | ||
|
@@ -107,15 +114,15 @@ private void doExecute() throws IOException { | |
private void writePluginHooks(Path hooksDirectory) throws IOException { | ||
getLog().debug("Removing legacy pre commit hook file"); | ||
Files.deleteIfExists(hooksDirectory.resolve(legacyPluginPreCommitHookFileName())); | ||
getLog().debug("Rmeoved legacy pre commit hook file"); | ||
getLog().debug("Removed legacy pre commit hook file"); | ||
|
||
getLog().debug("Writing plugin pre commit hook file"); | ||
executableManager | ||
.getOrCreateExecutableScript(hooksDirectory.resolve(pluginPreCommitHookFileName())) | ||
.truncateWithTemplate( | ||
() -> getClass().getResourceAsStream(BASE_PLUGIN_PRE_COMMIT_HOOK), | ||
StandardCharsets.UTF_8.toString(), | ||
mavenEnvironment.getMavenExecutable(debug).toAbsolutePath(), | ||
useGlobalMavenExecutable ? "mvn" : mavenEnvironment.getMavenExecutable(debug).toAbsolutePath(), | ||
pomFile().toAbsolutePath(), | ||
mavenCliArguments()); | ||
getLog().debug("Written plugin pre commit hook file"); | ||
|
There was a problem hiding this comment.
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 :)
There was a problem hiding this comment.
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 ofmaven.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?