@@ -28,46 +28,50 @@ description = 'Release module'
2828// ./gradlew ciRelease -PreleaseVersion=x.y.z.Final -PdevelopmentVersion=x.y.z-SNAPSHOT -PgitRemote=origin -PgitBranch=main
2929
3030// The folder containing the rendered documentation
31- final String documentationDir = rootProject. project( ' documentation' ) . buildDir
31+ final String documentationDir = rootProject. layout . buildDirectory . dir( " documentation" )
3232
3333// Relative path on the static website where the documentation is located
3434final String docWebsiteRelativePath = " reactive/documentation/${ projectVersion.family} "
3535
3636// The location of the docs when the website has been cloned
37- final String docWebsiteReactiveFolder = " ${ project.buildDir } / docs-website/${ docWebsiteRelativePath} "
37+ final String docWebsiteReactiveFolder = project. layout . buildDirectory . dir( " docs-website/${ docWebsiteRelativePath} " )
3838
3939/**
4040 * Assembles all documentation into the {buildDir}/documentation directory.
4141 */
42- task assembleDocumentation (dependsOn : [rootProject. project( ' documentation' ). tasks. assemble]) {
43- group = ' Documentation'
44- description = ' Render the documentation'
42+ tasks. register( ' assembleDocumentation' ) {
43+ dependsOn ' :documentation:assemble'
44+ group ' Documentation'
45+ description ' Render the documentation'
4546}
4647assemble. dependsOn assembleDocumentation
4748
4849/**
4950* Clone the website
5051*/
51- task removeDocsWebsite ( type : Delete ) {
52- delete " ${ project.buildDir } / docs-website/ "
52+ tasks . register( ' removeDocsWebsite ' , Delete ) {
53+ delete project. layout . buildDirectory . dir( " docs-website" )
5354}
5455
5556// Depending on compileJava makes sure that the buildDir exists. Otherwise this task will fail.
56- task cloneDocsWebsite ( type : Exec , dependsOn : [removeDocsWebsite, compileJava] ) {
57- workingDir project. buildDir
57+ tasks. register( ' cloneDocsWebsite' , Exec ) {
58+ dependsOn removeDocsWebsite, compileJava
59+ workingDir project. layout. buildDirectory
5860 commandLine ' git' , ' clone' , docPublishRepoUri, ' -b' , docPublishBranch, ' --sparse' , ' --depth' , ' 1' , ' docs-website'
5961}
6062
61- task sparseCheckoutDocumentation ( type : Exec , dependsOn : cloneDocsWebsite ) {
62- workingDir " ${ project.buildDir} /docs-website"
63+ tasks. register( ' sparseCheckoutDocumentation' , Exec ) {
64+ dependsOn cloneDocsWebsite
65+ workingDir project. layout. buildDirectory. dir( " docs-website" )
6366 commandLine ' git' , ' sparse-checkout' , ' set' , docWebsiteRelativePath
6467}
6568
6669/**
6770* Update the docs on the cloned website
6871*/
69- task updateDocumentation ( dependsOn : [assembleDocumentation, sparseCheckoutDocumentation] ) {
70- description = " Update the documentation o the cloned static website"
72+ tasks. register( ' updateDocumentation' ) {
73+ dependsOn assembleDocumentation, sparseCheckoutDocumentation
74+ description = " Update the documentation on the cloned static website"
7175
7276 // copy documentation outputs into target/documentation:
7377 // * this is used in building the dist bundles
@@ -94,22 +98,26 @@ task updateDocumentation( dependsOn: [assembleDocumentation, sparseCheckoutDocum
9498/**
9599* Push documentation changes on the remote repository
96100*/
97- task stageDocChanges ( type : Exec , dependsOn : updateDocumentation ) {
98- workingDir " ${ project.buildDir} /docs-website"
101+ tasks. register( ' stageDocChanges' , Exec ) {
102+ dependsOn updateDocumentation
103+ workingDir project. layout. buildDirectory. dir( " docs-website" )
99104 commandLine ' git' , ' add' , ' -A' , ' .'
100105}
101106
102- task commitDocChanges ( type : Exec , dependsOn : stageDocChanges ) {
107+ tasks. register( ' commitDocChanges' , Exec ) {
108+ dependsOn stageDocChanges
103109 workingDir " ${ project.buildDir} /docs-website"
104110 commandLine ' git' , ' commit' , ' -m' , " [HR] Hibernate Reactive documentation for ${ projectVersion} "
105111}
106112
107- task pushDocChanges ( type : Exec , dependsOn : commitDocChanges ) {
108- workingDir " ${ project.buildDir} /docs-website"
113+ tasks. register( ' pushDocChanges' , Exec ) {
114+ dependsOn commitDocChanges
115+ workingDir project. layout. buildDirectory. dir( " docs-website" )
109116 commandLine ' git' , ' push' , ' --atomic' , ' origin' , docPublishBranch
110117}
111118
112- task publishDocumentation (dependsOn : pushDocChanges) {
119+ tasks. register( ' publishDocumentation' ) {
120+ dependsOn pushDocChanges
113121 group = " Release"
114122 description = " Upload documentation on the website"
115123
@@ -118,16 +126,50 @@ task publishDocumentation(dependsOn: pushDocChanges) {
118126 }
119127}
120128
129+ tasks. register( " releasePrepare" ) {
130+ group = " Release"
131+ description = " Performs release preparations on local check-out, including updating changelog"
132+ doFirst {
133+ if ( ! project. hasProperty( ' releaseVersion' ) || ! project. hasProperty( ' developmentVersion' )
134+ || ! project. hasProperty( ' gitRemote' ) || ! project. hasProperty( ' gitBranch' ) ) {
135+ throw new GradleException (
136+ " Task 'releasePrepare' requires all of the following properties to be set:"
137+ + " 'releaseVersion', 'developmentVersion', 'gitRemote' and 'gitBranch'."
138+ )
139+ }
140+ }
141+
142+ doLast {
143+ logger. lifecycle( " Switching to branch '${ project.gitBranch} '..." )
144+ executeGitCommand( ' switch' , project. gitBranch )
145+
146+ logger. lifecycle( " Checking that all commits are pushed..." )
147+ String diffWithUpstream = executeGitCommand( ' diff' , ' @{u}' )
148+ if ( ! diffWithUpstream. isEmpty() ) {
149+ throw new GradleException (
150+ " Cannot release because there are commits on the branch to release that haven't been pushed yet."
151+ + " \n Push your commits to the branch to release first."
152+ )
153+ }
154+
155+ logger. lifecycle( " Adding commit to update version to '${ project.releaseVersion} '..." )
156+ project. projectVersionFile. text = " projectVersion=${ project.releaseVersion} "
157+ executeGitCommand( ' add' , ' .' )
158+ executeGitCommand( ' commit' , ' -m' , project. releaseVersion )
159+ }
160+ }
161+
121162/*
122163* Release everything
123164*/
124- task ciRelease {
165+ tasks . register( ' ciRelease' ) {
125166 group = " Release"
126167 description = " Triggers the release on CI: creates commits to change the version (release, then development), creates a tag, pushes everything. Then CI will take over and perform the release."
168+ dependsOn releasePrepare
127169
128170 doFirst {
129- if (! project. hasProperty(' releaseVersion' ) || ! project. hasProperty(' developmentVersion' )
130- || ! project. hasProperty(' gitRemote' ) ||! project. hasProperty(' gitBranch' ) ) {
171+ if ( ! project. hasProperty( ' releaseVersion' ) || ! project. hasProperty( ' developmentVersion' )
172+ || ! project. hasProperty( ' gitRemote' ) || ! project. hasProperty( ' gitBranch' ) ) {
131173 throw new GradleException (
132174 " Task 'ciRelease' requires all of the following properties to be set:"
133175 + " 'releaseVersion', 'developmentVersion', 'gitRemote' and 'gitBranch'."
@@ -136,51 +178,34 @@ task ciRelease {
136178 }
137179
138180 doLast {
139- logger. lifecycle(" Checking that the working tree is clean..." )
140- String uncommittedFiles = executeGitCommand(' status' , ' --porcelain' )
181+ logger. lifecycle( " Checking that the working tree is clean..." )
182+ String uncommittedFiles = executeGitCommand( ' status' , ' --porcelain' )
141183 if ( ! uncommittedFiles. isEmpty() ) {
142184 throw new GradleException (
143185 " Cannot release because there are uncommitted or untracked files in the working tree."
144186 + " \n Commit or stash your changes first."
145187 + " \n Uncommitted files:\n " + uncommittedFiles
146188 )
147189 }
148-
149- logger. lifecycle(" Switching to branch '${ project.gitBranch} '..." )
150- executeGitCommand(' switch' , project. gitBranch)
151-
152- logger. lifecycle(" Checking that all commits are pushed..." )
153- String diffWithUpstream = executeGitCommand(' diff' , ' @{u}' )
154- if ( ! diffWithUpstream. isEmpty() ) {
155- throw new GradleException (
156- " Cannot release because there are commits on the branch to release that haven't been pushed yet."
157- + " \n Push your commits to the branch to release first."
158- )
159- }
160-
161- logger. lifecycle(" Adding commit to update version to '${ project.releaseVersion} '..." )
162- project. projectVersionFile. text = " projectVersion=${ project.releaseVersion} "
163- executeGitCommand(' add' , ' .' )
164- executeGitCommand(' commit' , ' -m' , project. releaseVersion)
165190 String tag = project. releaseVersion
166191 if ( tag. endsWith( " .Final" ) ) {
167192 tag = tag. replace( " .Final" , " " )
168193 }
194+ logger. lifecycle( " Tagging '${ tag} '..." )
195+ executeGitCommand( ' tag' , ' -a' , ' -m' , " Release ${ project.releaseVersion} " , tag )
169196
170- logger. lifecycle(" Tagging '${ tag} '..." )
171- executeGitCommand(' tag' , ' -a' , ' -m' , " Release ${ project.releaseVersion} " , tag)
172-
173- logger. lifecycle(" Adding commit to update version to '${ project.developmentVersion} '..." )
197+ logger. lifecycle( " Adding commit to update version to '${ project.developmentVersion} '..." )
174198 project. projectVersionFile. text = " projectVersion=${ project.developmentVersion} "
175- executeGitCommand(' add' , ' .' )
176- executeGitCommand(' commit' , ' -m' , project. developmentVersion)
199+ executeGitCommand( ' add' , ' .' )
200+ executeGitCommand( ' commit' , ' -m' , project. developmentVersion )
177201
178- logger. lifecycle(" Pushing branch and tag to remote '${ project.gitRemote} '..." )
179- executeGitCommand(' push' , ' --atomic' , project. gitRemote, project. gitBranch, tag)
202+ logger. lifecycle( " Pushing branch and tag to remote '${ project.gitRemote} '..." )
203+ executeGitCommand( ' push' , ' --atomic' , project. gitRemote, project. gitBranch, tag )
180204
181- logger. lifecycle(" Done!" )
205+ logger. lifecycle( " Done!" )
182206
183- logger. lifecycle(" Go to https://github.com/hibernate/hibernate-reactive/actions?query=branch%3A${ tag} to check the progress of the automated release." )
207+ // logger
208+ // .lifecycle( "Go to https://github.com/hibernate/hibernate-reactive/actions?query=branch%3A${tag} to check the progress of the automated release." )
184209 }
185210}
186211
0 commit comments