ad-core-mavencentral.gradle 3.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. apply plugin: 'maven-publish'
  2. apply plugin: 'signing'
  3. def PUBLISH_VERSION = '1.0.2-SNAPSHOT'
  4. def PUBLISH_GROUP_ID = 'com.compdf'
  5. def PUBLISH_ARTIFACT_ID = 'ad-core'
  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('local.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/lib_ad_core-release.aar")
  35. // artifact(sourceJar)
  36. pom {
  37. name = PUBLISH_ARTIFACT_ID
  38. url = 'https://www.compdf.com/'
  39. developers {
  40. developer {
  41. id = 'compdfkit'
  42. name = 'compdfkit' //你的sonatype用户名
  43. email = 'youna@compdf.com' //你的sonatype注册邮箱
  44. }
  45. }
  46. withXml{
  47. def dependenciesNode = asNode().appendNode('dependencies')
  48. //Iterate over the compile dependencies (we don't want the test ones), adding a <dependency> node for each
  49. configurations.implementation.allDependencies.each {
  50. if(it.group != null && (it.name != null || "unspecified".equals(it.name)) && it.version != null)
  51. {
  52. def dependencyNode = dependenciesNode.appendNode('dependency')
  53. dependencyNode.appendNode('groupId', it.group)
  54. dependencyNode.appendNode('artifactId', it.name)
  55. dependencyNode.appendNode('version', it.version)
  56. }
  57. }
  58. }
  59. }
  60. }
  61. }
  62. repositories {
  63. maven {
  64. name = PUBLISH_ARTIFACT_ID
  65. def releasesRepoUrl = layout.buildDirectory.dir('repos/releases')
  66. def snapshotsRepoUrl = layout.buildDirectory.dir('repos/snapshots')
  67. // def releasesRepoUrl = "https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/"
  68. // def snapshotsRepoUrl = "https://s01.oss.sonatype.org/content/repositories/snapshots/"
  69. println("publish version:${PUBLISH_VERSION}")
  70. url = PUBLISH_VERSION.endsWith('SNAPSHOT') ? snapshotsRepoUrl : releasesRepoUrl
  71. credentials {
  72. username ossrhUsername
  73. password ossrhPassword
  74. }
  75. }
  76. }
  77. }
  78. }
  79. signing {
  80. sign publishing.publications
  81. }