Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Construction apply from : to: in Gradle script

I met this construction apply from: - to: in one Gradle build and I do not understand what it does

task ("someName", type: someType) { task ->
        def path = "src/main/tran/${transformType}.groovy"

        def global = "$rootDir/$path"
        apply from: global, to: task
}

If this something Groovysh or it is entirely Gradle concept?

like image 939
Xelian Avatar asked Jun 10 '14 16:06

Xelian


People also ask

What is apply from in Gradle?

apply(from = "other.gradle.kts") Script plugins are automatically resolved and can be applied from a script on the local filesystem or at a remote location. Filesystem locations are relative to the project directory, while remote script locations are specified with an HTTP URL.

What is Buildscript in build Gradle?

The buildscript is for the build.gradle file itself. So, this would contain dependencies for say creating RPMs, Dockerfile , and any other dependencies for running the tasks in all the dependent build.gradle.

How do I run a Gradle project from the command line?

To run a Gradle command, open a command window on the project folder and enter the Gradle command. Gradle commands look like this: On Windows: gradlew <task1> <task2> … ​ e.g. gradlew clean allTests.


Video Answer


1 Answers

apply is a Gradle concept. apply from: applies the given script to the current project. In other words, simple names occurring in the script (e.g. path) will be resolved using the project object. To give an example, applying a script containing println path will print project.path.

apply from:, to: applies the given script to the object specified by to:. To give an example, applying a script containing println path to task will print task.path.

like image 196
Peter Niederwieser Avatar answered Sep 28 '22 10:09

Peter Niederwieser