Hi Guys- refactored maven-rhino-compiler-plugin Mojo to successfully execute javascript with inputDirectory,outputDirectory and args parameters could steve connolly (or anyone else) help me write testcases?
who to ping for review? thanks! Martin Gainty ______________________________________________ Verzicht und Vertraulichkeitanmerkung/Note de déni et de confidentialité Diese Nachricht ist vertraulich. Sollten Sie nicht der vorgesehene Empfaenger sein, so bitten wir hoeflich um eine Mitteilung. Jede unbefugte Weiterleitung oder Fertigung einer Kopie ist unzulaessig. Diese Nachricht dient lediglich dem Austausch von Informationen und entfaltet keine rechtliche Bindungswirkung. Aufgrund der leichten Manipulierbarkeit von E-Mails koennen wir keine Haftung fuer den Inhalt uebernehmen. Ce message est confidentiel et peut être privilégié. Si vous n'êtes pas le destinataire prévu, nous te demandons avec bonté que pour satisfaire informez l'expéditeur. N'importe quelle diffusion non autorisée ou la copie de ceci est interdite. Ce message sert à l'information seulement et n'aura pas n'importe quel effet légalement obligatoire. Étant donné que les email peuvent facilement être sujets à la manipulation, nous ne pouvons accepter aucune responsabilité pour le contenu fourni. From: [email protected] To: [email protected]; [email protected] Subject: maven test harness for JavaScript Date: Fri, 3 Jun 2011 11:45:29 -0400 someone from europe asked me about compile routines for Javascript my response was what i needed to know which build environment do you implement? The response was IBM JAZZ realising their bus was headed to a cliff I decided to look at ways of incorporating JS routines into a maven3 build plugin the only JavaScript compile option currently supported is: http://cefiro.homelinux.org/topics/java/maven-rhino-compiler-plugin/ $M2_HOME/Rhino>mvn -e -X compile $M2_HOME/Rhino>mvn -e -X package and deployed up to my local repository and then implemented using the following build configuration: <plugin> <groupId>rhino</groupId> <artifactId>rhino</artifactId> <version>1.0</version> <configuration> <packageName>packageName</packageName> <!-- optional --> <outputDirectory>output</outputDirectory> <sourceDirectory>${build.dir}/src/dojo/util/shrinksafe/</sourceDirectory> <sourceExtension>js</sourceExtension> <versionNumber>160</versionNumber> </configuration> <executions> <execution> <id>js-compile</id> <phase>integration-test</phase> <goals> <goal>compile</goal> </goals> </execution> </executions> </plugin> i then executed: $M2_HOME/Rhino>mvn -e -X integration-test here is the original test.js: function test(x) { print("test"); java.lang.Thread.sleep(x*1000); print("exit"); } take a look at what the current plugin produced: $M2_HOME/Rhino/output>javap ./packageName/test public class packageName.test extends org.mozilla.javascript.NativeFunction impl ements org.mozilla.javascript.Script{ public packageName.test(org.mozilla.javascript.Scriptable, org.mozilla.javas cript.Context, int); public packageName.test(); public static void main(java.lang.String[]); public final java.lang.Object exec(org.mozilla.javascript.Context, org.mozil la.javascript.Scriptable); public final java.lang.Object call(org.mozilla.javascript.Context, org.mozil la.javascript.Scriptable, org.mozilla.javascript.Scriptable, java.lang.Object[]); public int getLanguageVersion(); public java.lang.String getFunctionName(); public int getParamCount(); public int getParamAndVarCount(); public java.lang.String getParamOrVarName(int); public java.lang.String getEncodedSource(); public boolean getParamOrVarConst(int); static final {}; } //all i wanted was a simple test class that would look something like: public String test(int x) //so i load rhino classes to output folder and have a run with no params $M2_HOME/Rhino/output>java -classpath . packageName.test //Nothing returned lets try with integer param set to 1 (assume whitespace delim) $M2_HOME/Rhino/output>java -classpath . packageName.test 1 //Nothing returned ..perhaps (1) $M2_HOME/Rhino/output>java -classpath . packageName.test(1) Exception in thread "main" java.lang.NoClassDefFoundError: packageName/test(1) //no joy using the above implementation but there is another way is we use the //function.invoker from <Rhino>ScriptEngine e.g. java -classpath %CLASSPATH% org.dojotoolkit.shrinksafe.Main util\shrinksafe\test.js 1 1>>LOG //lets take a look at the output Main::processFiles *************** Main::processFiles ******************* files=[Ljava.lang.String;@e09713 function_name=test args=1 thiz=util\shrinksafe\test.js ****************************** * Script result= testexit ****************************** function test(x){ print("test"); java.lang.Thread.sleep(x*1000); print("exit"); }; the script result of test and exit is exactly the JavaScript test requirement i need so unless someone has a better alternative i will take the weekend to refactor the current cefiro.homelinux.org maven-rhino-compiler-plugin to add the test goal which will run the test on the discovered javascript files i will retain the compile goal which currently compiles a generated java class with ${outputDirectory}/${packageName}/NameOfDiscoveredJSFile.class my feeling is that by incorporating javascript testing we can hold accountable UI folk who introduce non-operational javascript onto a website BEFORE deployment to web-server advice? Martin Gainty ______________________________________________ Verzicht und Vertraulichkeitanmerkung/Note de déni et de confidentialité Diese Nachricht ist vertraulich. Sollten Sie nicht der vorgesehene Empfaenger sein, so bitten wir hoeflich um eine Mitteilung. Jede unbefugte Weiterleitung oder Fertigung einer Kopie ist unzulaessig. Diese Nachricht dient lediglich dem Austausch von Informationen und entfaltet keine rechtliche Bindungswirkung. Aufgrund der leichten Manipulierbarkeit von E-Mails koennen wir keine Haftung fuer den Inhalt uebernehmen. Ce message est confidentiel et peut être privilégié. Si vous n'êtes pas le destinataire prévu, nous te demandons avec bonté que pour satisfaire informez l'expéditeur. N'importe quelle diffusion non autorisée ou la copie de ceci est interdite. Ce message sert à l'information seulement et n'aura pas n'importe quel effet légalement obligatoire. Étant donné que les email peuvent facilement être sujets à la manipulation, nous ne pouvons accepter aucune responsabilité pour le contenu fourni.
