How can I sort source files in task?

How can I sort source files in task?

I have combineJs task from gradle-js-plugin:

combineJs {

def jsFiles = fileTree(dir: “/lib/”, include: “jquery.js”)

jsFiles += fileTree(dir: “/lib/plugins”, include: “*.js”) //.sort()

jsFiles += fileTree(dir: “/lib/”, include: “underscore.js”)

source = jsFiles

dest = file("/js/all.js") }

I want to sort plugins in natural order, because when it combines on unix it is in different order than on windows.

Is it possible, have tried many different ways.

I have tried it like this:

combineJs {

def jsFiles = fileTree(dir: “/lib/”, include: “jquery.js”)

jsFiles += fileTree(dir: “/lib/plugins”, include: “*.js”)

jsFiles += fileTree(dir: “/lib/”, include: “underscore.js”)

source = jsFiles.collect { File file -> relativePath(file) }.sort().each { fileTree(it) }

dest = file("/js/all.js") }

it says UP TO DATE on task and does nothing

‘jsFiles.files.sort()’ should return a sorted ‘List<File>’. I’m not familiar with ‘gradle-js-plugin’, so I can’t say if it will solve the problem.