multiproject.dependencies.outgoingArtifact.kotlin.buildSrc.src.main.java.BuildInfo Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of gradle-api Show documentation
Show all versions of gradle-api Show documentation
Gradle 6.9.1 API redistribution.
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