publish-root.gradle 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. // Create variables with empty default values
  2. ext["signing.keyId"] = ''
  3. ext["signing.password"] = ''
  4. ext["signing.key"] = ''
  5. ext["ossrhGroupId"] = ''
  6. ext["ossrhUsername"] = ''
  7. ext["ossrhPassword"] = ''
  8. ext["sonatypeStagingProfileId"] = ''
  9. File secretPropsFile = project.rootProject.file('local.properties')
  10. if (secretPropsFile.exists()) {
  11. // Read local.properties file first if it exists
  12. Properties p = new Properties()
  13. new FileInputStream(secretPropsFile).withCloseable { is -> p.load(is) }
  14. p.each { name, value -> ext[name] = value }
  15. } else {
  16. // Use system environment variables
  17. ext["ossrhGroupId"] = System.getenv('OSSRH_GROUP_ID')
  18. ext["ossrhUsername"] = System.getenv('OSSRH_USERNAME')
  19. ext["ossrhPassword"] = System.getenv('OSSRH_PASSWORD')
  20. ext["sonatypeStagingProfileId"] = System.getenv('SONATYPE_STAGING_PROFILE_ID')
  21. ext["signing.keyId"] = System.getenv('SIGNING_KEY_ID')
  22. ext["signing.password"] = System.getenv('SIGNING_PASSWORD')
  23. ext["signing.key"] = System.getenv('SIGNING_KEY')
  24. }
  25. // Set up Sonatype repository
  26. nexusPublishing {
  27. repositories {
  28. sonatype {
  29. stagingProfileId = sonatypeStagingProfileId
  30. username = ossrhUsername
  31. password = ossrhPassword
  32. nexusUrl.set(uri("https://ossrh-staging-api.central.sonatype.com/service/local/"))
  33. snapshotRepositoryUrl.set(uri("https://central.sonatype.com/repository/maven-snapshots/"))
  34. }
  35. }
  36. }