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

  • SEARCH
  • Home
  • 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 7530821
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T05:00:59+00:00 2026-05-30T05:00:59+00:00

I have a method that takes a string and a closure, which I include

  • 0

I have a method that takes a string and a closure, which I include in my plugin convention:

def someMethod( String obj, Closure closure) {
    println('HERE I AM')
    confFileTree = project.fileTree( obj, closure )
}

From a Junit test I call it like so:

project.convention.plugins.license.licenseFiles( 'src') {
    include "main/java/**"
    include "main/resources/*.properties"
    exclude "**/Licensed.java"
}

I know the method is called because ‘HERE I AM’ is printed. But I then get an error that says:

org.gradle.api.internal.MissingMethodException: 
    Could not find method fileTree() for arguments 
    [src, nl.javadude.gradle.plugins.license.tasks.LicenseTaskTest$_shouldScanFilesForLicenseWithExclude_closure1@3cbdb6ae] 
    on root project 'test'.

I should state that this code originally just called the Closure form of fileTree, with “from ‘src'” in the closure, which works fine, but Gradle milestone 8 is telling me that it is a deprecated method.

  • 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-05-30T05:01:00+00:00Added an answer on May 30, 2026 at 5:01 am

    Are you sure that the test is running against m8? In any case, here are a few suggestions for improvement (since I already know what you are trying to achieve):

    • I don’t think you want to construct your own file tree. You just want the user to pass a ‘filter’ closure (like in your example) which you then apply to the source directory set (e.g. sourceSets.main.java) with the FileTree.matching(Closure) method. You’ll get back a new file tree with the filter applied.
    • I recommend to use an extension rather than a convention object
    • You don’t need the long-winded syntax when accessing convention objects or extensions from Groovy code. In your unit test example, you can just say project.licenseFiles(...) {...}.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a service method that takes a String and then replaces tags in
I have a method that effectively takes a string. However, there is a very
I have a search method that takes in a user-entered string, splits it at
I have an init method that takes an (id) argument: -(id) initWithObject:(id) obj; I'm
I have a method that takes a List<int> , which is a list of
I have created a method that takes two Collection<String> as input and copies one
I have a method that (sometimes) takes in a string in the format dddd
Say I have a method that takes an int as a string and returns
I have a method that takes a string value as a parameter and then
I have a C# method that takes a string as an argument, that string

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.