I have a Gradle build script ( build.gradle ) in which I created some tasks. These tasks consist mainly of method calls. The called methods are also in the assembly script.
Now, here is the situation:
I create a large number of build scripts that contain different tasks, but use the same methods from the original script. Thus, I would like to somehow extract these "common methods", so I can easily use them instead of copying for every new script that I create.
If Gradle were PHP, then it would be ideal:
//script content ... require("common-methods.gradle"); ... //more script content
But of course this is not possible. Or that?
In any case, how can I achieve this result? What is the best way to do this? I have already read the Gradle documentation, but I can not determine which method will be the simplest and most suitable for this.
Thanks in advance!
UPDATE:
I managed to extract methods in another file
(using apply from: 'common-methods.gradle' ),
therefore, the structure is as follows:
parent/ /build.gradle
After completing the task from build.gradle I ran into a new problem: apparently, the methods are not recognized when they are in common-methods.gradle .
Any ideas on how to fix this?
build.gradle gradle
Pieter VDE Sep 10 '13 at 9:22 2013-09-10 09:22
source share