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