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

multiproject.dependencies.outgoingArtifact.kotlin.buildSrc.src.main.java.BuildInfo Maven / Gradle / Ivy

There is a newer version: 8.11.1
Show newest version
import org.gradle.api.DefaultTask;
import org.gradle.api.tasks.Input;
import org.gradle.api.tasks.OutputFile;
import org.gradle.api.tasks.TaskAction;

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.util.Properties;

public class BuildInfo extends DefaultTask {
    private String version;
    private File outputFile;

    @Input
    public String getVersion() {
        return version;
    }

    public void setVersion(String version) {
        this.version = version;
    }

    @OutputFile
    public File getOutputFile() {
        return outputFile;
    }

    public void setOutputFile(File outputFile) {
        this.outputFile = outputFile;
    }

    @TaskAction
    public void create() throws IOException {
        Properties prop = new Properties();
        OutputStream output = null;

        try {
            output = new FileOutputStream(outputFile);
            prop.setProperty("version", version);
            prop.store(output, null);
        } finally {
            if (output != null) {
                try {
                    output.close();
                } catch (IOException e) {
                    // ignore
                }
            }
        }
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy