Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

Gradle Goodness: Show Hidden Model Objects [Code Snippet]

DZone's Guide to

Gradle Goodness: Show Hidden Model Objects [Code Snippet]

Learn how to use rule based model configuration in order to see which objects are available in the Gradle model space.

· Java Zone ·
Free Resource

Download Microservices for Java Developers: A hands-on introduction to frameworks and containers. Brought to you in partnership with Red Hat.

We use the model task to see which objects are available in the Gradle model space. The model spaced is managed by Rule based model configuration. Objects can be defined as hidden by the object author(s). By default a hidden object is not shown in the model report. We must use the task option --showHidden to show also the hidden objects in the model report.

$ gradle -q model --showHidden
 
------------------------------------------------------------
Root project
------------------------------------------------------------
 
+ buildDir
      | Type:           java.io.File
      | Value:          /Users/mrhaki/Projects/mrhaki.com/blog/posts/samples/gradle/versionrule/build
      | Creator:        Project.<init>.buildDir()
+ extensionContainer
      | Type:           org.gradle.api.plugins.ExtensionContainer
      | Creator:        Project.<init>.extensionContainer()
+ fileOperations
      | Type:           org.gradle.api.internal.file.FileOperations
      | Creator:        DefaultProject.BasicServicesRules#fileOperations(ServiceRegistry)
+ instantiator
      | Type:           org.gradle.internal.reflect.Instantiator
      | Creator:        DefaultProject.BasicServicesRules#instantiator(ServiceRegistry)
+ nodeInitializerRegistry
      | Type:           org.gradle.model.internal.core.NodeInitializerRegistry
      | Creator:        DefaultProject.BasicServicesRules#nodeInitializerRegistry(ModelSchemaStore, StructBindingsStore)
+ projectIdentifier
      | Type:           org.gradle.api.internal.project.ProjectIdentifier
      | Value:          root project 'versionrule'
      | Creator:        Project.<init>.projectIdentifier()
+ proxyFactory
      | Type:           org.gradle.model.internal.manage.instance.ManagedProxyFactory
      | Creator:        DefaultProject.BasicServicesRules#proxyFactory(ServiceRegistry)
+ schemaStore
      | Type:           org.gradle.model.internal.manage.schema.ModelSchemaStore
      | Creator:        DefaultProject.BasicServicesRules#schemaStore(ServiceRegistry)
+ serviceRegistry
      | Type:           org.gradle.internal.service.ServiceRegistry
      | Value:          ProjectScopeServices
      | Creator:        Project.<init>.serviceRegistry()
+ sourceDirectorySetFactory
      | Type:           org.gradle.api.internal.file.SourceDirectorySetFactory
      | Creator:        DefaultProject.BasicServicesRules#sourceDirectorySetFactory(ServiceRegistry)
+ structBindingsStore
      | Type:           org.gradle.model.internal.manage.binding.StructBindingsStore
      | Creator:        DefaultProject.BasicServicesRules#structBindingsStore(ServiceRegistry)
+ taskFactory
      | Type:           org.gradle.api.internal.project.taskfactory.ITaskFactory
      | Creator:        DefaultProject.BasicServicesRules#taskFactory(ServiceRegistry)
