How to use tasks from plugins into type

(Trilok agarwal) #1
class ResolverPlugin implements org.gradle.api.Plugin<Project> {
    void apply (Project project) {
        this.project = project;
        project.extensions.create("resolver", ResolverExtension)
<< {
            File pomFile = getManifestFile();
            if (! pomFile.canRead()){

And I want to use the task resolve Manifest in build.gradle

task printDependencies(type: resolveManifest) << {
    println project.Libraries.""

but it returns this error * What went wrong: A problem occurred evaluating root project ‘entsec’. > org.gradle.api.DefaultTask_Decorated cannot be cast to java.lang.Class

Also using gradle resolveManifest :resolveManifest FAILED

FAILURE: Build failed with an exception.

  • What went wrong: Execution failed for task ‘:resolveManifest’. > org.codehaus.plexus.util.xml.pull.XmlPullParserException: Unrecognised tag: ‘type’ (position: START_TAG seen …\n… @8:7)

(Peter Niederwieser) #2

‘resolveManifest’ is a task instance, not a task type. A task type is a class extending ‘org.gradle.api.DefaultTask’.

(Trilok agarwal) #3

how about the errors when

just running

gradle resolveManifest

Is there a place where I can look at the intermediate files produced for dynamic tasks like resolveManifest. Assuming there is an xml file produced for this task.

(Trilok agarwal) #4

sorry my bad, the exception is coming from the task itself,

Thanks for the reply, have changed to using

task printDependencies(dependsOn: resolveManifest) << {

since resolveManifest is an instance of task and not type

(Evgeny Goldin) #5

You can always grab the source code for Gradle and Groovy, set the breakpoint where it fails and debug the Gradle execution. I have ‘“gradle/bin/grd”’ script that is a copy of ‘“gradle/bin/gradle”’ with the last line set to:

exec “$JAVACMD” “${JVM_OPTS[@]}” -agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=8000 -classpath “$CLASSPATH” org.gradle.launcher.GradleMain -S --no-daemon “$@”

So to debug an execution I run ‘“grd taskName”’ and connect to port 8000.