Package com.jalios.jcms.tools
Class JsPacker
java.lang.Object
com.jalios.jcms.tools.AbstractFilePacker
com.jalios.jcms.tools.JsPacker
-
Field Summary
Fields inherited from class com.jalios.jcms.tools.AbstractFilePacker
channel, CHANNEL_PACKER_MINIFY_EXCLUSION_REGEX -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic CheckResultcheckAndMinifyJS(boolean force, boolean isUnittest) Create a minified version of all JS found in JCMS.getJSFilesInPack(Collection<String> jsFiles, String browserName) Returns the set of the URLs created with the JS packer, respecting the constraints of the browser.protected org.apache.log4j.LoggerReturns the logger to be used for log messages.static voidminifyJS(boolean force) Create a minified version of all JS found in JCMS.protected booleanCheck if minification should be performed on each file as opposed to the whole pack.protected StringprocessFileContent(String relativeFilePath, File file, String fileContent) Process Javascript files' contentprotected StringprocessPackContent(String packContent) Process Javascript pack's contentMethods inherited from class com.jalios.jcms.tools.AbstractFilePacker
getFilePack, getFilesInPack, getMinifiedFile, isExcludedFromMinification, minifyFile, postProcessPackContent
-
Constructor Details
-
JsPacker
- Throws:
IOException
-
-
Method Details
-
processFileContent
Process Javascript files' content- Specified by:
processFileContentin classAbstractFilePacker- Parameters:
relativeFilePath- the relative path of the file being processedfile- the file being processedfileContent- the fileContent as read by the AbstractFilePacker- Returns:
- the processed file content, must not return null.
-
processPackContent
Process Javascript pack's content- Specified by:
processPackContentin classAbstractFilePacker- Parameters:
packContent- the whole pack content as computed by the AbstractFilePacker- Returns:
- the processed pack content, must not return null.
-
perFileMinificationEnabled
protected boolean perFileMinificationEnabled()Description copied from class:AbstractFilePackerCheck if minification should be performed on each file as opposed to the whole pack.- Specified by:
perFileMinificationEnabledin classAbstractFilePacker- Returns:
- true to use minified version of individual file, false if minification is disabled or enabled on whole pack
-
getLogger
protected org.apache.log4j.Logger getLogger()Description copied from class:AbstractFilePackerReturns the logger to be used for log messages. This methods must be implemented by the file packer.- Specified by:
getLoggerin classAbstractFilePacker- Returns:
Loggerof this packer, must not return null.
-
minifyJS
public static void minifyJS(boolean force) Create a minified version of all JS found in JCMS.This method only process css file if minification is enabled through property
"channel.js-packer.compressor.enabled".
Only files contained in directories css, plugins and js are processed- Parameters:
force- set to true to force generation of minified file even if an up to date apparently exists
-
checkAndMinifyJS
Create a minified version of all JS found in JCMS.This method only process css file if minification is enabled through property
"channel.js-packer.compressor.enabled".
Only files contained in directories css, plugins and js are processed- Parameters:
force- set to true to force generation of minified file even if an up to date apparently existsisUnittest- set to true to generate minified file temporarly to check- Returns:
- an instance of CheckResult, with all minification errors, when unittest was requested and packer successfully created, null otherwise
- Since:
- 10.0.9 / JCMS-11077
-
getJSFilesInPack
Returns the set of the URLs created with the JS packer, respecting the constraints of the browser.- Parameters:
jsFiles- collection of JavaScript files to packbrowserName- name of the browser used to find the properties 'channel.packer.xxx' defining the limit values. Ifnull, use 'IE' because it's the most constraining.- Returns:
- Set of the JS Packer URLs
-