SNAPSHOT for zip files

(Meera Viswanathan) #1

I have a gradle script to:

  1. Build a project

  2. Create a zip

  3. Upload it to a Maven repository

I want to add a timestamp to the version number. After some digging around, I found that appending x.x-SNAPSHOT accomplished that for me.

The problem I’m facing at the moment is that the SNAPSHOT timestamp value is not appended to the zip file created.

Sample file that I’m using:

buildscript {

repositories {



dependencies {

classpath “com.ullink.gradle:gradle-msbuild-plugin:1.6”



apply plugin:‘msbuild’

apply plugin: ‘maven’

project.ext {

repoUrl = “http://url/repositories

someTextRepoUrl = project.repoUrl + “/sometext”

groupID = “somegroup”

artifactID = “artifactid”

versionNo = ‘1.0-SNAPSHOT’


repositories {

maven {

url project.snapshotsRepoUrl



msbuild {

// mandatory

projectFile = ‘projectFile\projectFile.csproj’

// MsBuild project name (/p:Project=…)

projectName =

// Verbosity (/v:detailed, by default uses gradle logging level)

verbosity = ‘detailed’

// targets to execute (/t:Clean;Rebuild, no default)

targets = [‘Clean’, ‘Rebuild’]


task zipFileZip(type: Zip, dependsOn: msbuild) {

from ‘projectFile\bin\Debug’

from (‘projectFile\someFolder’) {




task buildAndUploadAll(dependsOn: uploadArchives) {}

artifacts {

archives zipFileZip


uploadArchives {

repositories {

mavenDeployer {

repository(url: project.someTextRepoUrl) {

authentication(userName: “xxxxxx”, password: “xxxxxxxx”)


pom.version = project.versionNo

pom.artifactId = project.artifactID

pom.groupId = project.groupID




(Peter Niederwieser) #2

I don’t quite understand what’s not working for you, since you say that “I found that appending x.x-SNAPSHOT accomplished that for me.”. Anyway, try to get rid of the ‘pom.version’ and ‘project.versionNo’ and simply set ‘project.version’ to something that ends in ‘-SNAPSHOT’. Likewise, you can set ‘’ instead of ‘pom.groupId’.

(Meera Viswanathan) #3

It doesn’t add the timestamp to the zip file. The zip file is submitted as ZipFile-1.0-SNAPSHOT. And when it tries to upload the file, it looks for the ZipFile-1.0- instead.

(Peter Niederwieser) #4

I don’t understand what you mean by that, but typically all that’s required is to set ‘project.version’ to something that ends in '-SNAPSHOT. If that doesn’t work, chances are that something is wrong with your build script. Hard to say what it is.

(Meera Viswanathan) #5

I have a task to zip my files up called zipFilesZip. In that, it takes the build directory and zips it up. The zip file is then uploaded into our maven repository.

The part that I’m having trouble with is to have the zip task append the timestamp to the created zip file.

(Peter Niederwieser) #6

It’s not the responsibility of the zip task to do this. The timestamp is added automatically when the zip is uploaded.