No able to add a dependency using Gradle to the Custom Auth App on Git

Hi I have cloned the Custom auth app from Git, I have a third party local jar file which I want to bundle with the custom plugin for auth. I am trying to add the dependency in the gradle but am faced with an error:

Link: https://github.com/elastic/shield-custom-realm-example/tree/5.5

Caused by: org.gradle.api.InvalidActionClosureException: The closure 'org.elasticsearch.gradle.BuildPlugin$_configureConfigurations_closure5@6192400e' is not valid as an action for argument 'org.gradle.api.internal.artifacts.dependencies.DefaultSelfResolvingDependency_Decorated@433edba9'. It should accept no parameters, or one compatible with type 'org.gradle.api.internal.artifacts.dependencies.DefaultSelfResolvingDependency_Decorated'. It accepts (org.gradle.api.artifacts.ModuleDependency).
        at org.gradle.api.internal.ClosureBackedAction.execute(ClosureBackedAction.java:75)
        at org.gradle.util.ConfigureUtil.configureTarget(ConfigureUtil.java:160)
        at org.gradle.util.ConfigureUtil.configure(ConfigureUtil.java:106)
        at org.gradle.util.ConfigureUtil$1.execute(ConfigureUtil.java:123)
        at org.gradle.listener.ActionBroadcast.execute(ActionBroadcast.java:39)
        at org.gradle.api.internal.DefaultDomainObjectCollection.doAdd(DefaultDomainObjectCollection.java:172)
        at org.gradle.api.internal.DefaultDomainObjectCollection.add(DefaultDomainObjectCollection.java:166)
        at org.gradle.api.internal.DelegatingDomainObjectSet.add(DelegatingDomainObjectSet.java:82)
        at org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.doAdd(DefaultDependencyHandler.java:84)
        at org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.methodMissing(DefaultDependencyHandler.java:123)
        at org.gradle.internal.metaobject.BeanDynamicObject$MetaClassAdapter.invokeOpaqueMethod(BeanDynamicObject.java:426)
        at org.gradle.internal.metaobject.BeanDynamicObject$MetaClassAdapter.invokeMethod(BeanDynamicObject.java:405)
        at org.gradle.internal.metaobject.BeanDynamicObject.invokeMethod(BeanDynamicObject.java:170)
        at org.gradle.internal.metaobject.CompositeDynamicObject.invokeMethod(CompositeDynamicObject.java:96)
        at org.gradle.internal.metaobject.MixInClosurePropertiesAsMethodsDynamicObject.invokeMethod(MixInClosurePropertiesAsMethodsDynamicObject.java:30)
        at org.gradle.internal.metaobject.ConfigureDelegate.invokeMethod(ConfigureDelegate.java:59)
        at build_682nbdyjxptc413ela1iaejze$_run_closure2.doCall(/Users/prime/Development/AskWorkspace/shield-custom-realm-example-5.5/build.gradle:52)
        at org.gradle.api.internal.ClosureBackedAction.execute(ClosureBackedAction.java:70)
        at org.gradle.util.ConfigureUtil.configureTarget(ConfigureUtil.java:160)
        at org.gradle.util.ConfigureUtil.configure(ConfigureUtil.java:106)
        at org.gradle.api.internal.project.DefaultProject.dependencies(DefaultProject.java:1002)
        at org.gradle.internal.metaobject.BeanDynamicObject$MetaClassAdapter.invokeMethod(BeanDynamicObject.java:382)
        at org.gradle.internal.metaobject.BeanDynamicObject.invokeMethod(BeanDynamicObject.java:170)
        at org.gradle.internal.metaobject.CompositeDynamicObject.invokeMethod(CompositeDynamicObject.java:96)
        at org.gradle.internal.metaobject.MixInClosurePropertiesAsMethodsDynamicObject.invokeMethod(MixInClosurePropertiesAsMethodsDynamicObject.java:30)
        at org.gradle.internal.metaobject.AbstractDynamicObject.invokeMethod(AbstractDynamicObject.java:163)
        at org.gradle.groovy.scripts.BasicScript.methodMissing(BasicScript.java:83)
        at build_682nbdyjxptc413ela1iaejze.run(/Users/prime/Development/AskWorkspace/shield-custom-realm-example-5.5/build.gradle:51)
        at org.gradle.groovy.scripts.internal.DefaultScriptRunnerFactory$ScriptRunnerImpl.run(DefaultScriptRunnerFactory.java:90)
        ... 62 more

Can you give me a headsup?

I am facing the same issue while using an external jar. Could someone please help how to set it up in build.gradle
P.S: I had to reuse some code which was used in a different project; so I had packaged it into a .jar file and trying to use it here by adding a dependency.

I just fixed it. Please follow the below steps

You can try reusing your local Maven repository for Gradle:

Install the jar into your local Maven repository:

mvn install:install-file -Dfile=utility.jar -DgroupId=com.company -DartifactId=utility -Dversion=0.0.1 -Dpackaging=jar

Check that you have the jar installed into your ~/.m2/ local Maven repository

Enable your local Maven repository in your build.gradle file:

repositories {

mavenCentral()
mavenLocal()

}

dependencies {

compile ("com.company:utility:0.0.1")

}
    Now you should have the jar enabled for compilation in your project

Hi Vivek, I tried the same yesterday and found out that the jar also needs to be supplied and stored in the relative plugin folder. Otherwise it will not work. Checkout more details here: Class Not Found, for a local jar I try to add to a plugin

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.