+ tasks
      | Type:           org.gradle.model.ModelMap<org.gradle.api.Task>
      | Creator:        Project.<init>.tasks()
      | Rules:
         ⤷ VersionFileTaskRules#createVersionFileTask(ModelMap<Task>, VersionFile)
    + buildEnvironment
          | Type:       org.gradle.api.tasks.diagnostics.BuildEnvironmentReportTask
          | Value:      task ':buildEnvironment'
          | Creator:    tasks.addPlaceholderAction(buildEnvironment)
          | Rules:
             ⤷ copyToTaskContainer
    + components
          | Type:       org.gradle.api.reporting.components.ComponentReport
          | Value:      task ':components'
          | Creator:    tasks.addPlaceholderAction(components)
          | Rules:
             ⤷ copyToTaskContainer
    + dependencies
          | Type:       org.gradle.api.tasks.diagnostics.DependencyReportTask
          | Value:      task ':dependencies'
          | Creator:    tasks.addPlaceholderAction(dependencies)
          | Rules:
             ⤷ copyToTaskContainer
    + dependencyInsight
          | Type:       org.gradle.api.tasks.diagnostics.DependencyInsightReportTask
          | Value:      task ':dependencyInsight'
          | Creator:    tasks.addPlaceholderAction(dependencyInsight)
          | Rules:
             ⤷ HelpTasksPlugin.Rules#addDefaultDependenciesReportConfiguration(DependencyInsightReportTask, ServiceRegistry)
             ⤷ copyToTaskContainer
    + dependentComponents
          | Type:       org.gradle.api.reporting.dependents.DependentComponentsReport
          | Value:      task ':dependentComponents'
          | Creator:    tasks.addPlaceholderAction(dependentComponents)
          | Rules:
             ⤷ copyToTaskContainer
    + generateVersionFile
          | Type:       mrhaki.gradle.VersionFileTask
          | Value:      task ':generateVersionFile'
          | Creator:    VersionFileTaskRules#createVersionFileTask(ModelMap<Task>, VersionFile) > create(generateVersionFile)
          | Rules:
             ⤷ copyToTaskContainer
    + help
          | Type:       org.gradle.configuration.Help
          | Value:      task ':help'
          | Creator:    tasks.addPlaceholderAction(help)
          | Rules:
             ⤷ copyToTaskContainer
    + init
          | Type:       org.gradle.buildinit.tasks.InitBuild
          | Value:      task ':init'
          | Creator:    tasks.addPlaceholderAction(init)
          | Rules:
             ⤷ copyToTaskContainer
    + model
          | Type:       org.gradle.api.reporting.model.ModelReport
          | Value:      task ':model'
          | Creator:    tasks.addPlaceholderAction(model)
          | Rules:
             ⤷ copyToTaskContainer
    + projects
          | Type:       org.gradle.api.tasks.diagnostics.ProjectReportTask
          | Value:      task ':projects'
          | Creator:    tasks.addPlaceholderAction(projects)
          | Rules:
             ⤷ copyToTaskContainer
    + properties
          | Type:       org.gradle.api.tasks.diagnostics.PropertyReportTask
          | Value:      task ':properties'
          | Creator:    tasks.addPlaceholderAction(properties)
          | Rules:
             ⤷ copyToTaskContainer
    + tasks
          | Type:       org.gradle.api.tasks.diagnostics.TaskReportTask
          | Value:      task ':tasks'
          | Creator:    tasks.addPlaceholderAction(tasks)
          | Rules:
             ⤷ copyToTaskContainer
    + wrapper
          | Type:       org.gradle.api.tasks.wrapper.Wrapper
          | Value:      task ':wrapper'
          | Creator:    tasks.addPlaceholderAction(wrapper)
          | Rules:
             ⤷ copyToTaskContainer
+ typeConverter
      | Type:           org.gradle.internal.typeconversion.TypeConverter
      | Creator:        DefaultProject.BasicServicesRules#typeConverter(ServiceRegistry)
+ versionFile
      | Type:           mrhaki.gradle.VersionFile
      | Creator:        VersionFileTaskRules#versionFile(VersionFile)
      | Rules:
         ⤷ versionFile { ... } @ build.gradle line 8, column 5
    + outputFile
          | Type:       java.io.File
          | Value:      /Users/mrhaki/Projects/mrhaki.com/blog/posts/samples/gradle/versionrule/build/version.file
          | Creator:    VersionFileTaskRules#versionFile(VersionFile)
    + version
          | Type:       java.lang.String
          | Value:      1.0.1.RELEASE
          | Creator:    VersionFileTaskRules#versionFile(VersionFile)
$


Written with Gradle 3.2.

Download Building Reactive Microservices in Java: Asynchronous and Event-Based Application Design. Brought to you in partnership with Red Hat

Topics:
objects ,model ,groovy ,java

Published at DZone with permission of

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}