Need a javaScript Plugin to minify every JavaScript file

Can someone tell me how to get a plugin to minify every javascript file inside his own javascript file?

Example: a.js will be minified to b-min.js b.js will be minidified to b-min.js

The Problem is: There are many javascript plugins, but I do not know how to use them. I have a usual gradle projekt and want that every javascript file is minified when I build the project. Does someone knows a good javascript plugin with a good doku? Here seems to be a good one (http://flashmattic.blogspot.de/2011/11/combine-minify-and-copy-your-jss-to.html) but they do not describe how to build for every file his own minified version. Does someone knows a site (example/tutorial) that shows a full example for a standard gradle project? Thanks!

Shalom Amin Zamani

Have you looked at https://github.com/eriwen/gradle-js-plugin ?

Thanks very much for your reply. But there is even not one example. how to use this plugin when I want that every javascript file should stand in his own js-minified file and not mixed with other js files in one file. I only want, that when I start a special task, that every js file gets his OWN minified js file version.

Inside the obove link I find in the Quick Link no task that creates for every js file a new min.js file. But every js file is inserted in one and the same js file. But I want that every js file gets his own js minified version.

This is how you might use the Gradle JS plugin for what you’re asking. First, apply the plugin using the examples and write:

javascript.source {
    custom {
        js {
            srcDir "src/js"
            include "*.js"
        }
    }
}
  javascript.source.custom.js.files.eachWithIndex { jsFile, idx ->
    tasks.add(name: "dominify${idx}", type: com.eriwen.gradle.js.tasks.MinifyJsTask) {
        source = jsFile
        dest = "${buildDir}/${jsFile.name}"
    }
}
task individualMinify(dependsOn: tasks.matching { Task task -> task.name.startsWith("dominify")})