Reputation: 7521
I have the simple gradle.build
file
ext {
port = 10001
}
task expand(type: Copy) {
// Substitute property tokens in files
expand(module_name: project.name
, port: port
)
}
It works like a charm without any problems.
Then I want to refactor my build script and split build.gradle
on build.gradle
:
apply from: 'rpm.gradle'
ext {
port = 10001
}
and rpm.gradle
:
task expand(type: Copy) {
expand(module_name: project.name
, port: port
)
}
Task gradle expand
fails with
Error:Could not get unknown property 'port' for task ':expand' of type org.gradle.api.tasks.Copy.
How to resolve it by modifiing only the build.gradle
with next constraints:
gradle.properties
is not allowed (Of course it is strange condition. It appeared due usage of gradle.properties
by other plugin in auto-mode on CI-server)rpm.gradle
cannot contain actual value of port
property, becouse rpm.gradle
will be read-only and shared from single place across several members of the teamUpvotes: 0
Views: 343
Reputation: 38649
You try to use port before you defined it. Swap that and it should work like
ext {
port = 10001
}
apply from: 'rpm.gradle'
Upvotes: 1