Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7992473
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T13:34:25+00:00 2026-06-04T13:34:25+00:00

To explain my problem in the simplest way, I’ll first show you a Groovy

  • 0

To explain my problem in the simplest way, I’ll first show you a Groovy script that does work and then add some Gradle sauce which breaks it.

The working script:

class MyMixin {
    String myname = 'max'
}

@Mixin(MyMixin)
class MyClass {}

MyClass c = new MyClass()
println 'hello ' + c.myname

This prints out “hello max” as expected. Now let’s replace that MyClass with a Gradle task class. For this we extend DefaultTask and use the @TaskAction annotation.

@Mixin(MyMixin)
class MyTask extends DefaultTask {

    @TaskAction
    void sayHello() {
        println 'hello ' + myname
    }
}

If we now install this Gradle task and execute it, we get the following runtime error:

Execution failed for task ':myproject:mytask'.
> MyTask.getMyname()Ljava/lang/String;

What’s funny is that this only happens with methods returning something. void methods execute just fine.

So the question is simple: how can I get my mixin to cooperate with my Gradle task? (FYI: it doesn’t seem to be related to inheritance; I checked that, but didn’t include it in the sample script to keep it simple. I have also tested with a runtime mixin instead of compile-time: the result is the same).

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T13:34:26+00:00Added an answer on June 4, 2026 at 1:34 pm

    I posted the same question on the Gradle forum and according to the Gradle developers it is an incompatibility between Groovy’s @Mixin and Gradle’s own meta-programming facilities. They suggest to use Gradle’s extra properties and/or extension objects instead.

    For reference: http://forums.gradle.org/gradle/topics/groovy_mixin_combined_with_gradle_defaulttask_results_in_runtime_error

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The easiest way to explain this problem is to show you some code: Public
I hope I can explain my problem in a way that it's clear for
It might sound unnecessary, but let me explain my problem first. Probably then it
I will show an example to explain my problem. VARIABLE='some string' I want to
The best way to explain my problem is to just show you. Input String:
The best way to explain my problem is probably just to show you my
Let me explain my problem, and hopefully someone can offer some good advice. I
The best way to explain my problem is with a code snippet: enum Resource
The best way for me to explain my problem is to basically just give
Before explain my problem, I have to say that my GWT version is 2.2.0

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.