From ac8a212393972723b19a2ae369eb9c0f94cebea1 Mon Sep 17 00:00:00 2001 From: Steve Ebersole Date: Wed, 4 Aug 2021 11:17:25 -0500 Subject: [PATCH] plugin publishing tokens --- .../hibernate-gradle-plugin.gradle | 32 ++++++++++--------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/tooling/hibernate-gradle-plugin/hibernate-gradle-plugin.gradle b/tooling/hibernate-gradle-plugin/hibernate-gradle-plugin.gradle index c4a9be9310..5568e3edbb 100644 --- a/tooling/hibernate-gradle-plugin/hibernate-gradle-plugin.gradle +++ b/tooling/hibernate-gradle-plugin/hibernate-gradle-plugin.gradle @@ -107,22 +107,24 @@ afterEvaluate { } gradle.taskGraph.whenReady { tg -> - // look for sys-prop or env-var overrides of the tokens used for publishing - if ( System.properties.containsKey( 'gradle.publish.key' ) - || System.properties.containsKey( 'gradle.publish.secret' ) - || System.getenv().containsKey( 'GRADLE_PUBLISH_KEY' ) - || System.getenv().containsKey( 'GRADLE_PUBLISH_SECRET' ) ) { - // nothing to do - already explicitly set - } - else { - // use the values from the credentials provider, if any - if ( credentials.hibernatePluginPortalUsername == null ) { - throw new RuntimeException( "`hibernatePluginPortalUsername` not found" ) + if ( tg.hasTask( project.tasks.publishPlugins ) ) { + // look for sys-prop or env-var overrides of the tokens used for publishing + if ( System.properties.containsKey( 'gradle.publish.key' ) + || System.properties.containsKey( 'gradle.publish.secret' ) + || System.getenv().containsKey( 'GRADLE_PUBLISH_KEY' ) + || System.getenv().containsKey( 'GRADLE_PUBLISH_SECRET' ) ) { + // nothing to do - already explicitly set } - if ( credentials.hibernatePluginPortalPassword == null ) { - throw new RuntimeException( "`hibernatePluginPortalPassword` not found" ) + else { + // use the values from the credentials provider, if any + if ( credentials.hibernatePluginPortalUsername == null ) { + throw new RuntimeException( "`hibernatePluginPortalUsername` not found" ) + } + if ( credentials.hibernatePluginPortalPassword == null ) { + throw new RuntimeException( "`hibernatePluginPortalPassword` not found" ) + } + System.setProperty( 'gradle.publish.key', credentials.hibernatePluginPortalUsername ) + System.setProperty( 'gradle.publish.secret', credentials.hibernatePluginPortalPassword ) } - System.setProperty( 'gradle.publish.key', credentials.hibernatePluginPortalUsername ) - System.setProperty( 'gradle.publish.secret', credentials.hibernatePluginPortalPassword ) } } \ No newline at end of file