0

Does anyone know of a maven plugin which can gracefully check that the maven process is running with elevated privileges on Windows.

I searched using Google, the Maven Users mailing list archive, Commons Exec mailing list archives, stackoverflow but I've only found people saying Run As Administrator. The search terms I used included

  • elevated
  • maven
  • exec-maven-plugin
  • administrator
  • privileged
  • commons-exec

I'd just like a way to check for elevated privileges and end the maven build early with a user friendly error message before time is wasted executing a bunch of maven plugins only to fail at the end when trying to execute exec-maven-plugin with an error like

Downloaded: http://somehost:8082/artifactory/repo/org/apache/commons/commons-exec/1.3/commons-exec-1.3.jar (54 kB at 85 kB/s)
[ERROR] Command execution failed.
java.io.IOException: Cannot run program "C:\Program Files (x86)\InstallAnywhere 2017\build.exe" (in directory "C:\Downloads\New Builds\Artifactory Downloads\Maven Implementation\InstallerSharedDownloa
d\WindowsDownload"): CreateProcess error=740, The requested operation requires elevation
        at java.lang.ProcessBuilder.start(ProcessBuilder.java:1048)
        at java.lang.Runtime.exec(Runtime.java:620)
        at org.apache.commons.exec.launcher.Java13CommandLauncher.exec(Java13CommandLauncher.java:61)
        at org.apache.commons.exec.DefaultExecutor.launch(DefaultExecutor.java:279)
        at org.apache.commons.exec.DefaultExecutor.executeInternal(DefaultExecutor.java:336)
        at org.apache.commons.exec.DefaultExecutor.execute(DefaultExecutor.java:166)
        at org.codehaus.mojo.exec.ExecMojo.executeCommandLine(ExecMojo.java:804)
        at org.codehaus.mojo.exec.ExecMojo.executeCommandLine(ExecMojo.java:751)
        at org.codehaus.mojo.exec.ExecMojo.execute(ExecMojo.java:313)
        at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:154)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:146)
        at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:117)
        at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:81)
        at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
        at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
        at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:309)
        at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:194)
        at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:107)
        at org.apache.maven.cli.MavenCli.execute(MavenCli.java:993)
        at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:345)
        at org.apache.maven.cli.MavenCli.main(MavenCli.java:191)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
        at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
        at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
        at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
Caused by: java.io.IOException: CreateProcess error=740, The requested operation requires elevation
        at java.lang.ProcessImpl.create(Native Method)
        at java.lang.ProcessImpl.<init>(ProcessImpl.java:386)
        at java.lang.ProcessImpl.start(ProcessImpl.java:137)
        at java.lang.ProcessBuilder.start(ProcessBuilder.java:1029)
        ... 30 more
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 02:13 min
[INFO] Finished at: 2017-07-31T14:27:38-04:00
[INFO] Final Memory: 21M/298M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.6.0:exec (My Command Runner) on project WindowsDownload: Command execution failed.: Cannot run program "C:\Program Files (x86)\Inst
allAnywhere 2017\build.exe" (in directory "C:\Downloads\New Builds\Artifactory Downloads\Maven Implementation\InstallerSharedDownload\WindowsDownload"): CreateProcess error=740, The requested operatio
n requires elevation -> [Help 1]
[ERROR]
buzz3791
  • 1,683
  • 2
  • 20
  • 38
  • Why is this needed `C:\Program Files (x86)\InstallAnywhere 2017\build.exe`? What is the purpose of that? – khmarbaise Aug 01 '17 at 19:33
  • @kmarbaise build.exe is a tool provided with InstallAnywhere. The tool is a command-line means to convert an InstallAnywhere project iap_xml file to a setup.exe. Sadly, InstallAnywhere lacks a maven plugin. Google build.exe and iap_xml for more info e.g. http://helpnet.flexerasoftware.com/installanywhere2015/Content/helplibrary/ia_ref_command_line_build.htm. – buzz3791 Aug 23 '17 at 13:53

0 Answers0