Task type JavaCompile dependencies

Hello. In my project I need get a repository from git and compile it to generate a jar for my another project. The first part is done, but when I execute the task compileSuite it’s can’t find the dependencies.

Part of my script:

dependencies {
        compile (
    task compileSuite(type: JavaCompile) {
        options.encoding = "UTF-8"
        source = file("libs/suite")
        destinationDir = file("libs/teste")
        classpath = files("libs/")

error: package javax.persistence does not exist import javax.persistence.Entity;
The javax.persistence is in the libs/hibernate-jpa-2.1-api-1.0.0.Final.jar.

Already grateful.

Any reason you are not going for transitive dependency management to ensure you have the required dependencies?

I didn’t understand. :frowning: Sorry, I’m a newbie.

The question was related to the fact that you are depending on JAR files in a directory (in your case libs). If you’d rely on dependencies in a public repository like Maven Central or JCenter, Gradle evaluates the metadata of a dependency (e.g. pom.xml) to resolve other dependencies that are required by your declared libraries. For more information please have a look at Dependency Management Best Practices.

Thank you, Benjamin. I will read it and reply soon.

One more comment here: I assume you are currently not using the Java Plugin? If you use the plugin you won’t have to set up the compilation task yourself which makes it much easier. Check out the Java project quickstart guide.