Skip to content

Commit 143f9cc

Browse files
committed
fix
1 parent 58d3d57 commit 143f9cc

File tree

1 file changed

+72
-13
lines changed

1 file changed

+72
-13
lines changed

release/build.gradle

Lines changed: 72 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import java.nio.charset.StandardCharsets
33
ext {
44
// Select which repository to use for publishing the documentation
55
// Example:
6-
// ./gradlew publishDocumentation \
6+
// ./gradlew uploadDocumentation \
77
// -PdocPublishRepoUri="[email protected]:DavideD/hibernate.org.git" \
88
// -PdocPublishBranch="staging"
99
if ( !project.hasProperty('docPublishRepoUri') ) {
@@ -22,7 +22,7 @@ description = 'Release module'
2222
// To publish the documentation:
2323
// 1. Add the relevant SSH key to your SSH agent.
2424
// 2. Execute this:
25-
// ./gradlew publishDocumentation -PdocPublishBranch=production
25+
// ./gradlew uploadDocumentation -PdocPublishBranch=production
2626

2727
// To tag a version and trigger a release on CI (which will include publishing to Bintray and publishing documentation):
2828
// ./gradlew ciRelease -PreleaseVersion=x.y.z.Final -PdevelopmentVersion=x.y.z-SNAPSHOT -PgitRemote=origin -PgitBranch=main
@@ -115,7 +115,7 @@ def pushDocChangesTask = tasks.register( 'pushDocChanges', Exec ) {
115115
commandLine 'git', 'push', '--atomic', 'origin', docPublishBranch
116116
}
117117

118-
def publishDocumentationTask = tasks.register( 'publishDocumentation' ) {
118+
def uploadDocumentationTask = tasks.register( 'uploadDocumentation' ) {
119119
description "Upload documentation on the website"
120120
dependsOn pushDocChangesTask
121121
group "Release"
@@ -244,17 +244,7 @@ def pushChangesTask = tasks.register( "pushChanges" ) {
244244
}
245245
}
246246

247-
def releasePerformTask = tasks.register( 'releasePerform' ) {
248-
group 'Release'
249-
description 'Performs a release on local check-out, including updating changelog and '
250-
251-
dependsOn publishReleaseArtifactsTask
252-
253-
finalizedBy releasePerformPostGitTask
254-
}
255-
256247
def releasePerformPostGitTask = tasks.register( 'gitTasksAfterReleasePerform' ) {
257-
258248
doLast {
259249
if ( project.createTag ) {
260250
logger.lifecycle( "Pushing branch and tag to remote `${project.gitRemote}`..." )
@@ -267,6 +257,16 @@ def releasePerformPostGitTask = tasks.register( 'gitTasksAfterReleasePerform' )
267257
}
268258
}
269259

260+
def releasePerformTask = tasks.register( 'releasePerform' ) {
261+
group 'Release'
262+
description 'Performs a release on local check-out, including updating changelog and '
263+
264+
mustRunAfter releasePrepareTask
265+
dependsOn uploadDocumentationTask
266+
267+
finalizedBy releasePerformPostGitTask
268+
}
269+
270270
/*
271271
* Release everything
272272
*/
@@ -303,3 +303,62 @@ static String inputStreamToString(InputStream inputStream) {
303303
}
304304
}
305305
}
306+
307+
gradle.getTaskGraph().whenReady {tg->
308+
309+
if ( ( tg.hasTask( project.tasks.releasePrepare ) || tg.hasTask( project.tasks.releasePerform ) )
310+
&& ! project.getGradle().getStartParameter().isDryRun() ) {
311+
String releaseVersionLocal
312+
String developmentVersionLocal
313+
314+
def console = tg.hasTask( project.tasks.release ) && !tg.hasTask( project.tasks.ciRelease )
315+
? System.console()
316+
: null
317+
318+
if (project.hasProperty('releaseVersion')) {
319+
releaseVersionLocal = project.property('releaseVersion')
320+
}
321+
else {
322+
if (console) {
323+
// prompt for `releaseVersion`
324+
releaseVersionLocal = console.readLine('> Enter the release version: ')
325+
}
326+
else {
327+
throw new GradleException(
328+
"`release`-related tasks require the following properties: 'releaseVersion', 'developmentVersion'"
329+
)
330+
}
331+
}
332+
333+
if (project.hasProperty('developmentVersion')) {
334+
developmentVersionLocal = project.property('developmentVersion')
335+
}
336+
else {
337+
if (console) {
338+
// prompt for `developmentVersion`
339+
developmentVersionLocal = console.readLine('> Enter the next development version: ')
340+
}
341+
else {
342+
throw new GradleException(
343+
"`release`-related tasks require the following properties: 'releaseVersion', 'developmentVersion'"
344+
)
345+
}
346+
}
347+
348+
assert releaseVersionLocal != null && developmentVersionLocal != null;
349+
350+
// set up information for the release-related tasks
351+
project.ext {
352+
releaseVersion = releaseVersionLocal;
353+
developmentVersion = developmentVersionLocal;
354+
createTag = !project.hasProperty('noTag')
355+
releaseTag = project.createTag ? determineReleaseTag(releaseVersionLocal) : ''
356+
}
357+
}
358+
}
359+
360+
static String determineReleaseTag(String releaseVersion) {
361+
return releaseVersion.endsWith( '.Final' )
362+
? releaseVersion.replace( ".Final", "" )
363+
: releaseVersion;
364+
}

0 commit comments

Comments
 (0)