Map collectExtensionsMap()

in src/main/groovy/org/jetbrains/gradle/ext/IdeaExtPlugin.groovy [87:118]


  Map<String, Object> collectExtensionsMap() {
    def result = [:]
    if (this instanceof ExtensionAware) {
      def extContainer = (this as ExtensionAware).extensions
      if (GradleVersion.current() >= GradleVersion.version("4.5")) {
        extContainer.extensionsSchema.each { schema ->
          def name = schema.name
          def typeOfExt = schema.publicType

          def converted = convertToMapOrList(typeOfExt, extContainer.findByName(name))
          if (converted != null) {
            result.put(name, converted)
          }
        }
      } else {
        try {
          def schemaMethod = extContainer.class.getMethod("getSchema")
          Map<String, TypeOf> schema = schemaMethod.invoke(extContainer) as Map<String, TypeOf>
          schema.each { name, typeOfExt ->
            def converted = convertToMapOrList(typeOfExt, extContainer.findByName(name))
            if (converted != null) {
              result.put(name, converted)
            }
          }
        } catch (NoSuchMethodException e) {
          throw new GradleException("Can not collect extensions information in IDEA settings." +
                  " Please, use Gradle 4.2 or later.", e)
        }
      }
    }
    return result
  }