manosbatsis / gradle-reflections-plugin

A Gradle plugin that uses Reflections to scan and index your project classes at build-time, allowing run-time querying without the indexing performance hit.
Apache License 2.0
4 stars 2 forks source link

Dependency issues #4

Open majgab8852 opened 5 years ago

majgab8852 commented 5 years ago

I added the plugin into my build.gradle file as I saw it here. Here is the complete build.gradle file:

plugins {
    id "io.github.manosbatsis.gradle.plugin.reflections" version "1.1"
}

apply plugin: 'java'

reflections {
    dependsOn classes
}
jar {
    dependsOn reflections
}

apply plugin: 'com.android.application'

android {
    compileSdkVersion 26
    buildToolsVersion '28.0.3'

    defaultConfig {
        applicationId "com.avaya.mobilevideo"
        minSdkVersion 24
        targetSdkVersion 26

        //jackOptions {
        //    enabled true
        //}
    }

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
        }
    }
    packagingOptions {
        exclude 'META-INF/DEPENDENCIES'
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/LICENSE.txt'
        exclude 'META-INF/license.txt'
        exclude 'META-INF/NOTICE'
        exclude 'META-INF/NOTICE.txt'
        exclude 'META-INF/notice.txt'
    }
}

dependencies {
    api 'com.android.support:support-v4:26.1.0'
    implementation 'org.reflections:reflections:0.9.11'
    implementation 'dom4j:dom4j:1.6.1'
    implementation files('libs/avaya-client-sdk-android-3.4.1.jar')
    implementation files('libs/android-logging-log4j-1.0.3.jar')
    implementation files('libs/log4j-1.2.17.jar')
}

The rest of the stuff was already part of the file (this is a sample project that was provided by vendor). When synchronizing, I got this error:

The 'java' plugin has been applied, but it is not compatible with the Android plugins.

When I remove the java plugin, I get another error:

Could not get unknown property 'classes' for task ':app:reflections' of type io.github.manosbatsis.gradle.plugin.reflections.ReflectionsMetadataEmbeddingTask.

How to proceed from here?

manosbatsis commented 5 years ago

I've never developed for android but i believe an android module cannot also be a java module. Assuming the plugin actually works with android classes, you will have to do the equivalent setup like bellow, only using *android" gradle tasks

// reflections plugin needs the compiled
// project classes, so either chain tasks
// with dependsOn as bellow or execute tasks explicitly
// when using the command line
reflections{
    dependsOn classes
}
jar{
    dependsOn reflections
}