Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,10 @@ gradle task to have the app module's package name and relevant strings replaced.

### Cleanup

Once you've done this, feel free to delete that [setup.gradle](buildscripts/setup.gradle) file from your project. In
addition, you can remove the [template_change_test](.github/workflows/template_change_test.yml)
workflow which validates the above process for the template repo itself.
After [this PR](https://github.com/AdamMc331/AndroidAppTemplate/pull/44), running the renameTemplate
task should do all the necessary cleanup like deleting the setup file and test workflow so you can
go ahead and commit the renamed files and be on your way. If you encounter any problems with the setup
workflow, please report a new [issue](https://github.com/AdamMc331/AndroidAppTemplate/issues).

## What's Included

Expand Down
36 changes: 34 additions & 2 deletions buildscripts/setup.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,31 @@ def renameConfig = [
newProjectName: "Your Project",
]

task deleteSetupCode() {
def workflowsFolder = "${rootDir}/.github/workflows"
def buildscriptsFolder = "${rootDir}/buildscripts"
def templateChangeWorkflowFile = "$workflowsFolder/template_change_test.yml"
def setupGradle = "$buildscriptsFolder/setup.gradle"

doLast {
delete(templateChangeWorkflowFile)

delete(setupGradle)

// Remove setup.gradle reference in build.gradle by filtering
// any lines that reference it.
def rootGradleFile = new File("${rootDir}/build.gradle.kts")
List rootGradleLines = rootGradleFile.readLines()
rootGradleFile.text = ""
rootGradleLines.each { line ->
if (!line.contains("setup.gradle")) {
rootGradleFile.append(line)
rootGradleFile.append("\n")
}
}
}
}

task renameAppPackage(type: Copy) {
description "Renames the template package in the app module."
group null
Expand Down Expand Up @@ -34,8 +59,6 @@ task renameAppPackage(type: Copy) {

doLast {
delete(startingDirectory)

("git add $endingDirectory").execute()
}
}

Expand Down Expand Up @@ -122,5 +145,14 @@ task renameTemplate {
replaceProjectName,
replaceAppName,
replacePackageInAppGradle,
deleteSetupCode,
)

doLast {
exec {
// After all setup changes happen, run a `git add` so
// folks can just immediately commit and push if they wish.
commandLine "git", "add", "${rootDir}/."
}
}
}