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

pl.allegro.tech.build.axion.release.infrastructure.di.GradleAwareContext.groovy Maven / Gradle / Ivy

There is a newer version: 1.18.15
Show newest version
package pl.allegro.tech.build.axion.release.infrastructure.di

import org.gradle.api.Project
import pl.allegro.tech.build.axion.release.domain.VersionConfig
import pl.allegro.tech.build.axion.release.domain.scm.ScmProperties
import pl.allegro.tech.build.axion.release.domain.scm.ScmRepository
import pl.allegro.tech.build.axion.release.infrastructure.config.LocalOnlyResolverFactory
import pl.allegro.tech.build.axion.release.infrastructure.config.RulesFactory
import pl.allegro.tech.build.axion.release.infrastructure.config.ScmPropertiesFactory

class GradleAwareContext {

    static Context create(Project project, VersionConfig versionConfig) {
        ScmProperties scmProperties = ScmPropertiesFactory.create(project, versionConfig)
        ScmRepository scmRepository = ScmRepositoryFactory.create(scmProperties)

        return new Context(
            RulesFactory.create(project, versionConfig, scmRepository),
            scmRepository,
            scmProperties,
            project.projectDir,
            LocalOnlyResolverFactory.create(project, versionConfig)
        )
    }

    static VersionConfig configOrCreateFromProject(Project project, VersionConfig versionConfig) {
        return versionConfig == null ? config(project) : versionConfig
    }

    static VersionConfig config(Project project) {
        return project.extensions.getByType(VersionConfig)
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy