
sbt.internal.inc.ResourceLoader.scala Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of zinc-lm-integration_2.12 Show documentation
Show all versions of zinc-lm-integration_2.12 Show documentation
sbt is an interactive build tool
The newest version!
/*
* sbt
* Copyright 2023, Scala center
* Copyright 2011 - 2022, Lightbend, Inc.
* Copyright 2008 - 2010, Mark Harrah
* Licensed under Apache License 2.0 (see LICENSE)
*/
package sbt.internal.inc
import java.util.Properties
/** Defines utilities to load Java properties from the JVM. */
private[inc] object ResourceLoader {
def getPropertiesFor(resource: String): Properties = {
val properties = new Properties
val propertiesStream = getClass.getResource(resource).openStream
try {
properties.load(propertiesStream)
} finally propertiesStream.close()
properties
}
def getSafePropertiesFor(resource: String, classLoader: ClassLoader): Properties = {
val properties = new Properties
val propertiesStream = classLoader.getResourceAsStream(resource)
if (propertiesStream ne null) {
try {
properties.load(propertiesStream)
} catch {
case _: Exception =>
} finally propertiesStream.close()
}
properties
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy