Can I silence Closure Compiler warnings for external libraries? - google-closure-compiler

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.

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

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

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.

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.

How to use custom tokens with flex ant tasks

I am trying to use the flex ant task to build my Flex project.
Before using ant, I ran the mxmlc command like this:
mxmlc -load-config mxmlc_conf.xml src\project.mxml -output bin-debug +libs=<absolute_path_to>3rdparty\libs +<other_token>=<absoulte_path_to_value>
The thing is now I am supposed to use flex ant tasks and it looks like they disabled (or forgot about) the custom tokens like += as I haven't found a way to pass those to the mxmlc task.
I have tried using:
< mxmlc ...>< arg token value="..." />< /mxmlc>
but that doesn't work.
What I am trying to accomplish is to get rid of hard-coded paths in the mxmlc config-file (mxmlc_conf.xml) and at first I used the custom tokens in mxmlc but now I don't know how to pass paths as variables to the config file.
I can accept suggestions.
Thanks a lot in advance.
I'm trying to do the exact same thing (replace hard-coded paths in the config file) and I'm looking for the same solution.
It seems we might have to abandon the mxmlc task and simply use mxmlc from the command line:
<exec searchpath="true" executable="amxmlc"
dir="${project.build.outputDirectory}">
<env key="PATH"
path="${env.PATH}:/Applications/Adobe\ Flash\ Builder\ 4.5/sdks/4.5.1/bin" />
<arg value="-load-config" />
<arg value="../src/main/resources/dumpConfig.xml" />
<arg value="+libs=/absolute/path/to/3rd/party/libs" />
<arg value="-output" />
<arg
value="${project.build.outputDirectory}/${application.name}.swf" />
<arg value="../src/main/flex/${application.name}.mxml" />
</exec>
Something like this should work. I'm just hoping there's a better way (that is, a way we can actually use the mxml ant target!)
I hope that helps someone...
Try this
<target>
<replace file="mxmlc_conf.xml" token="$${libs}" value="absolute/path/to/3rdparty/libs"/>
<mxmlc ...>
<load-config filename="mxmlc_conf.xml" />
</mxmlc>
<replace file="mxmlc_conf.xml" token="absolute/path/to/3rdparty/libs" value="$${libs}"/>
</target>

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