// SPDX-FileCopyrightText: Copyright 2020-2025 Mark Rotteveel
// SPDX-License-Identifier: LGPL-2.1-or-later
import org.apache.tools.ant.filters.*

publishing {
    publications {
        // Main maven artifact
        jaybird(MavenPublication) {
            from components.java
            artifactId = project.mavenName
            suppressPomMetadataWarningsFor 'nativeApiElements'
            suppressPomMetadataWarningsFor 'nativeRuntimeElements'
            pom {
                name = 'Jaybird JDBC Driver'
                packaging = 'jar'
                description = 'JDBC Driver for the Firebird RDBMS'
                url = 'https://www.firebirdsql.org/en/devel-jdbc-driver/'
                /*
                  Initial check-in was 2001-05-09 by "d_jencks" according to commit here:
                  https://github.com/FirebirdSQL/jaybird/commit/5e215213f916bc2c46d891da661131e18fb65f14
                */
                inceptionYear = '2001'

                developers {
                    developer {
                        id = 'mrotteveel'
                        name = 'Mark Rotteveel'
                        email = 'mark@lawinegevaar.nl'
                        roles = ['Administrator', 'Developer']
                    }
                    developer {
                        id = 'rrokytskyy'
                        name = 'Roman Rokytskyy'
                        roles = ['Developer']
                    }
                    developer {
                        id = 'd_jencks'
                        name = 'David Jencks'
                        roles = ['Developer']
                    }
                    developer {
                        id = 'brodsom'
                        name = 'Blas Rodriguez Somoza'
                        roles = ['Developer']
                    }
                    developer {
                        id = 'gab_reid'
                        name = 'Gabriel Reid'
                        roles = ['Developer']
                    }
                    developer {
                        id = 'ryanbaldwin'
                        name = 'Ryan Baldwin'
                        roles = ['Developer']
                    }
                    developer {
                        id = 'sjardine'
                        name = 'Steven Jardine'
                        roles = ['Developer']
                    }
                    developer {
                        id = 'alberola'
                        name = 'Alejandro Alberola Arias'
                        roles = ['Developer']
                    }
                    developer {
                        id = 'rfincher'
                        name = 'Rick Fincher'
                        roles = ['Developer']
                    }
                    developer {
                        id = 'skywalker'
                        name = 'Mark ODonohue'
                        roles = ['Developer']
                    }
                    developer {
                        id = 'skidder'
                        name = 'Nikolay Samofatov'
                        roles = ['Developer']
                    }
                    developer {
                        id = 'lorban'
                        name = 'Ludovic Orban'
                        roles = ['Developer']
                    }
                    developer {
                        id = 'tsteinmaurer'
                        name = 'Thomas Steinmaurer'
                        roles = ['Developer']
                    }
                }

                contributors {
                    contributor {
                        name = 'Smyatkin-Maxim'
                        url = 'https://github.com/Smyatkin-Maxim'
                    }
                    contributor {
                        name = 'Hajime Nakagami'
                        url = 'https://github.com/nakagami'
                    }
                    contributor {
                        name = 'Vjacheslav Borisov'
                        url = 'https://github.com/slavb18'
                    }
                    contributor {
                        name = 'Ivan Arabadzhiev'
                        url = 'https://github.com/ls4f'
                    }
                    contributor {
                        name = 'Artyom Smirnov'
                        url = 'https://github.com/artyom-smirnov'
                    }
                    contributor {
                        name = 'Vasiliy Yashkov'
                        url = 'https://github.com/vasiliy-yashkov'
                    }
                    contributor {
                        name = 'Julien Nabet'
                        url = 'https://github.com/serval2412'
                    }
                    contributor {
                        name = 'Tobias Weimer'
                    }
                    contributor {
                        name = 'Michael Romankiewicz'
                    }
                    contributor {
                        name = 'Adriano dos Santos Fernandes'
                        url = 'https://github.com/asfernandes'
                    }
                }

                mailingLists {
                    mailingList {
                        name = 'firebird-java'
                        subscribe = 'firebird-java+subscribe@googlegroups.com'
                        unsubscribe = 'firebird-java+unsubscribe@googlegroups.com'
                        post = 'firebird-java@googlegroups.com'
                        archive = 'https://groups.google.com/g/firebird-java'
                        otherArchives = ['http://fb-list-archive.s3-website-eu-west-1.amazonaws.com/firebird-java/index.html']
                    }
                }

                licenses {
                    license {
                        name = 'GNU Lesser General Public License'
                        url = 'https://www.gnu.org/copyleft/lesser.html'
                        distribution = 'repo'
                        comments = 'The Jaybird JDBC driver is distributed free of charge under the ' +
                                'GNU Lesser General Public License (LGPL). Text of the license can be ' +
                                'obtained from https://www.gnu.org/copyleft/lesser.html'
                    }
                    license {
                        name = 'Modified BSD (3-clause) License'
                        url = 'https://opensource.org/licenses/BSD-3-Clause'
                        distribution = 'repo'
                        comments = 'The extension interfaces of Jaybird are dual-licensed under ' +
                                'the modified BSD license and/or the GNU Lesser General Public License (LGPL).'
                    }
                }

                scm {
                    connection = 'scm:git:https://github.com/FirebirdSQL/jaybird.git'
                    developerConnection = 'scm:git:https://github.com/FirebirdSQL/jaybird.git'
                    url = 'https://github.com/FirebirdSQL/jaybird'
                }

                issueManagement {
                    system = 'GitHub'
                    url = 'https://github.com/FirebirdSQL/jaybird/issues/'
                }
            }
        }
    }
    repositories {
        maven {
            url = project.isReleaseVersion.get() ? project.releaseRepository : project.snapshotRepository
            credentials {
                username = findProperty('centralUsername') ?: null
                password = findProperty('centralPassword') ?: null
            }
        }
    }
}

allprojects {
    tasks.withType(PublishToMavenRepository).each {
        it.doFirst {
            if (findProperty('centralUsername') == null || findProperty('centralPassword') == null) {
                throw new RuntimeException('No credentials for publishing, make sure to specify the properties ' +
                        'credentialsPassphrase, or centralUsername and centralPassword. See devdoc/publish.md for details.')
            }
        }
    }
}

signing {
    required = { isReleaseVersion && gradle.taskGraph.hasTask(':publish') }
    sign publishing.publications.jaybird
    sign dist
}
