publish-japt.gradle 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. // 部分源码来自 kotlinx.coroutines
  2. def pomConfig = {
  3. licenses {
  4. license {
  5. name "AGPL-V3"
  6. url "https://www.gnu.org/licenses/agpl-3.0.txt"
  7. distribution "repo"
  8. }
  9. }
  10. developers {
  11. developer {
  12. id "mamoe"
  13. name "Mamoe Technologies"
  14. }
  15. }
  16. scm {
  17. url "https://github.com/mamoe/mirai"
  18. }
  19. }
  20. bintray {
  21. def keyProps = new Properties()
  22. def keyFile = file("../keys.properties")
  23. if (keyFile.exists()) keyFile.withInputStream { keyProps.load(it) }
  24. user = keyProps.getProperty("bintrayUser")
  25. key = keyProps.getProperty("bintrayKey")
  26. pkg {
  27. repo = 'mirai'
  28. name = "mirai-japt"
  29. licenses = ['AGPL']
  30. vcsUrl = 'https://github.com/mamoe/mirai'
  31. }
  32. }
  33. afterEvaluate {
  34. project.publishing.publications.forEach { publication ->
  35. publication.pom.withXml {
  36. def root = asNode()
  37. //root.appendNode('groupId', project.group)
  38. //root.appendNode('artifactId', project.name)
  39. //root.appendNode('version', project.version)
  40. root.appendNode('name', project.name)
  41. root.appendNode('description', project.description)
  42. root.appendNode('url', 'https://github.com/mamoe/mirai')
  43. root.children().last() + pomConfig
  44. }
  45. }
  46. }
  47. bintrayUpload.doFirst {
  48. publications = project.publishing.publications
  49. }
  50. bintrayUpload.dependsOn {
  51. def list = new LinkedList<Task>()
  52. list.add(tasks.getByName("build"))
  53. list.addAll(tasks.findAll { task -> task.name.contains('Jar') })
  54. list.addAll(tasks.findAll { task -> task.name.startsWith('generateMetadataFileFor') })
  55. list.addAll(tasks.findAll { task -> task.name.startsWith('generatePomFileFor') })
  56. list
  57. }
  58. // empty xxx-javadoc.jar
  59. task javadocJar(type: Jar) {
  60. archiveClassifier = 'javadoc'
  61. }
  62. publishing {
  63. publications.all {
  64. // add empty javadocs (no need for MPP root publication which publishes only pom file)
  65. if (it.name != 'kotlinMultiplatform') {
  66. it.artifact(javadocJar)
  67. }
  68. // Rename MPP artifacts for backward compatibility
  69. def type = it.name
  70. switch (type) {
  71. case 'kotlinMultiplatform':
  72. it.artifactId = "$project.name"
  73. break
  74. case 'metadata':
  75. it.artifactId = "$project.name-common"
  76. break
  77. case 'jvm':
  78. it.artifactId = "$project.name"
  79. break
  80. case 'js':
  81. case 'native':
  82. it.artifactId = "$project.name-$type"
  83. break
  84. }
  85. // disable metadata everywhere, but in native modules
  86. if (type == 'maven' || type == 'metadata' || type == 'jvm' || type == 'js') {
  87. moduleDescriptorGenerator = null
  88. }
  89. }
  90. }