From f24aa438d78bdc18499a90f25184c31e18c427e1 Mon Sep 17 00:00:00 2001 From: mars885 Date: Tue, 6 Aug 2024 22:51:51 +0300 Subject: [PATCH] Fataar Adapster library --- build.gradle.kts | 9 ++++ buildSrc/src/main/java/Dependencies.kt | 2 + buildSrc/src/main/java/Plugins.kt | 20 +++++---- gradle/wrapper/gradle-wrapper.properties | 2 +- persistentsearchview/build.gradle.kts | 3 +- publishing.gradle.kts | 52 +----------------------- 6 files changed, 28 insertions(+), 60 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index bda4fbd..f171b1b 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -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) } } diff --git a/buildSrc/src/main/java/Dependencies.kt b/buildSrc/src/main/java/Dependencies.kt index 3304dfc..19ad35b 100644 --- a/buildSrc/src/main/java/Dependencies.kt +++ b/buildSrc/src/main/java/Dependencies.kt @@ -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" @@ -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}" } diff --git a/buildSrc/src/main/java/Plugins.kt b/buildSrc/src/main/java/Plugins.kt index e3ee8a7..0305419 100644 --- a/buildSrc/src/main/java/Plugins.kt +++ b/buildSrc/src/main/java/Plugins.kt @@ -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) } @@ -44,4 +40,14 @@ fun PluginDependenciesSpec.androidLibrary(): PluginDependencySpec { fun PluginDependenciesSpec.kotlinAndroid(): PluginDependencySpec { return id(PLUGIN_KOTLIN_ANDROID) -} \ No newline at end of file +} + + +fun PluginDependenciesSpec.fatAar(): PluginDependencySpec { + return id(PLUGIN_FAT_AAR) +} + + +fun PluginDependenciesSpec.gradleVersions(): PluginDependencySpec { + return (id(PLUGIN_GRADLE_VERSIONS) version versions.gradleVersionsPlugin) +} diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 2e3a9f5..5ebadf9 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -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 diff --git a/persistentsearchview/build.gradle.kts b/persistentsearchview/build.gradle.kts index d186fab..800a426 100644 --- a/persistentsearchview/build.gradle.kts +++ b/persistentsearchview/build.gradle.kts @@ -16,6 +16,7 @@ plugins { androidLibrary() + fatAar() } android { @@ -49,7 +50,7 @@ android { } dependencies { - api(project(deps.local.adapster)) + embed(project(deps.local.adapster)) implementation(deps.appCompat) implementation(deps.cardView) diff --git a/publishing.gradle.kts b/publishing.gradle.kts index fc70d5f..af00a28 100644 --- a/publishing.gradle.kts +++ b/publishing.gradle.kts @@ -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 { publications { @@ -81,9 +34,6 @@ afterEvaluate { from(components["java"]) } - artifact(sourcesJar.get()) - artifact(javadocJar.get()) - pom { name.set(publishingConfig.artifactName) description.set(publishingConfig.artifactDescription) @@ -132,4 +82,4 @@ afterEvaluate { sign(publication) } -} \ No newline at end of file +}