publish.gradle 4.4 KB

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