What is the type of the "artifactory { ... }" block in my build.gradle?

I thought I’d extend the “artifactory” task, but it is not a task, so I am stumped.

artifactory {
  contextUrl = "http://artifactory/"
  publish {
    repository {
      repoKey = 'release-repo'
      ...
    }
    ...    
  }
}

I list the tasks but it’s not there, and it is not in the properties either. So what is “artifactory”? How would I go about configuring two “artifactory” instances with different repositories in the same project? I tried down this path:

task releaseToDev(type: artifactory.class) {
  publish.repository.repoKey = 'dev-repo'
}

But obviously that did not work. Can someone clarify what is the “artifactory { … }” block? Thanks.

The artifactory block belongs to a plug-in convention as seen in https://github.com/JFrogDev/build-info/blob/master/build-info-extractor-gradle/src/main/groovy/org/jfrog/gradle/plugin/artifactory/dsl/ArtifactoryPluginConvention.groovy
You can browse this code to look how Jfrog creates its artifactory plug-in, it’s instructive.

Thank you. I found this, it briefly explains the difference between a plugin convention and a plugin extension: What's the difference between plugin conventions vs plugin extensions?

Plugin convention is the old way, plugin extensions is the new way.

So what I try to do would be easier if JFrog had used a plugin extension. Or maybe that was a conscious decision on their part.

You’re trying to publish to several repositories, using several tasks.

This can easily be done with the core maven-publish or ivy-publish plug-ins.

If you want to stick with the artifactory plug-in,
why don’t you always publish to a single repo (eg unstable-repo), and then promote the published artifacts to other repositories (eg stable-repo or qualified-repo) using artifactory’s REST API promotion ?
http://www.jfrog.com/confluence/plugins/servlet/mobile#ArtifactoryRESTAPI-BuildPromotion

Would this suit your need?

Yes, I use the REST API. For a single project I put the REST API commands inside a gradle task, in a project-specific plugin under buildSrc. To reuse across all projects, I instead created a gradle artifactory artifact copier plugin that copies artifacts from a repository to another (using the REST API of course). So it is effectively a real plugin under the src folder. However, this creates a circular dependency for the plugin: it cannot promote itself because build.gradle cannot depend on src, only on buildSrc. Hence my original question.

Unfortunately IMHO that is a bad design in both the Artifactory and Bintray plugins.