hibernate-orm/release/release.gradle

745 lines
24 KiB
Groovy
Raw Normal View History

import java.nio.charset.StandardCharsets
2021-09-27 08:09:29 -04:00
import java.util.function.Function
import groovy.json.JsonSlurper
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
apply from: rootProject.file( 'gradle/module.gradle' )
apply plugin: 'org.hibernate.orm.build.doc-pub'
2023-08-07 21:05:47 -04:00
apply plugin: 'org.hibernate.orm.build.jdks'
apply plugin: 'idea'
idea.module {
}
configurations {
core
2021-09-27 08:09:29 -04:00
testing
envers
spatial
agroal
c3p0
hikaricp
proxool
vibur
jcache
jpamodelgen
2021-09-27 08:09:29 -04:00
javadocClasspath {
description = 'Class files for the javadoc to be built'
resolutionStrategy.capabilitiesResolution.withCapability('org.junit.jupiter:junit-jupiter-params:5.7.1') { details ->
details.select( details.candidates.first() ).because( 'first' )
}
extendsFrom core
extendsFrom testing
extendsFrom envers
extendsFrom spatial
extendsFrom agroal
extendsFrom c3p0
extendsFrom hikaricp
extendsFrom proxool
extendsFrom vibur
extendsFrom jcache
extendsFrom jpamodelgen
}
javadocSources {
description = 'Source files to be built by the javadoc tool'
}
}
2021-10-29 16:55:50 -04:00
// skip building this when `build` task is run from root, as many of our CI jobs do
tasks.build.dependsOn.clear()
dependencies {
2021-09-27 08:09:29 -04:00
attributesSchema { schema ->
schema.attribute(Bundling.BUNDLING_ATTRIBUTE) { matchStrategy ->
final def nameComparator = Comparator.comparing(
new Function<Bundling,String>() {
@Override
String apply(Bundling o) {
return o.name
}
}
)
matchStrategy.ordered(new Comparator<Bundling>() {
@Override
int compare(Bundling o1, Bundling o2) {
if ( Objects.equals( o1, o2 ) ) {
return 0;
}
if ( o1 == null ) {
return 1;
}
if ( o2 == null ) {
return -1;
}
if ( o1.name == Bundling.EMBEDDED ) {
return -1;
}
if ( o2.name == Bundling.EMBEDDED ) {
return 1;
}
return nameComparator.compare(o1,o2)
}
} )
}
}
core project( ':hibernate-core' )
2021-09-27 08:09:29 -04:00
javadocSources project( path: ':hibernate-core', configuration: 'javadocSources' )
testing project( ':hibernate-testing' )
javadocSources project( path: ':hibernate-testing', configuration: 'javadocSources' )
envers project( ':hibernate-envers' )
2021-09-27 08:09:29 -04:00
javadocSources project( path: ':hibernate-envers', configuration: 'javadocSources' )
spatial project( ':hibernate-spatial' )
2021-09-27 08:09:29 -04:00
javadocSources project( path: ':hibernate-spatial', configuration: 'javadocSources' )
agroal project( ':hibernate-agroal' )
2021-09-27 08:09:29 -04:00
javadocSources project( path: ':hibernate-agroal', configuration: 'javadocSources' )
c3p0 project( ':hibernate-c3p0' )
2021-09-27 08:09:29 -04:00
javadocSources project( path: ':hibernate-c3p0', configuration: 'javadocSources' )
hikaricp project( ':hibernate-hikaricp' )
2021-09-27 08:09:29 -04:00
javadocSources project( path: ':hibernate-hikaricp', configuration: 'javadocSources' )
proxool project( ':hibernate-proxool' )
2021-09-27 08:09:29 -04:00
javadocSources project( path: ':hibernate-proxool', configuration: 'javadocSources' )
vibur project( ':hibernate-vibur' )
2021-09-27 08:09:29 -04:00
javadocSources project( path: ':hibernate-vibur', configuration: 'javadocSources' )
jcache project( ':hibernate-jcache' )
javadocSources project( path: ':hibernate-jcache', configuration: 'javadocSources' )
jpamodelgen project( ':hibernate-jpamodelgen' )
2021-09-27 08:09:29 -04:00
javadocSources project( path: ':hibernate-jpamodelgen', configuration: 'javadocSources' )
javadocClasspath libs.loggingAnnotations
javadocClasspath jakartaLibs.validation
javadocClasspath jakartaLibs.cdi
javadocClasspath jakartaLibs.jacc
javadocClasspath jakartaLibs.jsonbApi
javadocClasspath libs.ant
javadocClasspath dbLibs.postgresql
javadocClasspath libs.jackson
2021-09-27 08:09:29 -04:00
javadocClasspath gradleApi()
javadocClasspath libs.jacksonXml
javadocClasspath dbLibs.oracle
}
2021-09-27 08:09:29 -04:00
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// aggregated JavaDoc
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
final File javadocDir = mkdir( new File( (File) project.buildDir, 'documentation/javadocs' ) );
/**
2021-09-27 08:09:29 -04:00
* Builds the JavaDocs aggregated (unified) across all the sub-projects
*/
2021-09-27 08:09:29 -04:00
task aggregateJavadocs(type: Javadoc) {
description = 'Builds an aggregated JavaDoc across all ORM sub-projects'
final int currentYear = new GregorianCalendar().get( Calendar.YEAR )
source configurations.javadocSources
classpath += configurations.javadocClasspath
// exclude any generated sources and internal packages
exclude '**/generated-src/**'
exclude '**/internal/**'
include '**/*.java'
// apply standard config
maxMemory = '512m'
destinationDir = javadocDir
configure( options ) {
overview = 'src/release/javadoc/overview.html'
stylesheetFile = new File(projectDir, 'src/release/javadoc/stylesheet.css')
2021-09-27 08:09:29 -04:00
windowTitle = 'Hibernate JavaDocs'
docTitle = "Hibernate JavaDoc ($project.version)"
bottom = "Copyright &copy; 2001-$currentYear <a href=\"https://redhat.com\">Red Hat, Inc.</a> All Rights Reserved."
use = true
options.encoding = 'UTF-8'
links = [
2021-12-02 17:46:09 -05:00
'https://docs.oracle.com/en/java/javase/11/docs/api/',
2021-09-27 08:09:29 -04:00
'https://docs.jboss.org/hibernate/beanvalidation/spec/2.0/api/',
'https://docs.jboss.org/cdi/api/2.0/',
2021-12-02 17:46:09 -05:00
'https://jakarta.ee/specifications/platform/8/apidocs/'
2021-09-27 08:09:29 -04:00
]
options.addStringOption( 'Xdoclint:none', '-quiet' )
2023-08-07 21:05:47 -04:00
if ( jdkVersions.explicit ) {
2021-09-27 08:09:29 -04:00
options.setJFlags( getProperty( 'toolchain.javadoc.jvmargs' ).toString().
split( ' ' ).toList().findAll( { !it.isEmpty() } ) )
}
}
2023-08-07 21:05:47 -04:00
if ( jdkVersions.explicit ) {
2021-09-27 08:09:29 -04:00
// Display version of Java tools
doFirst {
2021-09-29 03:16:35 -04:00
if ( javadocTool.present ) {
logger.lifecycle "Aggregating javadoc with '${javadocTool.get().metadata.installationPath}'"
}
2021-09-27 08:09:29 -04:00
}
}
}
task stageIntegrationGuide(type: Copy) {
2021-05-14 18:31:28 -04:00
group 'Release'
2022-03-31 12:01:06 -04:00
dependsOn ':documentation:renderIntegrationGuide'
2021-09-27 08:09:29 -04:00
from "${project( ':documentation' ).buildDir}/asciidoc/integrationguide"
into "${buildDir}/documentation/integrationguide"
2021-09-27 08:09:29 -04:00
}
2021-07-19 11:38:41 -04:00
2021-09-27 08:09:29 -04:00
task stageQuickstart(type: Copy) {
group 'Release'
2022-03-31 12:01:06 -04:00
dependsOn ':documentation:renderGettingStartedGuides'
2021-09-27 08:09:29 -04:00
from "${project( ':documentation' ).buildDir}/asciidoc/quickstart"
into "${buildDir}/documentation/quickstart"
2021-09-27 08:09:29 -04:00
}
2021-07-19 11:38:41 -04:00
2021-09-27 08:09:29 -04:00
task stageTopicalGuide(type: Copy) {
group 'Release'
2022-03-31 12:01:06 -04:00
dependsOn ':documentation:renderTopicalGuides'
2021-09-27 08:09:29 -04:00
from "${project( ':documentation' ).buildDir}/asciidoc/topical"
into "${buildDir}/documentation/topical"
2021-09-27 08:09:29 -04:00
}
task stageIntroduction(type: Copy) {
group 'Release'
dependsOn ':documentation:renderIntroduction', ':documentation:renderIntroductionPdf'
from "${project( ':documentation' ).buildDir}/asciidoc/introduction"
into "${buildDir}/documentation/introduction"
}
2023-05-27 15:01:52 -04:00
task stageQL(type: Copy) {
group 'Release'
dependsOn ':documentation:renderQL', ':documentation:renderQLPdf'
2023-05-27 15:01:52 -04:00
from "${project( ':documentation' ).buildDir}/asciidoc/querylanguage"
into "${buildDir}/documentation/querylanguage"
}
2021-09-27 08:09:29 -04:00
task stageUserGuide(type: Copy) {
group 'Release'
2021-07-19 11:38:41 -04:00
2022-03-31 12:01:06 -04:00
dependsOn ':documentation:renderUserGuide'
2021-09-27 08:09:29 -04:00
from "${project( ':documentation' ).buildDir}/asciidoc/userguide"
into "${buildDir}/documentation/userguide"
2021-09-27 08:09:29 -04:00
}
2021-07-19 11:38:41 -04:00
task stageMigrationGuide(type: Copy) {
group 'Release'
2022-03-31 12:01:06 -04:00
dependsOn ':documentation:renderMigrationGuide'
2023-04-01 10:33:34 -04:00
from project(":documentation").layout.buildDirectory.dir("asciidoc/migration-guide")
into layout.buildDirectory.dir("documentation/migration-guide")
}
tasks.named( "publishMigrationGuide" ).configure {
dependsOn stageMigrationGuide
migrationGuideDirectory = project.layout.buildDirectory.dir("documentation/migration-guide")
}
2022-03-31 12:01:06 -04:00
task stageOrmReports {
group 'Release'
dependsOn ':documentation:generateHibernateReports'
}
task stageOrmIncubationReport(type: Copy) { task ->
group 'Release'
dependsOn ':documentation:generateIncubationReport'
tasks.stageOrmReports.dependsOn task
from project( ":documentation" ).tasks.generateIncubationReport.reportFileReferenceAccess
into "${buildDir}/documentation/incubating"
}
task stageOrmInternalsReport(type: Copy) { task ->
group 'Release'
dependsOn ':documentation:generateInternalsReport'
tasks.stageOrmReports.dependsOn task
from project( ":documentation" ).tasks.generateInternalsReport.reportFileReferenceAccess
into "${buildDir}/documentation/internals"
}
task stageOrmDeprecationReport(type: Copy) { task ->
group 'Release'
dependsOn ':documentation:generateDeprecationReport'
tasks.stageOrmReports.dependsOn task
from project( ":documentation" ).tasks.generateDeprecationReport.reportFileReferenceAccess
into "${buildDir}/documentation/deprecated"
}
2022-03-31 12:01:06 -04:00
task stageOrmLoggingReport(type: Copy) { task ->
group 'Release'
dependsOn ':documentation:renderLoggingReport'
tasks.stageOrmReports.dependsOn task
from project( ":documentation" ).tasks.renderLoggingReport.outputDir
into "${buildDir}/documentation/logging"
}
task stageOrmDialectReport(type: Copy) { task ->
group 'Release'
dependsOn ':documentation:renderDialectReport'
tasks.stageOrmReports.dependsOn task
from project( ":documentation" ).tasks.renderDialectReport.outputDir
into "${buildDir}/documentation/dialect"
}
2021-09-27 08:09:29 -04:00
/**
* Assembles all documentation into the {buildDir}/documentation directory.
*
* Depends on building the docs
*/
task assembleDocumentation {
group 'Release'
description 'Assembles all documentation into the {buildDir}/documentation directory'
dependsOn ':documentation:buildDocsForPublishing'
dependsOn tasks.aggregateJavadocs
dependsOn tasks.stageIntegrationGuide
dependsOn tasks.stageTopicalGuide
dependsOn tasks.stageQuickstart
dependsOn tasks.stageIntroduction
dependsOn tasks.stageQL
2021-09-27 08:09:29 -04:00
dependsOn tasks.stageUserGuide
dependsOn tasks.stageMigrationGuide
2022-03-31 12:01:06 -04:00
dependsOn tasks.stageOrmReports
}
//task assembleProjectTemplates(type:Copy, dependsOn: project( ":project-template" ).tasks.assembleDist) {
// def templateProject = project( ":project-template" )
// from templateProject.layout.buildDirectory.dir( "distributions" )
// into projectTemplateStagingDir
//}
tasks.uploadDocumentation {
2021-05-14 18:31:28 -04:00
dependsOn assembleDocumentation
doFirst {
if ( rootProject.ormVersion.isSnapshot ) {
logger.error( "Cannot perform upload of SNAPSHOT documentation" );
throw new RuntimeException( "Cannot perform upload of SNAPSHOT documentation" );
}
else {
logger.lifecycle( "Uploading documentation ..." )
}
}
doLast {
logger.lifecycle( 'Done uploading documentation' )
}
}
2021-05-14 18:31:28 -04:00
task releaseChecks {
group 'Release'
2021-05-18 16:50:10 -04:00
description 'Checks and preparation for release'
2021-05-14 18:31:28 -04:00
}
2022-05-16 06:11:48 -04:00
task preVerifyRelease{
group 'Release'
description 'Pre-verifies a release job execution (Run locally before a CI release)'
dependsOn clean
dependsOn assembleDocumentation
}
2021-05-14 18:31:28 -04:00
task changeLogFile {
group 'Release'
description 'Updates the changelog.txt file based on the change-log report from Jira'
2021-05-14 18:31:28 -04:00
dependsOn project.tasks.releaseChecks
2020-06-22 05:31:36 -04:00
doFirst {
2021-05-18 16:50:10 -04:00
logger.lifecycle( "Appending version `${project.releaseVersion}` to changelog..." )
ChangeLogFile.update( ormVersion.fullName );
2020-06-22 05:31:36 -04:00
}
}
2021-05-18 16:50:10 -04:00
task changeToReleaseVersion {
group 'Release'
description 'Updates `gradle/version.properties` file to the specified release-version'
2021-05-14 18:31:28 -04:00
dependsOn project.tasks.releaseChecks
doFirst {
2021-05-18 16:50:10 -04:00
logger.lifecycle( "Updating version-file to release-version : `${project.releaseVersion}`" )
updateVersionFile( project.releaseVersion )
}
}
2021-05-18 16:50:10 -04:00
task gitPreparationForRelease {
dependsOn changeLogFile
dependsOn changeToReleaseVersion
doLast {
logger.lifecycle( "Performing pre-steps Git commit : `${project.releaseVersion}`" )
executeGitCommand( 'add', '.' )
2021-05-18 16:50:10 -04:00
executeGitCommand( 'commit', '-m', "Pre-steps for release : `${project.ormVersion.fullName}`" )
}
}
task changeToDevelopmentVersion {
group 'Release'
description 'Updates `gradle/version.properties` file to the specified development-version'
dependsOn project.tasks.releaseChecks
doFirst {
logger.lifecycle( "Updating version-file to development-version : `${project.developmentVersion}`" )
updateVersionFile( project.developmentVersion )
}
}
2021-05-14 18:31:28 -04:00
2021-05-18 16:50:10 -04:00
task gitTasksAfterRelease {
dependsOn changeToDevelopmentVersion
doLast {
logger.lifecycle( "Performing pre-steps Git commit : `${project.releaseVersion}`" )
executeGitCommand( 'add', '.' )
executeGitCommand( 'commit', '-m', "Post-steps for release : `${project.ormVersion.fullName}`" )
if ( project.createTag ) {
2021-05-18 16:50:10 -04:00
logger.lifecycle("Tagging release : `${project.releaseTag}`...")
executeGitCommand( 'tag', '-a', project.releaseTag, '-m', "Release $project.ormVersion.fullName" )
2021-05-18 16:50:10 -04:00
}
}
}
void updateVersionFile(String version) {
logger.lifecycle( "Updating `gradle/version.properties` version to `${version}`" )
project.ormVersionFile.text = "hibernateVersion=${version}"
}
2021-05-14 18:31:28 -04:00
task publishReleaseArtifacts {
dependsOn releaseChecks
dependsOn uploadDocumentation
2021-05-18 16:50:10 -04:00
mustRunAfter gitPreparationForRelease
2021-05-14 18:31:28 -04:00
}
task release {
group 'Release'
description 'Performs a release on local check-out, including updating changelog and '
2021-05-18 16:50:10 -04:00
dependsOn gitPreparationForRelease
2021-05-14 18:31:28 -04:00
dependsOn publishReleaseArtifacts
2021-05-18 16:50:10 -04:00
finalizedBy gitTasksAfterRelease
2021-05-14 18:31:28 -04:00
}
2021-05-14 18:31:28 -04:00
task ciReleaseChecks {
dependsOn releaseChecks
}
2021-05-18 16:50:10 -04:00
task gitTasksAfterCiRelease {
dependsOn gitTasksAfterRelease
2021-05-14 18:31:28 -04:00
doLast {
2021-05-18 16:50:10 -04:00
if ( project.createTag ) {
logger.lifecycle( "Pushing branch and tag to remote `${project.gitRemote}`..." )
executeGitCommand( 'push', '--atomic', project.gitRemote , project.gitBranch, project.releaseTag )
}
else {
2021-05-18 16:50:10 -04:00
logger.lifecycle("Pushing branch to remote `${project.gitRemote}`..." )
executeGitCommand( 'push', project.gitRemote , project.gitBranch )
}
}
}
2021-05-18 16:50:10 -04:00
task ciRelease {
group 'Release'
description 'Performs a release: the hibernate version is set and the changelog.txt file updated, the changes are pushed to github, then the release is performed, tagged and the hibernate version is set to the development one.'
dependsOn ciReleaseChecks
dependsOn release
finalizedBy gitTasksAfterCiRelease
}
static String executeGitCommand(Object ... subcommand){
List<Object> command = ['git']
Collections.addAll( command, subcommand )
def proc = command.execute()
def code = proc.waitFor()
def stdout = inputStreamToString( proc.getInputStream() )
def stderr = inputStreamToString( proc.getErrorStream() )
if ( code != 0 ) {
throw new GradleException( "An error occurred while executing " + command + "\n\nstdout:\n" + stdout + "\n\nstderr:\n" + stderr )
}
return stdout
}
static String inputStreamToString(InputStream inputStream) {
inputStream.withCloseable { ins ->
new BufferedInputStream(ins).withCloseable { bis ->
new ByteArrayOutputStream().withCloseable { buf ->
int result = bis.read();
while (result != -1) {
buf.write((byte) result);
result = bis.read();
}
return buf.toString( StandardCharsets.UTF_8.name());
}
}
}
}
class ChangeLogFile {
// Get the Release Notes from Jira and add them to the Hibernate changelog.txt file
static void update(String releaseVersion) {
def text = ""
File changelog = new File( "changelog.txt" )
def newReleaseNoteBlock = getNewReleaseNoteBlock(releaseVersion)
changelog.eachLine {
line ->
if ( line.startsWith( "Note:" ) ) {
text += line + System.lineSeparator() + System.lineSeparator() + newReleaseNoteBlock
}
else {
text += line + System.lineSeparator()
}
}
changelog.text = text
}
// Get the Release Notes from Jira
static String getNewReleaseNoteBlock(String releaseVersion) {
def restReleaseVersion;
if ( releaseVersion.endsWith( ".Final" ) ) {
restReleaseVersion = releaseVersion.replace( ".Final", "" )
}
else {
restReleaseVersion = releaseVersion
}
def apiString = "https://hibernate.atlassian.net/rest/api/2/search/?jql=project=HHH%20AND%20fixVersion=${restReleaseVersion}%20order%20by%20issuetype%20ASC"
def apiUrl = new URL( apiString )
def jsonReleaseNotes = new JsonSlurper().parse( apiUrl )
def releaseDate = new Date().format( 'MMMM dd, YYYY' )
def versionId = getVersionId( jsonReleaseNotes, restReleaseVersion )
ReleaseNote releaseNotes = new ReleaseNote( releaseVersion, releaseDate, versionId )
def issuetype
jsonReleaseNotes.issues.each {
issue ->
if ( issuetype != issue.fields.issuetype.name ) {
issuetype = issue.fields.issuetype.name
releaseNotes.addEmptyLine();
releaseNotes.addLine( "** ${issue.fields.issuetype.name}" )
}
releaseNotes.addLine( " * [" + issue.key + "] - " + issue.fields.summary )
}
releaseNotes.addEmptyLine()
return releaseNotes.notes
}
private static getVersionId(jsonReleaseNotes, String restReleaseVersion) {
def fixVersions = jsonReleaseNotes.issues.get( 0 ).fields.fixVersions
for ( def fixVersion : fixVersions ) {
if ( fixVersion.name.equals( restReleaseVersion ) ) {
return fixVersion.id
}
}
throw new GradleException( "Unable to determine the version id of the current release." )
}
}
class ReleaseNote {
String notes;
String notesHeaderSeparator = "------------------------------------------------------------------------------------------------------------------------"
ReleaseNote(String releaseVersion, String releaseDate, String versionId) {
notes = "Changes in ${releaseVersion} (${releaseDate})" + System.lineSeparator()
addHeaderSeparator()
addEmptyLine()
addLine( "https://hibernate.atlassian.net/projects/HHH/versions/${versionId}" )
}
void addLine(String text) {
notes += text + System.lineSeparator()
}
void addHeaderSeparator() {
addLine( notesHeaderSeparator )
}
void addEmptyLine() {
notes += System.lineSeparator()
}
void addEmptyLines(int numberOfLines) {
for ( i in 1..numberOfLines ) {
notes += System.lineSeparator()
}
}
}
2021-05-14 18:31:28 -04:00
gradle.getTaskGraph().whenReady {tg->
if ( tg.hasTask( project.tasks.releaseChecks )
&& ! project.getGradle().getStartParameter().isDryRun() ) {
String releaseVersionLocal
String developmentVersionLocal
def console = tg.hasTask( project.tasks.ciReleaseChecks )
? null
: System.console()
if (project.hasProperty('releaseVersion')) {
releaseVersionLocal = project.property('releaseVersion')
}
else {
if (console) {
// prompt for `releaseVersion`
releaseVersionLocal = console.readLine('> Enter the release version: ')
}
else {
throw new GradleException(
"`release`-related tasks require the following properties: 'releaseVersion', 'developmentVersion'"
)
}
2021-05-14 18:31:28 -04:00
}
if (project.hasProperty('developmentVersion')) {
developmentVersionLocal = project.property('developmentVersion')
}
else {
if (console) {
// prompt for `developmentVersion`
developmentVersionLocal = console.readLine('> Enter the next development version: ')
}
else {
throw new GradleException(
"`release`-related tasks require the following properties: 'releaseVersion', 'developmentVersion'"
)
}
}
assert releaseVersionLocal != null && developmentVersionLocal != null;
2021-05-14 18:31:28 -04:00
// set up information for the release-related tasks
project.ext {
releaseVersion = releaseVersionLocal;
developmentVersion = developmentVersionLocal;
createTag = !project.hasProperty('noTag')
releaseTag = project.createTag ? determineReleaseTag(releaseVersionLocal) : ''
2021-05-14 18:31:28 -04:00
}
logger.lifecycle("Checking that the working tree is clean...")
String uncommittedFiles = executeGitCommand('status', '--porcelain')
if (!uncommittedFiles.isEmpty()) {
2021-05-14 18:31:28 -04:00
throw new GradleException(
"Cannot release because there are uncommitted or untracked files in the working tree.\n" +
"Commit or stash your changes first.\n" +
"Uncommitted files:\n " +
uncommittedFiles
);
}
if (tg.hasTask(project.tasks.ciReleaseChecks)) {
String gitBranchLocal
String gitRemoteLocal
2021-05-14 18:31:28 -04:00
if (project.hasProperty('gitBranch')) {
gitBranchLocal = project.property('gitBranch')
}
else {
gitBranchLocal = executeGitCommand( 'branch', '--show-current' )
}
2021-05-14 18:31:28 -04:00
if (project.hasProperty('gitRemote')) {
gitRemoteLocal = project.property('gitRemote')
}
else {
final String remotes = executeGitCommand( 'remote', 'show' )
final List<String> tokens = remotes.tokenize()
if ( tokens.size() != 1 ) {
throw new GradleException( "Could not determine `gitRemote` property for `ciRelease` tasks." )
}
gitRemoteLocal = tokens.get( 0 )
}
2021-05-14 18:31:28 -04:00
project.ext {
gitBranch = gitBranchLocal
gitRemote = gitRemoteLocal
}
2021-05-14 18:31:28 -04:00
logger.lifecycle("Switching to branch '${project.gitBranch}'...")
executeGitCommand('checkout', project.gitBranch)
logger.lifecycle("Checking that all commits are pushed...")
String diffWithUpstream = executeGitCommand('diff', '@{u}')
if (!diffWithUpstream.isEmpty()) {
throw new GradleException(
"Cannot perform `ciRelease` tasks because there are un-pushed local commits .\n" +
"Push your commits first."
);
}
2021-05-14 18:31:28 -04:00
}
}
}
static String determineReleaseTag(String releaseVersion) {
return releaseVersion.endsWith( '.Final' )
? releaseVersion.replace( ".Final", "" )
: releaseVersion;
}