1616 * These are shared settings common to all Google Ads Java library subprojects.
1717 */
1818
19+
1920import org.gradle.api.DefaultTask
2021import groovy.io.FileType
2122import groovy.io.FileVisitResult
@@ -55,8 +56,6 @@ javadoc {
5556 options. addStringOption(' Xdoclint:none' , ' -quiet' )
5657}
5758
58- final def sonatypeCredentialsConfig = file(System . properties[' user.home' ] + ' /.sonatype-creds' )
59-
6059publishing {
6160 publications {
6261 maven(MavenPublication ) {
@@ -67,14 +66,11 @@ publishing {
6766 maven {
6867 url ' https://oss.sonatype.org/service/local/staging/deploy/maven2'
6968 name = " sonatype"
70-
71- if (sonatypeCredentialsConfig. exists()) {
72- def props = new Properties ()
73- sonatypeCredentialsConfig. withInputStream { props. load(it) }
74- credentials {
75- username props[' username' ]
76- password props[' password' ]
77- }
69+ credentials {
70+ // Avoids storing Sonatype credentials in plain-text. Specify these on
71+ // the command line: -PsonatypeUser=foo
72+ username project. properties. get(" sonatypeUser" )
73+ password project. properties. get(" sonatypePassword" )
7874 }
7975 }
8076 }
@@ -84,8 +80,13 @@ publishing {
8480tasks. findAll {
8581 if (it. name. matches(" publish.+ToSonatypeRepository" )) {
8682 it. doFirst {
87- if (! sonatypeCredentialsConfig. exists()) {
88- throw new GradleException (" Unable to load Sonatype credentials from ${ sonatypeCredentialsConfig} ." )
83+ def user = project. properties. get(" sonatypeUser" )
84+ def pass = project. properties. get(" sonatypePassword" )
85+ if (user == null || user. length() == 0 ) {
86+ throw new GradleException (" Missing property for sonatype username, try -PsonatypeUser=foo" )
87+ }
88+ if (pass == null || pass. length() == 0 ) {
89+ throw new GradleException (" Missing property for sonatype password, try -PsonatypePassword=foo" )
8990 }
9091 }
9192 }
0 commit comments