asset.pipeline.AssetPipelineConfigHolder.groovy Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of asset-pipeline-core Show documentation
Show all versions of asset-pipeline-core Show documentation
JVM Asset Pipeline library for serving static web assets, bundling, minifying, and extensibility for transpiling.
package asset.pipeline
import asset.pipeline.fs.AssetResolver
/**
* Holder for Asset Pipeline's configuration
* Also Provides Helper methods for loading in config from properties
* @author David Estes
*/
class AssetPipelineConfigHolder {
public static Collection resolvers = []
public static Properties manifest
public static Map config = [:]
private static Integer configHashCode
private static Integer resolverHashCode
private static String digestString
public static registerResolver(AssetResolver resolver) {
resolvers << resolver
}
public static Properties getManifest() {
return this.manifest
}
public static void setManifest(Properties manifest) {
this.manifest = manifest
}
public static Map getConfig() {
return this.config
}
public static void setConfig(Map config) {
this.config = config;
}
public static Collection getResolvers() {
return this.resolvers;
}
public static void setResolvers(Collection resolvers) {
this.resolvers = resolvers
}
public static String getDigestString() {
//check if the maps or arrays have changed to reset the digest
if(resolvers?.hashCode() != resolverHashCode || config?.hashCode() != configHashCode) {
digestString = AssetHelper.getByteDigest([config: config?.sort(),resolvers: resolvers?.collect{AssetResolver resolver -> resolver.name}?.sort()].sort().toString().bytes)
resolverHashCode = resolvers?.hashCode()
configHashCode = config?.hashCode()
}
return digestString
}
}