build.gradle.kts 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. plugins {
  2. id("com.android.library")
  3. kotlin("android")
  4. id("maven-publish")
  5. }
  6. buildscript {
  7. repositories {
  8. mavenCentral()
  9. }
  10. }
  11. android {
  12. compileSdkVersion(AndroidConstants.compileSdkVersions)
  13. defaultConfig {
  14. minSdkVersion(AndroidConstants.minSdkVersion)
  15. targetSdkVersion(AndroidConstants.targetSdkVersion)
  16. }
  17. compileOptions {
  18. sourceCompatibility = JavaVersion.VERSION_1_8
  19. targetCompatibility = JavaVersion.VERSION_1_8
  20. }
  21. kotlinOptions {
  22. jvmTarget = "1.8"
  23. }
  24. }
  25. dependencies {
  26. implementation(Libs.gson)
  27. }
  28. afterEvaluate {
  29. configure<PublishingExtension> {
  30. val artifact = "charts"
  31. val publishedGroupId = "com.github.aachartmodel.aainfographics"
  32. val libraryName = "AAChartCore-Kotlin"
  33. publications {
  34. create<MavenPublication>("maven") {
  35. groupId = publishedGroupId
  36. artifactId = artifact
  37. version = "1.0.0"
  38. artifact(tasks.getByName("sourcesJar"))
  39. artifact("$buildDir/outputs/aar/${artifactId}-release.aar") {
  40. builtBy(tasks.getByName("assemble"))
  41. }
  42. pom {
  43. packaging = "aar"
  44. name.set(libraryName)
  45. licenses {
  46. license {
  47. name.set("The Apache Software License, Version 2.0")
  48. url.set("http://www.apache.org/licenses/LICENSE-2.0.txt")
  49. }
  50. }
  51. withXml {
  52. val dependenciesNode = asNode().appendNode("dependencies")
  53. configurations.getByName("implementation") {
  54. dependencies.forEach {
  55. val dependencyNode = dependenciesNode.appendNode("dependency")
  56. dependencyNode.appendNode("groupId", it.group)
  57. dependencyNode.appendNode("artifactId", it.name)
  58. dependencyNode.appendNode("version", it.version)
  59. }
  60. }
  61. }
  62. }
  63. }
  64. }
  65. }
  66. }
  67. val sourcesJar by tasks.registering(Jar::class) {
  68. archiveClassifier.set("sources")
  69. from(android.sourceSets.getByName("main").java.srcDirs)
  70. }