publishing.gradle 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. // JReleaser config for release builds to Central Portal
  2. if (project.hasProperty('RELEASE')) {
  3. apply plugin: 'org.jreleaser'
  4. jreleaser {
  5. deploy {
  6. maven {
  7. mavenCentral {
  8. sonatype {
  9. active = 'ALWAYS'
  10. username = getRepositoryUsername()
  11. password = getRepositoryPassword()
  12. url = 'https://central.sonatype.com/api/v1/publisher'
  13. stagingRepository("${buildDir}/staging-deploy")
  14. sign = false
  15. verifyPom = false
  16. }
  17. }
  18. }
  19. }
  20. }
  21. }
  22. project("spine-libgdx") {
  23. apply plugin: "java-library"
  24. apply plugin: "maven-publish"
  25. apply plugin: "signing"
  26. dependencies {
  27. implementation "com.badlogicgames.gdx:gdx:$libgdxVersion"
  28. }
  29. tasks.register("sourceJar", Jar) {
  30. archiveClassifier.set("sources")
  31. from(sourceSets.main.allJava)
  32. }
  33. tasks.javadoc {
  34. failOnError = false
  35. options.addStringOption('Xdoclint:none', '-quiet')
  36. }
  37. tasks.register("javadocJar", Jar) {
  38. dependsOn javadoc
  39. archiveClassifier.set("javadoc")
  40. from(javadoc.destinationDir)
  41. }
  42. afterEvaluate {
  43. publishing {
  44. publications {
  45. create("release", MavenPublication) {
  46. from(components.java)
  47. artifact(tasks.getByName("sourceJar"))
  48. artifact(tasks.getByName("javadocJar"))
  49. groupId = "com.esotericsoftware.spine"
  50. artifactId = "spine-libgdx"
  51. version = project.version
  52. pom {
  53. packaging = "jar"
  54. name = POM_NAME
  55. if(!POM_DESCRIPTION.isEmpty())
  56. description = POM_DESCRIPTION
  57. url = POM_URL
  58. licenses {
  59. license {
  60. name = POM_LICENCE_NAME
  61. url = POM_LICENCE_URL
  62. distribution = POM_LICENCE_DIST
  63. }
  64. }
  65. developers {
  66. developer {
  67. name.set("Esoteric Software")
  68. email.set("[email protected]")
  69. }
  70. }
  71. scm {
  72. connection = POM_SCM_CONNECTION
  73. developerConnection = POM_SCM_DEV_CONNECTION
  74. url = POM_SCM_URL
  75. }
  76. }
  77. }
  78. }
  79. repositories {
  80. maven {
  81. name = "SonaType"
  82. url = project.version.endsWith("-SNAPSHOT")
  83. ? getSnapshotRepositoryUrl()
  84. // If release build, dump artifacts to root project build/staging-deploy folder for consumption by jreleaser
  85. : rootProject.layout.buildDirectory.dir('staging-deploy')
  86. if (project.version.endsWith("-SNAPSHOT") && (getRepositoryUsername() || getRepositoryPassword())) {
  87. credentials {
  88. username = getRepositoryUsername()
  89. password = getRepositoryPassword()
  90. }
  91. }
  92. }
  93. }
  94. }
  95. signing {
  96. useGpgCmd()
  97. sign(publishing.publications["release"])
  98. }
  99. // Simply using "required" in signing block doesn't work because taskGraph isn't ready yet.
  100. gradle.taskGraph.whenReady {
  101. tasks.withType(Sign) {
  102. onlyIf { !project.version.endsWith("-SNAPSHOT") }
  103. }
  104. }
  105. }
  106. }
  107. // JReleaser config for release builds to Central Portal
  108. if (project.hasProperty('RELEASE')) {
  109. apply plugin: 'org.jreleaser'
  110. jreleaser {
  111. deploy {
  112. maven {
  113. mavenCentral {
  114. sonatype {
  115. active = 'ALWAYS'
  116. username = getRepositoryUsername()
  117. password = getRepositoryPassword()
  118. url = 'https://central.sonatype.com/api/v1/publisher'
  119. stagingRepository("${rootProject.buildDir}/staging-deploy")
  120. sign = false
  121. verifyPom = false
  122. }
  123. }
  124. }
  125. }
  126. }
  127. // For release builds, create a task that depends on publishing and finalizes with jreleaser
  128. tasks.register('publishRelease') {
  129. dependsOn tasks.withType(PublishToMavenRepository)
  130. finalizedBy tasks.named('jreleaserDeploy')
  131. }
  132. }