Publish multiple sub project jars at the same location

I have a gradle multi-project (java)

ROOT |-subA |-subB |-subC

I successfully configured my root build.gradle and gradle.settings to resolve dependencies and build the overall project OK.

But then all jars are produced in subX/build/libs (with X=A,B,C)

Is there a way to regroup everything at the end (with runtime resources also) so everything is ready for shipping ?


Your solution has some problems: Task dependencies aren't correct, stale Jar files won't be removed, and there is no guarantee that all Jar tasks will be found. (The latter could be fixed by using project.tasks.withType(Jar).all, instead of .each.) Here is a more accurate solution:

task deploy(type: Sync) {
    into "$buildDir/deploy"
    for (subproject in subprojects) {
        from subproject.tasks.withType(Jar)

PS: Except for some cases where utmost flexibility is required, it's better to use a Copy or Sync task than the project.copy method.

Found the answer within the gradle online help (although it was somehow not really tagged to find it)

task deploy(dependsOn: assemble) << {
    File deployDist = mkdir("$buildDir/deploy")
    subprojects.each {project ->
        project.tasks.withType(Jar).each {archiveTask ->
            copy {
                from archiveTask.archivePath
                into deployDist

Need Your Help

Leaflet in R: SetView based on range of latitude and longitude from dataset

r zoom leaflet openstreetmap

In ggmap, you can set the view of the map based on longitude and latitude of input data, where two columns of csv are Longitude and Latitude, i.e.

raster package taking all hard drive

r raster

I am processing a time series of rasters (modis ndvi imagery) to calculate average and st.deviation of the series. Each yearly series is composed of 23 ndvi.tif images, each of 508Mb, so total is a...