2
0

publish.gradle 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. import upload.Bintray
  2. // 部分源码来自 kotlinx.coroutines
  3. // Source code from kotlinx.coroutines
  4. task ensureBintrayAvailable() {
  5. doLast {
  6. if (!Bintray.isBintrayAvailable(project)) {
  7. throw new IllegalStateException("bintray isn't available. ")
  8. }
  9. }
  10. }
  11. if (!Bintray.isBintrayAvailable(project)) {
  12. println("bintray isn't available. NO PUBLICATIONS WILL BE SET")
  13. return
  14. }
  15. def miraiGitHubUrl = "https://github.com/mamoe/mirai"
  16. bintray {
  17. user = Bintray.getUser(project)
  18. key = Bintray.getKey(project)
  19. pkg {
  20. repo = 'mirai'
  21. name = "mirai-core"
  22. licenses = ['AGPL']
  23. vcsUrl = miraiGitHubUrl
  24. websiteUrl = miraiGitHubUrl
  25. githubRepo = miraiGitHubUrl
  26. issueTrackerUrl = "$miraiGitHubUrl/issues"
  27. /* version {
  28. name = project.version
  29. }*/
  30. }
  31. }
  32. afterEvaluate {
  33. project.publishing.publications.forEach { publication ->
  34. publication.pom.withXml {
  35. def root = asNode()
  36. //root.appendNode('groupId', project.group)
  37. //root.appendNode('artifactId', project.name)
  38. //root.appendNode('version', project.version)
  39. root.appendNode('name', project.name)
  40. root.appendNode('description', project.description)
  41. root.appendNode('url', miraiGitHubUrl)
  42. root.children().last() + {
  43. licenses {
  44. license {
  45. name "AGPL-V3"
  46. url "https://www.gnu.org/licenses/agpl-3.0.txt"
  47. distribution "repo"
  48. }
  49. }
  50. developers {
  51. developer {
  52. id "mamoe"
  53. name "Mamoe Technologies"
  54. email "[email protected]"
  55. }
  56. }
  57. scm {
  58. url miraiGitHubUrl
  59. }
  60. }
  61. }
  62. }
  63. }
  64. bintrayUpload.doFirst {
  65. publications = project.publishing.publications
  66. }
  67. bintrayUpload.dependsOn {
  68. def list = new LinkedList<Task>()
  69. list.add(tasks.getByName("build"))
  70. list.addAll(tasks.findAll { task -> task.name.contains('Jar') })
  71. list.addAll(tasks.findAll { task -> task.name.startsWith('generateMetadataFileFor') })
  72. list.addAll(tasks.findAll { task -> task.name.startsWith('generatePomFileFor') })
  73. list
  74. }
  75. try {
  76. // empty xxx-javadoc.jar
  77. task javadocJar(type: Jar) {
  78. archiveClassifier = 'javadoc'
  79. }
  80. } catch (Exception ignored) {
  81. }
  82. publishing {
  83. publications.all {
  84. // add empty javadocs (no need for MPP root publication which publishes only pom file)
  85. if (it.name != 'kotlinMultiplatform') {
  86. it.artifact(javadocJar)
  87. }
  88. // Rename MPP artifacts for backward compatibility
  89. def type = it.name
  90. switch (type) {
  91. case 'kotlinMultiplatform':
  92. it.artifactId = "$project.name-native"
  93. break
  94. case 'metadata':
  95. it.artifactId = "$project.name-common"
  96. break
  97. case 'jvm':
  98. it.artifactId = "$project.name"
  99. break
  100. case 'js':
  101. case 'native':
  102. it.artifactId = "$project.name-$type"
  103. break
  104. }
  105. // disable metadata everywhere, but in native modules
  106. if (type == 'maven' || type == 'metadata' || type == 'jvm' || type == 'js') {
  107. moduleDescriptorGenerator = null
  108. }
  109. }
  110. }
  111. // bintrayUpload.dependsOn publishToMavenLocal