cancel
Showing results for 
Search instead for 
Did you mean: 

Developing Client-side Javascript, Maven environment

pjaromin
Champ on-the-rise
Champ on-the-rise
I've been working on client-side javascript with the a maven 3 build and am looking for a way to update the client-side javascript without restarting the server with each change.

I'm in "development" mode and have tried editing the files in the target directory, but Windows reports those files as *locked* by a java process.

What is the best/fastest way of editing client-side Javascript?

Thanks!

-Patrick
5 REPLIES 5

afaust
Legendary Innovator
Legendary Innovator
Hello,

I am a only slightly confused - you want to update client-side Javascript but when you fiddle around, you get a message about Java locking some files? It would be best to further describe your packaging and deployment approach so readers in this forum immediately know what / how your application is deployed.
I am going to assume you have packaged your extension as a JAR which includes the JavaScript and CSS source as well as web scripts and other artifacts. In such a scenario, you cannot update your web resources while the server is running and need to restart it in order to apply changes. This would not be necessary, if your web resources where exploded in the WAR directory - this can be achieved by copy- or AMP-deployment methods.

Please also note that modification of client side resources may not take effect due to client caching.

Regards
Axel

pjaromin
Champ on-the-rise
Champ on-the-rise
Thanks for the repsonse.

I'm using the maven share war extension archetype (run using "mvn install -Prun"), which as best I can tell does run out of an exploded war file. However, the client-side javascript files in the target directory cannot be edited as they are locked by Java.

I assume that there is some better way to do this. How in general do Maven folks develop Share extensions?

afaust
Legendary Innovator
Legendary Innovator
Hello,

I tried using the different Alfresco archetypes but found they did not suit what I wanted to do in our development projects. I ended up doing a regular JAR builds, packaging the JAR and everything else up in an AMP via the Maven assembly plugin. In the end, I have an identical build procedure for Repository and Share extensions, have both source and binary JARs in my Nexus and can use the MMT plugin to install everything into the WARs in my final build projects.

Are you trying to do another Maven run while the server is still running? This is something I'd never do…

Regards
Axel

pjaromin
Champ on-the-rise
Champ on-the-rise
Are you trying to do another Maven run while the server is still running? This is something I'd never do…

No, not really. I'm simply trying to work on client-side JavaScript code without having to continually restart the server to view/test them.

For other (non-Alfresco projects) I'm accustomed to using the jetty plugin to run exploded webapps, where I can update JSPs, javascript, css, etc. without restarting. I'm finding development under Surf in my present configuration incredibly slow.

You say you do regular JAR builds - but doesn't that mean you have to write code, create the JAR, deploy it, and restart the server with every change? Isn't there a way to tweak the code, especially non-Java or Spring context files like client-side JavaScript, without packing it up, deploying, and restarting the server?

I've got to be missing something fundamental here.

Thanks!

-Patrick

afaust
Legendary Innovator
Legendary Innovator
Hello,

it depends on the change you're doing. Since my deployment is based on WAR, which will be exploded by Tomcat, I can modify all the dynamic resources (JS, FTL, CSS) that are not bundled in JARs while the server is running. I / we only bundle Java-classes in JARs and add all other resources in the AMP assembly. This way, we immediately get a report if a business module overrides a default Alfresco file or a file of another module when the AMPs are installed in the WAR via MMT. You don't get that via the JAR way and have to rely on classpath ordering / lookup, which could lead to some files from a module transparently hiding files from another one…

Anyway, only if I modify a Java class or Spring context file (*-context.xml, not server-side JS / FTL) do I have to re-build, re-deploy and re-start the server(s). All others can be edited while the Tomcat is running and I never had to deal with a locked file. I don't use the embedded Jetty via Maven plugin at all…

Regards
Axel