publish.gradle 3.0 KB

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