KaptajnKold
KaptajnKold

Reputation: 10946

Does something like Sprocket exist for Java

Sprocket is a Ruby library for managing JavaScript dependencies. It makes it possible to declare dependencies in specially formatted comments in the JavaScript files, and have all the required files concatenated server side. (Read more here: http://getsprockets.org/)

Where I work, we have a real need for such a framework, but it has to be in the form of a Java library.

Does such a thing exist? What other solutions have you come up with to manage JavaScript dependencies?

Upvotes: 5

Views: 1538

Answers (6)

brutal de luxe
brutal de luxe

Reputation: 1

Yes, it does exist and its even richer in functionality https://github.com/QubitProducts/miniMerge.

Ii is also very fast and very small (few kb)! All you need is java.

I use it in my all projects, it is not only for JS, I use it also with CSS and HTML.

One awesome thing is that you can specify file or directory as input and filter contents based on tagging!

Upvotes: 0

benmmurphy
benmmurphy

Reputation: 2505

You can run sprockets inside a java web application using jruby. It is not too difficult. You could disable sprockets in production and only use statically compiled assets if you are worried about performance. It's also possible with Servlet-3.0 to completely disable sprockets in production and have the same web.xml or you could do dodgy things with a proxy context listener and proxy servlet filter if you are concerned about having to load the jruby runtime and sprockets even when you are not using it.

I have an example here: https://github.com/benmmurphy/java_sprockets

Upvotes: 0

woolyninja
woolyninja

Reputation: 762

I know this was answered a long time ago but my vote is for JAWR!

Upvotes: 1

ThiamTeck
ThiamTeck

Reputation: 385

You may have a look at this webutilities as well.

Upvotes: 3

Li0liQ
Li0liQ

Reputation: 11264

You can also use juicer to merge javascript files although it's also written in ruby.
Another option that, I suppose, will suit you is using combiner by Nicholas C. Zakas if you do not need all the features of juicer and sprockets. It is pretty simple, written in java (.jar) and the source can be found in author's repository. You can also fork the source in order to tune it according to your needs.

Upvotes: 2

Olivier Croisier
Olivier Croisier

Reputation: 6149

Such a feature exists in the Wicket framework. It is a component-oriented web framework for Java that is gaining momentum these days.

Wicket lets you define header resources in your components (eg, Javascript scripts, CSS files, etc.) and combines them at runtime, removing duplicates.

Upvotes: 2

Related Questions