I have an application with React in a children module and I'd like use the node.exe which exist in the parent module.
In Parent POM I defined a variable with path of the node.exe
<properties>
<project.name>Corretor Online</project.name>
<nodeBase>C:/col/COL</nodeBase>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
Obs.: I'd like to use ${project.basedir} in nodeBase Variable
And I try to access these variable in children POM to pass as parameter in ProcessBuilder method:
<plugin>
<groupId>org.codehaus.groovy.maven</groupId>
<artifactId>gmaven-plugin</artifactId>
<executions>
<execution>
<id>webpack</id>
<phase>process-resources</phase>
<goals>
<goal>execute</goal>
</goals>
<configuration>
<source><![CDATA[
println "Compiling client code..."
def webpack = new ProcessBuilder(["" + nodeBase + "/node/node", "" + nodeBase + "/node_modules/webpack/bin/webpack.js", "-p", "--progress", "--bail"]).inheritIO().directory(project.getBasedir())
def env = webpack.environment()
env.put("WAR_NAME", project.build.finalName)
def proc_webpack = webpack.start()
proc_webpack.waitForOrKill(120000)
if(proc_webpack.exitValue() != 0)
throw new org.apache.maven.plugin.MojoFailureException("Error compiling client code")
]]></source>
</configuration>
</execution>
</executions>
</plugin>
But I recive this error:
[ERROR] Failed to execute goal org.codehaus.groovy.maven:gmaven-plugin:1.0:execute (webpack) on project col-backoffice-war: groovy.lang.MissingPropertyException: No such property: nodeBase for class: script1539714060887 -> [Help 1]
And If I change from "nodeBase" to "${nodeBase}, I recive this error:
[ERROR] Failed to execute goal org.codehaus.groovy.maven:gmaven-plugin:1.0:execute (webpack) on project col-backoffice-war: startup failed, script1539714572018.groovy: 2: unexpected char: '#' @ line 2, column 134.
However, If I put the literal path, I can build.
def webpack = new ProcessBuilder(["C:/col/COL/node/node",
"C:/col/COL/node_modules/webpack/bin/webpack.js", "-p",
"--progress",
"--bail"]).inheritIO().directory(project.getBasedir())
I couldn't find the solution for it, may you help with how I can access this variable?
Thanks very much!
I discovey the problem.
It is necessary to put the parameter in quotation marks, like the example below.
def webpack = new ProcessBuilder("${nodeBase}" + "/node/node", "C:/col/COL/node_modules/webpack/bin/webpack.js", "-p", "--progress", "--bail"]).inheritIO().directory(project.getBasedir())