Skip to content

Commit d2dfc1c

Browse files
committed
Remove version folder when generating meta file template
During release (`./gradlew release`), the build script copy the generated `.meta` files back to `plugin/Asset` folder to be used as the templates for future builds, before next release. This change make sure the version folder is removed from the path in the staging folder before copying back to the template folder.
1 parent 03b5460 commit d2dfc1c

File tree

1 file changed

+19
-3
lines changed

1 file changed

+19
-3
lines changed

build.gradle

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -515,13 +515,17 @@ File versionedAssetFile(File fileObj, Boolean fullVersionPrefix,
515515
}
516516

517517
/*
518-
* Remove the version component from a filename.
518+
* Remove the version component from a path. (Both its filename and its parent
519+
* folder)
519520
*
520521
* @param fileObj File to remove version from.
521522
*
522523
* @returns File with removed version string.
523524
*/
524525
File unversionedAssetFile(File fileObj) {
526+
// Remove the version postfix. Ex.
527+
// "ExternalDependencyManager/Editor/Google.IOSResolver_v1.2.166.dll" ->
528+
// "ExternalDependencyManager/Editor/Google.IOSResolver.dll"
525529
String basename
526530
String extension
527531
(basename, extension) = splitFilenameExtension(fileObj)
@@ -537,8 +541,20 @@ File unversionedAssetFile(File fileObj) {
537541
}
538542
}
539543
String filename = basename + extension
540-
return fileObj.parent != null ?
541-
new File(fileObj.parent, filename) : new File(filename)
544+
545+
// Remove the version folder as well. Ex.
546+
// "ExternalDependencyManager/Editor/1.2.166/Google.IOSResolver.dll" ->
547+
// "ExternalDependencyManager/Editor/Google.IOSResolver.dll"
548+
def versionFolderRegEx = /^[0-9]+\.[0-9]+\.[0-9]+$/
549+
File parent = fileObj.parent != null ? new File(fileObj.parent) : null
550+
if (parent != null) {
551+
String parentFolder = parent.name
552+
def folderMatch = parentFolder =~ versionFolderRegEx
553+
if (folderMatch.matches()) {
554+
parent = parent.parent != null ? new File(parent.parent) : null
555+
}
556+
}
557+
return parent != null ? new File(parent, filename) : new File(filename)
542558
}
543559

544560
/*

0 commit comments

Comments
 (0)