How to make Gradle publish separate projects in a Multi-project builds to different repositories?

I have a multi project build, e.g.

project-parent ├── build.gradle ├── project-distTar │ └── build.gradle ├── project-jar1 │ └── build.gradle └── project-jar2

└── build.gradle

From the above example, I want to publish the project-jar1 and project-jar2 which would be normal jar’s to Artifactory and project-distTar which would be tar.gz to Nexus. How can i possibly achieve this using Gradle ?

Gradle’s publishing is configured per-project, so it isn’t any harder (or different) to publish to separate repositories than to the same repository. For more information on publishing in general, see the Gradle User Guide.

Thanks, Thats great news! Sorry am new to Gradle, So in the parent Gradle file, i have sub projects configured to all publish and resolve from one repo, Can I over ride this in one of the subproject to publish to other repo and resolve from main repo ?

Is there any best practices or sample Gradle files doing something like this ?

Also how would i manage credentials so only the CI is able to publish ?