Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Gradle: What is the counterpart to ant's buildnumber

Tags:

gradle

build

I've been trying to migrate an ant script to gradle and have so far not found gradle's counterpart to the ant <buildnumber/> which is an auto-incrementing number used within the build process.

like image 850
mana Avatar asked Oct 29 '12 08:10

mana


People also ask

What is Ant in Gradle?

In your build script, a property called ant is provided by Gradle. This is a reference to an AntBuilder instance. This AntBuilder is used to access Ant tasks, types and properties from your build script. There is a very simple mapping from Ant's build.


2 Answers

Gradle doesn't have a counterpart to <buildnumber/>, but you can always use the Ant task.

like image 124
Peter Niederwieser Avatar answered Oct 10 '22 08:10

Peter Niederwieser


In case there are any other noobs out there like me that don't know how to execute ant targets and access their properties, here's an example:

jar.doFirst {
  ant.buildnumber()
  manifest {
    attributes{
      'Implementation-Version': ant.antProject.properties['build.number']
    )
  }
}
like image 24
TheChrisPratt Avatar answered Oct 10 '22 08:10

TheChrisPratt