Skip to content

Commit

Permalink
chore: set version on build
Browse files Browse the repository at this point in the history
  • Loading branch information
tomasbjerre committed Sep 25, 2024
1 parent a9f6664 commit da6315d
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ WireMock extensions can be registered independently with each `@ConfigureWireMoc

## Credits

* [Wiremock Spring Boot](https://github.com/maciejwalkowiak/wiremock-spring-boot) (this is based on that project!)
* [Maciej Walkowiak](https://github.com/maciejwalkowiak) - This was originally his project and later moved to WireMock organization
* [Spring Cloud Contract WireMock](https://github.com/spring-cloud/spring-cloud-contract/blob/main/spring-cloud-contract-wiremock)
* [Spring Boot WireMock](https://github.com/skuzzle/spring-boot-wiremock)
* [Spring Boot Integration Tests With WireMock and JUnit 5](https://rieckpil.de/spring-boot-integration-tests-with-wiremock-and-junit-5/) by [Philip Riecks](https://twitter.com/rieckpil)
13 changes: 10 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,14 @@ def bumpVersionTo(version) {
def propertyFile = new File("$projectDir/gradle.properties")
def gradleProps = new Properties()
propertyFile.withReader { gradleProps.load(it) }
gradleProps.setProperty('version', version)
propertyFile.withWriter { gradleProps.store(it, null) }
def currentVersion = gradleProps.getProperty("version")
if (currentVersion == version) {
logger.lifecycle("Version not changed (${currentVersion})")
} else {
logger.lifecycle("Version changed (${currentVersion} -> ${version})")
gradleProps.setProperty('version', version)
propertyFile.withWriter { gradleProps.store(it, null) }
}
}

task setConventionalVersion() {
Expand All @@ -35,10 +41,10 @@ task setConventionalVersion() {
.getNextSemanticVersion()
.getVersion();
def nextSnapshot = "${nextVersion}-SNAPSHOT"
logger.lifecycle("Setting version ${nextSnapshot}...")
bumpVersionTo(nextSnapshot)
}
}
build.dependsOn setConventionalVersion

allprojects {
repositories {
Expand Down Expand Up @@ -98,6 +104,7 @@ project('wiremock-spring-boot', {
api "org.springframework:spring-test:6.1.13"
api "org.slf4j:slf4j-api:2.0.16"
api "org.junit.jupiter:junit-jupiter-api:5.11.0"
compileOnly "com.github.spotbugs:spotbugs-annotations:4.8.6"
}
})

Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#Wed Sep 25 17:54:02 CEST 2024
#Wed Sep 25 18:22:00 CEST 2024
baseArtifact=wiremock-spring-boot
developer.id=tomasbjerre
githubRepo=wiremock-spring-boot
Expand Down

0 comments on commit da6315d

Please sign in to comment.