I am intializing a variable in customised plugin Then I want to access in project level?
What purpose does that variable serve? It is a part of task or project configuration? If project, as you say, one way would be to create/set an extension property for that project, i.e. something like project.getExtensions().getExtraProperties().set(name, value). In that case I recommend exposing just one per plugin and have that one provide access to any number of actual variables and structured content. There are other ways.
See (and follow):
- https://docs.gradle.org/current/javadoc/org/gradle/api/Project.html#getExtensions--
- https://docs.gradle.org/current/javadoc/org/gradle/api/plugins/ExtensionContainer.html#getExtraProperties--
- https://docs.gradle.org/current/javadoc/org/gradle/api/plugins/ExtraPropertiesExtension.html#set-java.lang.String-java.lang.Object-
1 Like