Implementing custom publication plugin in gradle

I’d like to implement custom publication plugin for gradle.

My goal is to support syntax like this:

publishing {
    publications {      
        custom(CustomPublication) {
            artifact fooDistZip
            artifact foo2DistZip
        }
    }
    repositories {
        custom {
            url 'http://192.168.1.100:80'
        }
    }
}

I’ve checked the MavenPublication, but the implementation seems to be rather complicated.

Any reference for simple custom publisher in gradle would be much appreciated.

(Stackoverflow question)