Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rewrite versioned APK file renaming #456

Open
Tracked by #369
TWiStErRob opened this issue Apr 8, 2023 · 0 comments
Open
Tracked by #369

Rewrite versioned APK file renaming #456

TWiStErRob opened this issue Apr 8, 2023 · 0 comments
Labels
a:refactor internal change without functional change in:android Android Gradle Plugin helper plugin in:private private non-published plugin on:agp issue related to Android Gradle Plugin
Milestone

Comments

@TWiStErRob
Copy link
Owner

TWiStErRob commented Apr 8, 2023

TODO replace with new Variant API transformation.

//			androidTest as ComponentCreationConfig
//			val rename = project.tasks.register<RenameAPK>("renameVersionedPackage${androidTest.name.capitalize()}") {
////				inputFile.set(variant.artifacts.get(SingleArtifact.APK))
////				outputFile.fileProvider(inputFile.map { it.asFile.parentFile.resolve(it.asFile.nameWithoutExtension + "-renamed" + it.asFile.extension) })
//			}
//			androidTest.artifacts.get(SingleArtifact.APK)
//			androidTest.artifacts
//				.use(rename)
//				.wiredWithDirectories(RenameAPK::inputFile, RenameAPK::outputFile)
//				.toTransform(SingleArtifact.APK)
//					renameAPK7(androidTest, androidTest.outputs)

@DisableCachingByDefault(because = "Simple copy")
abstract class RenameAPK : DefaultTask() {

	@get:InputDirectory abstract val inputFile: DirectoryProperty
	@get:OutputDirectory abstract val outputFile: DirectoryProperty

	@TaskAction fun taskAction() {
		inputFile.get().asFile.copyRecursively(outputFile.get().asFile)
		outputFile.get().asFile
//			.listFiles { file -> file.extension == "apk" }
			.listFiles()
			.orEmpty()
			.forEach {
				val target = it.parentFile.resolve(it.name + ".renamed")
				it.renameTo(target)
				target.appendBytes(ByteArray(size = 1))
			}
	}
}
@TWiStErRob TWiStErRob mentioned this issue Apr 8, 2023
18 tasks
@TWiStErRob TWiStErRob changed the title TODO replace with new Variant API transformation. Rewrite file renaming Apr 8, 2023
@TWiStErRob TWiStErRob changed the title Rewrite file renaming Rewrite versioned APK file renaming Apr 8, 2023
@TWiStErRob TWiStErRob added a:refactor internal change without functional change on:agp issue related to Android Gradle Plugin in:private private non-published plugin in:android Android Gradle Plugin helper plugin labels Apr 8, 2023
@TWiStErRob TWiStErRob added this to the v0.17 milestone Apr 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
a:refactor internal change without functional change in:android Android Gradle Plugin helper plugin in:private private non-published plugin on:agp issue related to Android Gradle Plugin
Projects
None yet
Development

No branches or pull requests

1 participant