Reputation: 942
I have a libs folder, there I have few jar files. There names are like this - componentName + version.jar. There is in all 4 files in libs folder. Now I need the component names from these files and I want to use it for some other purpose. How can I get that in gradle. My jar files in libs folder are : bo-1.0.0.jar, so-2.2.1.jar, do-1.0.1.jar and fz-1.0.1.jar I want to get bo,so,do,fz in variables component_bo,component_so,component_do,component_fz.
Upvotes: 0
Views: 51
Reputation: 13466
You can just list the contents of that folder and do some simple string manipulation. Here's an example of a pretty naive implementation but I think you can get the idea.
def components = fileTree('libs').collect { it.name.split('-')[0] }
components.each { component ->
// do something
}
Upvotes: 0