/*
 * Copyright 2013-2019 the original author or authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

ext {
    pluginIdPrefix = 'org.asciidoctor'

    pluginExtraText = (version.contains('-alpha') || version.contains('-beta')) ?
            ". (If you need a production-ready version of the AsciidoctorJ plugin for Gradle use a 3.x release of this plugin instead)."
            : ''
}

tasks.named('jar', Jar) {
    manifest {
        attributes(
                'Built-By': System.properties['user.name'],
                'Created-By': buildCreatedBy,
//            'Build-Date': buildDate,
//            'Build-Time': buildTime,
                'Build-Revision': buildRevision,
                'Specification-Title': project.name,
                'Specification-Version': project.version,
                'Specification-Vendor': project.name,
                'Implementation-Title': project.name,
                'Implementation-Version': project.version,
                'Implementation-Vendor': project.name
        )
    }

    metaInf {
        from file('.')
        include 'LICENSE'
    }
}

ext {
    pomConfig = {
        name project.name
//        description project.project_description
        url project.project_website
        inceptionYear '2013'
        licenses {
            license([:]) {
                name 'The Apache Software License, Version 2.0'
                url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
                distribution 'repo'
            }
        }
        scm {
            url project.project_vcs
        }
        developers {
            developer {
                id 'mojavelinux'
                name 'Dan Allen'
                roles {
                    role 'Asciidoctor Founder and Benevolent Dictator'
                    role 'Open Source Hero'
                }
            }
            [
                    aalmiray: 'Andres Almiray',
                    ysb33r  : 'Schalk W. Cronjé'
            ].each { devId, devName ->
                developer {
                    id devId
                    name devName
                    roles {
                        role 'Developer'
                    }
                }
            }
        }
        contributors {
            [
                    afolmert   : 'Adam Folmert',
                    anschmi    : 'Andreas Schmidt',
                    bmuschko   : 'Benjamin Muschko',
                    bobbytank42: 'Robert Panzer',
                    dvyazelenko: 'Dmitri Vyazelenko',
                    jlupi      : 'Lukasz Pielak',
                    lhotari    : 'Lari Hotari',
                    McPringle  : 'Marcus Fihlon',
                    Mogztter   : 'Guillaume Grossetie',
                    mrhaki     : 'Hubert Klein Ikkink',
                    msgilligan : 'Sean Gilligan',
                    noamt      : 'Noam Tenne',
                    oti        : 'Otmar Humbel',
                    rwinch     : 'Rob Winch',
                    sclassen   : 'Stephan Classen',
                    Skyr       : 'Stefan Schlott',
                    tombujok   : 'Tom Bujok'
            ].each { devId, devName ->
                contributor {
                    name devName
                    roles {
                        role 'contributor'
                    }
                }
            }
        }
    }
}

publishing.publications.withType(MavenPublication).configureEach {
//    pom.withXml {
//        asNode().appendNode('description', project.project_description)
//    }
}

pluginBundle {
    website = project.project_website
    vcsUrl = project.project_vcs
}

