compdfkit-tools-mavencentral.gradle 4.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. apply plugin: 'maven-publish'
  2. apply plugin: 'signing'
  3. def PUBLISH_VERSION = '2.0.0'
  4. def PUBLISH_GROUP_ID = 'com.compdf'
  5. def PUBLISH_ARTIFACT_ID = 'compdfkit-tools'
  6. ext["signing.keyId"] = '' //签名的密钥后8位
  7. ext["signing.password"] = '' //签名设置的密码
  8. ext["signing.secretKeyRingFile"] = '' //生成的secring.gpg文件目录
  9. ext["ossrhUsername"] = '' //sonatype用户名
  10. ext["ossrhPassword"] = '' //sonatype密码
  11. task sourceJar(type: Jar) {
  12. from android.sourceSets.main.java.srcDirs
  13. classifier "source"
  14. }
  15. File secretPropsFile = project.rootProject.file('maven.properties')
  16. if (secretPropsFile.exists()) {
  17. println "Found secret props file, loading props"
  18. Properties p = new Properties()
  19. p.load(new FileInputStream(secretPropsFile))
  20. p.each { name, value ->
  21. ext[name] = value
  22. }
  23. } else {
  24. println "No props file, loading env vars"
  25. }
  26. afterEvaluate {
  27. publishing {
  28. publications {
  29. release(MavenPublication) {
  30. println("publish-maven Log-------> PUBLISH_GROUP_ID: $PUBLISH_GROUP_ID; PUBLISH_ARTIFACT_ID: $PUBLISH_ARTIFACT_ID; PUBLISH_VERSION: $PUBLISH_VERSION")
  31. groupId PUBLISH_GROUP_ID
  32. artifactId PUBLISH_ARTIFACT_ID
  33. version = PUBLISH_VERSION
  34. artifact("$buildDir/outputs/aar/ComPDFKit_Tools-release.aar")
  35. // artifact(sourceJar)
  36. pom {
  37. name = PUBLISH_ARTIFACT_ID
  38. url = 'https://www.compdf.com/'
  39. description = 'ComPDFKit SDK for Android'
  40. developers {
  41. developer {
  42. id = 'compdfkit'
  43. name = 'compdfkit' //你的sonatype用户名
  44. email = 'youna@compdf.com' //你的sonatype注册邮箱
  45. }
  46. }
  47. licenses {
  48. license {
  49. name = 'ComPDFKit License'
  50. url = 'https://github.com/ComPDFKit/PDF-SDK-Android/blob/main/LICENSE'
  51. }
  52. }
  53. scm {
  54. connection = 'https://github.com/ComPDFKit/PDF-SDK-Android'
  55. developerConnection = 'https://github.com/ComPDFKit/PDF-SDK-Android'
  56. url = 'https://github.com/ComPDFKit/PDF-SDK-Android/tree/main'
  57. }
  58. withXml{
  59. def dependenciesNode = asNode().appendNode('dependencies')
  60. //Iterate over the compile dependencies (we don't want the test ones), adding a <dependency> node for each
  61. configurations.implementation.allDependencies.each {
  62. if(it.group != null && (it.name != null || "unspecified".equals(it.name)) && it.version != null)
  63. {
  64. def dependencyNode = dependenciesNode.appendNode('dependency')
  65. dependencyNode.appendNode('groupId', it.group)
  66. dependencyNode.appendNode('artifactId', it.name)
  67. dependencyNode.appendNode('version', it.version)
  68. }
  69. }
  70. }
  71. }
  72. }
  73. }
  74. repositories {
  75. maven {
  76. name = PUBLISH_ARTIFACT_ID
  77. def releasesRepoUrl = "https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/"
  78. def snapshotsRepoUrl = "https://s01.oss.sonatype.org/content/repositories/snapshots/"
  79. println("publish version:${PUBLISH_VERSION}")
  80. url = PUBLISH_VERSION.endsWith('SNAPSHOT') ? snapshotsRepoUrl : releasesRepoUrl
  81. credentials {
  82. username ossrhUsername
  83. password ossrhPassword
  84. }
  85. }
  86. }
  87. }
  88. }
  89. signing {
  90. sign publishing.publications
  91. }