Cannot run program npm error when running Cordite network map JAR on Windows - corda

When running the network map using Java (as described here: https://gitlab.com/cordite/network-map-service#using-java) on Windows, I get the following error:
[ERROR] Failed to execute goal
org.apache.maven.plugins:maven-antrun-plugin:1.8:run (build-website)
on project network network-map-service: An Ant BuildException has
occured: Execute failed: java.io.IOException: Cannot run program
"npm": CreateProcess error-2, The system cannot find the file
specified around Ant part ...... # 4:45 in
C:\Users\x.x\network-map-service\target\antrun\build-main.xml
What is the cause of this error?

You are encountering this issue because the build file is as follows:
<?xml version="1.0" encoding="UTF-8" ?>
<project name="maven-antrun-" default="main" >
<target name="main">
<exec failonerror="true" executable="npm">
<arg value="install"/>
<arg value="-g"/>
<arg value="brunch"/>
</exec>
<exec failonerror="true" dir="website" executable="npm">
<arg value="install"/>
</exec>
<exec failonerror="true" dir="website" executable="brunch">
<arg value="build"/>
</exec>
</target>
</project>
But Windows requires the executable names to be npm.bat and brunch.bat instead.
If you change the executable names in the build file, it will work correctly.

Related

How to print the exec error code using ANT

I have my ANT file which uses exec task to create Jenkins job using cURL. Whether exec task is success or failed, the jenkins build will be succeeded. So I tried to use resultproperty in exec and tried to print the result, but it returns only 0.
<exec executable="curl" resultproperty="MyExecResult" failonerror="false">
<arg value="-k" />
<arg value="-X" />
<arg value="GET" />
<arg value="<MyJenkinsURL>config.xml" />
<arg value="-o" />
<arg value="<MyPath>\GET\config.xml" />
<arg value="-u" />
<arg value=":" />
<arg value="--ntlm" />
</exec>
<echo>MyExecResult-GET ::: ${MyExecResult}</echo>
How can I print the resultproperty value in this scenario to get the error code. Kindly provide inputs. Thanks!
You have to use the erroproperty attribute, see Ant manual exec task
errorproperty The name of a property in which the standard error of
the command should be stored. since Ant 1.6

Can I silence Closure Compiler warnings for external libraries?

When I run the closure compiler, I get a bunch of warnings like this:
[exec] jquery/3.2.1/dist/jquery.js:733: WARNING - Suspicious code. The result of the 'getprop' operator is not being used.
[exec] arr[ preferredDoc.childNodes.length ].nodeType;
[exec] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
I end up with about 30 warnings in my build, all from jquery and bootstrap.js
I'm handling my build using an Ant script. The call to the Closure Compiler looks like this:
<target name="build_scripts" description="Compile frontend scripts">
<exec executable="${java.exec}" failonerror="true">
<arg line="-client -d64 -jar ${closure.jar}"/>
<arg line="--js ${src.dir}/assets/js/*.js"/>
<arg line="--js ${src.dir}/assets/js/**/*.js"/>
<arg line="--js ${weblib.dir}/jquery/3.2.1/dist/jquery.js"/>
<arg line="--js ${weblib.dir}/bootstrap-sass/3.3.7/assets/javascripts/bootstrap.js"/>
<arg line="--externs ${build.dir}/jquery-3.2.externs.js"/>
<arg line="--dependency_mode=STRICT"/>
<arg line="--entry_point ${src.dir}/assets/js/main.js"/>
<arg line="--js_output_file ${out.js.dir}/main.js"/>
<env key="JAVA_HOME" path="${java_home}"/>
</exec>
</target>
I thought the point of the externs file was to get rid of warnings like this? The answers to this question seem to suggest I'd need to manually change it in the external libraries.
I don't want to silence all warnings; just these from external libraries. Is that possible?
The --hide_warnings_for='path/segment' flag should do what you need.

VS 2017 + ASP.Net Core + Angular 4 cant build

i create a blank new ASP.Net Core with Angular from VS 2017 (in my Document folder) and i try to build it i always get this error:
VS2017 Error
If i create a blank new asp.net without Angular it works fine.
It somehow has a error with the cmd.exe but i cant figure out why. The path to the cmd.exe is correct, launched VS with administrator privileges, notejs is installed, opening the .cspoj Line 33 (output TaskParameter...) and executing the command works too.
<Exec Command="node --version" ContinueOnError="true">
<Output TaskParameter="ExitCode" PropertyName="ErrorCode" />
</Exec>
After executing the following command manually in the CMD (from the .csproj) the error didnt come anymore while building, rebuilding.
<Target Name="DebugRunWebpack" BeforeTargets="Build" Condition=" '$(Configuration)' == 'Debug' And !Exists('wwwroot\dist') ">
....
<Exec Command="node node_modules/webpack/bin/webpack.js --config webpack.config.vendor.js" />
<Exec Command="node node_modules/webpack/bin/webpack.js" />
</Target>

Bamboo, NAnt, and PSExec shows no Console UI

I need NAnt to kick off a long running console app on the local machine during a Bamboo build. It does this correctly but without the console UI. Rather than try to show all that, I have worked it down to a trivial example that also does not show the UI.
When I type the following:
C:\PSExecPath\psexec -d -i ping localhost
or
C:\PSExecPath\psexec \\localmachinename -d -i ping localhost
I get exactly the results one would expect including the UI.
But when this same command is kicked off from NAnt there is no UI. For example when the following build file is run by NAnt after being started with Bamboo:
<?xml version="1.0"?>
<project default="all">
<target name="all">
<exec program="C:\PSExecPath\psexec.exe" spawn="true">
<arg value="\\localmachinename" />
<arg value="-d" />
<arg value="-i" />
<arg value="ping" />
<arg value="localhost" />
</exec>
</target>
</project>
Just to make sure it is stated, NAnt is being executed in the same profile.
Bamboo was running as a Service. I changed it to run as a Console and everything started running as expected.

Custom Flex Ant build task

A beginner's question.
I'm building a .swf with Flex Ant.
To my .swf I link a file, target.as, which I generate from file source.txt with command
./tool.sh source.txt > target.as
How can I add what is described in the above sentence to my ant build process?
The exec task executes any external program:
<exec executable="${basedir}/tool.sh" dir="${basedir}" output="target.as">
<arg path="source.txt"/>
</exec>
So if you use the mxmlc ant task to compile your swf, you can define your build task like this:
<target name="build">
<exec executable="${basedir}/tool.sh" dir="${basedir}" output="target.as">
<arg path="source.txt"/>
</exec>
<mxmlc ....>
...
</mxmlc>
</target>
To run that command in Ant use the exec task.
<exec executable="tool.sh" dir="toolshdir" output="target.as">
<arg value="source.txt" />
</exec>
http://livedocs.adobe.com/flex/3/html/anttasks_1.html
You may also want to use the Flex "mxmlc" task instead of calling it with exec. You can do a lot of configuration right within the XML if you'd prefer not to have to maintain the shell script.

Resources