Vicky
Vicky

Reputation: 17375

Gradle renaming file name with wildcards

I have the following task in my build.gradle

task zipConfiguration(type: Zip) { def myDir = project(':SomeProject').projectDir.toString() + '/build/libs/' from myDir archiveName 'Output.zip' destinationDirectory = file("$buildDir/libs") }

build/libs of project SomeProject will always have one versioned jar file. For e.g. configuration_2021_06.jar

With every build, the jar created will have a new version number. So the name of the jar I am zipping is dynamic.

However, I want a constant name myconfig.jar to go inside the Output.zip

How can I rename configuration_*.jar to myconfig.jar ?

Tried rename ('*.jar', 'myconfig.jar') : Gives error Dangling meta character '*' near index 0

Tried rename ('configuration*.jar', 'myconfig.jar') : Doesn't rename it. I still see configuration_2021_06.jar inside Output.zip

Upvotes: 1

Views: 718

Answers (1)

Vicky
Vicky

Reputation: 17375

The * needs to be like:

 rename ('configuration(.*).jar', 'myconfig.jar')

Upvotes: 1

Related Questions