trevjonez / composer-gradle-plugin

Gradle task type and plugin for interacting with https://github.com/gojuno/composer

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Configuration is not working

eothein opened this issue · comments

Following the Readme file on your repo I have configured composer in my top build.gradle file:

//All dependencies are gathered in this file
apply from: 'dependencies.gradle'
apply plugin: 'composer'

buildscript {
    repositories {
        google()
        jcenter()
        maven { url "https://jitpack.io" }
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.3.1'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.3.21"
        classpath 'com.github.trevjonez.composer-gradle-plugin:plugin:0.10.0'
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

We are working with different modules in our project, hence the // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files notion.

After syncing the project I get the following exceptions:

Caused by: com.trevjonez.composer.ComposerPlugin$MissingPluginException: Failed to configure com.trevjonez.composer.ComposerPlugin plugin on project: :
  Expected plugin: `com.android.build.gradle.api.AndroidBasePlugin` was not applied.
  If you believe this is an issue or missing feature, please consider opening an issue on github.
https://github.com/trevjonez/composer-gradle-plugin
	at com.trevjonez.composer.ComposerPlugin$apply$3.execute(ComposerPlugin.kt:63)
	at com.trevjonez.composer.ComposerPlugin$apply$3.execute(ComposerPlugin.kt:26)
	at org.gradle.configuration.internal.DefaultListenerBuildOperationDecorator$BuildOperationEmittingAction$1$1.run(DefaultListenerBuildOperationDecorator.java:155)
	at org.gradle.configuration.internal.DefaultUserCodeApplicationContext.reapply(DefaultUserCodeApplicationContext.java:58)
	at org.gradle.configuration.internal.DefaultListenerBuildOperationDecorator$BuildOperationEmittingAction$1.run(DefaultListenerBuildOperationDecorator.java:152)
	at org.gradle.internal.operations.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:300)
	at org.gradle.internal.operations.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:292)
	at org.gradle.internal.operations.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:174)
	at org.gradle.internal.operations.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:90)
	at org.gradle.configuration.internal.DefaultListenerBuildOperationDecorator$BuildOperationEmittingAction.execute(DefaultListenerBuildOperationDecorator.java:149)
	at org.gradle.internal.event.BroadcastDispatch$ActionInvocationHandler.dispatch(BroadcastDispatch.java:91)
	at org.gradle.internal.event.BroadcastDispatch$ActionInvocationHandler.dispatch(BroadcastDispatch.java:80)
	at org.gradle.internal.event.AbstractBroadcastDispatch.dispatch(AbstractBroadcastDispatch.java:42)
	at org.gradle.internal.event.BroadcastDispatch$SingletonDispatch.dispatch(BroadcastDispatch.java:230)
	at org.gradle.internal.event.BroadcastDispatch$SingletonDispatch.dispatch(BroadcastDispatch.java:149)
	at org.gradle.internal.event.AbstractBroadcastDispatch.dispatch(AbstractBroadcastDispatch.java:58)
	at org.gradle.internal.event.BroadcastDispatch$CompositeDispatch.dispatch(BroadcastDispatch.java:324)
	at org.gradle.internal.event.BroadcastDispatch$CompositeDispatch.dispatch(BroadcastDispatch.java:234)
	at org.gradle.internal.event.ListenerBroadcast.dispatch(ListenerBroadcast.java:140)
	at org.gradle.internal.event.ListenerBroadcast.dispatch(ListenerBroadcast.java:37)
	at org.gradle.internal.dispatch.ProxyDispatchAdapter$DispatchingInvocationHandler.invoke(ProxyDispatchAdapter.java:93)
	at com.sun.proxy.$Proxy33.afterEvaluate(Unknown Source)
	at org.gradle.configuration.project.LifecycleProjectEvaluator$NotifyAfterEvaluate$1.execute(LifecycleProjectEvaluator.java:187)
	at org.gradle.configuration.project.LifecycleProjectEvaluator$NotifyAfterEvaluate$1.execute(LifecycleProjectEvaluator.java:184)
	at org.gradle.api.internal.project.DefaultProject.stepEvaluationListener(DefaultProject.java:1418)
	at org.gradle.configuration.project.LifecycleProjectEvaluator$NotifyAfterEvaluate.run(LifecycleProjectEvaluator.java:193)
	... 95 more

Not sure what to do here?

Applying composer plugin to the top-level gradle script is incorrect, I think. Instead, you should apply it to your apk project which you want to test.

apply plugin: 'com.android.application'
apply plugin: 'composer'

android {}
composer {}

Thanks for the quick reply!

I have added it into the build.gradle for the module I wish to test:

apply plugin: 'com.android.application'

apply plugin: 'kotlin-android'

apply plugin: 'kotlin-android-extensions'

apply plugin: 'kotlin-kapt'

apply plugin: 'composer'

buildscript {
    repositories {
        google()
        jcenter()
        maven { url "https://jitpack.io" }
    }
    dependencies {
        classpath 'com.github.trevjonez.composer-gradle-plugin:plugin:0.10.0'
        classpath 'com.android.tools.build:gradle:3.3.1'
    }
}

But I get the following error message:

Unable to find method 'org.gradle.api.provider.ListProperty.empty()Lorg/gradle/api/provider/ListProperty;'.
Possible causes for this unexpected error include:
Gradle's dependency cache may be corrupt (this sometimes occurs after a network connection timeout.)
Re-download dependencies and sync project (requires network)

The state of a Gradle build process (daemon) may be corrupt. Stopping all Gradle daemons may solve this problem.
Stop Gradle build processes (requires restart)

Your project may be using a third-party plugin which is not compatible with the other plugins in the project or the version of Gradle requested by the project.

In the case of corrupt Gradle processes, you can also try closing the IDE and then killing all Java processes.

Based on the error message you need to update Gradle to 5.x and above. I suggest to try gradle 5.2.1

Dear @plastiv

Thanks for your swift reply. It indeed solved the problem. How did you figure out from the error output that the Gradle version was the problem?

Error message says Unable to find method 'org.gradle.api.provider.ListProperty.empty(). Since Gradle is open source you can google org.gradle.api.provider.ListProperty to find a class on github https://github.com/gradle/gradle/blob/master/subprojects/core-api/src/main/java/org/gradle/api/provider/ListProperty.java where git history shows when method empty() was added.

Thanks! I'll try to apply the same problem solving technique next time :)

Compiling works, but now I get warning

API 'variant.getAssemble()' is obsolete and has been replaced with 'variant.getAssembleProvider()'. |  
-- | --

which I will try to tackle now.

looks like the original issue was associated to a Gradle version being too low for the version of the composer. Thank you @plastiv for helping out here, it is your efforts that make our community great!