@@ -28,46 +28,50 @@ description = 'Release module'
28
28
// ./gradlew ciRelease -PreleaseVersion=x.y.z.Final -PdevelopmentVersion=x.y.z-SNAPSHOT -PgitRemote=origin -PgitBranch=main
29
29
30
30
// The folder containing the rendered documentation
31
- final String documentationDir = rootProject. project( ' documentation' ) . buildDir
31
+ final String documentationDir = rootProject. layout . buildDirectory . dir( " documentation" )
32
32
33
33
// Relative path on the static website where the documentation is located
34
34
final String docWebsiteRelativePath = " reactive/documentation/${ projectVersion.family} "
35
35
36
36
// 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} " )
38
38
39
39
/**
40
40
* Assembles all documentation into the {buildDir}/documentation directory.
41
41
*/
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'
45
46
}
46
47
assemble. dependsOn assembleDocumentation
47
48
48
49
/**
49
50
* Clone the website
50
51
*/
51
- task removeDocsWebsite ( type : Delete ) {
52
- delete " ${ project.buildDir } / docs-website/ "
52
+ tasks . register( ' removeDocsWebsite ' , Delete ) {
53
+ delete project. layout . buildDirectory . dir( " docs-website" )
53
54
}
54
55
55
56
// 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
58
60
commandLine ' git' , ' clone' , docPublishRepoUri, ' -b' , docPublishBranch, ' --sparse' , ' --depth' , ' 1' , ' docs-website'
59
61
}
60
62
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" )
63
66
commandLine ' git' , ' sparse-checkout' , ' set' , docWebsiteRelativePath
64
67
}
65
68
66
69
/**
67
70
* Update the docs on the cloned website
68
71
*/
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"
71
75
72
76
// copy documentation outputs into target/documentation:
73
77
// * this is used in building the dist bundles
@@ -94,22 +98,26 @@ task updateDocumentation( dependsOn: [assembleDocumentation, sparseCheckoutDocum
94
98
/**
95
99
* Push documentation changes on the remote repository
96
100
*/
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" )
99
104
commandLine ' git' , ' add' , ' -A' , ' .'
100
105
}
101
106
102
- task commitDocChanges ( type : Exec , dependsOn : stageDocChanges ) {
107
+ tasks. register( ' commitDocChanges' , Exec ) {
108
+ dependsOn stageDocChanges
103
109
workingDir " ${ project.buildDir} /docs-website"
104
110
commandLine ' git' , ' commit' , ' -m' , " [HR] Hibernate Reactive documentation for ${ projectVersion} "
105
111
}
106
112
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" )
109
116
commandLine ' git' , ' push' , ' --atomic' , ' origin' , docPublishBranch
110
117
}
111
118
112
- task publishDocumentation (dependsOn : pushDocChanges) {
119
+ tasks. register( ' publishDocumentation' ) {
120
+ dependsOn pushDocChanges
113
121
group = " Release"
114
122
description = " Upload documentation on the website"
115
123
@@ -118,16 +126,50 @@ task publishDocumentation(dependsOn: pushDocChanges) {
118
126
}
119
127
}
120
128
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
+
121
162
/*
122
163
* Release everything
123
164
*/
124
- task ciRelease {
165
+ tasks . register( ' ciRelease' ) {
125
166
group = " Release"
126
167
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
127
169
128
170
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' ) ) {
131
173
throw new GradleException (
132
174
" Task 'ciRelease' requires all of the following properties to be set:"
133
175
+ " 'releaseVersion', 'developmentVersion', 'gitRemote' and 'gitBranch'."
@@ -136,51 +178,34 @@ task ciRelease {
136
178
}
137
179
138
180
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' )
141
183
if ( ! uncommittedFiles. isEmpty() ) {
142
184
throw new GradleException (
143
185
" Cannot release because there are uncommitted or untracked files in the working tree."
144
186
+ " \n Commit or stash your changes first."
145
187
+ " \n Uncommitted files:\n " + uncommittedFiles
146
188
)
147
189
}
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)
165
190
String tag = project. releaseVersion
166
191
if ( tag. endsWith( " .Final" ) ) {
167
192
tag = tag. replace( " .Final" , " " )
168
193
}
194
+ logger. lifecycle( " Tagging '${ tag} '..." )
195
+ executeGitCommand( ' tag' , ' -a' , ' -m' , " Release ${ project.releaseVersion} " , tag )
169
196
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} '..." )
174
198
project. projectVersionFile. text = " projectVersion=${ project.developmentVersion} "
175
- executeGitCommand(' add' , ' .' )
176
- executeGitCommand(' commit' , ' -m' , project. developmentVersion)
199
+ executeGitCommand( ' add' , ' .' )
200
+ executeGitCommand( ' commit' , ' -m' , project. developmentVersion )
177
201
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 )
180
204
181
- logger. lifecycle(" Done!" )
205
+ logger. lifecycle( " Done!" )
182
206
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." )
184
209
}
185
210
}
186
211
0 commit comments