All Downloads are FREE. Search and download functionalities are using the official Maven repository.

ru.fix.gradle.release.plugin.ProjectFilesLookup.kt Maven / Gradle / Ivy

Go to download

Plugin automatically creates branches and tags and changes version in project gradle.properties file.

The newest version!
package ru.fix.gradle.release.plugin

import org.gradle.api.Project
import java.nio.file.Path


class ProjectFilesLookup(
        private val project: Project,
        private val userInteractor: UserInteractor) {

    fun openGitRepository(): GitRepository {
        val repo = GitRepository.openExisting(
                project.projectDir,
                GitCredentialsProvider(project, userInteractor))
        userInteractor.info("Found git repository at: ${repo.directory}")
        return repo
    }

    fun findGradlePropertiesFile(): Path {
        val fileName = "gradle.properties"
        userInteractor.info("Looking for '$fileName' at '${project.projectDir.absolutePath}'")
        val file = project.projectDir.listFiles()
                .filter { it.isFile }
                .filter { it.name == fileName }
                .singleOrNull()
        if (file != null)
            return file.toPath()
        else {
            throw Exception("Failed to find '$fileName' at '${project.projectDir.absolutePath}'")
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy