Archinamon / android-gradle-aspectj

gradle plug-in adding supports of AspectJ into Android project
Apache License 2.0
363 stars 58 forks source link

Problems with includeJar in multimodule project #124

Open blessedbyjobs opened 3 years ago

blessedbyjobs commented 3 years ago

Hello! I'm trying to connect your plugin to multimodule project and the goal is logging some events, like button clicks. I try to include rxbinding lib, but there's no effect. Full project you could see here: https://gitlab.com/surfstudio/public/android-standard/-/tree/ANDDEP-1080-user-action-logger1/template . Also there was try with empty project and everything was great.

Project build.gradle contain connection android-gradle-aspectj:

buildscript {
    ...
    dependencies {
        classpath "com.android.tools.build:gradle:${versions.gradlePluginVersion}"
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:${versions.kotlinVersion}"
        ...
        classpath "com.gradle:build-scan-plugin:${versions.buildScanPluginVersion}"
        classpath "com.archinamon:android-gradle-aspectj:${versions.aspectj}"
        ...
    }
}
...

Base_feature module looks like this:

apply from: '../commonModule.gradle'
apply from: '../commonKaptModule.gradle'

//the -ext postfix means that aspects from this module can be imported into other
apply plugin: 'com.archinamon.aspectj-ext'

aspectj {
    debugInfo true
    includeJar 'rxbinding'
}

dependencies {
    ...
    implementation androidX.multidex
    ...
    api rxBinding2.core
    api rxBinding2.kotlin
    api rxBinding2.appcompatV7
    ...
}

After build build/intermediates/transforms/aspectj/debug/content.json file looks like this:

[{"name":"aspectj","index":0,"scopes":["PROJECT"],"types":["CLASSES"],"format":"DIRECTORY","present":true}]

so there's no effect.

Build output is following:

> Task :base_feature:transformClassesWithAspectjForDebug
---------- Starting augmentation with AspectJ transformer ----------
Ignoring include/exclude option of -inpath parameter in simple mode.     // multiple times, multiple times
Switch to `aspectj-ext` plugin to enable this behavior!                              // multiple times, multiple times

Still, test project is working perfectly. It's project build.gradle:

buildscript {
    ext.kotlin_version = "1.3.+"
    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath "com.android.tools.build:gradle:4.0.1"
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
        classpath 'com.archinamon:android-gradle-aspectj:4.2.0'
    }
}

allprojects {
    repositories {
        google()
        jcenter()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

App module build.gradle:

apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'com.archinamon.aspectj-ext'

aspectj {
    debugInfo true
    includeJar 'rxbinding'
}

android {
    compileSdkVersion 29
    buildToolsVersion "29.0.3"
    ...
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

    kotlinOptions {
        jvmTarget = JavaVersion.VERSION_1_8.toString()
    }
}

dependencies {
    implementation fileTree(dir: "libs", include: ["*.jar"])
    ...
    implementation 'com.jakewharton.rxbinding4:rxbinding:4.0.0'
    ...
}

And it's content.json:

[
...
{
    "name": "io.reactivex.rxjava3:rxandroid:3.0.0",
    "index": 34,
    "scopes": [
      "EXTERNAL_LIBRARIES"
    ],
    "types": [
      "CLASSES"
    ],
    "format": "JAR",
    "present": true
  },
  {
    "name": "io.reactivex.rxjava3:rxjava:3.0.3",
    "index": 35,
    "scopes": [
      "EXTERNAL_LIBRARIES"
    ],
    "types": [
      "CLASSES"
    ],
    "format": "JAR",
    "present": true
  }
...
]

Any help/advice will be useful