How to include everything inside src/main/java to compile

I have a java project. Inside the project I have package “com” and “com.sql”, I used gradle to compile, I didn’t see com.sql package in my build folder.

How can I include everything to build?

Inside com.sql are only sql files.

You should declare your sql-package as a ressource, Have a look at

Hi Carlo
Thanks for your replying.

Can I do it in another way?

If let’s say I have other staff in other packages like com.customer.sql, com.customer.txt and com.product.sql, com.product.txt, I want all of them to be compiled without specify them one by one.

Can you describe what your directory layout for your project is? where com.* and com.sql.* source files, etc are?

Sorry, my bad.

Please get them from github

Ah, I see. You’re not talking about compiling com.sql source files, you have files in com/sql that you want in the jar at the end.

Those are usually called ‘resources’. Resources go in src/main/resources and not in src/main/java. Anything in resources gets included in the jar as-is. So if you put your sql file in src/main/resources/com/sql, it’ll end up in /com/sql/ in the jar.


Hi Sterling

I get understand it. But I still don’t want to organize it in this way. Is there anyway to just include everything in src/main/java folder to compile? And I don’t want to specify them one by one either.

In maven, I could do it in this way:


How to do it in gradle way?

The equivalent idea in Gradle is to configure the main sourceSet’s resources.

See the sample here:

This adds ‘src/resources’ as a resource directory.

I have solved this issue by adding following setting in my build.gradle.

Although it didn’t copy it to the same path as package com, it packaged together in jar.

sourceSets.main.resources { srcDirs = ["src/main/java"]; include "**/*.*" }