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 8045239
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T05:29:03+00:00 2026-06-05T05:29:03+00:00

I have a gradle project that contains only Selenium/TestNG test classes. They are executed

  • 0

I have a gradle project that contains only Selenium/TestNG test classes. They are executed against a deployed war application. All works fine and now I’m adding a java utility that will query the test base and print list of tests that belong to a given TestNG group. The utility should be compiled and executed separate from the main project, as users may want to query the test base before test execution.

I added the following to build.gradle:

task listgroups(dependsOn:'buildUtil' ) <<{
    ant.java(classname: 'util.TestGroupScanner', fork: true,
            classpath: "src/test/java")
}

task buildUtil {
    compile {
        source = "src/test/java/util"
    }
}

However, when calling listgroups task, I’m getting the following error:

C:\console-bg1>g listgroups

FAILURE: Build failed with an exception.
(...)

* What went wrong:
A problem occurred evaluating root project 'console-bg1'.
> Could not find method compile() for arguments [build_4emu7duna2isgubc1k8uts8k9
8$_run_closure6_closure11@d210ab] on root project 'console-bg1'.

I’m not sure how to resolve this issue and needless to say, haven’t found an answer online so far. Any pointers appreciated.

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

    The problem is in the buildUtil task, as the error suggests. The buildUtil declares a compile closure, but such closure does not exist for the default task.

    Let me try to clarify what your setup is. The util.TestGroupScanner source is in the src/test/java/util directory, which you want to compile separately from other source (presumably src/main/java and src/test/java). The buildUtil task is supposed to compile sources in src/test/java/util, and the listgroups task executes the scanner utility on sources src/test/java folder.

    In this case, I’d suggest you declare a new source set for your utility sources, like this:

    sourceSets {
      util {
        java {
           srcDir 'src/test/java/util'
        }
      }
    }
    

    This will automatically create a compile task called compileUtilJava for you, that will compile those sources. I also think you’ll want to include utility classes in the classpath when executing your tool, which can be retrieved by sourceSets.util.output.classesDir. So now your listgroups task will look like:

    task listgroups(dependsOn: 'compileUtilJava' ) <<{
      ant.java(classname: 'util.TestGroupScanner', fork: true,
               classpath: "src/test/java:" + sourceSets.util.output.classesDir)
    }
    

    One thing I have noticed about your setup, is that src/test/java/util source folder is nested under src/test/java. Gradle will assume src/test/java to be the default folder for your project test, and will therefore automatically include it, and all of its children when running tests. Since you want to keep your utility folder separate from the default setup, I would recommend you put it in src/testutil/java, to avoid any clashes. If you do, don’t forget to update the sourceSets setup above with the correct source path.

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

Sidebar

Related Questions

I have a Gradle build in Jenkins with various JUnit tests that are executed
We have a Project that contains 2 modules; web and client The web module
I have a multi-project C++ Gradle build, which produces a number of libraries and
Have a SomeLib.pro file that contains: CONFIG += debug TEMPLATE = lib TARGET =
Is there a way to build custom test phases in gradle? I have a
I have a small Java/Gradle project. I'm using the Application plugin to create a
I have a gradle build script similar to: apply plugin: 'war' task genSources <<
I’m trying to use Gradle to build a project that will run an imbedded
I have a project using Gradle as the build tool and I have to
We have an old project that is set up like this: . ├── customizationProject

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.