Hi all,

I want to call a script from my maven build so I use the maven-exec plugin
for this. The script I want to call calls in turn at some point java and
all environment variables are transmitted. I would like to override
JAVA_TOOL_OPTIONS and define an empty value for it so I used the following
configuration:

<execution>
<id>gulp-build</id>
<phase>process-resources</phase>
<goals>
<goal>exec</goal>
</goals>
<configuration>
<executable>gulp</executable>
<failWithNullKeyOrValueInEnvironment>false</failWithNullKeyOrValueInEnvironment>
<environmentVariables>
  <JAVA_TOOL_OPTIONS/>
</environmentVariables>
<workingDirectory>${basedir}/src/main/resources/webapp</workingDirectory>
<arguments>
<argument>maven</argument>
</arguments>
</configuration>
</execution>

But then I end up with the same NPE that was reported in MEXEC-108 (
http://jira.codehaus.org/browse/MEXEC-108) and marked as fixed in the 1.3
version although I'm using this version:

[INFO] --- exec-maven-plugin:1.3:exec (gulp-build) @ kpi-app ---
[DEBUG] Configuring mojo org.codehaus.mojo:exec-maven-plugin:1.3:exec from
plugin realm ClassRealm[plugin>org.codehaus.mojo:exec-maven-plugin:1.3,
parent: sun.misc.Launcher$AppClassLoader@777d57d6]
[DEBUG] Configuring mojo 'org.codehaus.mojo:exec-maven-plugin:1.3:exec'
with basic configurator -->
[DEBUG]   (f) arguments = [maven]
[DEBUG]   (f) basedir = /home/jolivier/workspace/kpi/app
[DEBUG]   (f) classpathScope = runtime
[DEBUG]   (f) environmentVariables = {JAVA_TOOL_OPTIONS=null}
[DEBUG]   (f) executable = gulp
[DEBUG]   (f) failWithEmptyArgument = true
[DEBUG]   (f) failWithNullKeyOrValueInEnvironment = false
[DEBUG]   (f) longClasspath = false
[DEBUG]   (f) project = MavenProject:
quartetfs.biz.kpis:kpi-app:1.0.0-SNAPSHOT @
/home/jolivier/workspace/kpi/app/pom.xml
[DEBUG]   (f) skip = false
[DEBUG]   (f) workingDirectory =
/home/jolivier/workspace/kpi/app/src/main/resources/webapp
[DEBUG]   (f) session = org.apache.maven.execution.MavenSession@4be271de
[DEBUG] -- end configuration --
[DEBUG] Entry: key:JAVA_TOOL_OPTIONS value:null
[WARNING] The defined environment contains an entry with null value
(key:JAVA_TOOL_OPTIONS). This could cause failures.
[DEBUG] Executing command line: [gulp, maven]
[INFO]
------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO]
------------------------------------------------------------------------
[INFO] Total time: 5.594 s
[INFO] Finished at: 2014-04-24T11:30:55+01:00
[INFO] Final Memory: 22M/484M
[INFO]
------------------------------------------------------------------------
[ERROR] Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.3:exec
(gulp-build) on project kpi-app: Execution gulp-build of goal
org.codehaus.mojo:exec-maven-plugin:1.3:exec failed. NullPointerException
-> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute
goal org.codehaus.mojo:exec-maven-plugin:1.3:exec (gulp-build) on project
kpi-app: Execution gulp-build of goal
org.codehaus.mojo:exec-maven-plugin:1.3:exec failed.
at
org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:224)
at
org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
at
org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
at
org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:108)
at
org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:76)
at
org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
at
org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:116)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:361)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:155)
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:584)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:213)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:157)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
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: org.apache.maven.plugin.PluginExecutionException: Execution
gulp-build of goal org.codehaus.mojo:exec-maven-plugin:1.3:exec failed.
at
org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:144)
at
org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
... 19 more
Caused by: java.lang.NullPointerException
at
org.apache.commons.exec.environment.EnvironmentUtils.toStrings(EnvironmentUtils.java:66)
at
org.apache.commons.exec.launcher.Java13CommandLauncher.exec(Java13CommandLauncher.java:56)
at org.apache.commons.exec.DefaultExecutor.launch(DefaultExecutor.java:277)
at
org.apache.commons.exec.DefaultExecutor.executeInternal(DefaultExecutor.java:334)
at org.apache.commons.exec.DefaultExecutor.execute(DefaultExecutor.java:164)
at org.codehaus.mojo.exec.ExecMojo.executeCommandLine(ExecMojo.java:688)
at org.codehaus.mojo.exec.ExecMojo.execute(ExecMojo.java:274)
at
org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:133)
... 20 more


Any idea on how to fix this and clear an environment variable without
having maven crashing?

Regards,

Olivier

Reply via email to