Skip to content

Commit 60ff229

Browse files
committed
HHH-18912 - Fix ORM release process
1 parent 9eb6cdd commit 60ff229

File tree

1 file changed

+19
-28
lines changed

1 file changed

+19
-28
lines changed

build.gradle

Lines changed: 19 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ plugins {
3939

4040
apply from: file( 'gradle/module.gradle' )
4141

42+
4243
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
4344
// Release Task
4445

@@ -61,19 +62,23 @@ task publish {
6162
"themselves if they have any publish-related activities to perform"
6263
}
6364

64-
ext {
65-
if ( project.hasProperty( 'hibernatePublishUsername' ) ) {
66-
if ( ! project.hasProperty( 'hibernatePublishPassword' ) ) {
67-
throw new GradleException( "Should specify both `hibernatePublishUsername` and `hibernatePublishPassword` as project properties" );
68-
}
65+
66+
67+
def ossrhUsername = extractPropertyOrSetting( "OSSRH_USER" )
68+
def ossrhPassword = extractPropertyOrSetting( "OSSRH_PASSWORD" )
69+
70+
String extractPropertyOrSetting(String name) {
71+
if ( project.hasProperty( name) ) {
72+
return project.property( name )
6973
}
74+
return System.getProperty( name )
7075
}
7176

7277
nexusPublishing {
7378
repositories {
7479
sonatype {
75-
username = project.hasProperty( 'hibernatePublishUsername' ) ? project.property( 'hibernatePublishUsername' ) : null
76-
password = project.hasProperty( 'hibernatePublishPassword' ) ? project.property( 'hibernatePublishPassword' ) : null
80+
username = ossrhUsername
81+
password = ossrhPassword
7782
}
7883
}
7984
}
@@ -82,26 +87,15 @@ gradle.taskGraph.addTaskExecutionGraphListener(
8287
new TaskExecutionGraphListener() {
8388
@Override
8489
void graphPopulated(TaskExecutionGraph graph) {
85-
String[] tasksToLookFor = [
86-
'publish',
87-
'publishToSonatype',
88-
'publishAllPublicationsToSonatype',
89-
'publishPublishedArtifactsPublicationToSonatypeRepository',
90-
'publishRelocationArtifactsPublicationToSonatypeRepository',
91-
]
92-
93-
for ( String taskToLookFor : tasksToLookFor ) {
94-
if ( graph.hasTask( taskToLookFor ) ) {
95-
// trying to publish - make sure the needed credentials are available
96-
97-
if ( project.property( 'hibernatePublishUsername' ) == null ) {
98-
throw new RuntimeException( "`-PhibernatePublishUsername=...` not found" )
90+
for ( final def task in graph.allTasks ) {
91+
if ( task instanceof PublishToMavenRepository ) {
92+
if ( ossrhUsername == null ) {
93+
throw new RuntimeException( "OSSRH username not specified, but publishing was requested" )
9994
}
100-
if ( project.property( 'hibernatePublishPassword' ) == null ) {
101-
throw new RuntimeException( "`-PhibernatePublishPassword=...` not found" )
95+
if ( ossrhPassword == null ) {
96+
throw new RuntimeException( "OSSRH password not specified, but publishing was requested" )
10297
}
103-
104-
break;
98+
break
10599
}
106100
}
107101
}
@@ -139,6 +133,3 @@ idea {
139133
name = "hibernate-orm"
140134
}
141135
}
142-
143-
144-

0 commit comments

Comments
 (0)