War plugin - rename JARs included in WEB-INF/lib

(Matthew Accola) #1

I am building a war file using the War plugin. During the assembly of the WAR file JARs will be added to the WEB-INF/lib directory. I would like to strip the version number from the file name while the WAR is being assembled. The reason I need to do this is so I can do an accurate compare with an existing WAR file.

Renaming files is pretty straight forward using the “rename” in the “war” closure…however, I have found that only the files from src/main/webapp are passed to the rename function and NOT the dependent JAR files.

Is there any way to do this type of rename?

(Peter Niederwieser) #2

Good question. This might work:


(Matthew Accola) #3

That results in an error:

Could not find property 'allSpecs' on task ':FrameworkWeb:war'.

I don’t see “allSpecs” as a property or method in the API Docs for War.

(Juha Ranta) #4

I have a similar problem with the ear plugin. We need to have the wars in the ear without a version number, because otherwise the Weblogic portal framework will choke.

(Peter Niederwieser) #5

Sorry, this should have been “war.rootSpec.allSpecs*.rename(…)”.

(Matthew Accola) #6

Awesome, works great. I had to rename 4 files so this is kind of clumsy but here is what i came up with as a quick-and-dirty fix:

war.rootSpec.allSpecs*.rename('(.*)FleetcycleModel-SNAPSHOT.jar(.*)', '$1FleetcycleModel.jar$2')
war.rootSpec.allSpecs*.rename('(.*)FleetCycleFramework-SNAPSHOT.jar(.*)', '$1FleetCycleFramework.jar$2')
war.rootSpec.allSpecs*.rename('(.*)fc-core-1.14-SNAPSHOT.jar(.*)', '$1fc-core.jar$2')
war.rootSpec.allSpecs*.rename('(.*)fc-core-ui-1.14-SNAPSHOT.jar(.*)', '$1fc-core-ui.jar$2')

Perhaps there is a better to do multiple renames like with the copy task?

(Simon McClenahan) #7

With Gradle 1.8 this now returns an error:

No such property: allSpecs for class: org.gradle.api.internal.file.copy.DefaultCopySpec_Decorated