build.gradle.kts 2.6 KB

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