final JUNIT5_ROBOLECTRIC_EXTENSION_MAVEN_USERNAME = System.getenv('JUNIT5_ROBOLECTRIC_EXTENSION_MAVEN_USERNAME') ?: ''
final JUNIT5_ROBOLECTRIC_EXTENSION_MAVEN_PASSWORD = System.getenv('JUNIT5_ROBOLECTRIC_EXTENSION_MAVEN_PASSWORD') ?: ''

if (JUNIT5_ROBOLECTRIC_EXTENSION_MAVEN_USERNAME != '' && JUNIT5_ROBOLECTRIC_EXTENSION_MAVEN_PASSWORD != '') {
    apply plugin: 'maven-publish'

    publishing {
        repositories {
            maven {
                name = 'MavenCentral'
                final releasesRepoUrl = 'https://s01.oss.sonatype.org/service/local/staging/deploy/maven2'
                final snapshotsRepoUrl = 'https://s01.oss.sonatype.org/content/repositories/snapshots'
                url = version.toString().endsWith("SNAPSHOT") ? snapshotsRepoUrl : releasesRepoUrl
                credentials {
                    username = System.getenv('JUNIT5_ROBOLECTRIC_EXTENSION_MAVEN_USERNAME')
                    password = System.getenv('JUNIT5_ROBOLECTRIC_EXTENSION_MAVEN_PASSWORD')
                }
            }
        }
    }
}
