[GRADLE-3207] Task extending 'jar' compiled with Gradle 2.0 fails to run in Gradle 2.2 Created: 05/Dec/14  Updated: 27/Jan/15  Resolved: 27/Jan/15

Status: Resolved
Project: Gradle
Affects Version/s: None
Fix Version/s: 2.3-rc-1

Type: Bug
Reporter: Gradle Forums Assignee: Unassigned
Resolution: Fixed Votes: 0

Known Issue Of:

 Description   

In Gradle 2.2, the Jar task was ported from Groovy to Java. This causes issues with some tasks that subclass Jar: if they are compiled with a version of Gradle < 2.2 they are unable to execute in Gradle 2.2.

To workaround this problem:
1. Recompile the affected tasks with Gradle 2.2
2. Use Gradle 2.3, where this issue will be fixed.

-------------------------------------------------------------------
Original report from John Engelman

Defining a task class that extends a built in task type in Gradle 2.2 throws an exception when trying to call a protected method from the super class.

class ShadowJar extends Jar {

@TaskAction
protected void copy()

{ super.copy() println 'copy done' }

}

Results in the following exception: [1]https://gist.github.com/johnrengelman...

Caused by: groovy.lang.MissingMethodException: No signature of method: com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar_Decorated.copy() is applicable for argument types: () values: []
Possible solutions: any(), any(groovy.lang.Closure), notify(), wait(), grep()
----------------------------------------------------------------------------------------
[1] https://gist.github.com/johnrengelman/06ef65018aab9ec935b3



 Comments   
Comment by Gradle Forums [ 05/Dec/14 ]

Can you try two things please:

1. Run with `-S` and provide the stacktrace (need to see the Groovy internals)
2. Recompile the plugin with 2.2, then try your test case again

If the result of 2.2 is different, that means we've introduced a binary incompatibility in our class decoration goop.

Comment by Gradle Forums [ 05/Dec/14 ]

Hey Luke,
The full strack trace is in the GIST link that I included above.
Building the plugin with Gradle 2.2 does fix the problem and that build of the plugin seems to run in Gradle 2.1 and 2.0, but it no longer runs in Gradle 1.x because of the change in Groovy versions.

That's something I can work around by documenting that you need to include the `groovy-backports-compat23` library when using with Gradle 1.x

Comment by Gradle Forums [ 05/Dec/14 ]

So that is definitely the trace when running with `-S` and not `-s`?

Comment by Gradle Forums [ 05/Dec/14 ]

I guess not. I had compared it earlier and thought they were the same, but on close look they are a bit different.

I updated the GIST to have the full output using `-S` and also added a sample `build.gradle` file
[1]https://gist.github.com/johnrengelman...
----------------------------------------------------------------------------------------
[1] https://gist.github.com/johnrengelman/06ef65018aab9ec935b3

Comment by Gradle Forums [ 05/Dec/14 ]

Another workaround would be to implement the ShadowJar class in Java instead of Groovy and rebuild with a 1.x version of Gradle.

Comment by Gradle Forums [ 05/Dec/14 ]

Oh that's a thought. I'll give that a shot today.

Comment by Gradle Forums [ 05/Dec/14 ]

Hi Luke,
we have exactly the same problem here. Due to the fact that we implemented all our plugins in Groovy it would be a real pain for us to rewrite the tasks in Java.
So at this time, moving to a higher version of gradle than 2.1 is a showstopper for us.

Cheers
Thorsten

Comment by Gradle Forums [ 05/Dec/14 ]

Thorsten,

To fix these, you'd just need to recompile your subclasses with Gradle 2.2. They will then work.

Is this still a blocker for you?

Comment by Gradle Forums [ 05/Dec/14 ]

Luke,
this is a good hint. Haven't tried it yet. I will tell you on Monday if that'll work.

Comment by Gradle Forums [ 05/Dec/14 ]

It is working if I compile it with gradle 2.2 though we had a "chicken-and-egg" problem because we build our own plugins with our own plugin. But for us the case is closed.
Thanks Luke!

Generated at Wed Jun 30 12:42:48 CDT 2021 using Jira 8.4.2#804003-sha1:d21414fc212e3af190e92c2d2ac41299b89402cf.