org.anarres.cpp.BuildMetadata Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jcpp Show documentation
Show all versions of jcpp Show documentation
An embeddable C Preprocessor for the JVM.
package org.anarres.cpp;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import java.util.Properties;
import javax.annotation.Nonnull;
/**
* Returns information about the build.
*
* @author shevek
*/
public class BuildMetadata {
public static final String RESOURCE = "/META-INF/jcpp.properties";
private static BuildMetadata INSTANCE;
/** @throws RuntimeException if the properties file cannot be found on the classpath. */
@Nonnull
public static synchronized BuildMetadata getInstance() {
try {
if (INSTANCE == null)
INSTANCE = new BuildMetadata();
return INSTANCE;
} catch (IOException e) {
throw new RuntimeException(e);
}
}
private final Properties properties = new Properties();
private BuildMetadata() throws IOException {
URL url = BuildMetadata.class.getResource(RESOURCE);
InputStream in = url.openStream();
try {
properties.load(in);
} finally {
in.close();
}
}
@Nonnull
public Map extends String, ? extends String> asMap() {
Map out = new HashMap();
for (Map.Entry
© 2015 - 2024 Weber Informatics LLC | Privacy Policy