Gradle project with only configuration and no sources

I would like to create a new Gradle project without any sources. I am going to add some config files in there and I want to create a zip file on build. With maven, I would use a build plugin. I am looking for the easiest and easiest way to do this using Gradle. I wonder if I need to apply the java plugin even if I don't have sources, simply because it provides some basic and useful tasks like cleaning, building, etc. Creating a zip is pretty simple, I know how to do it, but I don't know where or how to put the zip generation into the Gradle world.


source to share

3 answers

I've done it manually so far. In other words, for projects where all I want to do is build some kind of distribution and I need basic life tasks like building and cleaning, I just created those tasks along with the required dependencies.

But there is a "base" plugin (mentioned in the "Base Plugins" section of the "Standard Gradle Plugins" in the user manual) that seems to be a good fit for this feature. Please note that the user manual mentions that this and other core plugins are not yet considered part of the Gradle API and are not actually documented.

The results are pretty much identical to yours, with the only difference that there are no convoluted java jobs that always remain UP-TO-DATE.

apply plugin: 'base'

task dist(type: Zip) {



Run example:

$ gradle clean assemble


Total time: 2.562 secs




As far as I understood, this might sound strange, but it looks like I need to apply a java plugin to create a zip file. In addition, it can have some common tasks such as clean

. Below is mine build.gradle


apply plugin: 'java'

task('dist', type: Zip) {

assemble.dependsOn dist


I have applied a java plugin and defined a task dist

that creates a zip file containing the solr directory with the contents of the solr directory in my project. The last line is handy for completing the task when I run the general ones gradle build

or gradle assemble

since I don't want to explicitly call the task dist

. Thus, if I work with multiple projects, I just need to execute gradle build

for the parent to generate all artifacts including the config zip.

Please let me know if you have any better solutions and add your own answer!



You can just use groovy plugin and use ant. I did something like this. I also like the answer to javan.

  task jars(dependsOn: ['dev_jars']) << {
    def fromDir = file('/database-files/non_dev').listFiles().sort()

    File dist = new File("${project.buildDir}/dist")

    fromDir.each { File dir ->
    File destFile = new File("${dist.absolutePath}" + "/" + "database-connection-" + + ".jar")
    println destFile.getAbsolutePath()
    ant.jar(destfile:destFile, update:false, baseDir:dir)




All Articles