A powerful utility for copying and transforming Android project files with configurable regex patterns.
Kopy Tool helps Android developers to easily copy and transform project files, allowing for:
- Package and import path transformations
- File and directory name substitutions
- Pattern detection for sensitive data
- Directory filtering
- And more...
Add JitPack repository to your build file:
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
....
maven("https://jitpack.io")
}
}Add the dependency:
dependencies {
implementation ("com.github.alexiyous:kopy-tool:v1.0.2")
}Kopy Tool provides two approaches for configuration:
val config = RegexTemplates.custom()
.addPackageAndImportsConversion("com.alexius.tool", "com.something.tool")
.addComponentConversion("OldPrefix", "NewPrefix")
.addFileNameConversion("OldName", "NewName")
.build(
sourceFolder = "/path/to/source",
tempFolder = "/path/to/destination"
)
copyProject(config)val config = RegexTemplates {
conversions {
packagesAndImports("com.alexius.tool", "com.something.tool")
component("OldPrefix", "NewPrefix")
fileName("OldName", "NewName")
}
detections {
sensitive {
pattern("password|secret|credential", "Security risk")
}
directories {
ignore("build", "Skip build artifacts")
}
}
skipNewerFiles()
}
copyProject(config.build(
sourceFolder = "/path/to/source",
tempFolder = "/path/to/destination"
))Only changes text that appears after "package" or "import" statements:
packagesAndImports("com.alexius.tool", "com.something.tool")Transform class names and variables:
// Transform OldPrefixSomething to NewPrefixSomething
component("OldPrefix", "NewPrefix")
// Transform oldPrefixVariable to newPrefixVariable
variable("oldPrefix", "newPrefix")Prevent copying files with sensitive information:
sensitive {
pattern("password|apiKey", "Security risk")
}Skip or detect specific directories:
directories {
ignore("build", "Skip build artifacts")
detect("secret", "Sensitive directory")
}Check the copytool/src/main/java/com/alexius/copytool/testing directory in the repository for more examples.