王学岗切面编程(AOP)最新配置

不懂啥是切面编程的看我这篇文章
本文主要讲解最新的切面编程配置
首先看下app的build.gradle界面,有两处配置

plugins {
    id("com.android.application")
    id("org.jetbrains.kotlin.android")
//    配置1
    id("com.ibotta.gradle.aop")
}

android {
    namespace = "com.example.myaspecttest1"
    compileSdk = 34

    defaultConfig {
        applicationId = "com.example.myaspecttest1"
        minSdk = 24
        targetSdk = 34
        versionCode = 1
        versionName = "1.0"

        testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
    }

    buildTypes {
        release {
            isMinifyEnabled = false
            proguardFiles(
                getDefaultProguardFile("proguard-android-optimize.txt"),
                "proguard-rules.pro"
            )
        }
    }
    compileOptions {
        sourceCompatibility = JavaVersion.VERSION_1_8
        targetCompatibility = JavaVersion.VERSION_1_8
    }
    kotlinOptions {
        jvmTarget = "1.8"
    }
}

dependencies {

    implementation("androidx.core:core-ktx:1.9.0")
    implementation("androidx.appcompat:appcompat:1.6.1")
    implementation("com.google.android.material:material:1.10.0")
    implementation("androidx.constraintlayout:constraintlayout:2.1.4")
    //    配置2
    implementation("org.aspectj:aspectjrt:1.9.7")
    testImplementation("junit:junit:4.13.2")
    androidTestImplementation("androidx.test.ext:junit:1.1.5")
    androidTestImplementation("androidx.test.espresso:espresso-core:3.5.1")
}

项目的build.gradle里,有一处配置

// Top-level build file where you can add configuration options common to all sub-projects/modules.
plugins {
    id("com.android.application") version "8.1.1" apply false
    id("org.jetbrains.kotlin.android") version "1.9.0" apply false
//    配置1
    id("com.ibotta.plugin") version "1.4.1" apply false
}

setting.gradle里有一处配置

pluginManagement {
    repositories {
        google()
        mavenCentral()
        gradlePluginPortal()
    }
//    配置1
    resolutionStrategy {
        eachPlugin {
            if (requested.id.id == "com.ibotta.plugin") {
                useModule("com.ibotta:plugin:1.4.1")
            }
        }
    }
}
dependencyResolutionManagement {
    repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
    repositories {
        google()
        mavenCentral()
    }
}

rootProject.name = "MyAspectTest1"
include(":app")
 

怎么样,是不是比以前简洁多啦

你可能感兴趣的:(随笔,android)