Skip to content

Commit

Permalink
Fataar Adapster library (#49)
Browse files Browse the repository at this point in the history
  • Loading branch information
mars885 authored Aug 6, 2024
1 parent 324e5e9 commit 6e3e434
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 60 deletions.
9 changes: 9 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,20 @@ buildscript {
repositories {
mavenCentral()
google()

// FatAar plugin
maven {
setUrl("https://jitpack.io")
content {
includeGroup("com.github.aasitnikov")
}
}
}

dependencies {
classpath(deps.plugins.androidGradle)
classpath(deps.plugins.kotlinGradle)
classpath(deps.plugins.fatAar)
classpath(deps.plugins.gradleVersions)
}
}
Expand Down
2 changes: 2 additions & 0 deletions buildSrc/src/main/java/Dependencies.kt
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ object versions {

const val kotlin = "2.0.0" // also in buildSrc build.gradle.kts file
const val androidPlugin = "8.3.1" // also in buildSrc build.gradle.kts file
const val fatAarPlugin = "1.4.1"
const val gradleVersionsPlugin = "0.51.0"
const val appCompat = "1.7.0"
const val cardView = "1.0.0"
Expand All @@ -78,6 +79,7 @@ object deps {

const val androidGradle = "com.android.tools.build:gradle:${versions.androidPlugin}"
const val kotlinGradle = "org.jetbrains.kotlin:kotlin-gradle-plugin:${versions.kotlin}"
const val fatAar = "com.github.aasitnikov:fat-aar-android:${versions.fatAarPlugin}"
const val gradleVersions = "com.github.ben-manes:gradle-versions-plugin:${versions.gradleVersionsPlugin}"

}
Expand Down
20 changes: 13 additions & 7 deletions buildSrc/src/main/java/Plugins.kt
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,15 @@ import org.gradle.plugin.use.PluginDependenciesSpec
import org.gradle.plugin.use.PluginDependencySpec


const val PLUGIN_GRADLE_VERSIONS = "com.github.ben-manes.versions"
const val PLUGIN_ANDROID_APPLICATION = "com.android.application"
const val PLUGIN_ANDROID_LIBRARY = "com.android.library"
const val PLUGIN_KOTLIN_ANDROID = "kotlin-android"
const val PLUGIN_FAT_AAR = "com.kezong.fat-aar"
const val PLUGIN_GRADLE_VERSIONS = "com.github.ben-manes.versions"
const val PLUGIN_MAVEN_PUBLISH = "maven-publish"
const val PLUGIN_SIGNING = "org.gradle.signing"


fun PluginDependenciesSpec.gradleVersions(): PluginDependencySpec {
return (id(PLUGIN_GRADLE_VERSIONS) version versions.gradleVersionsPlugin)
}


fun PluginDependenciesSpec.androidApplication(): PluginDependencySpec {
return id(PLUGIN_ANDROID_APPLICATION)
}
Expand All @@ -44,4 +40,14 @@ fun PluginDependenciesSpec.androidLibrary(): PluginDependencySpec {

fun PluginDependenciesSpec.kotlinAndroid(): PluginDependencySpec {
return id(PLUGIN_KOTLIN_ANDROID)
}
}


fun PluginDependenciesSpec.fatAar(): PluginDependencySpec {
return id(PLUGIN_FAT_AAR)
}


fun PluginDependenciesSpec.gradleVersions(): PluginDependencySpec {
return (id(PLUGIN_GRADLE_VERSIONS) version versions.gradleVersionsPlugin)
}
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-all.zip
3 changes: 2 additions & 1 deletion persistentsearchview/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

plugins {
androidLibrary()
fatAar()
}

android {
Expand Down Expand Up @@ -49,7 +50,7 @@ android {
}

dependencies {
api(project(deps.local.adapster))
embed(project(deps.local.adapster))

implementation(deps.appCompat)
implementation(deps.cardView)
Expand Down
52 changes: 1 addition & 51 deletions publishing.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -20,53 +20,6 @@ apply(plugin = PLUGIN_SIGNING)
project.group = publishingConfig.artifactGroupId
project.version = publishingConfig.artifactVersion

val sourcesJar by tasks.registering(Jar::class) {
archiveClassifier.set("sources")

if(project.plugins.hasPlugin(PLUGIN_ANDROID_LIBRARY)) {
val libExt = checkNotNull(project.extensions.findByType(com.android.build.gradle.LibraryExtension::class.java))
val libMainSourceSet = libExt.sourceSets.getByName("main")

from(libMainSourceSet.java.srcDirs)
} else {
val sourceSetExt = checkNotNull(project.extensions.findByType(SourceSetContainer::class.java))
val mainSourceSet = sourceSetExt.getByName("main")

from(mainSourceSet.java.srcDirs)
}
}

// https://gist.github.com/Robyer/a6578e60127418b380ca133a1291f017#file-maven-publish-helper-gradle-L14
val javadoc by tasks.registering(Javadoc::class) {
if(project.plugins.hasPlugin(PLUGIN_ANDROID_LIBRARY)) {
val libExt = checkNotNull(project.extensions.findByType(com.android.build.gradle.LibraryExtension::class.java))
val libMainSourceSet = libExt.sourceSets.getByName("main")

source = libMainSourceSet.java.getSourceFiles()
classpath += project.files(libExt.bootClasspath.joinToString(java.io.File.pathSeparator))

libExt.libraryVariants.forEach { variant ->
if(variant.name == "release") {
classpath += variant.javaCompileProvider.get().classpath
}
}
} else {
val sourceSetExt = checkNotNull(project.extensions.findByType(SourceSetContainer::class.java))
val mainSourceSet = sourceSetExt.getByName("main")

source = mainSourceSet.java
}
}

val javadocJar by tasks.registering(Jar::class) {
archiveClassifier.set("javadoc")

val javadocTask = tasks.getByName("javadoc")

from(javadocTask)
dependsOn(javadocTask)
}

afterEvaluate {
configure<PublishingExtension> {
publications {
Expand All @@ -81,9 +34,6 @@ afterEvaluate {
from(components["java"])
}

artifact(sourcesJar.get())
artifact(javadocJar.get())

pom {
name.set(publishingConfig.artifactName)
description.set(publishingConfig.artifactDescription)
Expand Down Expand Up @@ -132,4 +82,4 @@ afterEvaluate {

sign(publication)
}
}
}

0 comments on commit 6e3e434

Please sign in to comment.