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 (
            files(
                "libs/c3p0-0.9.2.1.jar",
                "libs/hibernate-c3p0-4.3.7.Final.jar",
                "libs/hibernate-commons-annotations-4.0.5.Final.jar",
                "libs/hibernate-core-4.3.7.Final.jar",
                "libs/hibernate-entitymanager-4.3.7.Final.jar",
                "libs/hibernate-jpa-2.1-api-1.0.0.Final.jar",
                "libs/ojdbc6.jar",
                "libs/sqljdbc4.jar",
                "libs/itextpdf-5.5.5.jar",
                "libs/commons-io-2.4.jar",
                "libs/jboss-logging-3.1.3.GA.jar",
                "libs/jboss-logging-annotations-1.2.0.Beta1.jar",
                "libs/jboss-transaction-api_1.2_spec-1.0.0.Final.jar",
                "libs/jandex-1.1.0.Final.jar",
                "libs/javassist-3.18.1-GA.jar",
                "libs/dom4j-1.6.1.jar",
                "libs/antlr-2.7.7.jar"
            )
        )
    }
    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.