@@ -19,57 +19,8 @@ description = 'Release module'
1919// The folder containing the rendered documentation
2020final Directory documentationDir = project(" :documentation" ). layout. buildDirectory. get()
2121
22- def releaseChecksTask = tasks. register( " releaseChecks" ) {
23- description ' Checks and preparation for release'
24- group ' Release'
25-
26- doFirst {
27- logger. lifecycle(" Checking that the working tree is clean..." )
28- String uncommittedFiles = executeGitCommand(' status' , ' --porcelain' )
29- if (! uncommittedFiles. isEmpty()) {
30- throw new GradleException (
31- " Cannot release because there are uncommitted or untracked files in the working tree.\n " +
32- " Commit or stash your changes first.\n " +
33- " Uncommitted files:\n " +
34- uncommittedFiles
35- )
36- }
37-
38- String gitBranchLocal = project. hasProperty( ' gitBranch' ) && ! project. property( ' gitBranch' ). isEmpty()
39- ? project. property( ' gitBranch' )
40- : executeGitCommand( ' branch' , ' --show-current' ). trim()
41-
42- String gitRemoteLocal
43- if ( project. hasProperty( ' gitRemote' ) && ! project. property( ' gitRemote' ). isEmpty() ) {
44- gitRemoteLocal = project. property( ' gitRemote' )
45- }
46- else {
47- final String remotes = executeGitCommand( ' remote' , ' show' ). trim()
48- final List<String > tokens = remotes. tokenize()
49- if ( tokens. size() != 1 ) {
50- throw new GradleException ( " Could not determine `gitRemote` property for `releaseChecks` tasks." )
51- }
52- gitRemoteLocal = tokens. get( 0 )
53- }
54-
55- project. ext {
56- gitBranch = gitBranchLocal
57- gitRemote = gitRemoteLocal
58- }
59-
60- logger. lifecycle( " Switching to branch '${ project.gitBranch} '..." )
61- executeGitCommand( ' checkout' , project. gitBranch )
62-
63- logger. lifecycle( " Checking that all commits are pushed..." )
64- String diffWithUpstream = executeGitCommand( ' diff' , ' @{u}' )
65- if ( ! diffWithUpstream. isEmpty() ) {
66- throw new GradleException (
67- " Cannot perform `ciRelease` tasks because there are un-pushed local commits .\n " +
68- " Push your commits first."
69- )
70- }
71- }
72- }
22+ // Relative path on the static website where the documentation is located
23+ final String docWebsiteRelativePath = " reactive/documentation/${ projectVersion.family} "
7324
7425/**
7526 * Assembles all documentation into the {buildDir}/documentation directory.
@@ -81,22 +32,9 @@ def assembleDocumentationTask = tasks.register( 'assembleDocumentation' ) {
8132}
8233assemble. dependsOn assembleDocumentationTask
8334
84- def changeToReleaseVersionTask = tasks. register( ' changeToReleaseVersion' ) {
85- description ' Updates `gradle/version.properties` file to the specified release-version'
86- group ' Release'
87-
88- dependsOn releaseChecksTask
89-
90- doFirst {
91- logger. lifecycle( " Updating version-file to release-version : `${ project.releaseVersion} `" )
92- updateVersionFile( " ${ project.releaseVersion} " )
93- }
94- }
95-
9635def updateDocumentationTask = tasks. register( ' updateDocumentation' ) {
9736 description " Update the documentation on the cloned static website"
9837 dependsOn assembleDocumentationTask
99- mustRunAfter changeToReleaseVersion
10038
10139 // copy documentation outputs into target/documentation:
10240 // * this is used in building the dist bundles
@@ -117,188 +55,13 @@ def updateDocumentationTask = tasks.register( 'updateDocumentation' ) {
11755 }
11856}
11957
120- def gitPreparationForReleaseTask = tasks. register( ' gitPreparationForRelease' ) {
121- dependsOn releaseChecksTask, changeToReleaseVersionTask
122- finalizedBy updateDocumentationTask
123-
124- doLast {
125- logger. lifecycle( " Performing pre-steps Git commit : `${ project.releaseVersion} `" )
126- executeGitCommand( ' add' , ' .' )
127- executeGitCommand( ' commit' , ' -m' , " Update project version to : `${ project.releaseVersion} `" )
128- }
129- }
130-
131- def changeToDevelopmentVersionTask = tasks. register( ' changeToDevelopmentVersion' ) {
132- description ' Updates `gradle/version.properties` file to the specified development-version'
133- group ' Release'
134-
135- dependsOn releaseChecksTask
136-
137- doFirst {
138- logger. lifecycle( " Updating version-file to development-version : `${ project.developmentVersion} `" )
139- updateVersionFile( " ${ project.developmentVersion} " )
140- }
141- }
142-
143- def releasePreparePostGitTask = tasks. register( ' gitTasksAfterRelease' ) {
144- dependsOn changeToDevelopmentVersionTask
145-
146- doLast {
147- if ( project. createTag ) {
148- logger. lifecycle( " Tagging release : `${ project.releaseTag} `..." )
149- executeGitCommand( ' tag' , ' -a' , project. releaseTag, ' -m' , " Release $project . projectVersion " )
150- }
151-
152- logger. lifecycle( " Performing post-steps Git commit : `${ project.releaseVersion} `" )
153- executeGitCommand( ' add' , ' .' )
154- executeGitCommand( ' commit' , ' -m' , " Update project version to : `${ project.developmentVersion} `" )
155- }
156- }
157-
158- void updateVersionFile (var version ) {
159- logger. lifecycle( " Updating `gradle/version.properties` version to `${ version} `" )
160- project. versionFile. text = " projectVersion=${ version} "
161- project. version = version
162- }
163-
164- def publishReleaseArtifactsTask = tasks. register( ' publishReleaseArtifacts' ) {
165- dependsOn updateDocumentationTask
166-
167- mustRunAfter gitPreparationForReleaseTask
168- }
169-
170- def releasePerformPostGitTask = tasks. register( ' gitTasksAfterReleasePerform' ) {
171-
172- doLast {
173- if ( project. createTag ) {
174- logger. lifecycle( " Pushing branch and tag to remote `${ project.gitRemote} `..." )
175- executeGitCommand( ' push' , ' --atomic' , project. gitRemote, project. gitBranch, project. releaseTag )
176- }
177- else {
178- logger. lifecycle( " Pushing branch to remote `${ project.gitRemote} `..." )
179- executeGitCommand( ' push' , project. gitRemote, project. gitBranch )
180- }
181- }
182- }
183-
18458def releasePrepareTask = tasks. register( " releasePrepare" ) {
185- description " On a local checkout, performs all the changes required for the release, website updates included"
186- group " Release"
187-
188- dependsOn gitPreparationForReleaseTask
189-
190- finalizedBy releasePreparePostGitTask
191- }
192-
193- def releasePerformTask = tasks. register( ' releasePerform' ) {
194- group ' Release'
195- description ' Performs a release on local check-out, including updating changelog and '
196-
197- dependsOn publishReleaseArtifactsTask
198-
199- finalizedBy releasePerformPostGitTask
200- }
201-
202- /*
203- * Release everything
204- */
205- def releaseTask = tasks. register( ' release' ) {
206- description ' Performs a release on local check-out'
207- group ' Release'
208-
209- dependsOn releasePrepareTask
210- dependsOn releasePerformTask
211- }
212-
213- def ciReleaseTask = tasks. register( ' ciRelease' ) {
214- 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."
59+ description " Prepares all the artifacts and documentation for a JReleaser release."
21560 group " Release"
21661
217- dependsOn releaseTask
218- }
219-
220- static String executeGitCommand (Object ... subcommand ){
221- List<Object > command = [' git' ]
222- Collections . addAll( command, subcommand )
223- def proc = command. execute()
224- def code = proc. waitFor()
225- def stdout = inputStreamToString( proc. getInputStream() )
226- def stderr = inputStreamToString( proc. getErrorStream() )
227- if ( code != 0 ) {
228- throw new GradleException ( " An error occurred while executing " + command + " \n\n stdout:\n " + stdout + " \n\n stderr:\n " + stderr )
229- }
230- return stdout
231- }
232-
233- static String inputStreamToString (InputStream inputStream ) {
234- inputStream. withCloseable { ins ->
235- new BufferedInputStream (ins). withCloseable { bis ->
236- new ByteArrayOutputStream (). withCloseable { buf ->
237- int result = bis. read()
238- while (result != -1 ) {
239- buf. write((byte ) result)
240- result = bis. read()
241- }
242- return buf. toString(StandardCharsets . UTF_8 . name())
243- }
244- }
245- }
246- }
247-
248- gradle. getTaskGraph(). whenReady { tg->
249- if ( ( tg. hasTask( project. tasks. releasePrepare ) || tg. hasTask( project. tasks. releasePerform ) )
250- && ! project. getGradle(). getStartParameter(). isDryRun() ) {
251- String releaseVersionLocal
252- String developmentVersionLocal
253-
254- def console = tg. hasTask( project. tasks. release ) && ! tg. hasTask( project. tasks. ciRelease )
255- ? System . console()
256- : null
257-
258- if (project. hasProperty(' releaseVersion' )) {
259- releaseVersionLocal = project. property(' releaseVersion' )
260- }
261- else {
262- if (console) {
263- // prompt for `releaseVersion`
264- releaseVersionLocal = console. readLine(' > Enter the release version: ' )
265- }
266- else {
267- throw new GradleException (
268- " `release`-related tasks require the following properties: 'releaseVersion', 'developmentVersion'"
269- )
270- }
271- }
272-
273- if (project. hasProperty(' developmentVersion' )) {
274- developmentVersionLocal = project. property(' developmentVersion' )
275- }
276- else {
277- if (console) {
278- // prompt for `developmentVersion`
279- developmentVersionLocal = console. readLine(' > Enter the next development version: ' )
280- }
281- else {
282- throw new GradleException (
283- " `release`-related tasks require the following properties: 'releaseVersion', 'developmentVersion'"
284- )
285- }
286- }
287-
288- assert releaseVersionLocal != null && developmentVersionLocal != null
289-
290- // set up information for the release-related tasks
291- project. ext {
292- releaseVersion = releaseVersionLocal
293- developmentVersion = developmentVersionLocal
294- createTag = ! project. hasProperty(' noTag' )
295- releaseTag = project. createTag ? determineReleaseTag(releaseVersionLocal) : ' '
296- }
297- }
298- }
299-
300- static String determineReleaseTag (String releaseVersion ) {
301- return releaseVersion. endsWith( ' .Final' )
302- ? releaseVersion. replace( " .Final" , " " )
303- : releaseVersion
62+ // Render the Documentation/Javadocs and move them to the staging directory (for JReleaser):
63+ dependsOn updateDocumentationTask
64+ // Create all the published artifacts (i.e. jars) and move them to the staging directory (for JReleaser):
65+ // this one is defined in the publish.gradle
66+ // dependsOn project.getTasksByName(publishAllPublicationsToStagingRepository, false)
30467}
0 commit comments