简体   繁体   中英

using apache ant to validate Javsacsript syntax

My Java web app contains java files for the back-end and javascript files for the front-end. I have an ant script that compiles the java code and creates and deploys a war file (which contains the js files and other assets).

Additionally, I would like the ant script to validate that the js has correct syntax. If someone accidentally breaks the js by deleting a curly brace or semicolon, I want to the ant script to tell me.

I'm using Java 7, so Rhino is already available in the jdk.

How would I set up an ant task that uses Rhino to load up a javascript file and return an error code if Rhino was unable to parse the javascript file?

I have had good experience using WRO4J to lint and minify my js resources.

http://code.google.com/p/wro4j/

Please check https://github.com/philmander/ant-jshint looks promising to automate JShint with Apache Ant.

check http://www.jshint.com/platforms/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM