publish.gradle 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. apply plugin: 'maven-publish'
  2. apply plugin: 'signing'
  3. ext {
  4. PUBLISH_GROUP_ID = 'io.github.yyxxgame.sdk'
  5. PUBLISH_ARTIFACT_ID = 'yyxx-comm-core'
  6. PUBLISH_VERSION = '3.0.304'
  7. }
  8. ext["signing.keyId"] = ''
  9. ext["signing.password"] = ''
  10. ext["signing.secretKeyRingFile"] = ''
  11. ext["ossrhUsername"] = ''
  12. ext["ossrhPassword"] = ''
  13. Properties properties = new Properties()
  14. properties.load(project.rootProject.file('local.properties').newDataInputStream())
  15. properties.each { name, value ->
  16. ext[name] = value
  17. }
  18. task androidSourcesJar(type: Jar) {
  19. archiveClassifier.set('source')
  20. if (project.plugins.findPlugin('com.android.library')) {
  21. from android.sourceSets.main.java.srcDirs
  22. } else {
  23. form sourceSets.main.java.srcDirs
  24. }
  25. exclude "**/R.class"
  26. exclude "**/BuildConfig.class"
  27. }
  28. publishing {
  29. publications {
  30. release(MavenPublication) {
  31. // The coordinates of the library, being set from variables that
  32. // we'll set up in a moment
  33. groupId PUBLISH_GROUP_ID
  34. artifactId PUBLISH_ARTIFACT_ID
  35. version PUBLISH_VERSION
  36. // Two artifacts, the `aar` and the sources
  37. artifact("$buildDir/outputs/aar/$PUBLISH_ARTIFACT_ID" + "-" + "$PUBLISH_VERSION"+ ".aar")
  38. artifact androidSourcesJar
  39. // Self-explanatory metadata for the most part
  40. pom {
  41. name = "${PUBLISH_GROUP_ID}${PUBLISH_ARTIFACT_ID}"
  42. description = 'game comm sdk of yyxx_comm'
  43. // If your project has a dedicated site, use its URL here
  44. url = 'https://github.com/yyxxgame'
  45. licenses {
  46. license {
  47. // 协议类型,一般默认Apache License2.0的话不用改:
  48. name = 'The Apache License, Version 2.0'
  49. url = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
  50. }
  51. }
  52. developers {
  53. developer {
  54. id = 'yyxxgame'
  55. name = 'yyxxgame'
  56. email = 'developcentre@yyxxgame.com'
  57. }
  58. }
  59. // Version control info, if you're using GitHub, follow the format as seen here
  60. scm {
  61. //修改成你的Git地址:
  62. connection = 'scm:git:gogs.yyxxgame.com:3000/Client/YYXXCommSdk.git'
  63. developerConnection = 'scm:git:ssh://gogs.yyxxgame.com:3000/Client/YYXXCommSdk.git'
  64. //分支地址:
  65. url = 'http://gogs.yyxxgame.com:3000/Client/YYXXCommSdk.git'
  66. }
  67. // A slightly hacky fix so that your POM will include any transitive dependencies
  68. // that your library builds upon
  69. withXml {
  70. def dependenciesNode = asNode().appendNode('dependencies')
  71. for (def node : project.configurations.implementation.allDependencies) {
  72. if (node.group == "null" || node.name == "unspecified" || node.version == "null") {
  73. break
  74. }
  75. def dependencyNode = dependenciesNode.appendNode('dependency')
  76. dependencyNode.appendNode('groupId', node.group)
  77. dependencyNode.appendNode('artifactId', node.name)
  78. dependencyNode.appendNode('version', node.version)
  79. }
  80. }
  81. }
  82. }
  83. }
  84. repositories {
  85. // The repository to publish to, Sonatype/MavenCentral
  86. maven {
  87. // This is an arbitrary name, you may also use "mavencentral" or
  88. // any other name that's descriptive for you
  89. name = "mavencentral"
  90. def releasesRepoUrl = "https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/"
  91. def snapshotsRepoUrl = "https://s01.oss.sonatype.org/content/repositories/snapshots/"
  92. // You only need this if you want to publish snapshots, otherwise just set the URL
  93. // to the release repo directly
  94. url = version.endsWith('SNAPSHOT') ? snapshotsRepoUrl : releasesRepoUrl
  95. // The username and password we've fetched earlier
  96. credentials {
  97. username ossrhUsername
  98. password ossrhPassword
  99. }
  100. }
  101. }
  102. }
  103. signing {
  104. sign publishing.publications
  105. }
  106. publishReleasePublicationToMavencentralRepository.dependsOn(assemble)