diff --git a/CHANGELOG.md b/CHANGELOG.md index 650c1d0..1f3aabd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed - Changed JSR-305 dependency from `implementation` to `api` +- Use cthing-projectversion library `ProjectVersion` object for project version ## [1.0.0] - 2023-12-22 diff --git a/README.md b/README.md index 4ee9708..757afba 100644 --- a/README.md +++ b/README.md @@ -46,9 +46,9 @@ This project is released on the [Maven Central repository](https://central.sonat Perform the following steps to create a release. - Commit all changes for the release -- In the `build.gradle.kts` file - - Ensure that `baseVersion` is set to the version for the release. The project follows [semantic versioning](https://semver.org/). - - Set `isSnapshot` to `false` +- In the `build.gradle.kts` file, edit the `ProjectVersion` object + - Set the version for the release. The project follows [semantic versioning](https://semver.org/). + - Set the build type to `BuildType.release` - Commit the changes - Wait until CI builds the release candidate - Run the command `mkrelease cthing-annotations ` @@ -61,9 +61,9 @@ Perform the following steps to create a release. - Wait for the new release to be available on Maven Central - In a browser, go to the project on GitHub - Generate a release with the tag `` -- In the build.gradle.kts file - - Increment the `baseVersion` patch number - - Set `isSnapshot` to `true` +- In the build.gradle.kts file, edit the `ProjectVersion` object + - Increment the version patch number + - Set the build type to `BuildType.snapshot` - Update the `CHANGELOG.md` with the changes in the release and prepare for next release changes - Update the `Usage` section in the `README.md` with the latest artifact release version - Commit these changes diff --git a/build.gradle.kts b/build.gradle.kts index 7cfa10b..0212f22 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,5 +1,7 @@ import com.github.spotbugs.snom.Effort import com.github.spotbugs.snom.Confidence +import org.cthing.projectversion.BuildType +import org.cthing.projectversion.ProjectVersion import java.text.SimpleDateFormat import java.util.Date import java.util.Locale @@ -18,12 +20,16 @@ plugins { alias(libs.plugins.versions) } -val baseVersion = "1.0.1" -val isSnapshot = true +buildscript { + repositories { + mavenCentral() + } + dependencies { + classpath(libs.cthingProjectVersion) + } +} -val isCIServer = System.getenv("CTHING_CI") != null -val buildNumber = if (isCIServer) System.currentTimeMillis().toString() else "0" -version = if (isSnapshot) "$baseVersion-$buildNumber" else baseVersion +version = ProjectVersion("1.0.1", BuildType.snapshot) group = "org.cthing" description = "A library providing various annotations to enhance code quality and readability." @@ -169,7 +175,8 @@ publishing { } } - val repoUrl = if (isSnapshot) findProperty("cthing.nexus.snapshotsUrl") else findProperty("cthing.nexus.candidatesUrl") + val repoUrl = if ((version as ProjectVersion).isSnapshotBuild) + findProperty("cthing.nexus.snapshotsUrl") else findProperty("cthing.nexus.candidatesUrl") if (repoUrl != null) { repositories { maven { diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 026e778..c0e4c7d 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -10,5 +10,6 @@ spotbugs = { id = "com.github.spotbugs", version = "6.0.7" } versions = { id = "com.github.ben-manes.versions", version = "0.51.0" } [libraries] +cthingProjectVersion = "org.cthing:cthing-projectversion:1.0.0" jsr305 = "com.google.code.findbugs:jsr305:3.0.2" spotbugsContrib = "com.mebigfatguy.sb-contrib:sb-contrib:7.6.4"