-
Notifications
You must be signed in to change notification settings - Fork 3
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
Implement Secrets Vault Plugin #2
Conversation
azizutku
commented
May 23, 2023
- Set up initial project
- Add detekt
- Add CPP resources and CMakeLists.txt
- Add initial kotlin file for secrets
- Implement task that unzip plugin to temp folder
- Implement utility methods
- Implement code generator methods
- Add capitalize extension function to capitalize the first character
- Add kotlinx serialization dependency
- Implement keep secrets task
- Register KeepSecretsTask to the plugin
- Generate obfuscation key randomly
- Add CHANGELOG.md
- Add README.md
- Create build workflow
secretsvaultplugin/src/main/kotlin/com/commencis/secretsvaultplugin/KeepSecretsTask.kt
Outdated
Show resolved
Hide resolved
secretsvaultplugin/src/main/kotlin/com/commencis/secretsvaultplugin/KeepSecretsTask.kt
Outdated
Show resolved
Hide resolved
secretsvaultplugin/src/main/kotlin/com/commencis/secretsvaultplugin/KeepSecretsTask.kt
Outdated
Show resolved
Hide resolved
secretsvaultplugin/src/main/kotlin/com/commencis/secretsvaultplugin/KeepSecretsTask.kt
Outdated
Show resolved
Hide resolved
secretsvaultplugin/src/main/kotlin/com/commencis/secretsvaultplugin/KeepSecretsTask.kt
Outdated
Show resolved
Hide resolved
* @return the destination file for the CPP code | ||
*/ | ||
private fun getCppDestination(flavor: String, fileName: String): File { | ||
return project.file(SOURCE_SET_TEMPLATE.format(flavor, "cpp") + fileName) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
since project.layout.file returns provider, it is generally preferred(Of course providers can be used If we inject these as input/output)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In this specific case, we don't have a Provider readily available, and so we cannot use project.layout.file. The method project.file is suitable in our current context, where we have a file path represented as a String.
* | ||
* @return the package name of the Android app | ||
*/ | ||
private fun getAppPackageName(): String { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i think most of these methods would be better if they were defined as input/output properties
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've moved these methods to the plugin extension.
secretsvaultplugin/src/main/kotlin/com/commencis/secretsvaultplugin/SecretsVaultPlugin.kt
Outdated
Show resolved
Hide resolved
secretsvaultplugin/src/main/kotlin/com/commencis/secretsvaultplugin/SecretsVaultPlugin.kt
Outdated
Show resolved
Hide resolved
secretsvaultplugin/src/main/kotlin/com/commencis/secretsvaultplugin/KeepSecretsTask.kt
Outdated
Show resolved
Hide resolved
secretsvaultplugin/src/main/kotlin/com/commencis/secretsvaultplugin/KeepSecretsTask.kt
Outdated
Show resolved
Hide resolved
* @return a string containing the generated C++ code for app signature check | ||
*/ | ||
fun getAppSignatureCheck(appSignatures: List<String>): String { | ||
val signatures = appSignatures.joinToString(separator = "") { " $it,\n" }.trimEnd(',', '\n') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
{ " $it,\n" }
can we use \t instead of whitespaces?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I prefer to use spaces for indentation as the size of a tab character can vary between different IDEs, potentially leading to inconsistent formatting. Using spaces ensures that our code looks the same everywhere.
alias(libs.plugins.gradle.publish).apply(false) | ||
alias(libs.plugins.detekt).apply(false) | ||
alias(libs.plugins.kotlin.serialization).apply(false) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ack.
import java.io.IOException | ||
import java.nio.charset.Charset | ||
|
||
private const val SOURCE_SET_TEMPLATE = "src/%1\$s/%2\$s/" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ack.