/* * Copyright 2020 See AUTHORS file * * 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. */ package com.libgdx.gradle import org.gradle.api.Project import org.gradle.api.artifacts.dsl.RepositoryHandler import java.net.URI /** * URI for the GitHub Packr Maven repository. */ val gitHubPackrMavenUri: URI = URI("https://maven.pkg.github.com/libgdx/packr") /** * Username for signing into GitHub Maven packages url [gitHubPackrMavenUri]. The username is loaded from the Gradle property or * environment variable `PACKR_GITHUB_MAVEN_USERNAME`. */ val Project.gitHubMavenUsername: String? get() { return findProperty("PACKR_GITHUB_MAVEN_USERNAME") as String? ?: System.getenv("PACKR_GITHUB_MAVEN_USERNAME") } /** * Authentication token for signing into GitHub Maven packages url [gitHubPackrMavenUri]. The token is loaded from the Gradle * property or environment variable `PACKR_GITHUB_MAVEN_TOKEN` */ val Project.gitHubMavenToken: String? get() = this.findProperty("PACKR_GITHUB_MAVEN_TOKEN") as String? ?: System.getenv("PACKR_GITHUB_MAVEN_TOKEN") /** * Adds the GitHub Maven repository for [gitHubPackrMavenUri] only if the [gitHubMavenUsername] is non null. */ fun RepositoryHandler.gitHubRepositoryForPackr(project: Project) { if (project.gitHubMavenToken != null) { maven { url = gitHubPackrMavenUri credentials { username = project.gitHubMavenUsername password = project.gitHubMavenToken } } } } /** * Searches for Gradle properties of Maven repositories to publish to. * * The properties are: * * `maven.repository.url.n=` // This is the Maven repository url * * `maven.repository.ispublishsnapshot.n=` // true if snapshot builds should be published to this repository * * `maven.repository.ispublishrelease.n=` // true if release builds should be published to this repository * * `maven.repository.ispublishpackr.n=` // true if packr builds should be published to this repository * * `maven.repository.username.n=` // The username for authenticating to the Maven repository * * `maven.repository.password.n=