Skip to content

Commit

Permalink
Merge pull request #82 from infinum/gradle-task-for-updating-version-…
Browse files Browse the repository at this point in the history
…in-gradle

Add gradle tasks for updating version in readme
  • Loading branch information
KCeh authored Sep 9, 2024
2 parents 346483e + 19f5f87 commit bafb681
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ Then add the following dependencies in your app `build.gradle` or `build.gradle.

**Groovy**

<!--
If format of version definition is changed, make sure to update `generateReadme` task
-->
```groovy
def sentinelVersion = "1.4.1"
debugImplementation "com.infinum.sentinel:sentinel:$sentinelVersion"
Expand Down
6 changes: 5 additions & 1 deletion sentinel/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -125,4 +125,8 @@ project.gradle.taskGraph.whenReady {
connectedDebugAndroidTest {
ignoreFailures = true
}
}
}

apply from: '../tasks.gradle'
preBuild.dependsOn ':sentinel:generateReadme'

13 changes: 13 additions & 0 deletions tasks.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
apply from: '../config.gradle'

private void replaceVersionsInFile(File file) {
def content = file.text
content = content.replaceAll(~/sentinelVersion\s*=\s*".*"/, "sentinelVersion = \"${releaseConfig.version}\"")
file.setText(content)
}

tasks.register('generateReadme') {
doFirst {
replaceVersionsInFile(new File("${rootDir}/README.md"))
}
}

0 comments on commit bafb681

Please sign in to comment.