Thufir
Thufir

Reputation: 8497

Gradle DSL meaning for it.name

What does it.name mean? Is it generated, or can the values be specified? Is it like this, refers to the current object?

 jar.doFirst
 {
     // aggregate all the jars needed at runtime into a local variable (array)
     def manifestClasspath = configurations.runtime.collect { it.name }

     // remove duplicate jar names, and join the array into a single string
     manifestClasspath = manifestClasspath.unique().join(" ")

     // set manifest attributes - mainClassName must be set before it is used here
     manifest.attributes.put("Main-Class", mainClassName)
     manifest.attributes.put("Class-Path", manifestClasspath)
 }

This method will execute before the jar task?

see:

https://stackoverflow.com/a/22736602/262852

Upvotes: 2

Views: 1406

Answers (1)

Tuan Pham
Tuan Pham

Reputation: 1120

1.

it is the implicit parameter for Groovy's closures.

configurations.runtime.collect { it.name }

is equivalent to

configurations.runtime.collect { it -> it.name }

name is simply a property. For more information about it look here.

2.

Yes, it will be executed before jar task. It's a part of the API, look here in section 14.7 for example

Upvotes: 3

Related Questions