publishOld.gradle 3.9 KB

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