ru.yoomoney.gradle.plugins.grafana.impl.RawContentCreator Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of grafana-dashboard-plugin Show documentation
Show all versions of grafana-dashboard-plugin Show documentation
Gradle plugin by YooMoney. See README: https://github.com/yoomoney/grafana-dashboard-plugin
The newest version!
package ru.yoomoney.gradle.plugins.grafana.impl;
import kotlin.text.Charsets;
import org.jetbrains.annotations.NotNull;
import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
/**
* Create content without additional modifications
*
* @author Oleg Kandaurov
* @since 29.11.2018
*/
public class RawContentCreator implements DashboardContentCreator {
@Override
public boolean isSupported(@NotNull File file) {
return file.getName().toLowerCase().endsWith(".json");
}
@Override
public String createContent(@NotNull File file) {
try {
return new String(Files.readAllBytes(file.toPath()), Charsets.UTF_8);
} catch (IOException e) {
throw new RuntimeException("cannot read file: path=" + file.getAbsolutePath(), e);
}
}
}