freefair / gradle-plugins

Gradle Plugin Collection
https://docs.freefair.io/gradle-plugins/current/reference/
MIT License
217 stars 32 forks source link

Inpath project in multimodule project not working #616

Open Daniel63656 opened 1 year ago

Daniel63656 commented 1 year ago

Hi,

I have a .jar file (lets say example.jar) that contains classes to weave as well as an aspect. I want to use this jar in another project. Using intelliJ I achieved this very easily by adding the freefair.aspectj plugin to my build.gradle and adding it by using inpath files.

plugins {
    id 'java'
    id 'io.freefair.aspectj' version '6.4.1'  //compile-time-weaving
}
repositories {
    mavenCentral()
}
dependencies {
    implementation files('libs/example.jar')

    implementation group: 'org.aspectj', name: 'aspectjrt', version: '1.9.6'
    inpath files('libs/example.jar')

    testImplementation 'org.junit.jupiter:junit-jupiter-api:5.8.1'
    testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.8.1'
}
test {
    useJUnitPlatform()
}

The library is in a 'libs' folder. The problem arises when trying to do the same in Android studio where there are multiple projects. When trying to do the same in the build.gradle of my app module, inpath is not recognized at all

Could not find method inpath() for arguments [file collection] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.

How do I configure this to work in a multimodule case? Do I need to put something in the projects build.gradle (currently looks like this

plugins {
    id 'com.android.application' version '7.1.2' apply false
    id 'com.android.library' version '7.1.2' apply false
}

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

)?

larsgrefer commented 1 year ago

io.freefair.aspectj does not work for android projects.

There is a separate plugin for this, which you could try:

https://github.com/freefair/android-gradle-plugins/blob/master/examples/aspectj/post-compile/build.gradle