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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T12:07:30+00:00 2026-06-14T12:07:30+00:00

How do I configure Gradle to include main classes as well as test classes

  • 0

How do I configure Gradle to include main classes as well as test classes into my .jar archive. Currently the .jar that gets built in the build/libs directory is missing my test classes. It is only including classes sourced from project-root/src/main/java/com/package in the .jar after Gradle compiles them into project-root/bin/com/package/ .

jar {
    manifest {
        attributes 'Implementation-Title': title, 'Implementation-Version': version, 'Main-Class': mainTestClass
    }
}

The wierd thing is that while Gradle is putting the compiled test classes into project-root/bin/com/package/ ALONG with the main classes, it strangely is deciding to not put them into the .jar archive. So, how do I get the .jar to also include the test classes that were originally sourced in the project-root/src/test/java/com/package/ directory?

Here is my build.gradle file that I need help with.

  • 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-14T12:07:31+00:00Added an answer on June 14, 2026 at 12:07 pm

    From the docs:

    The Java plugin defines two standard source sets, called main and test. The main source set contains your production source code, which is compiled and assembled into a JAR file. The test source set contains your unit test source code, which is compiled and executed using JUnit or TestNG.

    It’s highly suspect that you would want your tests in your jar, but adding them to the main source set would likely be the simplest solution.

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

Sidebar

Related Questions

I'm looking to configure a Build System in Sublime Text for TypeScript. I'm currently
I'm new to Gradle and I'm trying to configure it to build rosjava. I
How do I configure build.gradle to depend on LWJGL? I'm new to Gradle, and
I build a jar file without using Gradle Jar task (I need to be
How I can configure the Jar task in Gradle to create the jar file
I am trying to configure my xmonad.hs so that when I start my session
I am trying to configure the CLIENTS table on my database such that if
Is it possible to configure Apache Tomcat to simulate network latency that a client
I've tried to configure a gaelyk project in eclipse using the gradle script of
Although configure -platform win32-msvc2005 -arch x86 works well, nmake is immediately giving a fatal

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.