Unable to publish artifact to artifactory in a sub module so that it could be used in subsequent module

Hi,
I am migrating my project from maven to gradle. Becasue it is a multi-module project some modules are dependent on other module jars. On maven everything was getting built and published in the local or remote repository and then next module in the build sequence was taking that. But in gradle i am not able to achieve the same behavior.
I tried to use the following but it is just compiling the module (not building the jars and installing them to local repo)

project(‘:sub-module-2’){
dependencies {
compile project(“:sub-module-1”)
}
}

Please Help!!

Figured out a way to achieve this. I added following to parent build.gradle file and everything is now working as expected.

project(‘:project-B’).tasks.compileJava.dependsOn project(‘:project-A’).tasks.install

So now when i am executing the build, artifacts of project-A is being installed to local repository and then project-B is able to take them from there.