Skip to content

Commit

Permalink
HHH-15765 Get rid of the credentials plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
beikov committed Nov 28, 2022
1 parent 3df0674 commit 4b2492c
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 25 deletions.
23 changes: 6 additions & 17 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ plugins {
id 'org.hibernate.orm.database-service' apply false

id 'io.github.gradle-nexus.publish-plugin' version '1.1.0'
id 'nu.studer.credentials' version '3.0'

id 'idea'
id 'org.jetbrains.gradle.plugin.idea-ext' version '1.0'
Expand Down Expand Up @@ -60,28 +59,18 @@ task publish {
}

ext {
// look for command-line overrides of the username/password pairs for publishing
if ( project.hasProperty( 'hibernatePublishUsername' ) ) {
if ( ! project.hasProperty( 'hibernatePublishPassword' ) ) {
throw new GradleException( "Should specify both `hibernatePublishUsername` and `hibernatePublishPassword` as project properties" );
}
credentials.hibernatePublishUsername = project.property( 'hibernatePublishUsername' )
credentials.hibernatePublishPassword = project.property( 'hibernatePublishPassword' )
}
else if ( System.properties.hibernatePublishUsername != null ) {
if ( System.properties.hibernatePublishPassword == null ) {
throw new GradleException( "Should specify both `hibernatePublishUsername` and `hibernatePublishPassword` as system properties" );
}
credentials.hibernatePublishUsername = System.properties.hibernatePublishUsername
credentials.hibernatePublishPassword = System.properties.hibernatePublishPassword
}
}

nexusPublishing {
repositories {
sonatype {
username = credentials.forKey( 'hibernatePublishUsername' )
password = credentials.forKey( 'hibernatePublishPassword' )
username = project.property( 'hibernatePublishUsername' )
password = project.property( 'hibernatePublishPassword' )
}
}
}
Expand All @@ -102,11 +91,11 @@ gradle.taskGraph.addTaskExecutionGraphListener(
if ( graph.hasTask( taskToLookFor ) ) {
// trying to publish - make sure the needed credentials are available

if ( credentials.forKey( 'hibernatePublishUsername' ) == null ) {
throw new GradleException( "Publishing credentials not specified" );
if ( project.property( 'hibernatePublishUsername' ) == null ) {
throw new RuntimeException( "`-PhibernatePublishUsername=...` not found" )
}
if ( credentials.forKey( 'hibernatePublishPassword' ) == null ) {
throw new GradleException( "Publishing credentials not specified" );
if ( project.property( 'hibernatePublishPassword' ) == null ) {
throw new RuntimeException( "`-PhibernatePublishPassword=...` not found" )
}

break;
Expand Down
4 changes: 2 additions & 2 deletions ci/snapshot-publish.Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ pipeline {
sh '''./gradlew clean publish \
-PhibernatePublishUsername=$hibernatePublishUsername \
-PhibernatePublishPassword=$hibernatePublishPassword \
-PhibernatePluginPortalUsername=$hibernatePluginPortalUsername \
-PhibernatePluginPortalPassword=$hibernatePluginPortalPassword \
-Pgradle.publish.key=$hibernatePluginPortalUsername \
-Pgradle.publish.secret=$hibernatePluginPortalPassword \
--no-scan \
-DsigningPassword=$SIGNING_PASS \
-DsigningKeyFile=$SIGNING_KEYRING \
Expand Down
10 changes: 4 additions & 6 deletions tooling/hibernate-gradle-plugin/hibernate-gradle-plugin.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -154,14 +154,12 @@ gradle.taskGraph.whenReady { tg ->
}
else {
// use the values from the credentials provider, if any
if ( credentials.forKey( 'hibernatePluginPortalUsername' ) == null ) {
throw new RuntimeException( "`hibernatePluginPortalUsername` not found" )
if ( project.property( 'gradle.publish.key' ) == null ) {
throw new RuntimeException( "`-Pgradle.publish.key=...` not found" )
}
if ( credentials.forKey( 'hibernatePluginPortalPassword' ) == null ) {
throw new RuntimeException( "`hibernatePluginPortalPassword` not found" )
if ( project.property( 'gradle.publish.secret' ) == null ) {
throw new RuntimeException( "`-Pgradle.publish.secret=...` not found" )
}
System.setProperty( 'gradle.publish.key', credentials.forKey( 'hibernatePluginPortalUsername' ) )
System.setProperty( 'gradle.publish.secret', credentials.forKey( 'hibernatePluginPortalPassword') )
}
}
}

0 comments on commit 4b2492c

Please sign in to comment.