build.gradle.kts 2.6 KB

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