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

pl.allegro.tech.build.axion.release.OutputCurrentVersionTask.groovy Maven / Gradle / Ivy

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

import org.gradle.api.DefaultTask
import org.gradle.api.tasks.Nested
import org.gradle.api.tasks.Optional
import org.gradle.api.tasks.TaskAction
import pl.allegro.tech.build.axion.release.domain.VersionConfig
import pl.allegro.tech.build.axion.release.infrastructure.di.GradleAwareContext
import pl.allegro.tech.build.axion.release.infrastructure.output.OutputWriter

class OutputCurrentVersionTask extends DefaultTask {

    @Nested
    @Optional
    VersionConfig versionConfig

    OutputCurrentVersionTask() {
        this.outputs.upToDateWhen { false }
    }

    @TaskAction
    void output() {
        boolean quiet = project.hasProperty('release.quiet')
        VersionConfig config = GradleAwareContext.configOrCreateFromProject(project, versionConfig)

        String outputContent = config.version
        if (!quiet) {
            outputContent = '\nProject version: ' + outputContent
        }

        OutputWriter output = new OutputWriter()
        output.println(outputContent)
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy